Converting object_gallery() from a block to a macro and updating usages of it
authorChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 12 Aug 2011 14:55:50 +0000 (09:55 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 12 Aug 2011 14:55:50 +0000 (09:55 -0500)
The main motivation here is that this lets us pass in a specific number of col_number

mediagoblin/templates/mediagoblin/listings/tag.html
mediagoblin/templates/mediagoblin/root.html
mediagoblin/templates/mediagoblin/user_pages/gallery.html
mediagoblin/templates/mediagoblin/user_pages/user.html
mediagoblin/templates/mediagoblin/utils/object_gallery.html

index a013797ff606b9bcaf359afd7b55d323f2f20d02..a43355a731c4dc7ef6e086a2da981e3631a6670b 100644 (file)
@@ -17,6 +17,8 @@
 #}
 {% extends "mediagoblin/base.html" %}
 
+{% from "mediagoblin/utils/object_gallery.html" import object_gallery %}
+
 {% block mediagoblin_head %}
     <link rel="alternate" type="application/atom+xml"
           href="{{ request.urlgen(
@@ -30,7 +32,7 @@
   </h1>
 
   <div class="container_16 media_gallery">
-    {% include "mediagoblin/utils/object_gallery.html" %}
+    {{ object_gallery(request, media_entries, pagination) }}
   </div>
 
   <div class="grid_16">
index a4e1998402731975db83d81131dbe2cb80599726..06beb4362b681e1834475bee18c80a740b16c766 100644 (file)
@@ -17,6 +17,8 @@
 #}
 {% extends "mediagoblin/base.html" %}
 
+{% from "mediagoblin/utils/object_gallery.html" import object_gallery %}
+
 {% block mediagoblin_content %}
   <h1>{% trans %}Welcome to GNU MediaGoblin!{% endtrans %}</h1>
 
@@ -41,7 +43,5 @@
     {% endif %}
   {% endif %}
 
-  {# temporarily, an "image gallery" that isn't one really ;) #}
-
-  {% include "mediagoblin/utils/object_gallery.html" %}
+  {{ object_gallery(request, media_entries, pagination) }}
 {% endblock %}
index a66a547e58409e2aa8fc240b7363293ae5342971..ff935ac4a6d52e09d65ea6205994a773d539a294 100644 (file)
@@ -17,6 +17,8 @@
 #}
 {% extends "mediagoblin/base.html" %}
 
+{% from "mediagoblin/utils/object_gallery.html" import object_gallery %}
+
 {% block mediagoblin_head %}
     <link rel="alternate" type="application/atom+xml"
           href="{{ request.urlgen(
@@ -37,7 +39,7 @@
 
     </div>
     <div class="container_16 media_gallery">
-      {% include "mediagoblin/utils/object_gallery.html" %}
+      {{ object_gallery(request, media_entries, pagination) }}
     </div>
     <div class="grid_16">
       <a href="{{ request.urlgen(
index 1115fc56c99fb70dc5b456fcf96c14dcba34e639..4649c8c797b7cad9819dca069013248484c6f032 100644 (file)
@@ -17,6 +17,8 @@
 #}
 {% extends "mediagoblin/base.html" %}
 
+{% from "mediagoblin/utils/object_gallery.html" import object_gallery %}
+
 {% block mediagoblin_head %}
     <link rel="alternate" type="application/atom+xml"
           href="{{ request.urlgen(
@@ -87,7 +89,8 @@
     </div>
 
     <div class="grid_10 omega">
-      {% set pagination_base_url = user_gallery_url %}
+      {{ object_gallery(request, media_entries, pagination,
+                        pagination_base_url=user_gallery_url, col_number=3) }}
       {% include "mediagoblin/utils/object_gallery.html" %}
       <div class="clear"></div>
       <p>
index c5e890fc6beb21a95eb162c1820fc8de94920f26..c7286678c4f2d3f43cb38891657ed2d0e517dad1 100644 (file)
@@ -18,7 +18,7 @@
 
 {% from "mediagoblin/utils/pagination.html" import render_pagination %}
 
-{% macro media_grid(media_list, col_number=5) %}
+{% macro media_grid(request, media_list, col_number=5) %}
     {% set num_items = media_list.count() %}
     {% set col_counter = 0 %}
     {% set row_counter = 0 %}
     </div>
 {%- endmacro %}
 
-{% block object_gallery_content -%}
+
+{#
+  Render a media gallery with pagination.
+
+  Args:
+   - request: Request
+   - media_entries: pymongo cursor of media entries
+   - pagination: Paginator object
+   - pagination_base_url: If you want the pagination to point to a
+     different URL, point it here
+   - col_number: How many columns per row (default 5)
+#}
+{% macro object_gallery(request, media_entries, pagination,
+                        pagination_base_url=None, col_number=5) %}
   {% if media_entries and media_entries.count() %}
-    {{ media_grid(media_entries) }}
+    {{ media_grid(request, media_entries, col_number=col_number) }}
     <div class="clear"></div>
     {% if pagination_base_url %}
       {# different url, so set that and don't keep the get params #}
@@ -70,4 +83,4 @@
       <i>There doesn't seem to be any media here yet...</i>
     </p>
   {% endif %}
-{% endblock %}
+{% endmacro %}