Plugins
Clear Cache plugin for CakePHP
I have been responsible for updating a number of CakePHP applications lately, and needed to delete the cache files every time I did a 'git pull' on the server. I couldn't find any existing shell that takes care of a task like this, so decided to write one quickly.
What it does
At the moment, the plugin deletes each and every file in /app/tmp with a prefix 'cake_'.How to use it?
You have to to use it from CakePHP console for now. If I have time later, may be I will make it a Croogo supported plugin so that cache files can be deleted from admin panel too.$ ./cake clear_cache all
Download
Get it from GitHub here: https://github.com/fahad19/clear_cache.
Happy Caching!
Note: I just found out about another CakePHP plugin by Ceeram, and surprisingly it has the same name. I just wish I found it earlier: https://github.com/ceeram/clear_cache.
Markdown plugin
I have been writing documentation for Croogo for the past few weeks in markdown format. The more I use it, the more I like it. It is really very nice to write in plain text and be able to convert it to proper (X)HTML when it is finally shown in the browser. So I decided to write a plugin for converting markdown to html. It can be used in Croogo for writing content, as well as manually in your CakePHP applications.
What is Markdown?
Markdown is a text-to-HTML conversion tool for web writers by John Gruber. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).
Learn more about markdown here: http://daringfireball.net/projects/markdown/.
I have used the PHP Markdown_Parser class by Michel Fortin for this plugin.
Download
Get the plugin from GitHub: http://github.com/fahad19/markdown.
How to use this plugin with Croogo?
Read the wiki for information on how to upload and activate the plugin. Once active, you can start writing content in markdown format.
You don't need to convert your already existing content (in HTML) into markdown because it is aware of what is already in HTML and won't convert them twice. It is recommended that you deactivate any WYSIWYG editors (like TinyMCE) before using this plugin.
Using the plugin in CakePHP applications manually
After placing the plugin at /app/plugins/markdown, let you Controller know to load the plugin's Helper:
<?php
class PostsController extends AppController {
pubic $helpers = array('Markdown.Markdown');
}
?>
Now, in your views:
<?php
// will output in HTML format
echo $this->Markdown->transform($textInMarkdownFormat);
?>DebugKit plugin for Croogo
If you are a CakePHP developer, you must know about DebugKit plugin by Mark Story already. It provides a debugging toolbar and enhanced debugging tools for CakePHP applications. As far as I remember, it is the first plugin I tried in my applications and this may be the case for most developers too.
So why am I posting it here again? Just to demonstrate how it can be used with Croogo's plugin/hook system. A few weeks ago, I forked DebugKit and made it Croogo ready so anyone can upload it from the admin panel and start using it without having to worry about editing php files (app_controller.php here) manually.
All I did was add two files under a new directory 'config' to this awesome plugin, and done! First was an YAML file and the other was a PHP file. The file structure looks like this:
-
/app/plugins/debug_kit/
-
config (the new directory)
- debug_kit_bootstrap.php
- plugin.yml
- controllers/
- models/
- views/
- ...
- debug_kit_app_controller.php
- debug_kit_app_model.php
-
config (the new directory)
The YAML file
plugin.yml file is used for storing basic information about the plugin like it's description, author's name, website, etc. It can also contain information like it's dependencies. But we don't need anything like that for this plugin now:
name: DebugKit
description: DebugKit plugin
author: Mark Story
authorEmail:
authorUrl: http://mark-story.com
The plugin's bootstrap file
debug_kit_bootstrap.php is loaded every time the application bootstraps (only when the plugin is active). It handles configuration so DebugKit's Toolbar component is loaded in every controller.
<?php Croogo::hookComponent('*', 'DebugKit.Toolbar'); ?>
If you wanted the component to load only in, say, Users controller:
<?php Croogo::hookComponent('Users', 'DebugKit.Toolbar'); ?>
That wasn't too difficult, right? Now you can log in to Croogo's admin panel and activate the plugin from Extensions > Plugins page and you will see the toolbar at top right of your browser immediately. You can also deactivate it once you are done with debugging.
To learn more about how plugins work in Croogo, read the wiki.
Download
Get the modified version of DebugKit from http://github.com/fahad19/debug_kit.
