Created the basic structure of the metadata display table in rdfa lite
authortilly-Q <nattilypigeonfowl@gmail.com>
Mon, 21 Apr 2014 19:42:57 +0000 (15:42 -0400)
committertilly-Q <nattilypigeonfowl@gmail.com>
Mon, 21 Apr 2014 19:42:57 +0000 (15:42 -0400)
mediagoblin/templates/mediagoblin/user_pages/media.html
mediagoblin/templates/mediagoblin/utils/metadata_table.html [new file with mode: 0644]
mediagoblin/user_pages/lib.py
mediagoblin/user_pages/views.py

index e01cce5c3bb97592c13d1e0e239550f2c0c680b3..22971fec6a06cb805e96c117389072f3a202efad 100644 (file)
@@ -18,6 +18,7 @@
 {%- extends "mediagoblin/base.html" %}
 
 {% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
+{% import "/mediagoblin/utils/metadata_table.html" as metadata_util %}
 {% from "mediagoblin/utils/pagination.html" import render_pagination %}
 
 {% block title %}{{ media.title }} &mdash; {{ super() }}{% endblock %}
     {% template_hook("media_sideinfo") %}
 
     {% block mediagoblin_sidebar %}
+       {{ metadata_util.render_table(request, media, rdfa_to_readable) }}
     {% endblock %}
 
   </div><!--end media_sidebar-->
diff --git a/mediagoblin/templates/mediagoblin/utils/metadata_table.html b/mediagoblin/templates/mediagoblin/utils/metadata_table.html
new file mode 100644 (file)
index 0000000..38b580d
--- /dev/null
@@ -0,0 +1,37 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#}
+
+{%- macro render_table(request, media_entry, format_predicate) %}
+  {%- set metadata=media_entry.media_metadata %}
+  {%- set metadata_context=metadata['@context'] %}
+  {%- if metadata %}
+      <table prefix="{%- for prefix in metadata_context -%}
+                     {{ prefix }} {{ metadata_context[prefix] }}
+                     {%- endfor %}">
+        {%- for key, value in metadata.iteritems() if not key=='@context' %}
+          <tr>
+            <td>{{ format_predicate(key) }}</td>
+            {% if value -%}
+                <td property="{{ key }}">{{ value }}</td>
+            {%- else -%}
+                <td></td>
+            {%- endif -%}
+        {%- endfor %}
+      </table>
+  {% endif %}
+{%- endmacro %}
index e5c8defcabe33b2729d12b20c2a0f85faa478d02..83a99ceeda2727a315fe22b113bc52ce6ef892a6 100644 (file)
@@ -116,3 +116,6 @@ def build_report_object(report_form, media_entry=None, comment=None):
     report_object.reporter_id = report_form.reporter_id.data
     return report_object
 
+def rdfa_to_readable(rdfa_predicate):
+    readable = rdfa_predicate.split(u":")[1].capitalize()
+    return readable
index 78751a28f85ef0d2ccc794618c2ba0b71b7033c0..f42eae1fe3e83b4b98656cbcaacded0763cdb08e 100644 (file)
@@ -28,7 +28,7 @@ from mediagoblin.tools.translate import pass_to_ugettext as _
 from mediagoblin.tools.pagination import Pagination
 from mediagoblin.user_pages import forms as user_forms
 from mediagoblin.user_pages.lib import (send_comment_email,
-       add_media_to_collection, build_report_object)
+       add_media_to_collection, build_report_object, rdfa_to_readable)
 from mediagoblin.notifications import trigger_notification, \
     add_comment_subscription, mark_comment_notification_seen
 from mediagoblin.tools.pluginapi import hook_transform
@@ -152,7 +152,8 @@ def media_home(request, media, page, **kwargs):
         'comments': comments,
         'pagination': pagination,
         'comment_form': comment_form,
-        'app_config': mg_globals.app_config}
+        'app_config': mg_globals.app_config,
+        'rdfa_to_readable':rdfa_to_readable}
 
     # Since the media template name gets swapped out for each media
     # type, normal context hooks don't work if you want to affect all