Skip to content
Browse files

Replaced plugin_reference with api_references and improved the markup…

… for it
  • Loading branch information...
1 parent ebbc566 commit 5c1ec9ee1c748169d7aded93a1e0a55af047a716 ojii committed Dec 24, 2010
Showing with 88 additions and 135 deletions.
  1. +87 −0 docs/api_references.rst
  2. +1 −1 docs/index.rst
  3. +0 −134 docs/plugin_reference.rst
View
87 docs/api_references.rst
@@ -0,0 +1,87 @@
+##############
+API References
+##############
+
+
+*************
+CMSPluginBase
+*************
+
+.. module:: cms.plugin_base
+
+.. class:: CMSPluginBase
+
+ Inherits ``django.contrib.admin.options.ModelAdmin``.
+
+ .. attribute:: admin_preview
+
+ Defaults to ``True``, if ``False`` no preview is done in the admin.
+
+ .. attribute:: change_form_template
+
+ Custom template to use to render the form to edit this plugin.
+
+ .. attribute:: form
+
+ Custom form class to be used to edit this plugin.
+
+ .. attribute:: model
+
+ Is the CMSPlugin model we created earlier. If you don't need a model
+ because you just want to display some template logic, use CMSPlugin from
+ ``cms.models`` as the model instead.
+
+ .. attribute:: module
+
+ Will be group the plugin in the plugin editor. If module is None,
+ plugin is grouped "Generic" group.
+
+ .. attribute:: name
+
+ Will be displayed in the plugin editor.
+
+ .. attribute:: render_plugin
+
+ If set to ``False``, this plugin will not be rendered at all.
+
+ .. attribute:: render_template
+
+ Will be rendered with the context returned by the render function.
+
+ .. attribute:: text_enabled
+
+ Whether this plugin can be used in text plugins or not.
+
+ .. method:: icon_alt(instance)
+
+ Returns the alt text for the icon used in text plugins, see
+ :meth:`icon_src`.
+
+ .. method:: icon_src(instance)
+
+ Returns the url to the icon to be used for the given instance when that
+ instance is used inside a text plugin.
+
+ .. method:: render(context, instance, placeholder)
+
+ This method returns the context to be used to render the template
+ specified in :attr:`render_template`.
+
+ :param context: Current template context.
+ :param instance: Plugin instance that is being rendered.
+ :param placeholder: Name of the placeholder the plugin is in.
+ :rtype: ``dict``
+
+ .. class:: PluginMedia
+
+ Defines media which is required to render this plugin.
+
+ .. attribute:: css
+
+ The CSS files required to render this plugin as a dictionary with
+ the display type as keys and a sequence of strings as values.
+
+ .. attribute:: js
+
+ The Javascript files required to render this plugin as a sequence
+ of strings.
View
2 docs/index.rst
@@ -48,7 +48,7 @@ Extending the CMS
custom_plugins
app_integration
- plugin_reference
+ api_references
placeholders
searchdocs
View
134 docs/plugin_reference.rst
@@ -1,134 +0,0 @@
-################
-Plugin Reference
-################
-
-*****
-model
-*****
-
-Is the CMSPlugin model we created earlier. If you don't need a model because
-you just want to display some template logic, use CMSPlugin from
-``cms.models`` as the model instead.
-
-****
-name
-****
-
-Will be displayed in the plugin editor.
-
-******
-module
-******
-
-Will be group the plugin in the plugin editor. If module is None, plugin is
-grouped "Generic" group.
-
-***************
-render_template
-***************
-
-Will be rendered with the context returned by the render function
-
-******
-render
-******
-
-The render function takes 3 arguments:
-
-**context**:
-
-The context of the template placeholder was placed.
-
-**instance**:
-
-The instance of the GalleryPlugin model
-
-**placeholder**:
-
-The name of the placeholder this plugin appears. It is normally a good idea to
-give the placeholder to the template so you can style the content differently
-in the template based on which placeholder it is placed.
-
-If you want to process forms in the render function or if you want to see if
-the user is logged in you may want to access the request. You can accomplish
-this simply with::
-
- request = context['request']
-
-Because the request will always be in the context as the requestcontext
-processor is required by the CMS.
-
-
-***********
-PluginMedia
-***********
-
-With a PluginMedia Class you can define a list of javascript and css files
-that should get loaded with the html. You will need to palce a ``{%
-plugin_media %}`` templatetag in your ``<head>``
-
-example::
-
- class GalleryPlugin(CMSPluginBase):
- model = Gallery
- name = _("Gallery")
- render_template = "cms/plugins/gallery.html"
-   
- def render(self, context, instance, placeholder):
- context.update({
- 'instance': instance,
- 'gallery': instance.gallery,
- 'placeholder': placeholder,
- })
- return context
-    
- class PluginMedia:
- css = {
- 'all': ('%scss/jquery.lightbox-0.5.css' % settings.MEDIA_URL,)
- }
- js = ('%sgallery/js/jquery.cycle.min.js'% settings.MEDIA_URL,
- '%sgallery/js/jquery.cycle.trans.min.js'% settings.MEDIA_URL,
- '%sgallery/js/jquery.lightbox-0.5.min.js'% settings.MEDIA_URL,)
-
- plugin_pool.register_plugin(GalleryPlugin)
-
-In this example a Gallery Plugin loads jquery lightbox and jquery cicle plugin
-with some CSS
-
-************
-text_enabled
-************
-
-*** icon_src ***
-
-*** icon_alt ***
-
-****
-form
-****
-
-The form that will be displayed if you edit the plugin.
-Have a read on django forms for this.
-
-********************
-change_form_template
-********************
-
-The template that renders the form.
-
-*************
-admin_preview
-*************
-
-default = True
-
-Should the plugin be rendered in the admin for a preview?
-
-*************
-render_plugin
-*************
-
-default = True
-
-Should the plugin be rendered at all, or doesn't it have any output?
-

0 comments on commit 5c1ec9e

Please sign in to comment.
Something went wrong with that request. Please try again.