Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin system #164

Closed
wants to merge 13 commits into from
Closed

Plugin system #164

wants to merge 13 commits into from

Conversation

nodiscc
Copy link
Member

@nodiscc nodiscc commented Mar 11, 2015

See commit messages for detailed and up-to date info

You can now place raintpl template elements in tpl/plugins/
This allows adding custom HTML elements to the base template.
It is possible to inject these elements at the following places on the
default template. Where they are loaded depends on their path/filename.

  • Toolbar buttons (eg. tpl/plugins/coolbutton/coolbutton.toolbar.html)
  • Link info fields (eg. tpl/plugins/send-to-twitter.html)
  • Page footer (eg. tpl/plugins/footer-message/footer-message.footer.html)

Plugins have to be manually enabled in data/options.php. If you want to enable
the 'example1' and 'example2' plugins:

$GLOBALS['config']['PLUGINS'] = array('example1', 'example2');

You can now place raintpl template elements in tpl/plugins/
This allows adding custom HTML elements to the base template.
It is possible to inject these elements at the following places on the
default template. Where they are loaded depends on their path/filename.

 * Toolbar buttons (eg. tpl/plugins/coolbutton/coolbutton.toolbar.html)
 * Link info fields (eg. tpl/plugins/send-to-twitter.html)
 * Page footer (eg. tpl/plugins/footer-message/footer-message.footer.html)

Plugins have to be manually enabled in data/options.php. If you want to enable
the 'example1' and 'example2' plugins:

    $GLOBALS['config']['PLUGINS'] = array('example1', 'example2');

Some cleanup: Move rendering the linklist to a separate function;
Create a PageBuilder **every time** we render the page.

Credits to @pikzen for the refactoring and plugin loading code.
 * add QR code rendering to tpl/plugins/qrcode/*
 * move required resources (js, image) there and update COPYING
 * use the minified qr.js
 * enable the 'qrcode' plugin by default in index.php 'PLUGINS' config array
  to preserve old functionality.
to enable it, add 'archiveorg' to the 'PLUGINS' config array in data/options.php
Plays all Youtube videos linked from the page in an overlay HTML5 player, one
after another (playlist).
Files should be named tpl/plugins/*/*.includes.html
…r later reading

wallabag is a self hostable application for saving web pages. It saves the
content you select so that you can read it when you have time.
https://www.wallabag.org/

There are two ways to use wallabag: you can install it on your web server or
you can create a free account at Framabag. Framabag is a Framasoft service.

Configuration of base wallabag URL is done through the WALLABAG_URL global
variable in data/options.php. Example

    $GLOBALS['config']['WALLABAG_URL'] = "https://demo.wallabag.org/"

Fixes sebsauvage#167

Temporarily define the default WALLABAG_URL value in index.php. It should be
loaded from a file in the plugin directory (tpl/*/*.config.php)
…e" version of the links content

Fixes sebsauvage#66

This plugin adds, for each link, a button to display a more readable version
using an external readityourself service - self-hostable web application,
similar to the Pocket proprietary service: https://github.com/memiks/readityourself

The base readityourself url is configurable through the READITYOURSELF_URL
config variable in data/options.php
@nodiscc nodiscc added enhancement in progress plugin bells and whistles cleanup code cleanup and refactoring labels Mar 11, 2015
@nodiscc nodiscc self-assigned this Mar 12, 2015
@nodiscc nodiscc modified the milestone: 0.9beta Mar 13, 2015
@alexisju
Copy link

Would it not make more sense that plugins are at the same level as the template folder ?

it might be better to do :

/tpl/templates/
/tpl/plugins/

or

/tpl/
/plugins/

@nodiscc
Copy link
Member Author

nodiscc commented Mar 17, 2015

I'll look into this, but I don't think you can include template elements from outside the RAINTPL_TPL directory. I'll try again. Of course this needs to be solved. Currently it means you'd have to install plugins for each template (eg. your third-party template would not be able to use plugins in tpl/default/plugins, unless you do a symlink plugins/ -> ../default/plugins/).

@nodiscc
Copy link
Member Author

nodiscc commented Apr 6, 2015

Blocked by #163

@ArthurHoaro ArthurHoaro mentioned this pull request Jul 12, 2015
5 tasks
ArthurHoaro added a commit that referenced this pull request Jul 15, 2015
I retrieved @nodiscc plugin system proposed in #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 #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.
ArthurHoaro added a commit to ArthurHoaro/Shaarli that referenced this pull request Jul 16, 2015
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.
ArthurHoaro added a commit to ArthurHoaro/Shaarli that referenced this pull request Jul 16, 2015
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.
@virtualtam virtualtam modified the milestones: 0.9beta, 0.6.0 Jul 30, 2015
@nodiscc
Copy link
Member Author

nodiscc commented Sep 29, 2015

Obsoleted by #275

@nodiscc nodiscc closed this Sep 29, 2015
@nodiscc nodiscc deleted the new-plugin-system branch September 29, 2015 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup code cleanup and refactoring enhancement in progress plugin bells and whistles
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants