Enable mongokit's "Dot notation"
[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
JW
71 {% if pagination.active_id == comment._id %}
72 <div class="comment_wrapper comment_active" id="comment-{{ comment['_id'] }}">
73 <a name="comment" id="comment"></a>
74 {% else %}
75 <div class="comment_wrapper" id="comment-{{ comment['_id'] }}">
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
JW
85 <a href="{{ request.urlgen('mediagoblin.user_pages.media_home.view_comment',
86 comment = comment['_id'],
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">
101 <input type="submit" value="{% trans %}Post comment!{% endtrans %}" class="button" />
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
CAW
116
117 {% if media['uploader'] == request.user['_id'] or
118 request.user['is_admin'] %}
ecc56c0a 119 <h3>{% trans %}Actions{% endtrans %}</h3>
894fa564 120 <p>
15144d06 121 {% set edit_url = request.urlgen('mediagoblin.edit.edit_media',
894fa564 122 user= media.uploader().username,
15144d06
CAW
123 media= media._id) %}
124 <a href="{{ edit_url }}"
894fa564 125 ><img src="{{ request.staticdirect('/images/icon_edit.png') }}"
15144d06
CAW
126 class="media_icon" /></a>
127 <a href="{{ edit_url }}">{% trans %}edit{% endtrans %}</a>
894fa564
CAW
128 </p>
129 <p>
15144d06 130 {% set delete_url = request.urlgen('mediagoblin.user_pages.media_confirm_delete',
7dc3a66f 131 user= media.uploader().username,
15144d06
CAW
132 media= media._id) %}
133 <a href="{{ delete_url }}"
7dc3a66f 134 ><img src="{{ request.staticdirect('/images/icon_delete.png') }}"
15144d06
CAW
135 class="media_icon" /></a>
136 <a href="{{ delete_url }}">{% trans %}delete{% endtrans %}</a>
894fa564
CAW
137 </p>
138 {% endif %}
5d900647 139
3a8c3a38 140 {% if media.attachment_files|count %}
894fa564
CAW
141 <h3>Attachments</h3>
142 <ul>
143 {% for attachment in media.attachment_files %}
144 <li>
145 <a href="{{ request.app.public_store.file_url(attachment.filepath) }}">
146 {{ attachment.name }}
147 </a>
148 </li>
149 {% endfor %}
150 </ul>
3a8c3a38 151 {% endif %}
894fa564
CAW
152
153 {% if app_config['allow_attachments']
154 and (media['uploader'] == request.user['_id']
155 or request.user['is_admin']) %}
a28f0726
CAW
156 <p>
157 <a href="{{ request.urlgen('mediagoblin.edit.attachments',
158 user=media.uploader().username,
159 media=media._id) }}">Add attachment</a>
160 </p>
3a8c3a38
JW
161 {% endif %}
162
6f2e4585 163 {% if media.tags %}
0712a06d 164 {% include "mediagoblin/utils/tags.html" %}
6f2e4585 165 {% endif %}
a54e5be7 166 </div>
9a16e16f 167 {% else %}
8f4c9b81 168 <p>{% trans %}Sorry, no such media found.{% endtrans %}<p/>
9a16e16f 169 {% endif %}
d3060210 170{% endblock %}