Cleanup svg list template, hide uneccesary pagination

This commit is contained in:
2017-11-12 23:13:19 +01:00
parent d3aaf2702e
commit cd3eebfc1f
3 changed files with 49 additions and 30 deletions
+1
View File
@@ -3,3 +3,4 @@ resourcedir = "resources/"
carddir = "cards/" carddir = "cards/"
svgdir = "svgs/" svgdir = "svgs/"
prettifyHTML = False#requires html5print module, only applies to html processed by airspeed prettifyHTML = False#requires html5print module, only applies to html processed by airspeed
svg_page_size = 150
+38 -23
View File
@@ -2,7 +2,7 @@
<title>SVG list</title> <title>SVG list</title>
<link rel="stylesheet" href="svg.css"> <link rel="stylesheet" href="svg.css">
#macro(form) #macro(upload_svgs_form)
<form action="svg" method="post" enctype="multipart/form-data"> <form action="svg" method="post" enctype="multipart/form-data">
<h3>Upload SVG:</h3> <h3>Upload SVG:</h3>
<p> <p>
@@ -16,28 +16,9 @@
</p> </p>
</form> </form>
#end #end
#macro(pagination) #macro(filter_and_collection_forms)
<center>
#set($self = "svg?")
#if($current_collection)
#set($self = "${self}collection=$escape_html($current_collection)&amp;")
#end
#if($filter)
#set($self = "${self}filter=$escape_html($filter)&amp;")
#end
#if($page>1)<a href="${self}page=$page.__sub__(1)">Previous page</a> - #end
<a href="${self}page=$page.__add__(1)">Next page</a>
</center>
#end
<a href="../" style="opacity:0.6;">Return to cardlist</a>
<div class="splitcontainer">
<div class="splitl">
#form()
</div>
<div class="splitr">
<form method="get" action="svg"> <form method="get" action="svg">
<h3>filter</h3> <h3>Filter svgs:</h3>
<input type="text" name="filter" value="$escape_html($filter)"> <input type="text" name="filter" value="$escape_html($filter)">
#if($current_collection) #if($current_collection)
<input type="hidden" name="collection" value="$escape_html($current_collection)"> <input type="hidden" name="collection" value="$escape_html($current_collection)">
@@ -51,6 +32,33 @@
- <a href="svg?collection=$escape_html($collection)">$escape_html($collection)</a> - <a href="svg?collection=$escape_html($collection)">$escape_html($collection)</a>
#end #end
</center> </center>
#end
#macro(pagination)
#if($has_next || $page>1)
<center>
#set($self = "svg?")
#if($current_collection)
#set($self = "${self}collection=$escape_html($current_collection)&amp;")
#end
#if($filter)
#set($self = "${self}filter=$escape_html($filter)&amp;")
#end
#if($page>1)<a href="${self}page=$page.__sub__(1)">Previous page</a> - #end
<b>Page $page</b>
#if($has_next)
- <a href="${self}page=$page.__add__(1)">Next page</a>
#end
</center>
#end
#end
<a href="../" style="opacity:0.6;">Return to cardlist</a>
<div class="splitcontainer">
<div class="splitl">
#upload_svgs_form()
</div>
<div class="splitr">
#filter_and_collection_forms()
</div> </div>
</div> </div>
@@ -69,6 +77,13 @@
#pagination() #pagination()
#form() <div class="splitcontainer">
<div class="splitl">
#upload_svgs_form()
</div>
<div class="splitr">
#filter_and_collection_forms()
</div>
</div>
<a href="../" style="opacity:0.6;">Return to cardlist</a> <a href="../" style="opacity:0.6;">Return to cardlist</a>
+4 -1
View File
@@ -134,8 +134,11 @@ async def svg_list(request, template={}):
if filter: if filter:
svgs = [i for i in svgs if filter in i] svgs = [i for i in svgs if filter in i]
if len(svgs) > page*config.svg_page_size:
has_next = True
svgs.sort() svgs.sort()
svgs = svgs[(page-1)*100:page*100] svgs = svgs[(page-1)*config.svg_page_size:page*config.svg_page_size]
return response.html(template["svg.vm"].merge(locals())) return response.html(template["svg.vm"].merge(locals()))