diff options
author | Bernhard Keller <keller_bernhard@web.de> | 2011-05-18 17:32:49 +0200 |
---|---|---|
committer | Bernhard Keller <keller_bernhard@web.de> | 2011-05-18 17:32:49 +0200 |
commit | ae85ed0f971147ce7cee9ce02b498f909d21ce79 (patch) | |
tree | 53f751a33265ce239c556da11fc4722e2a550078 /mediagoblin/templates | |
parent | 931f318cbc571419510b1ad37298c981df2f16b0 (diff) | |
download | mediagoblin-ae85ed0f971147ce7cee9ce02b498f909d21ce79.tar.lz mediagoblin-ae85ed0f971147ce7cee9ce02b498f909d21ce79.tar.xz mediagoblin-ae85ed0f971147ce7cee9ce02b498f909d21ce79.zip |
added Pagination class, usage description in Pagination,__call__
added pagination.html, object_gallery.html as templates
Diffstat (limited to 'mediagoblin/templates')
4 files changed, 81 insertions, 9 deletions
diff --git a/mediagoblin/templates/mediagoblin/root.html b/mediagoblin/templates/mediagoblin/root.html index e2b2730a..a93a7c75 100644 --- a/mediagoblin/templates/mediagoblin/root.html +++ b/mediagoblin/templates/mediagoblin/root.html @@ -53,4 +53,4 @@ </ul> </div> -{% endblock %} +{% endblock %} diff --git a/mediagoblin/templates/mediagoblin/user_pages/user.html b/mediagoblin/templates/mediagoblin/user_pages/user.html index 5c8692fc..48516679 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/user.html +++ b/mediagoblin/templates/mediagoblin/user_pages/user.html @@ -23,14 +23,9 @@ {#- Should we outsource such a media 'gallery' view to it's own file? It could be useful for the home page and other views too -#} <ul> - {%- for entry in media_entries %} - <li> - <a href="{{ request.urlgen('mediagoblin.user_pages.media_home', - user= entry.uploader.username, m_id= entry._id) }}"> - <img src="{{ request.app.public_store.file_url( - entry['media_files']['thumb']) }}" /></a> - </li> - {%- endfor %} + + {% include "mediagoblin/utils/object_gallery.html" %} + </ul> {% else %} {# This *should* not occur as the view makes sure we pass in a user. #} diff --git a/mediagoblin/templates/mediagoblin/utils/object_gallery.html b/mediagoblin/templates/mediagoblin/utils/object_gallery.html new file mode 100644 index 00000000..6e59c380 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/utils/object_gallery.html @@ -0,0 +1,36 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011 Free Software Foundation, Inc +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +#} + + + <div> + {% if media_entries %} + <ul> + {% for entry in media_entries %} + <li> + <a href="{{ request.urlgen('mediagoblin.user_pages.media_home', + user= entry.uploader.username, m_id= entry._id) }}"> + <img src="{{ request.app.public_store.file_url( + entry['media_files']['thumb']) }}" /></a> + </li> + {% endfor %} + </ul> + + {% import 'mediagoblin/utils/pagination.html' as paginationmacro %} + {{ paginationmacro.render_pagination(pagination) }} + {% endif %} + </div> diff --git a/mediagoblin/templates/mediagoblin/utils/pagination.html b/mediagoblin/templates/mediagoblin/utils/pagination.html new file mode 100644 index 00000000..80b4b820 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/utils/pagination.html @@ -0,0 +1,41 @@ +{# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011 Free Software Foundation, Inc +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +#} + + +{% macro render_pagination(pagination) %} + +{# only display if {{pagination}} is defined #} + +{% if pagination %} + <div class=pagination> + {%- for page in pagination.iter_pages() %} + {% if page %} + {% if page != pagination.page %} + <a href={{pagination.url_generator(page)}}>{{ page }}</a> + {% else %} + <strong>{{ page }}</strong> + {% endif %} + {% else %} + <span class=ellipsis>…</span> + {% endif %} + {%- endfor %} + {% if pagination.has_next %} + <a href={{pagination.url_generator(pagination.page+1)}}>Next »</a> + {% endif %} + </div> +{% endif %} +{% endmacro %} |