diff options
author | Aaron Williamson <aaron@copiesofcopies.org> | 2012-08-17 00:57:18 -0400 |
---|---|---|
committer | Joar Wandborg <git@wandborg.com> | 2012-09-18 18:10:36 +0200 |
commit | a0fdc00fab0a76e4f994ba62ce6d24a65f09a532 (patch) | |
tree | 289d613813a6ab9a04aac0d1de96d7c3f0e30e0f | |
parent | be5be1154fd22c548125ce5a055af1bdfdad9526 (diff) | |
download | mediagoblin-a0fdc00fab0a76e4f994ba62ce6d24a65f09a532.tar.lz mediagoblin-a0fdc00fab0a76e4f994ba62ce6d24a65f09a532.tar.xz mediagoblin-a0fdc00fab0a76e4f994ba62ce6d24a65f09a532.zip |
Added new files for collections
11 files changed, 548 insertions, 0 deletions
diff --git a/mediagoblin/static/images/icon_collect.png b/mediagoblin/static/images/icon_collect.png Binary files differnew file mode 100644 index 00000000..2911af24 --- /dev/null +++ b/mediagoblin/static/images/icon_collect.png diff --git a/mediagoblin/static/js/collection_form_show.js b/mediagoblin/static/js/collection_form_show.js new file mode 100644 index 00000000..03a4906b --- /dev/null +++ b/mediagoblin/static/js/collection_form_show.js @@ -0,0 +1,26 @@ +/** + * GNU MediaGoblin -- federated, autonomous media hosting + * Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. + * + * 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/>. + */ + +$(document).ready(function(){ + $('#new_collection').hide(); + $('#button_addcollection').click(function(){ + $('#new_collection').slideToggle('fast', function(){ + $('#collection_title').focus(); + }); + }); +}); diff --git a/mediagoblin/templates/mediagoblin/edit/edit_collection.html b/mediagoblin/templates/mediagoblin/edit/edit_collection.html new file mode 100644 index 00000000..5cf5bae8 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/edit/edit_collection.html @@ -0,0 +1,39 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# 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/>. +#} +{% extends "mediagoblin/base.html" %} + +{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %} + +{% block mediagoblin_content %} + + <form action="{{ request.urlgen('mediagoblin.edit.edit_collection', + user= collection.get_creator.username, + collection= collection.slug) }}" + method="POST" enctype="multipart/form-data"> + <div class="form_box_xl edit_box"> + <h1>{% trans collection_title=collection.title %}Editing {{ collection_title }}{% endtrans %}</h1> + {{ wtforms_util.render_divs(form) }} + <div class="form_submit_buttons"> + <a class="button_action" href="{{ collection.url_for_self(request.urlgen) }}">{% trans %}Cancel{% endtrans %}</a> + <input type="submit" value="{% trans %}Save changes{% endtrans %}" class="button_form" /> + {{ csrf_token }} + </div> + </div> + </form> + +{% endblock %} diff --git a/mediagoblin/templates/mediagoblin/listings/collection.html b/mediagoblin/templates/mediagoblin/listings/collection.html new file mode 100644 index 00000000..4d502201 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/listings/collection.html @@ -0,0 +1,43 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# 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/>. +#} +{% 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( + 'mediagoblin.listings.tag_atom_feed', + tag=tag_slug) }}"> +{% endblock mediagoblin_head %} + +{% block title %} + {% trans %}Media tagged with: {{ tag_name }}{% endtrans %} — {{ super() }} +{% endblock %} + +{% block mediagoblin_content -%} + <h1> + {% trans %}Media tagged with: {{ tag_name }}{% endtrans %} + </h1> + + {{ object_gallery(request, media_entries, pagination) }} + + {% set feed_url = request.urlgen('mediagoblin.listings.tag_atom_feed', + tag=tag_slug) %} + {% include "mediagoblin/utils/feed_link.html" %} +{% endblock %} diff --git a/mediagoblin/templates/mediagoblin/submit/collection.html b/mediagoblin/templates/mediagoblin/submit/collection.html new file mode 100644 index 00000000..4e2bc17d --- /dev/null +++ b/mediagoblin/templates/mediagoblin/submit/collection.html @@ -0,0 +1,34 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# 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/>. +#} +{% extends "mediagoblin/base.html" %} + +{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %} + +{% block mediagoblin_content %} + <form action="{{ request.urlgen('mediagoblin.submit.collection') }}" + method="POST" enctype="multipart/form-data"> + <div class="form_box_xl"> + <h1>{% trans %}Add a collection{% endtrans %}</h1> + {{ wtforms_util.render_divs(submit_form) }} + <div class="form_submit_buttons"> + {{ csrf_token }} + <input type="submit" value="{% trans %}Add{% endtrans %}" class="button_form" /> + </div> + </div> + </form> +{% endblock %} diff --git a/mediagoblin/templates/mediagoblin/user_pages/collection.html b/mediagoblin/templates/mediagoblin/user_pages/collection.html new file mode 100644 index 00000000..7ea84876 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/user_pages/collection.html @@ -0,0 +1,72 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# 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/>. +#} +{% extends "mediagoblin/base.html" %} + +{% from "mediagoblin/utils/collection_gallery.html" import collection_gallery %} + +{% block mediagoblin_head %} + <link rel="alternate" type="application/atom+xml" + href="{{ request.urlgen( + 'mediagoblin.user_pages.atom_feed', + user=user.username) }}"> +{% endblock mediagoblin_head %} + +{% block title %} + {%- trans username=user.username, + collection_title=collection.title + -%} + {{ collection_title }} ({{ username }}'s collection) + {%- endtrans %} — {{ super() }} +{% endblock %} + +{% block mediagoblin_content -%} + <h1> + {%- trans username=user.username, + user_url=request.urlgen( + 'mediagoblin.user_pages.user_home', + user=user.username), + collection_title=collection.title -%} + {{ collection_title }} by <a href="{{ user_url }}">{{ username }}</a> + {%- endtrans %} + </h1> + {% if request.user and (collection.creator == request.user._id or + request.user.is_admin) %} + {% set edit_url = request.urlgen('mediagoblin.edit.edit_collection', + user=collection.get_creator.username, + collection=collection.slug) %} + <a class="button_action" href="{{ edit_url }}">{% trans %}Edit{% endtrans %}</a> + {% set delete_url = request.urlgen('mediagoblin.user_pages.collection_confirm_delete', + user=collection.get_creator.username, + collection=collection.slug) %} + <a class="button_action" href="{{ delete_url }}">{% trans %}Delete{% endtrans %}</a> + {% endif %} + + {%- trans collection_description=collection.description -%} + <p> + {{ collection_description }} + </p> + {%- endtrans %} + + {{ collection_gallery(request, collection_items, pagination) }} + + {% set feed_url = request.urlgen('mediagoblin.user_pages.collection_atom_feed', + user=user.username, + collection=collection.slug ) %} + {% include "mediagoblin/utils/feed_link.html" %} + +{% endblock %} diff --git a/mediagoblin/templates/mediagoblin/user_pages/collection_confirm_delete.html b/mediagoblin/templates/mediagoblin/user_pages/collection_confirm_delete.html new file mode 100644 index 00000000..7499c0cf --- /dev/null +++ b/mediagoblin/templates/mediagoblin/user_pages/collection_confirm_delete.html @@ -0,0 +1,52 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# 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/>. +#} +{% extends "mediagoblin/base.html" %} + +{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %} + +{% block mediagoblin_content %} + + <form action="{{ request.urlgen('mediagoblin.user_pages.collection_confirm_delete', + user=collection.get_creator.username, + collection=collection.slug) }}" + method="POST" enctype="multipart/form-data"> + <div class="form_box"> + <h1> + {%- trans title=collection.title -%} + Really delete {{ title }}? + {%- endtrans %} + </h1> + + <br /> + + <p class="delete_checkbox_box"> + {{ form.confirm }} + <label for="{{ (form.confirm.name) }}">{{ _(form.confirm.label.text) }}</label> + </p> + + <div class="form_submit_buttons"> + {# TODO: This isn't a button really... might do unexpected things :) #} + <a class="button_action" href="{{ request.urlgen('mediagoblin.user_pages.user_collection', + collection=collection.slug, + user=request.user.username) }}">{% trans %}Cancel{% endtrans %}</a> + <input type="submit" value="{% trans %}Delete permanently{% endtrans %}" class="button_form" /> + {{ csrf_token }} + </div> + </div> + </form> +{% endblock %} diff --git a/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html b/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html new file mode 100644 index 00000000..f56ab5ab --- /dev/null +++ b/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html @@ -0,0 +1,59 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# 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/>. +#} +{% extends "mediagoblin/base.html" %} + +{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %} + +{% block mediagoblin_content %} + + <form action="{{ request.urlgen('mediagoblin.user_pages.collection_item_confirm_remove', + user=collection_item.in_collection.get_creator.username, + collection=collection_item.in_collection.slug, + collection_item=collection_item._id) }}" + method="POST" enctype="multipart/form-data"> + <div class="form_box"> + <h1> + {%- trans media_title=collection_item.get_media_entry.title, + collection_title=collection_item.in_collection.title -%} + Really remove {{ media_title }} from {{ collection_title }}? + {%- endtrans %} + </h1> + + <div style="text-align: center;" > + <img src="{{ request.app.public_store.file_url( + collection_item.get_media_entry.media_files['thumb']) }}" /> + </div> + + <br /> + + <p class="delete_checkbox_box"> + {{ form.confirm }} + <label for="{{ (form.confirm.name) }}">{{ _(form.confirm.label.text) }}</label> + </p> + + <div class="form_submit_buttons"> + {# TODO: This isn't a button really... might do unexpected things :) #} + <a class="button_action" href="{{ request.urlgen('mediagoblin.user_pages.user_collection', + collection=collection_item.in_collection.slug, + user=request.user.username) }}">{% trans %}Cancel{% endtrans %}</a> + <input type="submit" value="{% trans %}Remove{% endtrans %}" class="button_form" /> + {{ csrf_token }} + </div> + </div> + </form> +{% endblock %} diff --git a/mediagoblin/templates/mediagoblin/user_pages/media_collect.html b/mediagoblin/templates/mediagoblin/user_pages/media_collect.html new file mode 100644 index 00000000..a56c9cd3 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/user_pages/media_collect.html @@ -0,0 +1,88 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# 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/>. +#} +{% extends "mediagoblin/base.html" %} + +{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %} + +{% block mediagoblin_head %} + <script type="text/javascript" + src="{{ request.staticdirect('/js/collection_form_show.js') }}"></script> +{% endblock %} + +{% block mediagoblin_content %} + + <form action="{{ request.urlgen('mediagoblin.user_pages.media_collect', + user=media.get_uploader.username, + media=media._id) }}" + method="POST" enctype="multipart/form-data"> + <div class="form_box"> + <h1> + {%- trans title=media.title -%} + Add {{ title }} to collection + {%- endtrans %} + </h1> + + <div style="text-align: center;" > + <img src="{{ request.app.public_store.file_url( + media.media_files['thumb']) }}" /> + </div> + + <br /> + + <p class="form_field_label"> + <label for="{{ (form.collection.name) }}">{{ _(form.collection.label.text) }}</label> + </p> + <div class="form_field_input"> + {{ form.collection }} + <a class="button_action" id="button_addcollection">{% trans %}+{% endtrans %}</a> + </div> + + <div id="new_collection" class="subform"> + + <h3>{% trans %}Add a new collection{% endtrans %}</h3> + + <p class="form_field_label"> + <label for="{{ (form.collection_title.name) }}">{{ _(form.collection_title.label.text) }}</label> + </p> + <div class="form_field_input"> + {{ form.collection_title }} + </div> + <p class="form_field_label"> + <label for="{{ (form.collection_description.name) }}">{{ _(form.collection_description.label.text) }}</label> + </p> + <div class="form_field_input"> + {{ form.collection_description }} + </div> + + </div> + <p class="form_field_label"> + <label for="{{ (form.note.name) }}">{{ _(form.note.label.text) }}</label> + </p> + <div class="form_field_input"> + {{ form.note }} + </div> + + <div class="form_submit_buttons"> + {# TODO: This isn't a button really... might do unexpected things :) #} + <a class="button_action" href="{{ media.url_for_self(request.urlgen) }}">{% trans %}Cancel{% endtrans %}</a> + <input type="submit" value="{% trans %}Add{% endtrans %}" class="button_form" /> + {{ csrf_token }} + </div> + </div> + </form> +{% endblock %} diff --git a/mediagoblin/templates/mediagoblin/utils/collection_gallery.html b/mediagoblin/templates/mediagoblin/utils/collection_gallery.html new file mode 100644 index 00000000..a8742c74 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/utils/collection_gallery.html @@ -0,0 +1,93 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# 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/>. +#} + +{% from "mediagoblin/utils/pagination.html" import render_pagination %} + +{% macro media_grid(request, collection_items, col_number=5) %} + <table class="thumb_gallery"> + {% for row in gridify_cursor(collection_items, col_number) %} + <tr class="thumb_row + {%- if loop.first %} thumb_row_first + {%- elif loop.last %} thumb_row_last{% endif %}"> + {% for item in row %} + {% set media_entry = item.get_media_entry %} + {% set entry_url = media_entry.url_for_self(request.urlgen) %} + <td class="collection_thumbnail thumb_entry + {%- if loop.first %} thumb_entry_first + {%- elif loop.last %} thumb_entry_last{% endif %}"> + <a href="{{ entry_url }}"> + <img src="{{ request.app.public_store.file_url( + media_entry.media_files['thumb']) }}" /> + </a> + + {% if item.note %} + {%- trans note=item.note -%} + <br /> + <a href="{{ entry_url }}">{{ note }}</a> + {%- endtrans -%} + {% endif %} + {% if request.user and + (item.in_collection.creator == request.user._id or + request.user.is_admin) %} + {%- trans remove_url=request.urlgen( + 'mediagoblin.user_pages.collection_item_confirm_remove', + user=item.in_collection.get_creator.username, + collection=item.in_collection.slug, + collection_item=item.id) -%} + <br /><a href="{{ remove_url }}" class="remove">(remove)</a> + {%- endtrans -%} + {% endif %} + </td> + {% endfor %} + </tr> + {% endfor %} + </table> +{%- endmacro %} + +{# + Render a media gallery with pagination. + + Args: + - request: Request + - collection_items: cursor of collection items + - 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 collection_gallery(request, collection_items, pagination, + pagination_base_url=None, col_number=5) %} + {% if collection_items and collection_items.count() %} + {{ media_grid(request, collection_items, col_number=col_number) }} + <div class="clear"></div> + {% 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 %} + {% else %} + <p> + <i> + {%- trans -%} + There doesn't seem to be any media here yet... + {%- endtrans -%} + </i> + </p> + {% endif %} +{% endmacro %} diff --git a/mediagoblin/templates/mediagoblin/utils/collections.html b/mediagoblin/templates/mediagoblin/utils/collections.html new file mode 100644 index 00000000..feb5dac6 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/utils/collections.html @@ -0,0 +1,42 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. +# +# 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/>. +#} + +{% block collections_content -%} + <h3>{% trans collected=media.collected %}In collections ({{ collected }}){% endtrans %}</h3> + <p> + {% for collection in media.collections %} + {% if loop.last %} + {# the 'and' should only appear if there is more than one collections #} + {% if media.collections|length > 1 %} + · + {% endif %} + <a href="{{ request.urlgen( + 'mediagoblin.user_pages.user_collection', + collection=collection['slug'], user=request.user.username) }}">{{ collection['title'] }}</a> + {% elif loop.revindex == 2 %} + <a href="{{ request.urlgen( + 'mediagoblin.user_pages.user_collection', + collection=collection['slug'], user=request.user.username) }}">{{ collection['title'] }}</a> + {% else %} + <a href="{{ request.urlgen( + 'mediagoblin.user_pages.user_collection', + collection=collection['slug'], user=request.user.username) }}">{{ collection['title'] }}</a> · + {% endif %} + {% endfor %} + </p> +{% endblock %} |