Optimization: make pagination code shorter #9
This commit is contained in:
parent
c48c25922e
commit
da26255411
3 changed files with 39 additions and 101 deletions
|
@ -2,7 +2,7 @@
|
||||||
<h2>{{ Title }}</h2>
|
<h2>{{ Title }}</h2>
|
||||||
|
|
||||||
<div class="switcher">
|
<div class="switcher">
|
||||||
{{ url := "/ranking?mode=" + Mode + "&page=1&content=
|
{{ url := "/ranking?mode=" + Mode + "&page=1&content=" }}
|
||||||
<span class="switch-title">Content</span>
|
<span class="switch-title">Content</span>
|
||||||
<a href="{{ url }}all" class="switch-button">Overall</a>
|
<a href="{{ url }}all" class="switch-button">Overall</a>
|
||||||
<a href="{{ url }}illust" class="switch-button">Illustrations</a>
|
<a href="{{ url }}illust" class="switch-button">Illustrations</a>
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<div class="switcher">
|
<div class="switcher">
|
||||||
{{ url := "/ranking?content=" + Content + "&page=1&mode=
|
{{ url := "/ranking?content=" + Content + "&page=1&mode=" }}
|
||||||
<span class="switch-title">Modes</span>
|
<span class="switch-title">Modes</span>
|
||||||
<a href="{{ url }}daily" class="switch-button">Daily</a>
|
<a href="{{ url }}daily" class="switch-button">Daily</a>
|
||||||
<a href="{{ url }}weekly" class="switch-button">Weekly</a>
|
<a href="{{ url }}weekly" class="switch-button">Weekly</a>
|
||||||
|
@ -36,31 +36,19 @@
|
||||||
<a class="artwork-thumbnail-title" href="/artworks/{{ .ID }}">
|
<a class="artwork-thumbnail-title" href="/artworks/{{ .ID }}">
|
||||||
<h3 class="no-margin">{{ .Title }}</h3>
|
<h3 class="no-margin">{{ .Title }}</h3>
|
||||||
</a>
|
</a>
|
||||||
<a href="/users/{{ .ArtistID }}" class="artwork-thumbnail-artist flex"
|
<a href="/users/{{ .ArtistID }}" class="artwork-thumbnail-artist flex"><img src="{{ .ArtistAvatar }}"
|
||||||
><img
|
alt="{{ .ArtistName }}" class="artwork-thumbnail-artist-avatar border-rounded" />
|
||||||
src="{{ .ArtistAvatar }}"
|
{{ .ArtistName }}</a>
|
||||||
alt="{{ .ArtistName }}"
|
|
||||||
class="artwork-thumbnail-artist-avatar border-rounded"
|
|
||||||
/>
|
|
||||||
{{ .ArtistName }}</a
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
{{ if Page <= 1 }} <a href="#" class="pagination-button disabled">First</a>
|
{{ url := "/ranking?content=" + Content + "&mode=" + Mode + "&page=" }} {{
|
||||||
|
if Page <= 1 }} <a href="#" class="pagination-button disabled">First</a>
|
||||||
<a href="#" class="pagination-button disabled">Previous</a>
|
<a href="#" class="pagination-button disabled">Previous</a>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<a
|
<a href="{{ url }}1" class="pagination-button">First</a>
|
||||||
href="/ranking?content={{ Content }}&mode={{ Mode }}&page=1"
|
<a href="{{ url }}{{ Page - 1 }}" class="pagination-button">Previous</a>
|
||||||
class="pagination-button"
|
|
||||||
>First</a
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/ranking?content={{ Content }}&mode={{ Mode }}&page={{ dec(Page) }}"
|
|
||||||
class="pagination-button"
|
|
||||||
>Previous</a
|
|
||||||
>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<a href="#" class="pagination-button disabled">{{ Page }}</a>
|
<a href="#" class="pagination-button disabled">{{ Page }}</a>
|
||||||
|
@ -69,16 +57,8 @@
|
||||||
<a href="#" class="pagination-button disabled">Next</a>
|
<a href="#" class="pagination-button disabled">Next</a>
|
||||||
<a href="#" class="pagination-button disabled">Last</a>
|
<a href="#" class="pagination-button disabled">Last</a>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<a
|
<a href="{{ url }}{{ Page + 1 }}" class="pagination-button">Next</a>
|
||||||
href="/ranking?content={{ Content }}&mode={{ Mode }}&page={{ inc(Page) }}"
|
<a href="{{ url }}10" class="pagination-button">Last</a>
|
||||||
class="pagination-button"
|
|
||||||
>Next</a
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/ranking?content={{ Content }}&mode={{ Mode }}&page=10"
|
|
||||||
class="pagination-button"
|
|
||||||
>Last</a
|
|
||||||
>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,11 +2,7 @@
|
||||||
<div class="tag-header">
|
<div class="tag-header">
|
||||||
{{ if Tag.Metadata.id }}
|
{{ if Tag.Metadata.id }}
|
||||||
<a href="/artworks/{{ Tag.Metadata.id }}">
|
<a href="/artworks/{{ Tag.Metadata.id }}">
|
||||||
<img
|
<img class="tag-thumbnail" src="{{ Tag.Metadata.image }}" alt="{{ Tag.Name }}" />
|
||||||
class="tag-thumbnail"
|
|
||||||
src="{{ Tag.Metadata.image }}"
|
|
||||||
alt="{{ Tag.Name }}"
|
|
||||||
/>
|
|
||||||
</a>
|
</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
@ -63,28 +59,18 @@
|
||||||
<div>{{ include "small-tn" Data.Artworks.Artworks }}</div>
|
<div>{{ include "small-tn" Data.Artworks.Artworks }}</div>
|
||||||
|
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
{{ if toInt (Queries.Page) == 1 }}
|
{{ url := "/tags/" + Tag.Name + "?category=" + Queries.Category + "&order="
|
||||||
|
+ Queries.Order + "&mode=" + Queries.Mode + "&page=" }} {{ if toInt
|
||||||
|
(Queries.Page) == 1 }}
|
||||||
<a href="#" class="pagination-button disabled">First</a>
|
<a href="#" class="pagination-button disabled">First</a>
|
||||||
<a href="#" class="pagination-button disabled">Previous</a>
|
<a href="#" class="pagination-button disabled">Previous</a>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<a
|
<a href="{{url}}1" class="pagination-button">First</a>
|
||||||
href="/tags/{{ Tag.Name }}?category={{ Queries.Category }}&order={{ Queries.Order }}&mode={{ Queries.Mode }}&page=1"
|
<a href="{{url}}{{ toInt(Queries.Page) - 1 }}" class="pagination-button">Previous</a>
|
||||||
class="pagination-button"
|
|
||||||
>First</a
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/tags/{{ Tag.Name }}?category={{ Queries.Category }}&order={{ Queries.Order }}&mode={{ Queries.Mode }}&page={{ dec(toInt(Queries.Page)) }}"
|
|
||||||
class="pagination-button"
|
|
||||||
>Previous</a
|
|
||||||
>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<a href="#" class="pagination-button disabled">{{ Queries.Page }}</a>
|
<a href="#" class="pagination-button disabled">{{ Queries.Page }}</a>
|
||||||
|
|
||||||
<a
|
<a href="{{url}}{{ toInt(Queries.Page) + 1 }}" class="pagination-button">Next</a>
|
||||||
href="/tags/{{ Tag.Name }}?category={{ Queries.Category }}&order={{ Queries.Order }}&mode={{ Queries.Mode }}&page={{ inc(toInt(Queries.Page)) }}"
|
|
||||||
class="pagination-button"
|
|
||||||
>Next</a
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,20 +18,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="switcher">
|
<div class="switcher">
|
||||||
<span class="switch-title">Category</span>
|
<span class="switch-title">Category</span>
|
||||||
<a href="/users/{{ User.ID }}/artworks#checkpoint" class="switch-button"
|
<a href="/users/{{ User.ID }}/artworks#checkpoint" class="switch-button">All</a>
|
||||||
>All</a
|
<a href="/users/{{ User.ID }}/illustrations#checkpoint" class="switch-button">Illustrations</a>
|
||||||
>
|
<a href="/users/{{ User.ID }}/manga#checkpoint" class="switch-button">Mangas</a>
|
||||||
<a
|
<a href="/users/{{ User.ID }}/bookmarks#checkpoint" class="switch-button">Bookmarks</a>
|
||||||
href="/users/{{ User.ID }}/illustrations#checkpoint"
|
|
||||||
class="switch-button"
|
|
||||||
>Illustrations</a
|
|
||||||
>
|
|
||||||
<a href="/users/{{ User.ID }}/manga#checkpoint" class="switch-button"
|
|
||||||
>Mangas</a
|
|
||||||
>
|
|
||||||
<a href="/users/{{ User.ID }}/bookmarks#checkpoint" class="switch-button"
|
|
||||||
>Bookmarks</a
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h1 id="checkpoint">Illustrations and Mangas</h1>
|
<h1 id="checkpoint">Illustrations and Mangas</h1>
|
||||||
|
@ -39,10 +29,7 @@
|
||||||
<div>
|
<div>
|
||||||
{{ range User.FrequentTags }}
|
{{ range User.FrequentTags }}
|
||||||
<a href="/tags/{{ .Name }}">
|
<a href="/tags/{{ .Name }}">
|
||||||
<div
|
<div class="tag-container" style="background-color: {{ randomColor() }}">
|
||||||
class="tag-container"
|
|
||||||
style="background-color: {{ randomColor() }}"
|
|
||||||
>
|
|
||||||
{{ if ! .TranslatedName }}
|
{{ if ! .TranslatedName }}
|
||||||
<div class="main">{{ .Name }}</div>
|
<div class="main">{{ .Name }}</div>
|
||||||
<div class="sub">#</div>
|
<div class="sub">#</div>
|
||||||
|
@ -58,38 +45,23 @@
|
||||||
{{ include "small-tn" User.Artworks }}
|
{{ include "small-tn" User.Artworks }}
|
||||||
</div>
|
</div>
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
{{ if Page == 1 }}
|
{{ url := "/users/" + User.ID + "/" + Category + "?page="}} {{ if Page == 1
|
||||||
|
}}
|
||||||
<a href="#" class="pagination-button disabled">First</a>
|
<a href="#" class="pagination-button disabled">First</a>
|
||||||
<a href="#" class="pagination-button disabled">Previous</a>
|
<a href="#" class="pagination-button disabled">Previous</a>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<a
|
<a href="{{ url }}1#checkpoint" class="pagination-button">First</a>
|
||||||
href="/users/{{ User.ID }}/{{ Category }}?page=1#checkpoint"
|
<a href="{{ url }}{{ Page - 1 }}#checkpoint" class="pagination-button">Previous</a>
|
||||||
class="pagination-button"
|
|
||||||
>First</a
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/users/{{ User.ID }}/{{ Category }}?page={{ dec(Page) }}#checkpoint"
|
|
||||||
class="pagination-button"
|
|
||||||
>Previous</a
|
|
||||||
>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<a href="#" class="pagination-button disabled">{{ Page }}</a>
|
<a href="#" class="pagination-button disabled">{{ Page }}</a>
|
||||||
|
|
||||||
{{ if Page == dec(PageLimit) }}
|
{{ if Page == PageLimit - 1 }}
|
||||||
<a href="#" class="pagination-button disabled">Next</a>
|
<a href="#" class="pagination-button disabled">Next</a>
|
||||||
<a href="#" class="pagination-button disabled">Last</a>
|
<a href="#" class="pagination-button disabled">Last</a>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<a
|
<a href="{{ url }}{{ Page + 1 }}#checkpoint" class="pagination-button">Next</a>
|
||||||
href="/users/{{ User.ID }}/{{ Category }}?page={{ inc(Page) }}#checkpoint"
|
<a href="{{ url }}{{ PageLimit - 1 }}#checkpoint" class="pagination-button">Last</a>
|
||||||
class="pagination-button"
|
|
||||||
>Next</a
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/users/{{ User.ID }}/{{ Category }}?page={{ dec(PageLimit) }}#checkpoint"
|
|
||||||
class="pagination-button"
|
|
||||||
>Last</a
|
|
||||||
>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue