.. toctree::
:maxdepth: 1
- plugindocs/flatpagesfile
- plugindocs/sampleplugin
- plugindocs/trim_whitespace
- plugindocs/raven
plugindocs/basic_auth
+ plugindocs/flatpagesfile
+ plugindocs/ldap
plugindocs/openid
plugindocs/persona
- plugindocs/ldap
+ plugindocs/raven
+ plugindocs/sampleplugin
+ plugindocs/subtitles
+ plugindocs/trim_whitespace
Part 3: Plugin Writer's Guide
--- /dev/null
+================
+Subtitles plugin
+================
+
+This plugin enables text captioning of videos (though not yet audio). Once the
+plugin is enabled, you'll see a link to upload subtitles in `WebVTT format`_ as
+supported by the Video.js `Text Tracks`_ feature.
+
+.. _WebVTT format: https://en.wikipedia.org/wiki/WebVTT
+.. _Text Tracks: https://docs.videojs.com/docs/guides/text-tracks.html
+
+.. _subtitles-setup:
+
+Enabling the subtitles plugin
+=============================
+
+1. Add the following to your MediaGoblin .ini file in the ``[plugins]`` section::
+
+ [[mediagoblin.plugins.subtitles]]
+
+2. Run::
+
+ $ ./bin/gmg dbupdate
+
+3. Restart your MediaGoblin process.
import wtforms
+from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
+
class CustomizeSubtitlesForm(wtforms.Form):
subtitle = wtforms.TextAreaField(
('Subtitle'),
[wtforms.validators.Optional()],
- description=(""))
+ description=_('Subtitles in <a href="https://en.wikipedia.org/wiki/WebVTT" target="_blank">WebVTT format</a>'))
class EditSubtitlesForm(wtforms.Form):
subtitle_language = wtforms.StringField(
'Language')
subtitle_file = wtforms.FileField(
- 'File')
+ 'File',
+ description=_('Subtitles in <a href="https://en.wikipedia.org/wiki/WebVTT" target="_blank">WebVTT format</a>'))
#}
{% block subtitle_block %}
-{% if "video.html" in media.media_manager.display_template or "audio.html" in media.media_manager.display_template %}
+{% if "video.html" in media.media_manager.display_template %}
{%- if media.subtitle_files|count %}
<h3>{% trans %}Subtitles{% endtrans %}</h3>
<ul>
@user_may_delete_media
@require_active_login
def edit_subtitles(request, media):
- allowed_extensions = ['aqt','gsub','jss','sub','ttxt','pjs','psb',
- 'rt','smi','stl','ssf','srt','ssa','ass','usf','vtt','lrc']
+ # This was originally quite a long list of allowed extensions, but as far as
+ # I understand, Video.js only supports WebVTT format subtitles:
+ # https://docs.videojs.com/docs/guides/text-tracks.html
+ allowed_extensions = ['vtt']
form = forms.EditSubtitlesForm(request.form)
# Add any subtitles