~bouncepaw/betula

betula: Fix page not found error occurrences v1 SUPERSEDED

~danilax86: 1
 Fix page not found error occurrences

 3 files changed, 82 insertions(+), 55 deletions(-)
#1050654 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~bouncepaw/betula/patches/44244/mbox | git am -3
Learn more about email & git

[PATCH betula] Fix page not found error occurrences Export this patch

From: Danila Gorelko <danila@danilax86.space>

Fixes: https://todo.sr.ht/~bouncepaw/betula/75
---
Not so DRY (I tried to put error messages inside paginator template, but
couldn't get it right).

Here how errors show up.
* If there are no links, it doesn't show an error, but you can clearly
see betula is empty
* If there is a one page, but you want to get a second or a next one,
"Page not found" is here, but paginator is not (remember, only one page)
* If there are several pages, and you want to get some next one, "Page
not found. Select from paginator .. la-la" is here. Paginator shows up,
cause there are another pages you can look for.

 web/views/feed.gohtml   | 40 +++++++++++++++-----------
 web/views/search.gohtml | 34 ++++++++++++++--------
 web/views/tag.gohtml    | 63 +++++++++++++++++++++++------------------
 3 files changed, 82 insertions(+), 55 deletions(-)

diff --git a/web/views/feed.gohtml b/web/views/feed.gohtml
index 7664ebf..f4530cd 100644
--- a/web/views/feed.gohtml
+++ b/web/views/feed.gohtml
@@ -7,21 +7,29 @@
            {{if eq .TotalPosts 0 | and .Authorized}}
				<a class="btn btn-accent" href="/save-link">Save link</a>
            {{end}}
			{{if .SiteDescription}}<p class="p-summary">{{.SiteDescription}}</p>{{end}}
		</article>
        {{range .PostsInPage}}
			<article class="h-entry">
                {{if $authed}}
                    {{template "post buttons fragment" .}}
            {{if .SiteDescription}}<p class="p-summary">{{.SiteDescription}}</p>{{end}}
        </article>
        {{if ne .TotalPosts 0}}
            {{range .PostsInPage}}
                <article class="h-entry">
                    {{if $authed}}
                        {{template "post buttons fragment" .}}
                    {{end}}
                    <h3 class="p-name"><a class="u-url" href="/{{.ID}}">{{.Title}}</a></h3>
                    {{template "post main fragment" .}}
                </article>
            {{else}}
                {{if .MultiplePages}}
                    <article>
                        Page not found. Choose a page from the paginator below.
                    </article>
                {{else}}
                    <article>
                        Page not found.
                    </article>
                {{end}}
				<h3 class="p-name"><a class="u-url" href="/{{.ID}}">{{.Title}}</a></h3>
                {{template "post main fragment" .}}
			</article>
		{{else}}
	        <article>
		        Page not found. Choose a page from the paginator below.
	        </article>
            {{end}}
            {{template "paginator" .}}
        {{end}}
		{{template "paginator" .}}
	</main>
{{end}}
\ No newline at end of file
    </main>
{{end}}
diff --git a/web/views/search.gohtml b/web/views/search.gohtml
index 125a8b7..0da7f61 100644
--- a/web/views/search.gohtml
+++ b/web/views/search.gohtml
@@ -1,19 +1,29 @@
{{define "title"}}Search: {{.Query}}{{end}}
{{define "body"}}{{$authed := .Authorized}}
<main class="h-feed">
	<article>
		<h2 class="p-name">Search: {{.Query}}</h2>
		<p><span class="mv-count">{{.TotalPosts}}</span> bookmark{{if ne .TotalPosts 1}}s{{end}} match the query.</p>
	</article>
    <article>
        <h2 class="p-name">Search: {{.Query}}</h2>
        <p><span class="mv-count">{{.TotalPosts}}</span> bookmark{{if ne .TotalPosts 1}}s{{end}} match the query.</p>
    </article>
    {{range .PostsInPage}}
		<article class="h-entry">
        <article class="h-entry">
            {{if $authed}}{{template "post buttons fragment" .}}{{end}}
			<h3 class="p-name"><a class="u-url" href="/{{.ID}}">{{.Title}}</a></h3>
            <h3 class="p-name"><a class="u-url" href="/{{.ID}}">{{.Title}}</a></h3>
            {{template "post main fragment" .}}
		</article>
    {{else}}{{if .TotalPosts}}
	    <article>Page not found. Choose a page from the paginator below.</article>
    {{end}}{{end}}
	{{template "paginator" .}}
        </article>
    {{else}}
        {{if .TotalPosts}}
            {{if .MultiplePages}}
                <article>
                    Page not found. Choose a page from the paginator below.
                </article>
            {{else}}
                <article>
                    Page not found.
                </article>
            {{end}}
        {{end}}
    {{end}}
    {{template "paginator" .}}
</main>
{{end}}
\ No newline at end of file
{{end}}
diff --git a/web/views/tag.gohtml b/web/views/tag.gohtml
index d02fd11..63ce4fa 100644
--- a/web/views/tag.gohtml
+++ b/web/views/tag.gohtml
@@ -1,29 +1,38 @@
{{define "title"}}Tag {{.Name}}{{end}}
{{define "body"}}{{$authed := .Authorized}}
	<main class="h-feed">
		<article>
			{{if $authed}}
				<a class="edit-post-btn" href="/edit-tag/{{.Name}}">
					Edit
				</a>
			{{end}}
			<h2 class="p-name">Tag {{.Name}}</h2>
			<p><span class="mv-count">{{.TotalPosts}}</span> bookmark{{if ne .TotalPosts 1}}s have{{else}} has{{end}} this tag.</p>
			<div class="p-summary">{{.Description | mycomarkup}}</div>
		</article>
		{{range .PostsInPage}}
			<article class="h-entry">
                {{if $authed}}
                    {{template "post buttons fragment" .}}
                {{end}}
				<h3 class="p-name"><a class="u-url" href="/{{.ID}}">{{.Title}}</a></h3>
                {{template "post main fragment" .}}
			</article>
        {{else}}
			<article>
				Page not found. Choose a page from the paginator below.
			</article>
		{{end}}
		{{template "paginator" .}}
	</main>
{{end}}
\ No newline at end of file
<main class="h-feed">
    <article>
        {{if $authed}}
            <a class="edit-post-btn" href="/edit-tag/{{.Name}}">
                Edit
            </a>
        {{end}}
        <h2 class="p-name">Tag {{.Name}}</h2>
        <p><span class="mv-count">{{.TotalPosts}}</span> bookmark{{if ne .TotalPosts 1}}s have{{else}} has{{end}} this
            tag.</p>
        <div class="p-summary">{{.Description | mycomarkup}}</div>
    </article>
    {{range .PostsInPage}}
        <article class="h-entry">
            {{if $authed}}
                {{template "post buttons fragment" .}}
            {{end}}
            <h3 class="p-name"><a class="u-url" href="/{{.ID}}">{{.Title}}</a></h3>
            {{template "post main fragment" .}}
        </article>
    {{else}}
        {{if .TotalPosts}}
            {{if .MultiplePages}}
                <article>
                    Page not found. Choose a page from the paginator below.
                </article>
            {{else}}
                <article>
                    Page not found.
                </article>
            {{end}}
        {{end}}
    {{end}}
    {{template "paginator" .}}
</main>
{{end}}
-- 
2.38.5
betula/patches/.build.yml: SUCCESS in 1m50s

[Fix page not found error occurrences][0] from [~danilax86][1]

[0]: https://lists.sr.ht/~bouncepaw/betula/patches/44244
[1]: mailto:danila@danilax86.space

✓ #1050654 SUCCESS betula/patches/.build.yml https://builds.sr.ht/~bouncepaw/job/1050654