Thu
4 Nov 2004
7:45 pm
[This is a draft chapter in the as-yet-nonexistent Frassle Developer's Manual.]
The frassle studio allows users to build and customize dynamic websites without any programming. But what if the options the studio gives you don't meet your needs? Frassle provides a plugin API so that you can build custom page elements.
There are currently three kinds of plugins in frassle:
- block display styles, which define a format for a set of notes. The content of each block comes from a content stream specified by the user, and the block display style controls how the query results are displayed: headlines, full text, etc.
- widgets, which are programmatic elements that do not necessarily display a set of notes. A widget may display the current time, or some user's category tree, or just a static piece of text.
- themes, which provide a Cascading Style Sheet (CSS) for use in studio pages and sites.
Although these plugin types serve different purposes, they have some common structure:
- Don't call us, we'll call you. When it's time to render a page that includes your plugin, frassle loads your files and invokes the appropriate functions.
- Drop-in deployment. Simply put plugin files into the appropriate frassle/plugins directory, and you're ready to start using them. No need to restart your server.
- Separate code and template files. Each plugin has a template file, interpreted using the HTML::Template system, and optionally a program code file written in Perl.
- Full API access. Because your plugin code runs within the same Perl environment as frassle itself, you have full access to frassle's Perl interfaces and the attached database. This is powerful but dangerous; because a plugin can potentially harm your data or expose security vulnerabilities, you should not run untrusted plugins.
- Automatic options interface. You specify what configuration options are available for your plugin, and frassle automatically generates the interface for users to edit these options. When your plugin is called to render, frassle tells you what options apply.
- [coming soon] Caching. Concisely specify caching options for the output of your plugin. Frassle handles the mechanics of storing and serving the cached output, as well as expiring the cache as soon as it is invalidated.
If you know the basics of HTML and Perl, you can create plugins that customize the appearance and functionality of your frassle sites. In the following sections, we'll look at each plugin type and go through the code of an example plugin.
1. Themes
2. Widgets
3. Block Display Styles
[To be continued...]
Full Entries RSS