diff options
Diffstat (limited to 'mediagoblin/plugins/archivalook')
6 files changed, 64 insertions, 25 deletions
diff --git a/mediagoblin/plugins/archivalook/migrations/b10b5f822789_archivalook_plugin_initial_migration.py b/mediagoblin/plugins/archivalook/migrations/b10b5f822789_archivalook_plugin_initial_migration.py new file mode 100644 index 00000000..1bedcf3c --- /dev/null +++ b/mediagoblin/plugins/archivalook/migrations/b10b5f822789_archivalook_plugin_initial_migration.py @@ -0,0 +1,37 @@ +"""ArchivaLook plugin initial migration + +Revision ID: b10b5f822789 +Revises: 52bf0ccbedc1 +Create Date: 2016-03-12 23:37:51.551856 + +""" + +# revision identifiers, used by Alembic. +revision = 'b10b5f822789' +down_revision = '52bf0ccbedc1' +branch_labels = ('archivalook_plugin',) +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + if op.get_bind().engine.has_table('archivalook__featured_media'): + # Skip; this has already been instantiated + # (probably via sqlalchemy-migrate) + return + + op.create_table( + 'archivalook__featured_media', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('media_entry_id', sa.Integer(), nullable=False), + sa.Column('display_type', sa.Unicode(), nullable=False), + sa.Column('order', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['media_entry_id'], + ['core__media_entries.id']), + sa.PrimaryKeyConstraint('id')) + + +def downgrade(): + op.drop_table('archivalook__featured_media') diff --git a/mediagoblin/plugins/archivalook/templates/archivalook/feature.html b/mediagoblin/plugins/archivalook/templates/archivalook/feature.html index 6bcf792e..b19029c3 100644 --- a/mediagoblin/plugins/archivalook/templates/archivalook/feature.html +++ b/mediagoblin/plugins/archivalook/templates/archivalook/feature.html @@ -35,7 +35,7 @@ </a></strong> <p> {% trans %} - Go to the page of the media entry you want to feature. Copy it's URL and + Go to the page of the media entry you want to feature. Copy its URL and then paste it into a new line in the text box above. There should be only one url per line. The url that you paste into the text box should be under the header describing how prominent a feature it will be (whether Primary, @@ -52,7 +52,7 @@ Yes. If you would prefer, you may go to the media homepage of the piece of media you would like to feature or unfeature and look at the bar to the side of the media entry. If the piece of media has not been featured - yet you should see a button that says 'Feature'. Press that button and + yet you should see a button that says "Feature". Press that button and the media will be featured as a Primary Feature at the top of the page. All other featured media entries will remain as features, but will be pushed further down the page.<br /><br /> @@ -86,7 +86,7 @@ featured?{% endtrans %}</a></strong> <p> {% trans %} - When a media entry is featured, the entry's title, it's thumbnail and a + When a media entry is featured, the entry's title, its thumbnail and a portion of its description will be displayed on your website's front page. The number of characters displayed varies on the prominence of the feature. Primary Features display the first 512 characters of their description, diff --git a/mediagoblin/plugins/archivalook/templates/archivalook/feature_displays/audio_head.html b/mediagoblin/plugins/archivalook/templates/archivalook/feature_displays/audio_head.html index a53694b3..d1ea0b9a 100644 --- a/mediagoblin/plugins/archivalook/templates/archivalook/feature_displays/audio_head.html +++ b/mediagoblin/plugins/archivalook/templates/archivalook/feature_displays/audio_head.html @@ -1,5 +1,3 @@ <link rel="stylesheet" type="text/css" href="{{ request.staticdirect('/css/audio.css') }}" /> <script type="text/javascript" src="{{ request.staticdirect( - '/js/extlib/html5slider.js') }}"></script> - <script type="text/javascript" src="{{ request.staticdirect( '/js/audio.js') }}"></script> diff --git a/mediagoblin/plugins/archivalook/templates/archivalook/feature_media_sidebar.html b/mediagoblin/plugins/archivalook/templates/archivalook/feature_media_sidebar.html index c5b8a7d6..942a888b 100644 --- a/mediagoblin/plugins/archivalook/templates/archivalook/feature_media_sidebar.html +++ b/mediagoblin/plugins/archivalook/templates/archivalook/feature_media_sidebar.html @@ -21,7 +21,7 @@ {% if not media_feature %} <a href="{{ request.urlgen( 'mediagoblin.user_pages.media_feature', - user=media.get_uploader.username, + user=media.get_actor.username, media=media.slug_or_id) }}" class="button_action" id="button_featuremedia" title="{% trans %} Feature Media {% endtrans %}"> @@ -29,7 +29,7 @@ Feature Media {% endtrans %}"> {% else %} <a href="{{ request.urlgen( 'mediagoblin.user_pages.media_unfeature', - user=media.get_uploader.username, + user=media.get_actor.username, media=media.slug_or_id) }}" class="button_action" id="button_unfeaturemedia" title="{% trans %} Unfeature Media {% endtrans %}"> @@ -37,7 +37,7 @@ Unfeature Media {% endtrans %}"> {% if not media_feature.display_type == 'primary' %} <a href="{{ request.urlgen( 'mediagoblin.user_pages.feature_promote', - user=media.get_uploader.username, + user=media.get_actor.username, media=media.slug_or_id) }}" class="button_action" id="button_promotefeature" title="{% trans %} Promote Feature {% endtrans %}"> @@ -45,7 +45,7 @@ Promote Feature {% endtrans %}"> {% endif %}{% if not media_feature.display_type == 'tertiary' %} <a href="{{ request.urlgen( 'mediagoblin.user_pages.feature_demote', - user=media.get_uploader.username, + user=media.get_actor.username, media=media.slug_or_id) }}" class="button_action" id="button_demotefeature" title="{% trans %} Demote Feature {% endtrans %}"> diff --git a/mediagoblin/plugins/archivalook/templates/archivalook/root.html b/mediagoblin/plugins/archivalook/templates/archivalook/root.html index 72fe8656..4dbd0f9e 100644 --- a/mediagoblin/plugins/archivalook/templates/archivalook/root.html +++ b/mediagoblin/plugins/archivalook/templates/archivalook/root.html @@ -59,17 +59,19 @@ {%- elif request.user and request.user.has_privilege('featurer') %} <div> <h2>{% trans %}Nothing is currently featured.{% endtrans %}</h2> - {% trans %}If you would like to feature a + {% trans -%} + If you would like to feature a piece of media, go to that media entry's homepage and click the button - that says{% endtrans %} <a class="button_action">Feature</a>. - {% trans %}You're seeing this page because you are a user capable of + that says <a class="button_action">Feature</a>. + {%- endtrans %} + {% trans featured_media_url=request.urlgen('manage-featured-media') -%} + You're seeing this page because you are a user capable of featuring media, a regular user would see a blank page, so be sure to have media featured as long as your instance has the 'archivalook' plugin enabled. A more advanced tool to manage features can be found - in the{% endtrans %} - <a href="{{ request.urlgen( - 'manage-featured-media') }}"> - {% trans %}feature management panel.{% endtrans %}</a> + in the <a href="{{ featured_media_url }}">feature management panel.</a> + {%- endtrans %} + </a> </div> </div> {%- endif %} diff --git a/mediagoblin/plugins/archivalook/tools.py b/mediagoblin/plugins/archivalook/tools.py index 9c715c9b..ad2eee5f 100644 --- a/mediagoblin/plugins/archivalook/tools.py +++ b/mediagoblin/plugins/archivalook/tools.py @@ -13,7 +13,9 @@ # # 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.db.models import MediaEntry, User +import six + +from mediagoblin.db.models import MediaEntry, User, LocalUser from mediagoblin.plugins.archivalook.models import FeaturedMedia from mediagoblin.tools.translate import lazy_pass_to_ugettext as _ from mediagoblin.plugins.archivalook.models import FeaturedMedia @@ -32,11 +34,12 @@ def get_media_entry_from_uploader_slug(uploader_username, slug): :returns media A MediaEntry object or None if no entry matches the specifications. """ - uploader = User.query.filter( - User.username == uploader_username).first() + uploader = LocalUser.query.filter( + LocalUser.username==uploader_username + ).first() media = MediaEntry.query.filter( - MediaEntry.get_uploader == uploader ).filter( - MediaEntry.slug == slug).first() + MediaEntry.get_actor == uploader ).filter( + MediaEntry.slug == slug).first() return media @@ -53,7 +56,7 @@ def parse_url(url): who uploaded the piece of media, slug is the media entry's url slug. """ - url = unicode(url) + url = six.text_type(url) u_end, m_start, m_end, end = (url.find('/u/') + 3, url.find('/m/'), url.find('/m/') + 3, @@ -84,7 +87,7 @@ def split_featured_media_list(featured_media): or tertiary) """ - featured_media = unicode(featured_media) + featured_media = six.text_type(featured_media) featured_media_list = featured_media.split("\n") display_type = 0 media_already_featured = [] @@ -138,7 +141,7 @@ def create_featured_media_textbox(): for feature in feature_list: media_entry = feature.media_entry output_text += u'/u/{uploader_username}/m/{media_slug}/\n'.format( - uploader_username = media_entry.get_uploader.username, + uploader_username = media_entry.get_actor.username, media_slug = media_entry.slug) @@ -289,4 +292,3 @@ def demote_feature(media_entry): elif target_feature.display_type == u'primary': target_feature.display_type = u'secondary' target_feature.save() - |