Use media.url_for_self instead of calling urlgen directly
[mediagoblin.git] / mediagoblin / templates / mediagoblin / user_pages / media.html
CommitLineData
9a16e16f
SS
1{#
2# GNU MediaGoblin -- federated, autonomous media hosting
12a100e4 3# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
9a16e16f
SS
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" %}
aa7d1a2f
JW
19
20{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
5949be9a 21{% from "mediagoblin/utils/pagination.html" import render_pagination %}
aa7d1a2f 22
688f56c2
CAW
23{% block title %}{{ media.title }} &mdash; {{ super() }}{% endblock %}
24
75a12d63
JS
25{% block mediagoblin_head %}
26 <script>
27 $(document).ready(function(){
28 $('#form_comment').hide();
29 $('#button_addcomment').click(function(){
30 $(this).fadeOut('fast');
31 $('#form_comment').slideDown(function(){
32 $('#comment_content').focus();
33 });
34 });
35 });
36 </script>
37{% endblock mediagoblin_head %}
38
9a16e16f 39{% block mediagoblin_content %}
f80f5b58
CAW
40 <div class="grid_11 alpha">
41 <div class="media_image_container">
42 {% block mediagoblin_media %}
43 {% set display_media = request.app.public_store.file_url(
44 media.get_display_media(media.media_files)) %}
f80f5b58
CAW
45 {# if there's a medium file size, that means the medium size
46 # isn't the original... so link to the original!
47 #}
48 {% if media['media_files'].has_key('medium') %}
49 <a href="{{ request.app.public_store.file_url(
50 media['media_files']['original']) }}">
9b424b17
CAW
51 <img class="media_image"
52 src="{{ display_media }}"
53 alt="Image for {{ media.title }}" />
f80f5b58
CAW
54 </a>
55 {% else %}
56 <img class="media_image"
57 src="{{ display_media }}"
58 alt="Image for {{ media.title }}" />
59 {% endif %}
60 {% endblock %}
61 </div>
f80f5b58
CAW
62 <h2 class="media_title">
63 {{ media.title }}
64 </h2>
65 {% autoescape False %}
66 <p>{{ media.description_html }}</p>
bb3b9e40
JS
67 {% endautoescape %}
68 <p class="media_specs">
69 {% trans date=media.created.strftime("%Y-%m-%d") -%}
cd4b519a 70 Added on {{ date }}.
f80f5b58 71 {%- endtrans %}
bb3b9e40
JS
72 {% if media['uploader'] == request.user._id or
73 request.user['is_admin'] %}
74 {% set edit_url = request.urlgen('mediagoblin.edit.edit_media',
75 user= media.get_uploader().username,
76 media= media._id) %}
77 <a class="button_action" href="{{ edit_url }}">{% trans %}Edit{% endtrans %}</a>
78 {% set delete_url = request.urlgen('mediagoblin.user_pages.media_confirm_delete',
79 user= media.get_uploader().username,
80 media= media._id) %}
81 <a class="button_action" href="{{ delete_url }}">{% trans %}Delete{% endtrans %}</a>
82 {% endif %}
f80f5b58 83 </p>
18517e88 84 <h3>{% trans comment_count=comments.count() -%}{{ comment_count }} comments{%- endtrans %}
bb3b9e40
JS
85 <div class="right_align">
86 <a
87 {% if not request.user %}
88 href="{{ request.urlgen('mediagoblin.auth.login') }}"
f80f5b58 89 {% endif %}
bb3b9e40
JS
90 class="button_action" id="button_addcomment" title="Add a comment">
91 {% trans %}Add one{% endtrans %}
92 </a>
92ed2892 93 </div>
bb3b9e40
JS
94 </h3>
95 {# 0 comments. Be the first to add one! #}
f80f5b58
CAW
96 {% if request.user %}
97 <form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment',
98 user= media.get_uploader().username,
75a12d63 99 media=media._id) }}" method="POST" id="form_comment">
bb3b9e40
JS
100 <p>
101 {% trans %}Type your comment here. You can use <a href="http://daringfireball.net/projects/markdown/basics" target="_blank">Markdown</a> for formatting.{% endtrans %}
102 </p>
f80f5b58
CAW
103 {{ wtforms_util.render_divs(comment_form) }}
104 <div class="form_submit_buttons">
75a12d63 105 <input type="submit" value="{% trans %}Add this comment{% endtrans %}" class="button_action" />
f80f5b58
CAW
106 {{ csrf_token }}
107 </div>
108 </form>
109 {% endif %}
a86e66b5 110 {% if comments %}
a86e66b5 111 {% for comment in comments %}
fb7dd855 112 {% set comment_author = comment.get_author %}
bb3b9e40 113 {% if pagination.active_id == comment._id %}
eabe6b67 114 <div class="comment_wrapper comment_active" id="comment-{{ comment._id }}">
bb3b9e40 115 <a name="comment" id="comment"></a>
af2fcba5 116 {% else %}
eabe6b67 117 <div class="comment_wrapper" id="comment-{{ comment._id }}">
bb3b9e40
JS
118 {% endif %}
119 <div class="comment_content">
120 {% autoescape False %}
121 {{ comment.content_html }}
122 {% endautoescape %}
123 <img src="{{ request.staticdirect('/images/icon_comment.png') }}" />
124 <a href="{{ request.urlgen('mediagoblin.user_pages.user_home',
125 user = comment_author.username) }}">
126 {{ comment_author.username }}
127 </a>
128 {% trans %}at{% endtrans %}
129 <a href="{{ request.urlgen('mediagoblin.user_pages.media_home.view_comment',
130 comment = comment._id,
131 user = media.get_uploader().username,
132 media = media.slug) }}#comment">
133 {{ comment.created.strftime("%I:%M%p %Y-%m-%d") }}
134 </a>
135 </div>
136 </div>
a86e66b5 137 {% endfor %}
0eb649ff
E
138 {{ render_pagination(request, pagination,
139 media.url_for_self(request.urlgen)) }}
aa7d1a2f 140 {% endif %}
bb3b9e40 141 </div>
f80f5b58 142 <div class="grid_5 omega">
bb3b9e40
JS
143 {% trans user_url=request.urlgen(
144 'mediagoblin.user_pages.user_home',
145 user=media.get_uploader().username),
146 username=media.get_uploader().username -%}
3f45d9fb 147 <p>❖ Browsing media by <a href="{{ user_url }}">{{ username }}</a></p>
bb3b9e40 148 {%- endtrans %}
f80f5b58 149 {% include "mediagoblin/utils/prev_next.html" %}
f80f5b58
CAW
150 {% if media.attachment_files|count %}
151 <h3>Attachments</h3>
152 <ul>
153 {% for attachment in media.attachment_files %}
154 <li>
155 <a href="{{ request.app.public_store.file_url(attachment.filepath) }}">
156 {{ attachment.name }}
157 </a>
158 </li>
159 {% endfor %}
160 </ul>
161 {% endif %}
f80f5b58 162 {% if app_config['allow_attachments']
1ceb4fc8 163 and (media.uploader == request.user._id
bec591d8 164 or request.user.is_admin) %}
f80f5b58
CAW
165 <p>
166 <a href="{{ request.urlgen('mediagoblin.edit.attachments',
167 user=media.get_uploader().username,
168 media=media._id) }}">Add attachment</a>
169 </p>
170 {% endif %}
f80f5b58
CAW
171 {% if media.tags %}
172 {% include "mediagoblin/utils/tags.html" %}
173 {% endif %}
174 </div>
d3060210 175{% endblock %}