Skip to content

Commit

Permalink
Plugin system - CORE
Browse files Browse the repository at this point in the history
I retrieved @nodiscc plugin system proposed in shaarli#164 and changed it to create PHP plugin system. It relies on hooks triggered by certain actions (only template rendering for now).

**It's only a proposition, let me know what you think of it**.

  * I think that an 'only template' plugin system might be too restrictive, and doesn't allow a lot of extension.
  * I raised concerns in shaarli#44  and don't blend too well with user made templates.
  * @nodiscc lacks of time to finish this.
  * I'd like to see 0.9beta release one day. :)

PluginManager class includes enabled plugin PHP files at loading and register their hook function.

When we want to trigger a hook, 'PluginManager::executeHooks()' is called, eventually with rendering data. It will call every plugin function registered under the standardized name:

    hook_<plugin_name>_<hook_name>

Rendering data can be altered and/or completed.

This is exactly what @nodiscc did.

Templates contain plugin display at specific location, which are populated by the plugin functions.

Here is what's has been done:

  * hook_render_linklist: when linklist is rendered, all links data passed to plugins. It allows plugins to alter link rendering (such as Markdown parsing). They can also add a linklist icon for every link (QRCode, etc.)
  * hook_render_header: every page builder triggers this hook. Plugins can add specific data to header if the current page is concerned (toolbar).
  * hook_render_footer: : every page builder triggers this hook. Plugins can add specific data to header if the current page is concerned (JS file).
  * hook_render_includes: : every page builder triggers this hook. Plugins can add specific data to header if the current page is concerned (CSS file).

We can easily add hooks to whatever is pertinent (link add, picwal rendering, etc.).

  * Strong documentation, especially for plugin developers.
  * Unit tests for PluginManger and Router.
  * Test this heavily.

Later:

  * finish Markdown plugin.
  * Add a plugin page in administration.
  • Loading branch information
ArthurHoaro committed Jul 16, 2015
1 parent ffba1ce commit b8e79cf
Showing 1 changed file with 0 additions and 0 deletions.
Empty file modified index.php
100644 → 100755
Empty file.

0 comments on commit b8e79cf

Please sign in to comment.