aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2013-01-25 10:39:20 -0600
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-01-30 13:22:18 -0600
commit1c2d01ae3ba421536d5775e5992393019714b856 (patch)
tree3d06980079b075b6b3c73c71c75a522cbc4dd899
parent04453ccf422539a2f5752a83084cfac7a8c701ee (diff)
downloadmediagoblin-1c2d01ae3ba421536d5775e5992393019714b856.tar.lz
mediagoblin-1c2d01ae3ba421536d5775e5992393019714b856.tar.xz
mediagoblin-1c2d01ae3ba421536d5775e5992393019714b856.zip
Very start of plugin hooks and openstreetmap pluginification
- Added start of template hook code to pluginapi.py - Started to break openstreetmap into plugin; moved templates - Added plugin hooks in media and image media templates ... almost certainly, none of this works yet. :)
-rw-r--r--mediagoblin/plugins/geolocation/templates/mediagoblin/plugins/geolocation/map.html (renamed from mediagoblin/templates/mediagoblin/utils/geolocation_map.html)0
-rw-r--r--mediagoblin/templates/mediagoblin/media_displays/image.html8
-rw-r--r--mediagoblin/templates/mediagoblin/user_pages/media.html14
-rw-r--r--mediagoblin/tools/pluginapi.py27
4 files changed, 40 insertions, 9 deletions
diff --git a/mediagoblin/templates/mediagoblin/utils/geolocation_map.html b/mediagoblin/plugins/geolocation/templates/mediagoblin/plugins/geolocation/map.html
index b48678bb..b48678bb 100644
--- a/mediagoblin/templates/mediagoblin/utils/geolocation_map.html
+++ b/mediagoblin/plugins/geolocation/templates/mediagoblin/plugins/geolocation/map.html
diff --git a/mediagoblin/templates/mediagoblin/media_displays/image.html b/mediagoblin/templates/mediagoblin/media_displays/image.html
index 30c2a90d..b03cfc78 100644
--- a/mediagoblin/templates/mediagoblin/media_displays/image.html
+++ b/mediagoblin/templates/mediagoblin/media_displays/image.html
@@ -18,5 +18,13 @@
{% extends 'mediagoblin/user_pages/media.html' %}
+{% from "/mediagoblin/utils/templatehooks.html" import template_hook %}
+
+{% block mediagoblin_head %}
+ {{ super() }}
+ {% template_hook "image_extrahead" %}
+{% endblock mediagoblin_head %}
+
{% block mediagoblin_sidebar %}
+ {% template_hook "image_sideinfo" %}
{% endblock %}
diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html
index 7e184257..b18e0828 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/media.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/media.html
@@ -18,6 +18,7 @@
{% extends "mediagoblin/base.html" %}
{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
+{% from "/mediagoblin/utils/templatehooks.html" import template_hook %}
{% from "mediagoblin/utils/pagination.html" import render_pagination %}
{% block title %}{{ media.title }} &mdash; {{ super() }}{% endblock %}
@@ -30,15 +31,7 @@
<script type="text/javascript"
src="{{ request.staticdirect('/js/keyboard_navigation.js') }}"></script>
- {% if app_config['geolocation_map_visible'] %}
- <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>
- {% endif %}
+ {% template_hook "media_extrahead" %}
{% endblock mediagoblin_head %}
{% block mediagoblin_content %}
@@ -206,8 +199,11 @@
</p>
{% endif %}
+ {% template_hook "media_sideinfo" %}
+
{% block mediagoblin_sidebar %}
{% endblock %}
+
</div>
<div class="clear"></div>
{% endblock %}
diff --git a/mediagoblin/tools/pluginapi.py b/mediagoblin/tools/pluginapi.py
index 38ab631b..2b8e95f4 100644
--- a/mediagoblin/tools/pluginapi.py
+++ b/mediagoblin/tools/pluginapi.py
@@ -83,6 +83,9 @@ class PluginManager(object):
# list of registered template paths
"template_paths": set(),
+ # list of template hooks
+ "template_hooks": {},
+
# list of registered routes
"routes": [],
}
@@ -131,6 +134,28 @@ class PluginManager(object):
def get_routes(self):
return tuple(self.routes)
+ def register_template_hooks(self, template_hooks):
+ """
+ Register a dict of template hooks.
+
+ Takes template_hooks as an argument, which is a dictionary of
+ template hook names/keys to the templates they should provide.
+ (The value can either be a single template path or an iterable
+ of paths.)
+
+ Example:
+ {"media_sidebar": "/plugin/sidemess/mess_up_the_side.html",
+ "media_descriptionbox": ["/plugin/sidemess/even_more_mess.html",
+ "/plugin/sidemess/so_much_mess.html"]}
+ """
+ for hook, templates in template_hooks.items():
+ if isinstance(templates, (list, tuple)):
+ self.template_hooks.setdefault(hook, []).extend(list(templates))
+ else:
+ # In this case, it's actually a single callable---not a
+ # list of callables.
+ self.hooks.setdefault(hook, []).append(templates)
+
def register_routes(routes):
"""Registers one or more routes
@@ -208,3 +233,5 @@ def get_config(key):
return plugin_section.get(key, {})
+def register_template_hooks(template_hooks):
+ PluginManager().register_template_hooks(template_hooks)