DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:verinfo

verinfo plugin

Compatible with DokuWiki

2008-05-05

plugin <verinfo> tag is replaced with basic version/revision info on current page.

Last updated on
2008-11-10
Provides
Syntax

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to pagebreak

Tagged with include, revisions

Description

This plugin replaces the tag <verinfo> with a string containing basic version/revision info on the current page. Even though most HTML templates emit this information (tpl_pageinfo()), renderer plugins such as ODT and Dokutexit do not emit this information automatically in the generated document.

Use

Insert a <verinfo> tag where you want the version information to show up. The tag is replaced with the following information:

Last modified on <site format specific date/time> by <editor> 

Code

<?php
/**
 * Plugin verinfo: Inserts basic version info into the document for every <verinfo> it encounters.  Based on the tab plugin by Tim Skoch <timskoch@hotmail.com>
 * 
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Venkat Peri (venkatperi at gmail dot com) 
 * 
 */
 
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class syntax_plugin_verinfo extends DokuWiki_Syntax_Plugin {
 
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'Venkat Peri',
            'email'  => 'venkatperi at gmail dot com',
            'date'   => '11/10/2008',
            'name'   => 'Version Info Plugin',
            'desc'   => 'Inserts basic version info into the document for every <verinfo> it encounters',
            'url'    => 'NA',
        );
    }
 
    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'substition';
    }
 
    /**
     * What kind of syntax do we allow (optional)
     */
//    function getAllowedTypes() {
//        return array();
//    }
 
    /**
     * What about paragraphs? (optional)
     */
//    function getPType(){
//        return 'normal';
//    }
 
    /**
     * Where to sort in?
     */ 
    function getSort(){
        return 999;
    }
 
 
    /**
     * Connect pattern to lexer
     */
    function connectTo($mode) {
      $this->Lexer->addSpecialPattern('<verinfo>',$mode,'plugin_verinfo');
//      $this->Lexer->addEntryPattern('<TEST>',$mode,'plugin_test');
    }
 
//    function postConnect() {
//      $this->Lexer->addExitPattern('</TEST>','plugin_test');
//    }
 
 
    /**
     * Handle the match
     */
    function handle($match, $state, $pos, &$handler){
        switch ($state) {
          case DOKU_LEXER_ENTER : 
            break;
          case DOKU_LEXER_MATCHED :
            break;
          case DOKU_LEXER_UNMATCHED :
            break;
          case DOKU_LEXER_EXIT :
            break;
          case DOKU_LEXER_SPECIAL :
            break;
        }
        return array();
    }
 
    /**
     * Create output
     */
    function render($mode, &$renderer, $data) 
    {
        $mod= 'Last modified on ';
        global $INFO;
        global $conf;
        $mod .= strftime($conf['dformat'],$INFO['lastmod']);
 
        $mod .= ' by ';
        if($INFO['editor'])
        {
           $mod .= $INFO['editor'];
        }
        //print $mod;
 
        //if($mode == 'xhtml')
        {
            $renderer->doc .= $mod;
            return true;
        }
        return false;
    }
}

Installation

Create a new folder “lib/plugins/verionfo“ and create a file “syntax.php” with the above code as its contents.

FIXME: Probably verinfo dir, not verionfo :?:

Discussion

  • This plugin is hugely based on the pagebreak plugin.
  • Suggestions for changes
    • Accept a format for the generated version/revision string
    • Generate a field which can be accessed elsewhere and/or in ODT exports.
plugin/verinfo.txt · Last modified: 2022-07-30 00:27 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki