1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 from pkg_resources
import resource_filename
20 from mediagoblin
.tools
.pluginapi
import (register_template_path
,
22 register_template_hooks
)
23 from mediagoblin
.plugins
.archivalook
.views
import (get_root_view
,
24 add_featured_media_to_media_home
)
25 from mediagoblin
.tools
.staticdirect
import PluginStatic
28 _log
= logging
.getLogger(__name__
)
31 _setup_plugin_called
= 0
34 global _setup_plugin_called
36 my_plugin_dir
= os
.path
.dirname(__file__
)
37 template_dir
= os
.path
.join(my_plugin_dir
, 'templates')
38 register_template_path(template_dir
)
40 ('manage-featured-media', '/mod/feature-media/',
41 'mediagoblin.plugins.archivalook.views:featured_media_panel'),
42 ('gallery-recent-media', '/recent/',
43 'mediagoblin.plugins.archivalook.views:recent_media_gallery_view'),
44 ('mediagoblin.user_pages.media_feature',
45 '/u/<string:user>/m/<string:media>/feature/',
46 'mediagoblin.plugins.archivalook.views:feature_media'),
47 ('mediagoblin.user_pages.media_unfeature',
48 '/u/<string:user>/m/<string:media>/unfeature/',
49 'mediagoblin.plugins.archivalook.views:unfeature_media'),
50 ('mediagoblin.user_pages.feature_promote',
51 '/u/<string:user>/m/<string:media>/promote_feature/',
52 'mediagoblin.plugins.archivalook.views:promote_featured_media'),
53 ('mediagoblin.user_pages.feature_demote',
54 '/u/<string:user>/m/<string:media>/demote_feature/',
55 'mediagoblin.plugins.archivalook.views:demote_featured_media')])
56 register_template_hooks({
57 'media_sideinfo':'archivalook/feature_media_sidebar.html'})
58 register_template_hooks({
59 'moderation_powers':'archivalook/bits/feature_dropdown.html'})
61 # Add template head hooks, if certain media types are enabled
62 from mediagoblin
import mg_globals
63 plugin_section
= mg_globals
.global_config
.get("plugins", {})
64 if "mediagoblin.media_types.video" in plugin_section
:
65 register_template_hooks({
66 "archivalook_feature_head": (
67 "/archivalook/feature_displays/video_head.html")})
68 if "mediagoblin.media_types.audio" in plugin_section
:
69 register_template_hooks({
70 "archivalook_feature_head": (
71 "/archivalook/feature_displays/audio_head.html")})
74 IMAGE_PRIMARY_TEMPLATE
= "/archivalook/feature_displays/image_primary.html"
75 IMAGE_SECONDARY_TEMPLATE
= "/archivalook/feature_displays/image_secondary.html"
76 IMAGE_TERTIARY_TEMPLATE
= "/archivalook/feature_displays/image_tertiary.html"
77 AUDIO_PRIMARY_TEMPLATE
= "/archivalook/feature_displays/audio_primary.html"
78 AUDIO_SECONDARY_TEMPLATE
= "/archivalook/feature_displays/audio_secondary.html"
79 AUDIO_TERTIARY_TEMPLATE
= "/archivalook/feature_displays/audio_tertiary.html"
80 VIDEO_PRIMARY_TEMPLATE
= "/archivalook/feature_displays/video_primary.html"
81 VIDEO_SECONDARY_TEMPLATE
= "/archivalook/feature_displays/video_secondary.html"
82 VIDEO_TERTIARY_TEMPLATE
= "/archivalook/feature_displays/video_tertiary.html"
85 'setup': setup_plugin
,
86 'static_setup': lambda: PluginStatic(
88 resource_filename('mediagoblin.plugins.archivalook', 'static')
90 'frontpage_view': get_root_view
,
91 'media_home_context': add_featured_media_to_media_home
,
93 # # Primary and secondary templates
94 ("feature_primary_template",
95 "mediagoblin.media_types.image"): lambda: IMAGE_PRIMARY_TEMPLATE
,
96 ("feature_secondary_template",
97 "mediagoblin.media_types.image"): lambda: IMAGE_SECONDARY_TEMPLATE
,
98 ("feature_primary_template",
99 "mediagoblin.media_types.audio"): lambda: AUDIO_PRIMARY_TEMPLATE
,
100 ("feature_secondary_template",
101 "mediagoblin.media_types.audio"): lambda: AUDIO_SECONDARY_TEMPLATE
,
102 ("feature_primary_template",
103 "mediagoblin.media_types.video"): lambda: VIDEO_PRIMARY_TEMPLATE
,
104 ("feature_secondary_template",
105 "mediagoblin.media_types.video"): lambda: VIDEO_SECONDARY_TEMPLATE
,