aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-08-12 09:55:50 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-08-12 09:55:50 -0500
commit38bf03c6aae118870c1c58873c2aa72bfbf34887 (patch)
tree35c21a6f4f8645ce931ca4be211754f441fe2e9e
parent035c976fb2ccbbc7dc73cc6ceb4b5ed8d4523561 (diff)
downloadmediagoblin-38bf03c6aae118870c1c58873c2aa72bfbf34887.tar.lz
mediagoblin-38bf03c6aae118870c1c58873c2aa72bfbf34887.tar.xz
mediagoblin-38bf03c6aae118870c1c58873c2aa72bfbf34887.zip
Converting object_gallery() from a block to a macro and updating usages of it
The main motivation here is that this lets us pass in a specific number of col_number
-rw-r--r--mediagoblin/templates/mediagoblin/listings/tag.html4
-rw-r--r--mediagoblin/templates/mediagoblin/root.html6
-rw-r--r--mediagoblin/templates/mediagoblin/user_pages/gallery.html4
-rw-r--r--mediagoblin/templates/mediagoblin/user_pages/user.html5
-rw-r--r--mediagoblin/templates/mediagoblin/utils/object_gallery.html21
5 files changed, 30 insertions, 10 deletions
diff --git a/mediagoblin/templates/mediagoblin/listings/tag.html b/mediagoblin/templates/mediagoblin/listings/tag.html
index a013797f..a43355a7 100644
--- a/mediagoblin/templates/mediagoblin/listings/tag.html
+++ b/mediagoblin/templates/mediagoblin/listings/tag.html
@@ -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">
diff --git a/mediagoblin/templates/mediagoblin/root.html b/mediagoblin/templates/mediagoblin/root.html
index a4e19984..06beb436 100644
--- a/mediagoblin/templates/mediagoblin/root.html
+++ b/mediagoblin/templates/mediagoblin/root.html
@@ -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 %}
diff --git a/mediagoblin/templates/mediagoblin/user_pages/gallery.html b/mediagoblin/templates/mediagoblin/user_pages/gallery.html
index a66a547e..ff935ac4 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/gallery.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/gallery.html
@@ -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(
diff --git a/mediagoblin/templates/mediagoblin/user_pages/user.html b/mediagoblin/templates/mediagoblin/user_pages/user.html
index 1115fc56..4649c8c7 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/user.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/user.html
@@ -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>
diff --git a/mediagoblin/templates/mediagoblin/utils/object_gallery.html b/mediagoblin/templates/mediagoblin/utils/object_gallery.html
index c5e890fc..c7286678 100644
--- a/mediagoblin/templates/mediagoblin/utils/object_gallery.html
+++ b/mediagoblin/templates/mediagoblin/utils/object_gallery.html
@@ -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 %}
@@ -55,9 +55,22 @@
</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 %}