EXIF extraction, geolocation map, image rotation
[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 title %}{{ media.title }} &mdash; {{ super() }}{% endblock %}
24
25 {% block mediagoblin_head %}
26 <link rel="stylesheet"
27 href="{{ request.staticdirect('/extlib/leaflet/leaflet.css') }}" />
28 <!--[if lte IE 8]><link rel="stylesheet"
29 href="{{ request.staticdirect('/extlib/leaflet/leaflet.ie.css') }}" /><![endif]-->
30 <script type="text/javascript"
31 src="{{ request.staticdirect('/js/comment_show.js') }}"></script>
32 <script type="text/javascript"
33 src="{{ request.staticdirect('/extlib/leaflet/leaflet.js') }}"></script>
34 <script type="text/javascript"
35 src="{{ request.staticdirect('/js/geolocation-map.js') }}"></script>
36 {% endblock mediagoblin_head %}
37
38 {% block mediagoblin_content %}
39 <div class="media_pane">
40 <div class="media_image_container">
41 {% block mediagoblin_media %}
42 {% set display_media = request.app.public_store.file_url(
43 media.get_display_media(media.media_files)) %}
44 {# if there's a medium file size, that means the medium size
45 # isn't the original... so link to the original!
46 #}
47 {% if media.media_files.has_key('medium') %}
48 <a href="{{ request.app.public_store.file_url(
49 media.media_files['original']) }}">
50 <img class="media_image"
51 src="{{ display_media }}"
52 alt="Image for {{ media.title }}" />
53 </a>
54 {% else %}
55 <img class="media_image"
56 src="{{ display_media }}"
57 alt="Image for {{ media.title }}" />
58 {% endif %}
59 {% endblock %}
60 </div>
61 <h2 class="media_title">
62 {{ media.title }}
63 </h2>
64 {% autoescape False %}
65 <p>{{ media.description_html }}</p>
66 {% endautoescape %}
67 <p class="media_specs">
68 {% trans date=media.created.strftime("%Y-%m-%d") -%}
69 Added on {{ date }}.
70 {%- endtrans %}
71 {% if request.user and
72 (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 %}
83 {% if media.media_data.exif %}
84 {#-
85 TODO:
86 - Render GPS data in a human-readable format
87
88 <h4>EXIF</h4>
89 <table>
90 {% for tag, value in media.media_data.exif.items() %}
91 <tr>
92 <td>{{ tag }}</td>
93 <td>{{ value }}</td>
94 </tr>
95 {% endfor %}
96 </table>#}
97 {% endif %}
98 </p>
99 {% if comments %}
100 <h3>
101 {% if comments.count()==1 %}
102 {% trans comment_count=comments.count() -%}{{ comment_count }} comment{%- endtrans %}
103 {% elif comments.count()>1 %}
104 {% trans comment_count=comments.count() -%}{{ comment_count }} comments{%- endtrans %}
105 {% else %}
106 {% trans %}No comments yet.{% endtrans %}
107 {% endif %}
108 <div class="right_align">
109 <a
110 {% if not request.user %}
111 href="{{ request.urlgen('mediagoblin.auth.login') }}"
112 {% endif %}
113 class="button_action" id="button_addcomment" title="Add a comment">
114 {% trans %}Add one{% endtrans %}
115 </a>
116 </div>
117 </h3>
118 {% if request.user %}
119 <form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment',
120 user= media.get_uploader.username,
121 media=media._id) }}" method="POST" id="form_comment">
122 <p>
123 {% trans %}You can use <a href="http://daringfireball.net/projects/markdown/basics">Markdown</a> for formatting.{% endtrans %}
124 </p>
125 {{ wtforms_util.render_divs(comment_form) }}
126 <div class="form_submit_buttons">
127 <input type="submit" value="{% trans %}Add this comment{% endtrans %}" class="button_action" />
128 {{ csrf_token }}
129 </div>
130 </form>
131 {% endif %}
132 {% for comment in comments %}
133 {% set comment_author = comment.get_author %}
134 {% if pagination.active_id == comment._id %}
135 <div class="comment_wrapper comment_active" id="comment-{{ comment._id }}">
136 <a name="comment" id="comment"></a>
137 {% else %}
138 <div class="comment_wrapper" id="comment-{{ comment._id }}">
139 {% endif %}
140 <div class="comment_content">
141 {% autoescape False %}
142 {{ comment.content_html }}
143 {% endautoescape %}
144 <img src="{{ request.staticdirect('/images/icon_comment.png') }}" />
145 <a href="{{ request.urlgen('mediagoblin.user_pages.user_home',
146 user = comment_author.username) }}">
147 {{ comment_author.username }}
148 </a>
149 {% trans %}at{% endtrans %}
150 <a href="{{ request.urlgen('mediagoblin.user_pages.media_home.view_comment',
151 comment = comment._id,
152 user = media.get_uploader.username,
153 media = media.slug) }}#comment">
154 {{ comment.created.strftime("%I:%M%p %Y-%m-%d") }}
155 </a>
156 </div>
157 </div>
158 {% endfor %}
159 {{ render_pagination(request, pagination,
160 media.url_for_self(request.urlgen)) }}
161 {% endif %}
162 </div>
163 <div class="media_sidebar">
164 {% trans user_url=request.urlgen(
165 'mediagoblin.user_pages.user_home',
166 user=media.get_uploader.username),
167 username=media.get_uploader.username -%}
168 <p>❖ Browsing media by <a href="{{ user_url }}">{{ username }}</a></p>
169 {%- endtrans %}
170 {% include "mediagoblin/utils/prev_next.html" %}
171 {% if media.attachment_files|count %}
172 <h3>Attachments</h3>
173 <ul>
174 {% for attachment in media.attachment_files %}
175 <li>
176 <a href="{{ request.app.public_store.file_url(attachment.filepath) }}">
177 {{ attachment.name }}
178 </a>
179 </li>
180 {% endfor %}
181 </ul>
182 {% endif %}
183 {% if app_config['allow_attachments']
184 and request.user
185 and (media.uploader == request.user._id
186 or request.user.is_admin) %}
187 <p>
188 <a href="{{ request.urlgen('mediagoblin.edit.attachments',
189 user=media.get_uploader.username,
190 media=media._id) }}">Add attachment</a>
191 </p>
192 {% endif %}
193 {% if media.tags %}
194 {% include "mediagoblin/utils/tags.html" %}
195 {% endif %}
196
197 {% if media.media_data.gps %}
198 <h4>Map</h4>
199 <div>
200 {% set gps = media.media_data.gps %}
201 <div id="tile-map" style="width: 100%; height: 196px;">
202 <input type="hidden" id="gps-longitude"
203 value="{{ gps.longitude }}" />
204 <input type="hidden" id="gps-latitude"
205 value="{{ gps.latitude }}" />
206 </div>
207 <p>
208 <small>
209 View on
210 <a href="http://openstreetmap.org/?mlat={{ gps.latitude }}&mlon={{ gps.longitude }}">
211 OpenStreetMap
212 </a>
213 </small>
214 </p>
215 </div>
216 {% endif %}
217 {% include "mediagoblin/utils/license.html" %}
218 </div>
219 {% endblock %}