Make index page paginated
authorChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 1 Aug 2011 15:49:05 +0000 (10:49 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 1 Aug 2011 15:49:05 +0000 (10:49 -0500)
mediagoblin/templates/mediagoblin/root.html
mediagoblin/views.py

index bae033c415bcbcc5f4c2b7b7b85065f9c66ed516..ed7b931fc257e24d4881977323c1b1acf0d4cac7 100644 (file)
@@ -39,5 +39,5 @@
 
   {# temporarily, an "image gallery" that isn't one really ;) #}
 
-    {% include "mediagoblin/utils/object_gallery.html" %}
+  {% include "mediagoblin/utils/object_gallery.html" %}
 {% endblock %}
index e7d9dbdddfb1bc4cdab1782d4ae776778df04fa5..ccd7a2df2aad283492c9200e895bb3d0fabc7e8b 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from mediagoblin import mg_globals
-from mediagoblin.util import render_to_response
+from mediagoblin.util import render_to_response, Pagination
 from mediagoblin.db.util import DESCENDING
+from mediagoblin.decorators import uses_pagination
 
-def root_view(request):
-    media_entries = request.db.MediaEntry.find(
+@uses_pagination
+def root_view(request, page):
+    cursor = request.db.MediaEntry.find(
         {u'state': u'processed'}).sort('created', DESCENDING)
-    
+
+    pagination = Pagination(page, cursor)
+    media_entries = pagination()
+
     return render_to_response(
         request, 'mediagoblin/root.html',
         {'media_entries': media_entries,
-         'allow_registration': mg_globals.app_config["allow_registration"]})
+         'allow_registration': mg_globals.app_config["allow_registration"],
+         'pagination': pagination})
 
 
 def simple_template_render(request):