documenting the new media_type plugins and available hooks

This commit is contained in:
Rodney Ewing 2013-07-12 11:57:16 -07:00
parent 5305fee13b
commit 91bee92e8e
3 changed files with 46 additions and 19 deletions

View File

@ -74,6 +74,7 @@ This guide covers writing new GNU MediaGoblin plugins.
pluginwriter/database pluginwriter/database
pluginwriter/api pluginwriter/api
pluginwriter/tests pluginwriter/tests
pluginwriter/media_type_hooks
Part 4: Developer's Zone Part 4: Developer's Zone

View File

@ -0,0 +1,27 @@
==================
Media Type hooks
==================
This documents the hooks that are currently available for ``media_type`` plugins.
What hooks are available?
=========================
'sniff_handler'
---------------
This hook is used by ``sniff_media`` in ``mediagoblin.media_types.__init__``.
Your media type should return its ``sniff_media`` method when this hook is
called.
.. Note::
Your ``sniff_media`` method should return either the ``media_type`` or
``None``.
'get_media_type_and_manager'
----------------------------
This hook is used by ``get_media_type_and_manager`` in
``mediagoblin.media_types.__init__``. When this hook is called, your media type
plugin should check if it can handle the given extension. If so, your media
type plugin should return the media type and media manager.

View File

@ -18,16 +18,18 @@ Media Types
==================== ====================
In the future, there will be all sorts of media types you can enable, In the future, there will be all sorts of media types you can enable,
but in the meanwhile there are three additional media types: video, audio but in the meanwhile there are five additional media types: video, audio,
and ascii art. ascii art, STL/3d models, PDF and Document.
First, you should probably read ":doc:`configuration`" to make sure First, you should probably read ":doc:`configuration`" to make sure
you know how to modify the mediagoblin config file. you know how to modify the mediagoblin config file.
Enabling Media Types Enabling Media Types
==================== ====================
.. note::
Media types are now plugins
Media types are enabled in your mediagoblin configuration file, typically it is Media types are enabled in your mediagoblin configuration file, typically it is
created by copying ``mediagoblin.ini`` to ``mediagoblin_local.ini`` and then created by copying ``mediagoblin.ini`` to ``mediagoblin_local.ini`` and then
applying your changes to ``mediagoblin_local.ini``. If you don't already have a applying your changes to ``mediagoblin_local.ini``. If you don't already have a
@ -37,11 +39,13 @@ Most media types have additional dependencies that you will have to install.
You will find descriptions on how to satisfy the requirements of each media type You will find descriptions on how to satisfy the requirements of each media type
on this page. on this page.
To enable a media type, edit the ``media_types`` list in your To enable a media type, add the the media type under the ``[plugins]`` section
``mediagoblin_local.ini``. For example, if your system supported image and in you ``mediagoblin_local.ini``. For example, if your system supported image
video media types, then the list would look like this:: and video media types, then it would look like this::
media_types = mediagoblin.media_types.image, mediagoblin.media_types.video [plugins]
[[mediagoblin.media_types.image]]
[[mediagoblin.media_types.video]]
Note that after enabling new media types, you must run dbupdate like so:: Note that after enabling new media types, you must run dbupdate like so::
@ -83,8 +87,8 @@ good/bad/ugly). On Debianoid systems
gstreamer0.10-ffmpeg gstreamer0.10-ffmpeg
Add ``mediagoblin.media_types.video`` to the ``media_types`` list in your Add ``[[mediagoblin.media_types.video]]`` under the ``[plugins]`` section in
``mediagoblin_local.ini`` and restart MediaGoblin. your ``mediagoblin_local.ini`` and restart MediaGoblin.
Run Run
@ -133,7 +137,7 @@ Then install ``scikits.audiolab`` for the spectrograms::
./bin/pip install scikits.audiolab ./bin/pip install scikits.audiolab
Add ``mediagoblin.media_types.audio`` to the ``media_types`` list in your Add ``[[mediagoblin.media_types.audio]]`` under the ``[plugins]`` section in your
``mediagoblin_local.ini`` and restart MediaGoblin. ``mediagoblin_local.ini`` and restart MediaGoblin.
Run Run
@ -158,13 +162,8 @@ library, which is necessary for creating thumbnails of ascii art
Next, modify (and possibly copy over from ``mediagoblin.ini``) your Next, modify (and possibly copy over from ``mediagoblin.ini``) your
``mediagoblin_local.ini``. In the ``[mediagoblin]`` section, add ``mediagoblin_local.ini``. In the ``[plugins]`` section, add
``mediagoblin.media_types.ascii`` to the ``media_types`` list. ``[[mediagoblin.media_types.ascii]]``.
For example, if your system supported image and ascii art media types, then
the list would look like this::
media_types = mediagoblin.media_types.image, mediagoblin.media_types.ascii
Run Run
@ -184,7 +183,7 @@ your execution path. This feature has been tested with Blender 2.63.
It may work on some earlier versions, but that is not guaranteed (and It may work on some earlier versions, but that is not guaranteed (and
is surely not to work prior to Blender 2.5X). is surely not to work prior to Blender 2.5X).
Add ``mediagoblin.media_types.stl`` to the ``media_types`` list in your Add ``[[mediagoblin.media_types.stl]]`` under the ``[plugins]`` section in your
``mediagoblin_local.ini`` and restart MediaGoblin. ``mediagoblin_local.ini`` and restart MediaGoblin.
Run Run
@ -233,7 +232,7 @@ This feature has been tested on Fedora with:
It may work on some earlier versions, but that is not guaranteed. It may work on some earlier versions, but that is not guaranteed.
Add ``mediagoblin.media_types.pdf`` to the ``media_types`` list in your Add ``[[mediagoblin.media_types.pdf]]`` under the ``[plugins]`` section in your
``mediagoblin_local.ini`` and restart MediaGoblin. ``mediagoblin_local.ini`` and restart MediaGoblin.
Run Run