From 7fa4e19fc4e7d04175549ea2f21f8b741fbe69f2 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Tue, 25 Jun 2013 13:25:25 -0500 Subject: Add a bit more docs to plugin configuration This commit sponsored by Michael Rauch. Thank you! --- docs/source/pluginwriter/api.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'docs/source/pluginwriter') diff --git a/docs/source/pluginwriter/api.rst b/docs/source/pluginwriter/api.rst index 66def173..29adb691 100644 --- a/docs/source/pluginwriter/api.rst +++ b/docs/source/pluginwriter/api.rst @@ -69,6 +69,32 @@ example might look like:: This means that when people enable your plugin in their config you'll be able to provide defaults as well as type validation. +You can access this via the app_config variables in mg_globals, or you +can use a shortcut to get your plugin's config section:: + + >>> from mediagoblin.tools import pluginapi + # Replace with the path to your plugin. + # (If an external package, it won't be part of mediagoblin.plugins) + >>> floobie_config = pluginapi.get_config('mediagoblin.plugins.floobifier') + >>> floobie_dir = floobie_config['floobie_dir'] + # This is the same as the above + >>> from mediagoblin import mg_globals + >>> config = mg_globals.global_config['plugins']['mediagoblin.plugins.floobifier'] + >>> floobie_dir = floobie_config['floobie_dir'] + +A tip: you have access to the `%(here)s` variable in your config, +which is the directory that the user's mediagoblin config is running +out of. So for example, your plugin may need a "floobie" directory to +store floobs in. You could give them a reasonable default that makes +use of the default `user_dev` location, but allow users to override +it, like so:: + + [plugin_spec] + floobie_dir = string(default="%(here)s/user_dev/floobs/") + +Note, this is relative to the user's mediagoblin config directory, +*not* your plugin directory! + Context Hooks ------------- -- cgit v1.2.3 From 91bee92e8ef188e4a5aa191b6c047a57a668f5fa Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Fri, 12 Jul 2013 11:57:16 -0700 Subject: documenting the new media_type plugins and available hooks --- docs/source/pluginwriter/media_type_hooks.rst | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs/source/pluginwriter/media_type_hooks.rst (limited to 'docs/source/pluginwriter') diff --git a/docs/source/pluginwriter/media_type_hooks.rst b/docs/source/pluginwriter/media_type_hooks.rst new file mode 100644 index 00000000..0dfbbafd --- /dev/null +++ b/docs/source/pluginwriter/media_type_hooks.rst @@ -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. -- cgit v1.2.3 From 2d0028e93283fea397133294a5eb45b67d5ed0ab Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Fri, 12 Jul 2013 17:13:48 -0500 Subject: Documenting the media_manager fetching hook This commit sponsored by Christian Corrodi. Thank you! --- docs/source/pluginwriter/media_type_hooks.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'docs/source/pluginwriter') diff --git a/docs/source/pluginwriter/media_type_hooks.rst b/docs/source/pluginwriter/media_type_hooks.rst index 0dfbbafd..498b0b54 100644 --- a/docs/source/pluginwriter/media_type_hooks.rst +++ b/docs/source/pluginwriter/media_type_hooks.rst @@ -25,3 +25,14 @@ 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. + +('media_manager', MEDIA_TYPE) +----------------------------- + +If you already know the string representing the media type of a type +of media, you can pull down the manager specifically. Note that this +hook is not a string but a tuple of two strings, the latter being the +name of the media type. + +This is used by media entries to pull down their media managers, and +so on. -- cgit v1.2.3