Geolocation stuff, including including templates seems to be working-ish
- I'm having trouble seeing if the geolocation stuff actually works, but plugins are included - including a list of template hooks works, however the macro to include them does not, so it's kinda verbose
This commit is contained in:
parent
1c2d01ae3b
commit
a3f811a6e8
35
mediagoblin/plugins/geolocation/__init__.py
Normal file
35
mediagoblin/plugins/geolocation/__init__.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# 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/>.
|
||||||
|
|
||||||
|
from mediagoblin.tools import pluginapi
|
||||||
|
import os
|
||||||
|
|
||||||
|
PLUGIN_DIR = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
def setup_plugin():
|
||||||
|
config = pluginapi.get_config('mediagoblin.plugins.geolocation')
|
||||||
|
|
||||||
|
# Register the template path.
|
||||||
|
pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
|
||||||
|
|
||||||
|
pluginapi.register_template_hooks(
|
||||||
|
{"image_sideinfo": "mediagoblin/plugins/geolocation/map.html",
|
||||||
|
"image_extrahead": "mediagoblin/plugins/geolocation/map_js_head.html"})
|
||||||
|
|
||||||
|
|
||||||
|
hooks = {
|
||||||
|
'setup': setup_plugin
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
{#
|
||||||
|
# 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/>.
|
||||||
|
#}
|
||||||
|
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="{{ request.staticdirect('/extlib/leaflet/leaflet.css') }}" />
|
||||||
|
|
||||||
|
<script type="text/javascript"
|
||||||
|
src="{{ request.staticdirect('/extlib/leaflet/leaflet.js') }}"></script>
|
||||||
|
<script type="text/javascript"
|
||||||
|
src="{{ request.staticdirect('/js/geolocation-map.js') }}"></script>
|
@ -18,13 +18,19 @@
|
|||||||
|
|
||||||
{% extends 'mediagoblin/user_pages/media.html' %}
|
{% extends 'mediagoblin/user_pages/media.html' %}
|
||||||
|
|
||||||
{% from "/mediagoblin/utils/templatehooks.html" import template_hook %}
|
{% from "/mediagoblin/utils/templatehooks.html" import template_hook with context %}
|
||||||
|
|
||||||
{% block mediagoblin_head %}
|
{% block mediagoblin_head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
{% template_hook "image_extrahead" %}
|
{% for template in get_hook_templates("image_extrahead") %}
|
||||||
|
{% include template %}
|
||||||
|
{% endfor %}
|
||||||
|
{# {{ template_hook("image_extrahead") }} #}
|
||||||
{% endblock mediagoblin_head %}
|
{% endblock mediagoblin_head %}
|
||||||
|
|
||||||
{% block mediagoblin_sidebar %}
|
{% block mediagoblin_sidebar %}
|
||||||
{% template_hook "image_sideinfo" %}
|
{% for template in get_hook_templates("image_sideinfo") %}
|
||||||
|
{% include template %}
|
||||||
|
{% endfor %}
|
||||||
|
{# {{ template_hook("image_sideinfo") }} #}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
<script type="text/javascript"
|
<script type="text/javascript"
|
||||||
src="{{ request.staticdirect('/js/keyboard_navigation.js') }}"></script>
|
src="{{ request.staticdirect('/js/keyboard_navigation.js') }}"></script>
|
||||||
|
|
||||||
{% template_hook "media_extrahead" %}
|
{{ template_hook("media_extrahead") }}
|
||||||
{% endblock mediagoblin_head %}
|
{% endblock mediagoblin_head %}
|
||||||
|
|
||||||
{% block mediagoblin_content %}
|
{% block mediagoblin_content %}
|
||||||
@ -156,8 +156,6 @@
|
|||||||
|
|
||||||
{% include "mediagoblin/utils/license.html" %}
|
{% include "mediagoblin/utils/license.html" %}
|
||||||
|
|
||||||
{% include "mediagoblin/utils/geolocation_map.html" %}
|
|
||||||
|
|
||||||
{% include "mediagoblin/utils/exif.html" %}
|
{% include "mediagoblin/utils/exif.html" %}
|
||||||
|
|
||||||
{% if media.attachment_files|count %}
|
{% if media.attachment_files|count %}
|
||||||
@ -199,7 +197,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% template_hook "media_sideinfo" %}
|
{{ template_hook("media_sideinfo") }}
|
||||||
|
|
||||||
{% block mediagoblin_sidebar %}
|
{% block mediagoblin_sidebar %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
22
mediagoblin/templates/mediagoblin/utils/templatehooks.html
Normal file
22
mediagoblin/templates/mediagoblin/utils/templatehooks.html
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{#
|
||||||
|
# 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 template_hook(hook_name) %}
|
||||||
|
{% for template in get_hook_templates(hook_name) %}
|
||||||
|
{% include template %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endmacro %}
|
@ -154,7 +154,10 @@ class PluginManager(object):
|
|||||||
else:
|
else:
|
||||||
# In this case, it's actually a single callable---not a
|
# In this case, it's actually a single callable---not a
|
||||||
# list of callables.
|
# list of callables.
|
||||||
self.hooks.setdefault(hook, []).append(templates)
|
self.template_hooks.setdefault(hook, []).append(templates)
|
||||||
|
|
||||||
|
def get_template_hooks(self, hook_name):
|
||||||
|
return self.template_hooks.get(hook_name, [])
|
||||||
|
|
||||||
|
|
||||||
def register_routes(routes):
|
def register_routes(routes):
|
||||||
@ -235,3 +238,7 @@ def get_config(key):
|
|||||||
|
|
||||||
def register_template_hooks(template_hooks):
|
def register_template_hooks(template_hooks):
|
||||||
PluginManager().register_template_hooks(template_hooks)
|
PluginManager().register_template_hooks(template_hooks)
|
||||||
|
|
||||||
|
|
||||||
|
def get_hook_templates(hook_name):
|
||||||
|
return PluginManager().get_template_hooks(hook_name)
|
||||||
|
@ -23,6 +23,7 @@ from mediagoblin import mg_globals
|
|||||||
from mediagoblin import messages
|
from mediagoblin import messages
|
||||||
from mediagoblin.tools import common
|
from mediagoblin.tools import common
|
||||||
from mediagoblin.tools.translate import get_gettext_translation
|
from mediagoblin.tools.translate import get_gettext_translation
|
||||||
|
from mediagoblin.tools.pluginapi import get_hook_templates
|
||||||
from mediagoblin.meddleware.csrf import render_csrf_form_token
|
from mediagoblin.meddleware.csrf import render_csrf_form_token
|
||||||
|
|
||||||
|
|
||||||
@ -64,6 +65,9 @@ def get_jinja_env(template_loader, locale):
|
|||||||
|
|
||||||
template_env.filters['urlencode'] = url_quote_plus
|
template_env.filters['urlencode'] = url_quote_plus
|
||||||
|
|
||||||
|
# allow for hooking up plugin templates
|
||||||
|
template_env.globals['get_hook_templates'] = get_hook_templates
|
||||||
|
|
||||||
if exists(locale):
|
if exists(locale):
|
||||||
SETUP_JINJA_ENVS[locale] = template_env
|
SETUP_JINJA_ENVS[locale] = template_env
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user