Help:Codex_Wiki_Plugins
Codex Wiki Plugins
Introduction
Codex comes bundled with a set of custom wiki plugins that can be used in any wiki page by following the following syntax:
<nowiki>{{{PluginName arg1="" arg2="" ...}}}</nowiki>
Basically, you create a tag with the name of the plugin to use and then just create arguments of name-value pairs of whatever arguments the plugin's renderit() method takes in.
A Wiki Plugin
Creating wiki plugins are very easy. Just drop them in the /App/plugins/wiki folder and you are ready to start using them in your wiki pages.
A wiki plugin is exactly just like any other ColdBox plugin. ColdBox Plugin Guide.
Rules
- Plugin component must extend coldbox.system.plugin and implement the coldbox plugin init() method.
- Plugin can just implement the ColdBox init() method with no inheritance, but will not be able to tap into the framework's supertype's methods. It will have to do everything via the injected controller.
- Plugin must implement a method called renderit().
- This method can have 1 or more arguments.
Example
So if we have a plugin called DateTime, it's source code can look like this:
<cfcomponent name="DateTime" hint="A datetime wiki plugin" extends="coldbox.system.plugin" output="false" cache="true"> <-------------------------------------------- CONSTRUCTOR -------------------------------------------> <cffunction name="init" access="public" returntype="DateTime" output="false"> <cfargument name="controller" type="any" required="true"> <cfscript> super.Init(arguments.controller); setpluginName("DateTime"); setpluginVersion("1.0"); setpluginDescription("A date time wiki plugin"); //My own Constructor code here //Return instance return this; </cfscript> </cffunction> <-------------------------------------------- PUBLIC -------------------------------------------> <--- today ---> <cffunction name="renderit" output="false" access="public" returntype="string" hint="print today"> <cfargument name="format" type="string" required="true" default="full" hint="Full,Short, Medium"/> <cfreturn dateformat(now(),arguments.format)> </cffunction> <-------------------------------------------- PRIVATE -------------------------------------------> </cfcomponent>
And we can use it in our wiki pages like so:
//Initial space is left so wiki doesn't match and you can see the source <nowiki>{{{ Messagebox message="Hello World!"}}}</nowiki>
That's it. Welcome to the world of Codex Wiki Plugins. Now go out and start coding your very own plugins. Below you can see a plugin at work:
Installed Plugins
Below is a listing of all installed plugins that can be found in the following directory: /var/www/vhosts/coldbox.org/wiki/plugins/wiki
- Include
- Version: 1.0
- Description: A plugin to include other wiki pages as content.
- Hint: Include other pages as content, all you need is the page name to include. If the page name does not exist, it will be replaced with a message saying the page does not exist
- Renderit Arguments:
Argument Type Required Default Value Hint page string true The page name to render content args string true The name-value pairs for token replacements, please add the values in single quotes. Ex: name='luis',age='20'. The name will be replaced in the template by looking at {{{[name]}}} and {{{[age]}}} token.
- WikiPlugins
- Version: 1.0
- Description: This plugin will help you document all the installed wiki plugins in the system. It is also used to install and remove wiki plugins.
- Hint: print today
- Renderit Arguments:
Argument Type Required Default Value Hint title string true Installed Plugins A default title for the h2
- Messagebox
- Version: 1.0
- Description: A messagebox plugin. Valid Types are info, warning, error
- Hint: This plugin will create a simple messagebox on the page. Look at the output classes so you can skin them.
- Renderit Arguments:
Argument Type Required Default Value Hint message string true The message to display type string true info The type of messagebox: info, error, warning
- Timestamp
- Version: 1.0
- Description: A time stamp wiki plugin
- Hint: print today's date and time in a specific format
- Renderit Arguments:
Argument Type Required Default Value Hint format string true full Full,Short, Medium noTime boolean false false Flag to print also the time or not
- Revision
- Version: 1.0
- Description: A revision wiki plugin that tells you revision information about the current displayed page
- Hint: A revision wiki plugin that tells you revision information about the current displayed page
- Renderit Arguments:
Argument Type Required Default Value Hint format string true full The revision information type to render: full, medium, short, timestamp-full or timestamp, timestamp-medium, timestamp-short, useronly content codex.model.wiki.Content true This argument is passed automatically by codex, DO NOT PASS THIS.
- Redirect
- Version: 1.0
- Description: A plugin to redirect a page to another page.
- Hint: Redirect to another page, just tell it what wiki page to redirect to.
- Renderit Arguments:
Argument Type Required Default Value Hint pageName string true The page name to redirect to
- Flash
- Version: 1.0
- Description: A plugin to embedd flash movies in a wiki page
- Hint: Embed a flash movie in a wiki page
- Renderit Arguments:
Argument Type Required Default Value Hint movie string true The movie path name string false The name of the movie id string false The default id for the movie align string false left left,center,right width string false 100% Width of the movie height string false 100% Width of the movie quality string false best The video quality bgColor string false A background color wmode string false transparent The wmode of the movie allowFullScreen boolean false true Allow full screen allowScriptAccess string false sameDomain The allow script access arguemnt scale string false showAll The scale of the movie data string false A data string to add to the object element FlashVars string false A flashvars string to add to the object element

SideBar
User Login 




Comments (