DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:isns

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:isns [2007-10-13 15:22] achplugin:isns [2023-12-22 20:15] (current) – new download url Aleksandr
Line 1: Line 1:
 +====== isns Plugin ======
 +
 +---- plugin ----
 +description: If called page doesn't exist, convert page name in namespace name and try to open the index
 +author     : iDo
 +email      : ido@woow-fr.com
 +type       : syntax
 +lastupdate : 2006-01-18
 +compatible : 
 +depends    : 
 +conflicts 
 +similar    : 
 +tags       : namespace, redirect
 +
 +downloadurl: https://trello.com/1/cards/5b5f5ed20bc01adc35323b07/attachments/5b5f5ee7680dee2747c886da/download/isns.zip
 +bugtracker : 
 +sourcerepo : 
 +donationurl: 
 +
 +screenshot_img: 
 +----
 +
 +===== What's that? =====
 +
 +I have created this plugin because when you show a page which is located in sub-namespace (like php:class:mypage) the "youarehere" indication, show the page and all namespace (php >> class >> mypage). So, if you click on "php" or "class" link you go on "This topic does not exist"...
 +
 +Some of user will be disappointed by that...
 +
 +With this plugin, if you call a page which doesn't exist, the "index" page will be include.
 +
 +(I hope you'll understand me... I'm not really good in English...).
 +
 +See plugin in action here: http://www.wikistuce.info/doku.php/logiciels/firefox (this link try to call the page "logiciels:firefox", but this one does not exist.)
 +
 +===== How to install it =====
 +
 +With plugin manager: [[https://trello.com/1/cards/5b5f5ed20bc01adc35323b07/attachments/5b5f5ee7680dee2747c886da/download/isns.zip|isns.zip]]
 +
 +Or without: unpack the zip in /lib/plugins of your DokuWiki folder.
 +
 +
 +After installing, you must edit "newpage.txt" (located in /inc/lang/<your language>) and  write ''%%{{isns}}%%'' at the end of file.
 +
 +**WARNING: write ''%%{{isns}}%%'' ONLY AT THE END OF FILE!**
 +
 +===== Code =====
 +
 +<code php>
 +<?php
 + 
 +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_isns extends DokuWiki_Syntax_Plugin {
 + 
 +    /**
 +     * return some info
 +     */
 +    function getInfo(){
 +        return array(
 +            'author' => 'iDo',
 +            'email'  => 'iDo@woow-fr.com',
 +            'date'   => '18/01/2006',
 +            'name'   => 'isns Plugin',
 + 'desc'   => 'if the page doesnt exist, try tou open the index. syntax : {{isns}}',
 +            'url'    => 'http://www.dokuwiki.org/plugin:isns',
 +        );
 +    }
 +    
 +    /**
 +     * What kind of syntax are we?
 +     */
 +    function getType(){
 +        return 'substition';
 +    }
 + 
 +    /**
 +     * Where to sort in?
 +     */
 +    function getSort(){
 +        return 1;
 +    }
 + 
 +    /**
 +     * Connect pattern to lexer
 +     */
 +    function connectTo($mode) {
 +      $this->Lexer->addSpecialPattern("{{isns}}",$mode,'plugin_isns');
 +    }
 +      
 +    /**
 +     * Handle the match
 +     */
 +    function handle($match, $state, $pos, &$handler){
 +        return true;
 +    }  
 + 
 +    /**
 +     * Create output
 +     */
 +    function render($mode, &$renderer, $data) {
 +        if($mode == 'xhtml'){ 
 + $n=$this->_IsNs();
 + if (@$n)
 + $renderer->doc = $n;
 +            return true;
 +        }
 +        return false;
 +    }
 +
 + function _IsNs() {
 + global $conf;
 + global $ID;
 + $pn=wikiFN($ID);
 + if ((!file_exists($pn)) && (is_dir(substr($pn,0,-4)))) {
 + ob_start();
 + html_index($ID);
 + return ob_get_clean();;
 + }
 + return false;
 + }
 +}
 +
 +//Setup VIM: ex: et ts=4 enc=utf-8 :
 +</code>
 +
 +
 +===== Comments =====
 +
 +How can i modify that to bring "topic:start" or "topic:index" instead of the "index", is this possible? would be even cooler. Of course that should be ACL secure :|
 +
 +==== Solution ====
 +
 +I patched DokuWiki to do what you need (and me too). What my code does: If there is a page called "index" inside of the assumed namespace, this one is taken as the wanted one (ie, ACL and everything else applies, as this is done later on). Furthermore, if there is no such page, but a namespace exists, show an appropriate index page.
 +
 +I posted a patch here, but it is not accurate anymore. It had to be extended in some ways. If you are interested, better mail me for details.
 +
 +You can see it in action [[http://fsi.informatik.uni-erlangen.de/dw|here]]. Try the links to see the "index" redirect, playground/ to see the generated index page, or some invalid page, too (which should still show the "newpage" text).
 +
 +Sadly enough, this is not a plugin and I don't know how to do it as a plugin.
 +-- Johannes Jordan (dokuwiki //at// lanrules.de)
  

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