<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cakebaker &#187; plugin</title>
	<atom:link href="http://cakebaker.42dh.com/tags/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 20 Dec 2011 15:29:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Navigation with the &#8220;j&#8221; and &#8220;k&#8221; keys</title>
		<link>http://cakebaker.42dh.com/2010/12/04/navigation-with-the-j-and-k-keys/</link>
		<comments>http://cakebaker.42dh.com/2010/12/04/navigation-with-the-j-and-k-keys/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 09:33:19 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1456</guid>
		<description><![CDATA[If you are using Vim you already know the meaning of the &#8220;j&#8221; and &#8220;k&#8221; keys: they navigate one line downwards resp. upwards. Some websites like The Big Picture adopted this functionality to provide an easy way to navigate, in the case of The Big Picture to jump from photo to photo. As I wanted [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using <a href="http://www.vim.org/">Vim</a> you already know the meaning of the &#8220;j&#8221; and &#8220;k&#8221; keys: they navigate one line downwards resp. upwards. Some websites like <a href="http://www.boston.com/bigpicture/">The Big Picture</a> adopted this functionality to provide an easy way to navigate, in the case of The Big Picture to jump from photo to photo.</p>
<p>As I wanted to use the same functionality and didn&#8217;t find an existing solution I wrote a simple <a href="http://jquery.com/">jQuery</a> plugin for this purpose: <a href="https://github.com/cakebaker/jquery-jknavigable">jquery-jknavigable</a>. Its usage is pretty simple, to make the posts of a blog navigable with the &#8220;j&#8221; and &#8220;k&#8221; keys you would use the following code:</p>
<pre>
<code>$('.post').jknavigable();</code>
</pre>
<p>By default the active element is marked with the class &#8220;active&#8221; so you can style it differently. If necessary, you can specify your own class name:</p>
<pre>
<code>$('.post').jknavigable({'activeClass': 'someClass'});</code>
</pre>
<p>That&#8217;s it. Feedback is, as always, welcome.</p>
<p>PS: a good starting point for writing your own plugin is jQuery&#8217;s <a href="http://docs.jquery.com/Plugins/Authoring">Plugin Authoring page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2010/12/04/navigation-with-the-j-and-k-keys/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Reusable code and the import of vendors files</title>
		<link>http://cakebaker.42dh.com/2009/08/25/reusable-code-and-the-import-of-vendors-files/</link>
		<comments>http://cakebaker.42dh.com/2009/08/25/reusable-code-and-the-import-of-vendors-files/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 15:23:23 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[vendor]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1239</guid>
		<description><![CDATA[If you write reusable code with CakePHP (e.g. a component) you often forget (or at least I do) that the code could be used either in applications or in plugins. In most cases though, this doesn&#8217;t really matter, as your code will work fine in both &#8220;environments&#8221;. However, consider the following snippet: public function example() [...]]]></description>
			<content:encoded><![CDATA[<p>If you write reusable code with CakePHP (e.g. a component) you often forget (or at least I do) that the code could be used either in applications or in plugins. In most cases though, this doesn&#8217;t really matter, as your code will work fine in both &#8220;environments&#8221;. However, consider the following snippet:</p>
<pre>
<code>public function example() {
    App::import('Vendor', 'example', array('file' =&gt; 'Example.php'));
    $example = new Example();
    ...
}</code>
</pre>
<p>This snippet works fine if it is used in an application, but it will fail with a &#8220;Class not found&#8221; error if the snippet and the corresponding vendors file (&#8220;Example.php&#8221;) are put into a plugin. The reason for the failure is that you have to use the plugin name as a prefix when importing something from a plugin, even if you use App::import() from within the respective plugin:</p>
<pre>
<code>// test is the plugin name
App::import('Vendor', 'test.example', array('file' =&gt; 'Example.php'));</code>
</pre>
<p>The consequence of this behavior is that your code has to know in which &#8220;environment&#8221; it runs if you want to make it really reusable. An alternative is to &#8220;circumvent&#8221; the application &#8220;environment&#8221; and to distribute your code, and the required vendors files, as a plugin. </p>
<p>In the <a href="http://code.42dh.com/openid">OpenID component</a> I solved this problem by determining in which &#8220;vendors&#8221; directory the required library is. And if it is in the plugin&#8217;s &#8220;vendors&#8221; directory, I set an instance variable $importPrefix with the plugin name. This prefix is then used whenever a file is imported. </p>
<p>Here is the relevant code:</p>
<pre>
<code>class OpenidComponent extends Object {
    private $importPrefix = '';

    public function __construct() {
        parent::__construct();

        $pathToVendorsFolder = $this-&gt;getPathToVendorsFolderWithOpenIDLibrary();
		
        if ($pathToVendorsFolder == '') {
            exit('Unable to find the PHP OpenID library');
        }
		
        if ($this-&gt;isPathWithinPlugin($pathToVendorsFolder)) {
            $this-&gt;importPrefix = $this-&gt;getPluginName() . '.';
        }

        $this-&gt;importCoreFilesFromOpenIDLibrary();
    }

    private function getPathToVendorsFolderWithOpenIDLibrary() {
        $pathToVendorsFolder = '';
		
        if ($this-&gt;isPathWithinPlugin(__FILE__)) {
            $pluginName = $this-&gt;getPluginName();
			
            if (file_exists(APP.'plugins'.DS.$pluginName.DS.'vendors'.DS.'Auth')) {
                $pathToVendorsFolder = APP.'plugins'.DS.$pluginName.DS.'vendors'.DS;
            }
        }

        if ($pathToVendorsFolder == '') {
            if (file_exists(APP.'vendors'.DS.'Auth')) {
                $pathToVendorsFolder = APP.'vendors'.DS;
            } elseif (file_exists(VENDORS.'Auth')) {
                $pathToVendorsFolder = VENDORS;
            }
        }
		
        return $pathToVendorsFolder;
    }
	
    private function getPluginName() {
        $result = array();
        if (preg_match('#'.DS.'plugins'.DS.'(.*)'.DS.'controllers#', __FILE__, $result)) { 
            return $result[1];
        }

        return false;
    }

    private function importCoreFilesFromOpenIDLibrary() {
        App::import('Vendor', $this-&gt;importPrefix.'consumer', array('file' =&gt; 'Auth'.DS.'OpenID'.DS.'Consumer.php'));
        App::import('Vendor', $this-&gt;importPrefix.'sreg', array('file' =&gt; 'Auth'.DS.'OpenID'.DS.'SReg.php'));
    }

    private function isPathWithinPlugin($path) {
        return strpos($path, DS.'plugins'.DS) ? true : false;
    }
}</code>
</pre>
<p>This code is meant to give you an idea of how it could be solved in that specific situation, and not as a solution you can copy 1:1&#8230;</p>
<p>Happy baking!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2009/08/25/reusable-code-and-the-import-of-vendors-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Installing Rails Plugins from a Git repository</title>
		<link>http://cakebaker.42dh.com/2009/02/19/installing-rails-plugins-from-a-git-repository/</link>
		<comments>http://cakebaker.42dh.com/2009/02/19/installing-rails-plugins-from-a-git-repository/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 14:51:46 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1114</guid>
		<description><![CDATA[What I learned today is how you can install Rails plugins from Git repositories with a simple command: dho@tumulux:~/projects/myrailsproject$ ./script/plugin install git://github.com/rails/open_id_authentication.git The example command from above will download the OpenIdAuthentication plugin from GitHub and put the plugin in the vendor/plugins directory. Quite handy. In the CakePHP world there is currently no equivalent. However, John [...]]]></description>
			<content:encoded><![CDATA[<p>What I learned today is how you can install Rails plugins from <a href="http://git-scm.com/">Git</a> repositories with a simple command:</p>
<pre>
<code>dho@tumulux:~/projects/myrailsproject$ ./script/plugin install git://github.com/rails/open_id_authentication.git</code>
</pre>
<p>The example command from above will download the OpenIdAuthentication plugin from GitHub and put the plugin in the vendor/plugins directory. Quite handy.</p>
<p>In the CakePHP world there is currently no equivalent. However, <a href="http://twitter.com/raisinbread">John David Anderson</a> (aka _psychic_) recently published an early version of a <a href="http://plugins.thoughtglade.com/">Plugins shell console application</a> to manage plugins.</p>
<p>Happy working with plugins!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2009/02/19/installing-rails-plugins-from-a-git-repository/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>DebugKit for CakePHP</title>
		<link>http://cakebaker.42dh.com/2008/10/30/debugkit-for-cakephp/</link>
		<comments>http://cakebaker.42dh.com/2008/10/30/debugkit-for-cakephp/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 10:31:04 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=913</guid>
		<description><![CDATA[In CakePHP&#8217;s github account you can find a plugin called &#8220;DebugKit&#8221;, written by Mark Story. It provides some useful information while developing an application, and adds the following toolbar to your application: If you hover the mouse over one of the titles, it shows you the respective information, e.g. the content of the session. Pretty [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://github.com/cakephp">CakePHP&#8217;s github account</a> you can find a plugin called &#8220;DebugKit&#8221;, written by <a href="http://mark-story.com">Mark Story</a>. It provides some useful information while developing an application, and adds the following toolbar to your application:</p>
<p><img src="http://cakebaker.42dh.com/wp-content/uploads/2008/10/debug_kit.png" alt="" title="Debug Kit Toolbar" width="471" height="27" class="alignnone size-full wp-image-914" /></p>
<p>If you hover the mouse over one of the titles, it shows you the respective information, e.g. the content of the session. Pretty simple.</p>
<p>All you have to do is to place DebugKit in the plugins folder of your application and to add the following to your AppController (resp. the controller(s) where you want to use it):</p>
<pre>
<code>public $components = array('DebugKit.toolbar');</code>
</pre>
<p>You can get DebugKit either via Git with</p>
<pre>
<code>git clone git://github.com/cakephp/debug_kit.git</code>
</pre>
<p>or you can download it as zip/tar from <a href="http://github.com/cakephp/debug_kit/tree/master">github</a>. There is also some <a href="http://github.com/cakephp/debug_kit/wikis/home">documentation</a> available. </p>
<p>Happy baking!</p>
<p>PS: Some days ago Garrett Woodworth (aka gwoo) talked about <a href="http://www.ustream.tv/recorded/811617">CakePHP and Beyond</a> at the <a href="http://conference.cakephp.jp/">CakePHP conference</a> in Tokyo. It&#8217;s not a very technical talk, but maybe it is still of interest for some of you. [via <a href="http://groups.google.com/group/cake-php/browse_thread/thread/62102e335595693e/b6e38a0c302eb87d?lnk=raot#b6e38a0c302eb87d">CakePHP Google Group</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/10/30/debugkit-for-cakephp/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Plugin-specific styles, images, and javascript files</title>
		<link>http://cakebaker.42dh.com/2008/08/04/plugin-specific-styles-images-and-javascript-files/</link>
		<comments>http://cakebaker.42dh.com/2008/08/04/plugin-specific-styles-images-and-javascript-files/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 15:19:09 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=650</guid>
		<description><![CDATA[One missing piece for using plugins as mini-applications was the ability to have plugin-specific styles, images and javascript files. You had to put them to the respective folders in your application, or you had to use some hacks. In the meantime this ability has been introduced (I don&#8217;t know when it was added). To make [...]]]></description>
			<content:encoded><![CDATA[<p>One missing piece for using plugins as mini-applications was the ability to have plugin-specific styles, images and javascript files. You had to put them to the respective folders in your application, or you had to use some hacks.</p>
<p>In the meantime this ability has been introduced (I don&#8217;t know when it was added). To make use of it, you have to add a &#8220;vendors&#8221; folder with the subfolders &#8220;css&#8221;, &#8220;img&#8221;, and &#8220;js&#8221; to your plugin:</p>
<pre>
app
  plugins
    myplugin
      vendors
         css
         img
         js
</pre>
<p>Files in those folders can then be accessed like http://example.com/myplugin/img/my_image.jpg.</p>
<p>Unfortunately, HtmlHelper and JavascriptHelper are not (yet?) aware of this new feature. For example, the following code used in a view of your plugin:</p>
<pre>
<code>&lt;?php echo $html-&gt;image('my_image.jpg'); ?&gt;</code>
</pre>
<p>will create this HTML code:</p>
<pre>
<code>&lt;img src="/img/my_image.jpg" alt="" /&gt;</code>
</pre>
<p>As you see, the path points to the &#8220;img&#8221; folder of your application, and not to the &#8220;img&#8221; folder of your plugin. To avoid this, we have to specify the full path to the image:</p>
<pre>
<code>&lt;?php echo $html-&gt;image('/'.$this-&gt;plugin.'/img/my_image.jpg'); ?&gt;
// creates: &lt;img src="/myplugin/img/my_image.jpg" alt="" /&gt;</code>
</pre>
<p>The same also applies when including CSS styles and Javascript files.</p>
<p>Happy plugin baking :)</p>
<p>PS1: A new &#8220;notEmpty&#8221; validation rule has recently been added (&#8220;teknoid&#8221; was faster with an article, so here just a link to his <a href="http://teknoid.wordpress.com/2008/07/31/notempty-validation-rule/">article</a>). </p>
<p>PS2: A <a href="http://www.galileocomputing.de/techtalks/frameworks_cms">CakePHP presentation</a> (in German) by <a href="http://teemow.com">Timo Derstappen</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/08/04/plugin-specific-styles-images-and-javascript-files/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Baking plug-ins</title>
		<link>http://cakebaker.42dh.com/2008/01/26/baking-plug-ins/</link>
		<comments>http://cakebaker.42dh.com/2008/01/26/baking-plug-ins/#comments</comments>
		<pubDate>Sat, 26 Jan 2008 07:48:55 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[bake]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2008/01/26/baking-plug-ins/</guid>
		<description><![CDATA[Since CakePHP 1.2beta the bake script supports the generation of plug-ins. This feature is a bit hidden in the current version, as it is not mentioned when you call the help of the bake script: cake bake help Anyway, its usage is quite straight-forward. With cake bake plugin demo you can generate the structure and [...]]]></description>
			<content:encoded><![CDATA[<p>Since CakePHP 1.2beta the bake script supports the generation of plug-ins. This feature is a bit hidden in the current version, as it is not mentioned when you call the help of the bake script:</p>
<pre>
cake bake help
</pre>
<p>Anyway, its usage is quite straight-forward. With</p>
<pre>
cake bake plugin demo
</pre>
<p>you can generate the structure and the base files for a plug-in with the name &#8220;demo&#8221;. This actually creates the following structure and files in app/plugins:</p>
<pre>
demo
  controllers
    components
  models
    behaviors
  views
    helpers
  demo_app_controller.php
  demo_app_model.php
</pre>
<p>With </p>
<pre>
cake bake plugin demo controller
cake bake plugin demo model
cake bake plugin demo view
</pre>
<p>you can bake controllers, models, and views for the &#8220;demo&#8221; plug-in. The parameters you can use are the same as when baking &#8220;normal&#8221; controllers, models, and views, for example</p>
<pre>
cake bake plugin demo controller users
</pre>
<p>bakes a UsersController with var $scaffold set. See <a href="http://cakebaker.42dh.com/2007/06/06/faster-baking-of-controllers-with-the-bake-shell-script/">Faster baking of controllers with the bake shell script</a> or <a href="http://cakebaker.42dh.com/2007/06/11/baking-views/">Baking views</a> for more details.</p>
<p>One thing you have to be aware of is that the generated controllers and models extend AppController resp. AppModel by default, and not the plug-in-specific versions, i.e. DemoAppController resp. DemoAppModel in the &#8220;demo&#8221; plug-in example. That means you have to manually change this if you want to make use of the plug-in-specific AppController resp. AppModel. </p>
<p>Happy baking :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/01/26/baking-plug-ins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to test your plugins?</title>
		<link>http://cakebaker.42dh.com/2007/04/02/how-to-test-your-plugins/</link>
		<comments>http://cakebaker.42dh.com/2007/04/02/how-to-test-your-plugins/#comments</comments>
		<pubDate>Mon, 02 Apr 2007 16:54:59 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/04/02/how-to-test-your-plugins/</guid>
		<description><![CDATA[I just uploaded a new version of my test suite to the downloads section. This version allows you to test your CakePHP plugins. In contrast to the &#8220;normal&#8221; tests which are placed in app/tests, plugin tests are placed in app/plugins/[plugin name]/tests. The used folder structure for the tests folder is almost identical to the one [...]]]></description>
			<content:encoded><![CDATA[<p>I just uploaded a new version of my test suite to the <a href="http://cakebaker.42dh.com/downloads">downloads section</a>. This version allows you to test your CakePHP plugins. In contrast to the &#8220;normal&#8221; tests which are placed in app/tests, plugin tests are placed in app/plugins/[plugin name]/tests. The used folder structure for the tests folder is almost identical to the one used for app/tests:</p>
<pre>
app/
    plugins/
        pluginname/
            tests/
                components
                controllers
                fixtures
                helpers
                models
</pre>
<p>Only the groups folder is missing, as I am not (yet) convinced it is needed. </p>
<p>You can write the plugin tests in the same way you write your other tests (see http://cakebaker.42dh.com/2006/12/18/testing-with-cakephp-12-a-preview/).</p>
<p>You can execute the plugin test via command line with:</p>
<pre>
php bake2.php test application-alias plugins  // executes all plugin tests
php bake2.php test application-alias plugin pluginname  // executes all tests of the specified plugin
</pre>
<p>Or if you use the web interface you can call:</p>
<pre>
http://example.com/tests/plugins  // executes all plugin tests
http://example.com/tests/plugin/pluginname  // executes all tests of the specified plugin
</pre>
<p>Feedback is welcome. Happy testing :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/04/02/how-to-test-your-plugins/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

