Commits

Anonymous committed bb68ed0

default 添加分页

Comments (0)

Files changed (3)

 
 class MainHandler(AdminHandler):
     def get(self):
-        self.template_value['a']=[]
         self.render('index.html')
         
 class AlbumIndexHandler(AdminHandler):
         p = int(self.request.get('p','1'))
         album = get_or_404(Album.get_by_key_name,key_name)
         self.template_value['album']=album
-        PAGESIZE = 100 if self.settings.theme <> 'default' else 24
+        PAGESIZE = 500 if self.settings.theme <> 'default' else 24
         imgs = PagedQuery(Image.all().filter('album = ',album),PAGESIZE)
         temp = imgs.fetch_page(p)
         self.template_value['prev']=p-1 if p>1 else None
         self.template_value['next'] = p +1 if len(temp) == PAGESIZE else None
         self.template_value['imgs']  = temp
+        self.template_value['ps'] = range(1,imgs.page_count())
+        self.template_value['current_p'] = p
         self.render('album.html')
     
 class ImageViewHandler(PublicHandler):

themes/default/album.html

 {% endfor %}
 </ul>
 
-<h2 class="page">{% if prev %}<a href="?p={{prev}}">上一页</a> {% endif %} {% if next %}<a href="?p={{next}}">下一页</a> {% endif%}</h2>
+<h2 class="page">
+{% if prev %}<a href="?p={{prev}}">上一页</a> {% endif %}
+{% for p in ps %}
+{% ifequal p current_p %}
+{{p}}
+{% else %}
+<a href="?p={{p}}">{{p}}</a> 
+{% endifequal %}
+{% endfor %}
+{% if next %}<a href="?p={{next}}">下一页</a> {% endif%}</h2>
 {% endblock %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.