Added new files for collections

This commit is contained in:
Aaron Williamson 2012-08-17 00:57:18 -04:00 committed by Joar Wandborg
parent be5be1154f
commit a0fdc00fab
11 changed files with 548 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

View File

@ -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();
});
});
});

View File

@ -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 %}

View File

@ -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 %} &mdash; {{ 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 %}

View File

@ -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 %}

View File

@ -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 %} &mdash; {{ 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 %}

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 %}
&middot;
{% 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> &middot;
{% endif %}
{% endfor %}
</p>
{% endblock %}