{% extends "mediagoblin/base.html" %}
{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
+{% from "mediagoblin/utils/pagination.html" import render_pagination %}
{% block mediagoblin_content %}
{% if media %}
</div>
{% endfor %}
- {% include "mediagoblin/utils/pagination.html" %}
+ {{ render_pagination(request, pagination) }}
</div>
{% endif %}
<div class="grid_4 omega media_sidebar">
{% include "mediagoblin/utils/profile.html" %}
+ {% set pagination_base_url = user_gallery_url %}
{% include "mediagoblin/utils/object_gallery.html" %}
- <p><a href="{{ request.urlgen('mediagoblin.user_pages.user_gallery',
- user=user['username']) }}">View all of {{ user.username }}'s media</a></p>
+ <p><a href="user_gallery_url">View all of {{ user.username }}'s media</a></p>
<a href={{ request.urlgen(
'mediagoblin.user_pages.atom_feed',
- user=user.username) }}> atom feed</a>
+ user=user.username) }}>atom feed</a>
{% else %}
{# This *should* not occur as the view makes sure we pass in a user. #}
<p>Sorry, no such user found.<p/>
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
+{% from "mediagoblin/utils/pagination.html" import render_pagination %}
+
{% block object_gallery_content -%}
<div>
{% if media_entries %}
</li>
{% endfor %}
</ul>
- {% include "mediagoblin/utils/pagination.html" %}
- {% endif %}
-
+ {% if pagination_base_url %}
+ {# different url, so set that and don't keep the get params #}
+ {{ render_pagination(request, pagination, pagination_base_url, False) }}
+ {% else %}
+ {{ render_pagination(request, pagination) }}
+ {% endif %}
+ {% endif %}
</div>
{% endblock %}
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
-{# only display if {{pagination}} is defined #}
+{% macro render_pagination(request, pagination,
+ base_url=None, preserve_get_params=True) %}
+ {# only display if {{pagination}} is defined #}
+ {% if pagination and pagination.pages > 1 %}
+ {% if not base_url %}
+ {% set base_url = request.path_info %}
+ {% endif %}
-{% if pagination and pagination.pages > 1 %}
- <div class="pagination">
- <p>
- {% if pagination.has_prev %}
- <a href="{{ pagination.get_page_url(request, pagination.page-1) }}">« Prev</a>
- {% endif %}
+ {% if preserve_get_params %}
+ {% set get_params = request.GET %}
+ {% else %}
+ {% set get_params = {} %}
+ {% endif %}
- {%- for page in pagination.iter_pages() %}
- {% if page %}
- {% if page != pagination.page %}
- <a href="{{ pagination.get_page_url(request, page) }}">{{ page }}</a>
+ <div class="pagination">
+ <p>
+ {% if pagination.has_prev %}
+ <a href="{{ pagination.get_page_url_explicit(
+ base_url, get_params,
+ pagination.page - 1) }}">« Prev</a>
+ {% endif %}
+
+ {%- for page in pagination.iter_pages() %}
+ {% if page %}
+ {% if page != pagination.page %}
+ <a href="{{ pagination.get_page_url_explicit(
+ base_url, get_params,
+ page) }}">{{ page }}</a>
+ {% else %}
+ {{ page }}
+ {% endif %}
{% else %}
- {{ page }}
+ <span class="ellipsis">…</span>
{% endif %}
- {% else %}
- <span class="ellipsis">…</span>
+ {%- endfor %}
+
+ {% if pagination.has_next %}
+ <a href="{{ pagination.get_page_url_explicit(
+ base_url, get_params,
+ pagination.page + 1) }}">Next »</a>
{% endif %}
- {%- endfor %}
-
- {% if pagination.has_next %}
- <a href="{{ pagination.get_page_url(request, pagination.page + 1) }}">Next »</a>
- {% endif %}
- </p>
- </div>
-{% endif %}
-
+ </p>
+ </div>
+ {% endif %}
+{% endmacro %}
if media_entries == None:
return exc.HTTPNotFound()
+ user_gallery_url = request.urlgen(
+ 'mediagoblin.user_pages.user_gallery',
+ user=user['username'])
+
return render_to_response(
request,
'mediagoblin/user_pages/user.html',
{'user': user,
+ 'user_gallery_url': user_gallery_url,
'media_entries': media_entries,
'pagination': pagination})