433f74dcac73dcd96dd2ed97bd6c86fe3f2d1a41
[mediagoblin.git] / mediagoblin / templates / mediagoblin / user_pages / media.html
1 {#
2 # GNU MediaGoblin -- federated, autonomous media hosting
3 # Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
14 #
15 # You should have received a copy of the GNU Affero General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #}
18 {% extends "mediagoblin/base.html" %}
19
20 {% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
21 {% from "mediagoblin/utils/pagination.html" import render_pagination %}
22
23 {% block mediagoblin_content %}
24 {% if media %}
25 <div class="grid_11 alpha">
26 <div class="media_image_container">
27 {% set display_media = request.app.public_store.file_url(
28 media.get_display_media(media.media_files)) %}
29
30 {# if there's a medium file size, that means the medium size
31 # isn't the original... so link to the original!
32 #}
33 {% if media['media_files'].has_key('medium') %}
34 <a href="{{ request.app.public_store.file_url(
35 media['media_files']['original']) }}">
36 <img class="media_image"
37 src="{{ display_media }}"
38 alt="Image for {{ media.title }}" />
39 </a>
40 {% else %}
41 <img class="media_image"
42 src="{{ display_media }}"
43 alt="Image for {{ media.title }}" />
44 {% endif %}
45 </div>
46
47 <h2 class="media_title">
48 {{ media.title }}
49 </h2>
50
51 <p class="media_uploader">
52 {% trans date=media.created.strftime("%Y-%m-%d"),
53 user_url=request.urlgen(
54 'mediagoblin.user_pages.user_home',
55 user=media.uploader().username),
56 username=media.uploader().username -%}
57 Uploaded on {{ date }} by <a href="{{ user_url }}">{{ username }}</a>
58 {%- endtrans %}
59 </p>
60
61 {% autoescape False %}
62 <p>{{ media.description_html }}</p>
63 {% endautoescape %}
64
65 <br />
66 <h3>{% trans %}Comments{% endtrans %}</h3>
67
68 {% if request.user %}
69 <form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment',
70 user= media.uploader().username,
71 media=media._id) }}" method="POST">
72 {{ wtforms_util.render_divs(comment_form) }}
73 <div class="form_submit_buttons">
74 <input type="submit" value="{% trans %}Post comment!{% endtrans %}" class="button" />
75 {{ csrf_token }}
76 </div>
77 </form>
78 {% endif %}
79
80 {% if comments %}
81 {% for comment in comments %}
82 {% set comment_author = comment.author() %}
83 {% if pagination.active_id == comment._id %}
84 <div class="comment_wrapper comment_active" id="comment-{{ comment['_id'] }}">
85 <a name="comment" id="comment"></a>
86 {% else %}
87 <div class="comment_wrapper" id="comment-{{ comment['_id'] }}">
88 {% endif %}
89
90 <div class="comment_content">
91 {% autoescape False %}
92 {{ comment.content_html }}
93 {% endautoescape %}
94 </div>
95
96 <div class="comment_author">&mdash;
97 <a href="{{ request.urlgen('mediagoblin.user_pages.user_home',
98 user = comment_author['username']) }}">
99 {{ comment_author['username'] }}</a>
100 {% trans %}at{% endtrans %}
101 <a href="{{ request.urlgen('mediagoblin.user_pages.media_home.view_comment',
102 comment = comment['_id'],
103 user = media.uploader().username,
104 media = media._id) }}#comment">
105 {{ comment.created.strftime("%Y-%m-%d %I:%M%p") }}
106 </a>
107 </div>
108 </div>
109 {% endfor %}
110
111 {{ render_pagination(request, pagination,
112 request.urlgen('mediagoblin.user_pages.media_home',
113 user = media.uploader().username,
114 media = media._id)) }}
115 </div>
116 {% endif %}
117
118 <div class="grid_5 omega">
119 {% include "mediagoblin/utils/prev_next.html" %}
120
121 {% if media['uploader'] == request.user['_id'] or
122 request.user['is_admin'] %}
123 <h3>Temporary button holder</h3>
124 <p>
125 {% set edit_url = request.urlgen('mediagoblin.edit.edit_media',
126 user= media.uploader().username,
127 media= media._id) %}
128 <a href="{{ edit_url }}"
129 ><img src="{{ request.staticdirect('/images/icon_edit.png') }}"
130 class="media_icon" /></a>
131 <a href="{{ edit_url }}">{% trans %}edit{% endtrans %}</a>
132 </p>
133 <p>
134 {% set delete_url = request.urlgen('mediagoblin.user_pages.media_confirm_delete',
135 user= media.uploader().username,
136 media= media._id) %}
137 <a href="{{ delete_url }}"
138 ><img src="{{ request.staticdirect('/images/icon_delete.png') }}"
139 class="media_icon" /></a>
140 <a href="{{ delete_url }}">{% trans %}delete{% endtrans %}</a>
141 </p>
142 {% endif %}
143
144 {% if media.attachment_files|count %}
145 <h3>Attachments</h3>
146 <ul>
147 {% for attachment in media.attachment_files %}
148 <li>
149 <a href="{{ request.app.public_store.file_url(attachment.filepath) }}">
150 {{ attachment.name }}
151 </a>
152 </li>
153 {% endfor %}
154 </ul>
155 {% endif %}
156
157 {% if app_config['allow_attachments']
158 and (media['uploader'] == request.user['_id']
159 or request.user['is_admin']) %}
160 <p>
161 <a href="{{ request.urlgen('mediagoblin.edit.attachments',
162 user=media.uploader().username,
163 media=media._id) }}">Add attachment</a>
164 </p>
165 {% endif %}
166
167 {% if media.tags %}
168 {% include "mediagoblin/utils/tags.html" %}
169 {% endif %}
170 </div>
171 {% else %}
172 <p>{% trans %}Sorry, no such media found.{% endtrans %}<p/>
173 {% endif %}
174 {% endblock %}