{% 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 %}
{% 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 }} — {{ super() }}{% endblock %}
<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 %}
</p>
{% endif %}
+ {% template_hook "media_sideinfo" %}
+
{% block mediagoblin_sidebar %}
{% endblock %}
+
</div>
<div class="clear"></div>
{% endblock %}
# list of registered template paths
"template_paths": set(),
+ # list of template hooks
+ "template_hooks": {},
+
# list of registered routes
"routes": [],
}
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
return plugin_section.get(key, {})
+def register_template_hooks(template_hooks):
+ PluginManager().register_template_hooks(template_hooks)