652: Don't show empty field labels.
[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
9a16e16f 25{% block mediagoblin_content %}
9a16e16f 26 {% if media %}
18d9287a 27 <div class="grid_11 alpha">
92ed2892 28 <div class="media_image_container">
9b424b17
CAW
29 {% set display_media = request.app.public_store.file_url(
30 media.get_display_media(media.media_files)) %}
31
32 {# if there's a medium file size, that means the medium size
33 # isn't the original... so link to the original!
34 #}
35 {% if media['media_files'].has_key('medium') %}
36 <a href="{{ request.app.public_store.file_url(
37 media['media_files']['original']) }}">
38 <img class="media_image"
39 src="{{ display_media }}"
40 alt="Image for {{ media.title }}" />
41 </a>
42 {% else %}
43 <img class="media_image"
44 src="{{ display_media }}"
45 alt="Image for {{ media.title }}" />
46 {% endif %}
92ed2892 47 </div>
d8db3f11 48
74596110 49 <h2 class="media_title">
f645bde8 50 {{ media.title }}
b611476c 51 </h2>
157c6026
JS
52 {% autoescape False %}
53 <p>{{ media.description_html }}</p>
54 {% endautoescape %}
74596110 55 <p class="media_uploader">
ff9ad461 56 {% trans date=media.created.strftime("%Y-%m-%d"),
58b79b15
CAW
57 user_url=request.urlgen(
58 'mediagoblin.user_pages.user_home',
59 user=media.uploader().username),
60 username=media.uploader().username -%}
157c6026 61 By <a href="{{ user_url }}">{{ username }}</a> on {{ date }}
58b79b15 62 {%- endtrans %}
b611476c 63 </p>
157c6026 64 <h3></h3>
2b7aa99d 65 {% if request.user and comments.count() %}
e360a992
CAW
66 <p><a href="#comment_form">{% trans %}Post a comment{% endtrans %}</a></p>
67 {% endif %}
a86e66b5 68 {% if comments %}
a86e66b5 69 {% for comment in comments %}
2110408f 70 {% set comment_author = comment.author() %}
af2fcba5 71 {% if pagination.active_id == comment._id %}
eabe6b67 72 <div class="comment_wrapper comment_active" id="comment-{{ comment._id }}">
af2fcba5
JW
73 <a name="comment" id="comment"></a>
74 {% else %}
eabe6b67 75 <div class="comment_wrapper" id="comment-{{ comment._id }}">
af2fcba5 76 {% endif %}
f645bde8 77
157c6026 78 <div class="comment_content">{% autoescape False %}{{ comment.content_html }}
270dca58 79 {% endautoescape %}
157c6026
JS
80 <img src="{{ request.staticdirect('/images/icon_comment.png') }}" />
81 <a href="{{ request.urlgen('mediagoblin.user_pages.user_home',
29beee8c
CAW
82 user = comment_author['username']) }}">
83 {{ comment_author['username'] }}</a>
84 {% trans %}at{% endtrans %}
af2fcba5 85 <a href="{{ request.urlgen('mediagoblin.user_pages.media_home.view_comment',
eabe6b67 86 comment = comment._id,
af2fcba5
JW
87 user = media.uploader().username,
88 media = media._id) }}#comment">
157c6026 89 {{ comment.created.strftime("%I:%M%p %Y-%m-%d") }}
c13ce79a
JS
90 </a>
91 </div>
6f65e9eb 92 </div>
a86e66b5 93 {% endfor %}
6f65e9eb 94
b06e4f3b 95 {% if request.user %}
b06e4f3b
E
96 <form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment',
97 user= media.uploader().username,
98 media=media._id) }}" method="POST">
99 {{ wtforms_util.render_divs(comment_form) }}
100 <div class="form_submit_buttons">
13423daa 101 <input type="submit" value="{% trans %}Post comment!{% endtrans %}" class="button_form" />
b06e4f3b
E
102 {{ csrf_token }}
103 </div>
104 </form>
105 {% endif %}
b7206469 106
af2fcba5
JW
107 {{ render_pagination(request, pagination,
108 request.urlgen('mediagoblin.user_pages.media_home',
109 user = media.uploader().username,
110 media = media._id)) }}
a86e66b5 111 </div>
aa7d1a2f 112 {% endif %}
5d900647 113
18d9287a 114 <div class="grid_5 omega">
9c0fe63f 115 {% include "mediagoblin/utils/prev_next.html" %}
894fa564 116
eabe6b67 117 {% if media['uploader'] == request.user._id or
894fa564 118 request.user['is_admin'] %}
894fa564 119 <p>
15144d06 120 {% set edit_url = request.urlgen('mediagoblin.edit.edit_media',
894fa564 121 user= media.uploader().username,
15144d06 122 media= media._id) %}
7807f5a5 123 <a href="{{ edit_url }}">{% trans %}Edit{% endtrans %}</a>
894fa564
CAW
124 </p>
125 <p>
15144d06 126 {% set delete_url = request.urlgen('mediagoblin.user_pages.media_confirm_delete',
7dc3a66f 127 user= media.uploader().username,
15144d06 128 media= media._id) %}
7807f5a5 129 <a href="{{ delete_url }}">{% trans %}Delete{% endtrans %}</a>
894fa564
CAW
130 </p>
131 {% endif %}
5d900647 132
3a8c3a38 133 {% if media.attachment_files|count %}
894fa564
CAW
134 <h3>Attachments</h3>
135 <ul>
136 {% for attachment in media.attachment_files %}
137 <li>
138 <a href="{{ request.app.public_store.file_url(attachment.filepath) }}">
139 {{ attachment.name }}
140 </a>
141 </li>
142 {% endfor %}
143 </ul>
3a8c3a38 144 {% endif %}
894fa564
CAW
145
146 {% if app_config['allow_attachments']
eabe6b67 147 and (media['uploader'] == request.user._id
894fa564 148 or request.user['is_admin']) %}
a28f0726
CAW
149 <p>
150 <a href="{{ request.urlgen('mediagoblin.edit.attachments',
151 user=media.uploader().username,
152 media=media._id) }}">Add attachment</a>
153 </p>
3a8c3a38
JW
154 {% endif %}
155
6f2e4585 156 {% if media.tags %}
0712a06d 157 {% include "mediagoblin/utils/tags.html" %}
6f2e4585 158 {% endif %}
a54e5be7 159 </div>
9a16e16f 160 {% else %}
8f4c9b81 161 <p>{% trans %}Sorry, no such media found.{% endtrans %}<p/>
9a16e16f 162 {% endif %}
d3060210 163{% endblock %}