Changes of Plugins

Versiondbca1c32c8de9f1b6b0fe52554d9e606852e94aa
Commentinitial commit
AuthorDaniel Mendler
Date06 Apr 2014 21:44
Parents
Summary+-
Plugins.attributes10
Plugins.content750
Plugins/list200
Plugins.attributes
toc: true
Plugins.content
== Engines

Engines render pages and are selected by an acceptor pattern. There can be multiple engines which accept a page. The default engine is selected by priority. You can specify a engines with the query parameter "aspect".

Example:
* [[Images/forest.jpg]] to use default engine (imageinfo in this case)
* [[Images/forest.jpg?aspect=pageinfo]] to explicitly select the pageinfo engine
* [[Images/forest.jpg?aspect=imageinfo]] to select the imageinfo engine
* [[Images/forest.jpg?aspect=download]] to download the image
* [[Images/forest.jpg?aspect=image&geometry=10%25]] to select the image engine with a geometry specification
* [[Images/forest.jpg?aspect=markdown]] is not allowed because the image cannot be processed by the markdown engine.

Engines have to implement three methods:

* accepts: Accept pages
* output:  Render page content
* mime:    Output mime type

**Engine example**
<code lang="ruby">
require 'RMagick'

Engine.create(:image, :priority => 2, :layout => false, :cacheable => true) do
  def svg?(page); page.mime.to_s =~ /svg/; end
  def accepts?(page); page.mime.mediatype == 'image'; end
  def mime(page); svg?(page) ? 'image/png' : page.mime; end

  def output(context)
    page = context.page
    if svg?(page) || context['geometry']
      image = Magick::Image.from_blob(page.content).first
      image.change_geometry(context['geometry']) { |w,h| image.resize!(w, h) } if context['geometry']
      image.format = 'png' if svg?(page)
      image.to_blob
    else
      super
    end
  end
end
</code>

== Filter

There is a engine type "filter" which creates engines based on chained filters. The filter engines are configured in the file engines.yml. See the plugins under plugin/filter.

**Filter example**
<code lang="ruby">
Filter.create :markdown do |content|
  RDiscount.new(content).to_html
end
</code>

== Tags

Tags are a way to extend the wiki markup. See the plugins under plugin/tag.

**Tag definition example**
<code lang="ruby">
Tag.define(:code, :requires => :lang) do |context, attrs, content|
  Pygments.pygmentize(content, :format => attrs['lang'])
end
</code>

== Hooks

Hook example used in the private_wiki plugin:

<code lang="ruby">
App.before :routing do
  if @user.anonymous?
    halt if request.path_info == '/sys/fragments/sidebar'
    redirect '/login' if !WHITE_LIST.any? {|pattern| request.path_info =~ /^#{pattern}$/ }
  end
end
</code>
Plugins/list
= List of plugins

Description of install/config/usage for every plugin could come here


== Enabled Plugins


== Disabled Plugins

 List of disabled plugins by name.
 You can disable whole plugin directories.

* security/readonly_wiki
* security/private_wiki
* editor/recaptcha
* editor/ace
* filters/remind
* tags/fortune
* blog