Made the metadata table functional within the new metadata_display plugin and
removed all traces of it from core.
This commit is contained in:
parent
f14519c398
commit
b5dd245989
41
mediagoblin/plugins/metadata_display/__init__.py
Normal file
41
mediagoblin/plugins/metadata_display/__init__.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# 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/>.
|
||||||
|
import os
|
||||||
|
from pkg_resources import resource_filename
|
||||||
|
|
||||||
|
from mediagoblin.plugins.metadata_display.lib import add_rdfa_to_readable_to_media_home
|
||||||
|
from mediagoblin.tools import pluginapi
|
||||||
|
from mediagoblin.tools.staticdirect import PluginStatic
|
||||||
|
|
||||||
|
PLUGIN_DIR = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
def setup_plugin():
|
||||||
|
# Register the template path.
|
||||||
|
pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
|
||||||
|
|
||||||
|
pluginapi.register_template_hooks(
|
||||||
|
{"media_sideinfo": "mediagoblin/plugins/metadata_display/metadata_table.html",
|
||||||
|
"head": "mediagoblin/plugins/metadata_display/bits/metadata_extra_head.html"})
|
||||||
|
|
||||||
|
|
||||||
|
hooks = {
|
||||||
|
'setup': setup_plugin,
|
||||||
|
'static_setup': lambda: PluginStatic(
|
||||||
|
'metadata_display',
|
||||||
|
resource_filename('mediagoblin.plugins.metadata_display', 'static')
|
||||||
|
),
|
||||||
|
'media_home_context':add_rdfa_to_readable_to_media_home
|
||||||
|
}
|
31
mediagoblin/plugins/metadata_display/lib.py
Normal file
31
mediagoblin/plugins/metadata_display/lib.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# 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/>.
|
||||||
|
|
||||||
|
def rdfa_to_readable(rdfa_predicate):
|
||||||
|
"""
|
||||||
|
A simple script to convert rdfa resource descriptors into a form more
|
||||||
|
accessible for humans.
|
||||||
|
"""
|
||||||
|
readable = rdfa_predicate.split(u":")[1].capitalize()
|
||||||
|
return readable
|
||||||
|
|
||||||
|
def add_rdfa_to_readable_to_media_home(context):
|
||||||
|
"""
|
||||||
|
A context hook which adds the 'rdfa_to_readable' filter to
|
||||||
|
the media home page.
|
||||||
|
"""
|
||||||
|
context['rdfa_to_readable'] = rdfa_to_readable
|
||||||
|
return context
|
@ -0,0 +1,14 @@
|
|||||||
|
table.metadata_info {
|
||||||
|
font-size:85%;
|
||||||
|
margin-left:10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.metadata_info th {
|
||||||
|
font-weight: bold;
|
||||||
|
border-spacing: 10px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
table.metadata_info td {
|
||||||
|
padding: 4px 8px;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
|||||||
|
<link rel="stylesheet" type="text/css"
|
||||||
|
href="{{ request.staticdirect('css/metadata_display.css',
|
||||||
|
'metadata_display') }}"/>
|
@ -15,17 +15,18 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#}
|
#}
|
||||||
|
{% block metadata_information_table %}
|
||||||
{%- set metadata=media.media_metadata %}
|
{%- set metadata=media.media_metadata %}
|
||||||
{%- set metadata_context=metadata['@context'] %}
|
{%- set metadata_context=metadata['@context'] %}
|
||||||
{%- if metadata %}
|
{%- if metadata %}
|
||||||
|
<h3>{% trans %}Metadata{% endtrans %}</h3>
|
||||||
{#- NOTE: In some smart future where the context is more extensible,
|
{#- NOTE: In some smart future where the context is more extensible,
|
||||||
we will need to add to the prefix here-#}
|
we will need to add to the prefix here-#}
|
||||||
<table>
|
<table class="metadata_info">
|
||||||
{%- for key, value in metadata.iteritems() if not key=='@context' %}
|
{%- for key, value in metadata.iteritems() if not key=='@context' %}
|
||||||
{% if value -%}
|
{% if value -%}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ rdfa_to_readable(key) }}</td>
|
<th>{{ rdfa_to_readable(key) }}</th>
|
||||||
<td property="{{ key }}">{{ value }}</td>
|
<td property="{{ key }}">{{ value }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
@ -34,7 +35,8 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if request.user and request.user.has_privilege('admin') %}
|
{% if request.user and request.user.has_privilege('admin') %}
|
||||||
<a href="{{ request.urlgen('mediagoblin.edit.metadata',
|
<a href="{{ request.urlgen('mediagoblin.edit.metadata',
|
||||||
user=media_entry.get_uploader.username,
|
user=media.get_uploader.username,
|
||||||
media_id=media_entry.id) }}">
|
media_id=media.id) }}">
|
||||||
{% trans %}Edit Metadata{% endtrans %}</a>
|
{% trans %}Edit Metadata{% endtrans %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
{#
|
||||||
|
# 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/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
<<<<<<< HEAD:mediagoblin/templates/mediagoblin/utils/metadata_table.html
|
||||||
|
{%- macro render_table(request, media_entry, format_predicate) %}
|
||||||
|
{%- set metadata=media_entry.media_metadata %}
|
||||||
|
{%- set metadata_context=metadata['@context'] %}
|
||||||
|
{%- if metadata %}
|
||||||
|
<h3>{% trans %}Metadata Information{% endtrans %}</h3>
|
||||||
|
<table class="metadata_info">
|
||||||
|
{%- for key, value in metadata.iteritems() if (
|
||||||
|
not key=='@context' and value) %}
|
||||||
|
<tr {% if loop.index%2 == 1 %}class="highlight"{% endif %}>
|
||||||
|
<th>{{ format_predicate(key) }}</th>
|
||||||
|
<td property="{{ key }}">
|
||||||
|
{{ value }}</td>
|
||||||
|
</tr>
|
||||||
|
{%- endfor %}
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
{% if request.user and request.user.has_privilege('admin') %}
|
||||||
|
<a href="{{ request.urlgen('mediagoblin.edit.metadata',
|
||||||
|
user=media_entry.get_uploader.username,
|
||||||
|
media_id=media_entry.id) }}">
|
||||||
|
{% trans %}Edit Metadata{% endtrans %}</a>
|
||||||
|
{% endif %}
|
||||||
|
{%- endmacro %}
|
||||||
|
=======
|
||||||
|
{%- set metadata=media.media_metadata %}
|
||||||
|
{%- set metadata_context=metadata['@context'] %}
|
||||||
|
{%- if metadata %}
|
||||||
|
{#- NOTE: In some smart future where the context is more extensible,
|
||||||
|
we will need to add to the prefix here-#}
|
||||||
|
<table>
|
||||||
|
{%- for key, value in metadata.iteritems() if not key=='@context' %}
|
||||||
|
{% if value -%}
|
||||||
|
<tr>
|
||||||
|
<td>{{ rdfa_to_readable(key) }}</td>
|
||||||
|
<td property="{{ key }}">{{ value }}</td>
|
||||||
|
</tr>
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor %}
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
>>>>>>> acfcaf6366bd4695c1c37c7aa8ff5a176b412e2a:mediagoblin/plugins/metadata_display/templates/mediagoblin/plugins/metadata_display/metadata_table.html
|
@ -609,25 +609,6 @@ a img.media_image {
|
|||||||
cursor: -moz-zoom-in;
|
cursor: -moz-zoom-in;
|
||||||
cursor: zoom-in;
|
cursor: zoom-in;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.metadata_info {
|
|
||||||
font-size:85%;
|
|
||||||
margin-left:10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.metadata_info tr.highlight {
|
|
||||||
color:#f7f7f7;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.metadata_info th {
|
|
||||||
font-weight: bold;
|
|
||||||
border-spacing: 10px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
table.metadata_info td {
|
|
||||||
padding: 4px 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* icons */
|
/* icons */
|
||||||
|
|
||||||
img.media_icon {
|
img.media_icon {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user