<?xml version="1.0" encoding="UTF-8"?>
<wiki>
  <body>&lt;p&gt;Stream of Consciousness supports plugins to extend it&amp;#8217;s functionality&lt;/p&gt;
&lt;p&gt;To enable, make sure the &amp;#8220;plugindir&amp;#8221; option is set and points to a valid directory.&lt;/p&gt;
&lt;p&gt;In this dir, add files with the &amp;#8220;.rb&amp;#8221; extension,  a plugin as the following format:&lt;/p&gt;
&lt;pre&gt;
plugin_name=&quot;A test plugin&quot;
plugin_hook=&quot;sidebar&quot;
code=lambda {
    puts &quot;Hello World!&quot;
}
&lt;/pre&gt;
&lt;p&gt;the plugin_hook specifies when the code will execute.  The following hooks are defined:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;sideitems &amp;#8211; Executes when the side bar is rendered, useful for adding new items&lt;/li&gt;
	&lt;li&gt;html_head &amp;#8211; Executes in the template in the &lt;head&gt;&lt;/head&gt; section.  Good for adding any additional headers you want such as loading a new css or js file&lt;/li&gt;
	&lt;li&gt;load_entries &amp;#8211; Executes after entries are loaded.  Useful for altering the content of entries.  This can be used to fo text filters, add textile support, etc.  the instance variable @entries will hold all the posts.&lt;/li&gt;
	&lt;li&gt;before_single_entry &amp;#8211; executes before viewing a single entry&lt;/li&gt;
	&lt;li&gt;after_single_entry &amp;#8211; executes after viewing a single entry&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;New hooks can be added on the fly by calling the do_hook method,  For example, the code do_hook(&amp;#8216;my_new_hook&amp;#8217;) will call any plugin with &amp;#8220;my_new_hook&amp;#8221; defined.&lt;/p&gt;
&lt;p&gt;Since plugins are eval&amp;#8217;d inside the instanced class,  you have access to all the internals of the software from  your plugin,  it is therefore possible to do other neat things,  it should even be possible to redefine methods so that posts are loaded from a database,  new templates are loaded file files, etc.&lt;/p&gt;</body>
  <created-at type="datetime">2009-11-26T08:09:28-08:00</created-at>
  <id type="integer">122074</id>
  <permalink>plugins</permalink>
  <repository-id type="integer">93145</repository-id>
  <title>Plugins</title>
  <updated-at type="datetime">2009-02-18T11:27:52-08:00</updated-at>
  <user-id type="integer">41378</user-id>
</wiki>
