aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorubq323 <ubq323>2021-08-22 15:52:23 +0000
committerubq323 <ubq323>2021-08-22 15:52:23 +0000
commit510ecff54b74ab98bd8d8efcd0a3c1a99e979fb0 (patch)
treeab1225e110a831883bc9f229ce27805ab6e71564
parentd7db0af8f7ce9e608180047bbbdc4fe9dd624f50 (diff)
move navbar to common macro, post_jump function
-rw-r--r--apioforum/templates/common.html20
-rw-r--r--apioforum/templates/view_forum.html16
-rw-r--r--apioforum/templates/view_thread.html14
3 files changed, 20 insertions, 30 deletions
diff --git a/apioforum/templates/common.html b/apioforum/templates/common.html
index f6b6f29..8eeef70 100644
--- a/apioforum/templates/common.html
+++ b/apioforum/templates/common.html
@@ -2,10 +2,6 @@
<a href="{{url_for('user.view_user',username=username)}}" class="username">{{username}}</a>
{%- endmacro %}
-{% macro post_url(post) -%}
- {{url_for('thread.view_thread', thread_id=post.thread)}}#post_{{post.id}}
-{%- endmacro %}
-
{% macro disp_post(post, buttons=False, forum=None, footer=None) %}
<div class="post {% if post.deleted %}deleted-post{% endif %}" id="post_{{post.id}}">
<div class="post-heading">
@@ -49,7 +45,7 @@
href="{{url_for('thread.view_post',post_id=post.id)}}">src</a>
{% endif %}
- <a class="post-anchor-link" href="{{post_url(post)}}">#{{post.id}}</a>
+ <a class="post-anchor-link" href="{{post_jump(post.id)}}">#{{post.id}}</a>
</span>
</div>
<div class="post-content md">
@@ -142,3 +138,17 @@
</desc>
</svg>
{% endmacro %}
+
+{% macro pagination_nav(page,max_pageno,view) %}
+<nav aria-label="pagination" id="pages">
+ {% if page > 1 %}
+ <a href="{{url_for(view,**kwargs)}}" aria-label="first page">&lt;&lt;</a>
+ <a href="{{url_for(view,page=page-1,**kwargs)}}" aria-label="previous page">&lt;</a>
+ {% endif %}
+ page {{page}} of {{max_pageno}}
+ {% if page < max_pageno %} {# > #}
+ <a href="{{url_for(view,page=page+1,**kwargs)}}" aria-label="next page">&gt;</a>
+ <a href="{{url_for(view,page=max_pageno,**kwargs)}}" aria-label="last page">&gt;&gt;</a>
+ {% endif %}
+</nav>
+{% endmacro %}
diff --git a/apioforum/templates/view_forum.html b/apioforum/templates/view_forum.html
index a5e444e..75144c8 100644
--- a/apioforum/templates/view_forum.html
+++ b/apioforum/templates/view_forum.html
@@ -1,5 +1,5 @@
{% extends 'base.html' %}
-{% from 'common.html' import ts, tag, disp_user, post_url, forum_breadcrumb, ab, vote_meter %}
+{% from 'common.html' import ts, tag, disp_user, post_url, forum_breadcrumb, ab, vote_meter, pagination_nav %}
{% block header %}
<h1>{% block title %}{{forum.name}}{% endblock %} <span class="thing-id">#{{forum.id}}</span></h1>
{% if forum.id != 1 %}
@@ -133,18 +133,8 @@ you do not have permission to create threads in this forum
</div>
{%endfor%}
</div>
-<nav aria-label="pagination" id="pages">
- {% if page > 1 %}
- <a href="{{url_for('forum.view_forum',forum_id=forum.id)}}" aria-label="first page">&lt;&lt;</a>
- <a href="{{url_for('forum.view_forum',forum_id=forum.id,page=page-1)}}" aria-label="previous page">&lt;</a>
- {% endif %}
- page {{page}} of {{max_pageno}}
- {% if page < max_pageno %} {# > #}
- <a href="{{url_for('forum.view_forum',forum_id=forum.id,page=page+1)}}" aria-label="next page">&gt;</a>
- <a href="{{url_for('forum.view_forum',forum_id=forum.id,page=max_pageno)}}" aria-label="last page">&gt;&gt;</a>
- {% endif %}
-</nav>
-
+{{ pagination_nav(page,max_pageno,'forum.view_forum',forum_id=forum.id) }}
+
{% else %}
<p>you do not have permission to view threads in this forum</p>
diff --git a/apioforum/templates/view_thread.html b/apioforum/templates/view_thread.html
index 11d21e4..fe22cfc 100644
--- a/apioforum/templates/view_thread.html
+++ b/apioforum/templates/view_thread.html
@@ -1,4 +1,4 @@
-{% from 'common.html' import disp_post,tag,thread_breadcrumb,vote_meter %}
+{% from 'common.html' import disp_post,tag,thread_breadcrumb,vote_meter,pagination_nav %}
{% extends 'base.html' %}
{% block header %}
<h1>{%block title %}{{thread.title}}{% endblock %} <span class="thing-id">#{{thread.id}}</span></h1>
@@ -69,17 +69,7 @@
{% endif %}
{% endfor %}
</div>
-<nav aria-label="pagination" id="pages">
- {% if page > 1 %}
- <a href="{{url_for('thread.view_thread',thread_id=thread.id)}}" aria-label="first page">&lt;&lt;</a>
- <a href="{{url_for('thread.view_thread',thread_id=thread.id,page=page-1)}}" aria-label="previous page">&lt;</a>
- {% endif %}
- page {{page}} of {{max_pageno}}
- {% if page < max_pageno %} {# > #}
- <a href="{{url_for('thread.view_thread',thread_id=thread.id,page=page+1)}}" aria-label="next page">&gt;</a>
- <a href="{{url_for('thread.view_thread',thread_id=thread.id,page=max_pageno)}}" aria-label="last page">&gt;&gt;</a>
- {% endif %}
-</nav>
+{{ pagination_nav(page,max_pageno,'thread.view_thread',thread_id=thread.id) }}
{% if g.user and has_permission(thread.forum, g.user, "p_reply_threads") %}
<form class="new-post" action="{{url_for('thread.create_post',thread_id=thread.id)}}" method="POST">
<textarea class="new-post-box" placeholder="your post here..." name="content"></textarea>