Developing mediasyntax

From ThorstensHome
Jump to: navigation, search

This page is about how I develop my mediasyntax plugin.

Most important links for it are

Contents

adding debugging output

     global $conf;
     if($conf['allowdebug']) 
     {
         dbglog('---- PLUGIN INCLUDE META DATA START ----');
         dbglog($event->data);
         dbglog('---- PLUGIN INCLUDE META DATA END ----');
     }

goes to $conf['cachedir'].'/debug.log'

Understanding syntax plugins

$mode

$mode can be

  • base
  • listblock
  • plugin_mediasyntax_header
  • and much more

addEnTryPattern

Addentrypattern seems only to be valid for $mode.

getting plugins from github

With github, we can give a download URL that always points to the latest code, like this: http://github.com/tstaerk/mediasyntax/zipball/master. You will get a .zip file from there called something like tstaerk-mediasyntax-4ea4c86.zip. Now we have the challenge that we cannot predict the name of the folder inside the zip file where your plugin is stored (4ea4c86 should change with every version). Not a problem if you set the "base" value under http://github.com/tstaerk/mediasyntax/blob/master/plugin.info.txt. Plugin manager will then unpack the plugin to this directory.

Toolbar

The real problem about the toolbar is that you need to refresh it after you did changes. This works sometimes with:

tweedleburg:/srv/www/htdocs/dokuwiki # rm -rf data/cache/*

If it does not work you have to re-load the plugin using the plugin manager.

include

The ability to include other pages comes from the include plugin, here is the commit: https://github.com/tstaerk/mediasyntax/commit/76bf13abcb285e74ae78edcf18467e3fb854b861 The problem with including pages is that they will be kept in the cache. Example: Administrator a edits a page foo and includes the page secret. Now in the cache, the page foo contains the page secret. If bad boy b now reads page foo, he also sees secret. Possible solutions: Disable cache as in https://github.com/dr4Ke/editsections/blob/master/action/es.php#L34:

$controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, '_cache_use'); 

and in _cache_use:

$event->_default = 0;

See also