diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2014-09-16 14:01:43 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2014-09-16 14:01:43 -0500 |
commit | f6bad0eb26fa7e092570afe1fb7f38b3d1a1941d (patch) | |
tree | 0ca05e7a95cfb30d8b286f3ec72e8c95e212511b /mediagoblin/plugins/archivalook/__init__.py | |
parent | 5b64c92e0816e733c2f88b88ddc0aec070cdc0d3 (diff) | |
parent | 1b4e199668ada5c2ec47df7432ab69e315dc0601 (diff) | |
download | mediagoblin-f6bad0eb26fa7e092570afe1fb7f38b3d1a1941d.tar.lz mediagoblin-f6bad0eb26fa7e092570afe1fb7f38b3d1a1941d.tar.xz mediagoblin-f6bad0eb26fa7e092570afe1fb7f38b3d1a1941d.zip |
Merge branch 'master' into merge-python3-port
Has some issues, will iteratively fix!
Conflicts:
mediagoblin/gmg_commands/__init__.py
mediagoblin/gmg_commands/deletemedia.py
mediagoblin/gmg_commands/users.py
mediagoblin/oauth/views.py
mediagoblin/plugins/api/views.py
mediagoblin/tests/test_api.py
mediagoblin/tests/test_edit.py
mediagoblin/tests/test_oauth1.py
mediagoblin/tests/test_util.py
mediagoblin/tools/mail.py
mediagoblin/webfinger/views.py
setup.py
Diffstat (limited to 'mediagoblin/plugins/archivalook/__init__.py')
-rw-r--r-- | mediagoblin/plugins/archivalook/__init__.py | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/mediagoblin/plugins/archivalook/__init__.py b/mediagoblin/plugins/archivalook/__init__.py new file mode 100644 index 00000000..3f6d9c66 --- /dev/null +++ b/mediagoblin/plugins/archivalook/__init__.py @@ -0,0 +1,106 @@ +# 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 logging +import os +from pkg_resources import resource_filename + +from mediagoblin.tools.pluginapi import (register_template_path, + register_routes, + register_template_hooks) +from mediagoblin.plugins.archivalook.views import (get_root_view, + add_featured_media_to_media_home) +from mediagoblin.tools.staticdirect import PluginStatic + + +_log = logging.getLogger(__name__) + + +_setup_plugin_called = 0 + +def setup_plugin(): + global _setup_plugin_called + + my_plugin_dir = os.path.dirname(__file__) + template_dir = os.path.join(my_plugin_dir, 'templates') + register_template_path(template_dir) + register_routes([ + ('manage-featured-media', '/mod/feature-media/', + 'mediagoblin.plugins.archivalook.views:featured_media_panel'), + ('gallery-recent-media', '/recent/', + 'mediagoblin.plugins.archivalook.views:recent_media_gallery_view'), + ('mediagoblin.user_pages.media_feature', + '/u/<string:user>/m/<string:media>/feature/', + 'mediagoblin.plugins.archivalook.views:feature_media'), + ('mediagoblin.user_pages.media_unfeature', + '/u/<string:user>/m/<string:media>/unfeature/', + 'mediagoblin.plugins.archivalook.views:unfeature_media'), + ('mediagoblin.user_pages.feature_promote', + '/u/<string:user>/m/<string:media>/promote_feature/', + 'mediagoblin.plugins.archivalook.views:promote_featured_media'), + ('mediagoblin.user_pages.feature_demote', + '/u/<string:user>/m/<string:media>/demote_feature/', + 'mediagoblin.plugins.archivalook.views:demote_featured_media')]) + register_template_hooks({ + 'media_sideinfo':'archivalook/feature_media_sidebar.html'}) + register_template_hooks({ + 'moderation_powers':'archivalook/bits/feature_dropdown.html'}) + + # Add template head hooks, if certain media types are enabled + from mediagoblin import mg_globals + plugin_section = mg_globals.global_config.get("plugins", {}) + if "mediagoblin.media_types.video" in plugin_section: + register_template_hooks({ + "archivalook_feature_head": ( + "/archivalook/feature_displays/video_head.html")}) + if "mediagoblin.media_types.audio" in plugin_section: + register_template_hooks({ + "archivalook_feature_head": ( + "/archivalook/feature_displays/audio_head.html")}) + + +IMAGE_PRIMARY_TEMPLATE = "/archivalook/feature_displays/image_primary.html" +IMAGE_SECONDARY_TEMPLATE = "/archivalook/feature_displays/image_secondary.html" +IMAGE_TERTIARY_TEMPLATE = "/archivalook/feature_displays/image_tertiary.html" +AUDIO_PRIMARY_TEMPLATE = "/archivalook/feature_displays/audio_primary.html" +AUDIO_SECONDARY_TEMPLATE = "/archivalook/feature_displays/audio_secondary.html" +AUDIO_TERTIARY_TEMPLATE = "/archivalook/feature_displays/audio_tertiary.html" +VIDEO_PRIMARY_TEMPLATE = "/archivalook/feature_displays/video_primary.html" +VIDEO_SECONDARY_TEMPLATE = "/archivalook/feature_displays/video_secondary.html" +VIDEO_TERTIARY_TEMPLATE = "/archivalook/feature_displays/video_tertiary.html" + +hooks = { + 'setup': setup_plugin, + 'static_setup': lambda: PluginStatic( + 'archivalook', + resource_filename('mediagoblin.plugins.archivalook', 'static') + ), + 'frontpage_view': get_root_view, + 'media_home_context': add_featured_media_to_media_home, + + # # Primary and secondary templates + ("feature_primary_template", + "mediagoblin.media_types.image"): lambda: IMAGE_PRIMARY_TEMPLATE, + ("feature_secondary_template", + "mediagoblin.media_types.image"): lambda: IMAGE_SECONDARY_TEMPLATE, + ("feature_primary_template", + "mediagoblin.media_types.audio"): lambda: AUDIO_PRIMARY_TEMPLATE, + ("feature_secondary_template", + "mediagoblin.media_types.audio"): lambda: AUDIO_SECONDARY_TEMPLATE, + ("feature_primary_template", + "mediagoblin.media_types.video"): lambda: VIDEO_PRIMARY_TEMPLATE, + ("feature_secondary_template", + "mediagoblin.media_types.video"): lambda: VIDEO_SECONDARY_TEMPLATE, +} |