plugin:pagespace
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:pagespace [2008-02-08 19:32] – 196.1.53.29 | plugin:pagespace [2015-05-02 05:35] (current) – [Discussion] 24.214.43.25 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Pagespace Plugin ====== | ||
+ | ---- plugin ---- | ||
+ | description: | ||
+ | author | ||
+ | email : hendrybadao[at]gmail[dot]com | ||
+ | type : Syntax | ||
+ | lastupdate : 2008-02-09 | ||
+ | compatible : 2007-06-26b | ||
+ | depends | ||
+ | conflicts | ||
+ | similar | ||
+ | tags : links, namespace | ||
+ | ---- | ||
+ | |||
+ | |||
+ | ====== Rationale ====== | ||
+ | I love DokuWiki, and use it all the time both at work as a knowledge repository, and at home for my own thoughts and ideas. | ||
+ | The one thing I found a little tiresome was typing in long internal links; so I love the idea of relative links. | ||
+ | |||
+ | At present you can create the following relative links (if I've understood correctly...!): | ||
+ | *To the root namespace | ||
+ | |||
+ | [[:new link]] | ||
+ | |||
+ | *To the parent namespace (back 2) | ||
+ | |||
+ | [[..:new link]] | ||
+ | |||
+ | *Or to the current namespace (back 1) | ||
+ | |||
+ | [[.:new link]] | ||
+ | |||
+ | What I propose adding is a syntax to create a link to the // | ||
+ | |||
+ | ====== Syntax ====== | ||
+ | Let's assume the current page name (top left in a standard DokuWiki installation) is as follows: | ||
+ | [[plugin: | ||
+ | This means that the current namespace is //plugin// and the current page is // | ||
+ | |||
+ | Using the following syntax: | ||
+ | [[@new link]] | ||
+ | This link would be created: | ||
+ | [[plugin: | ||
+ | |||
+ | And that's basically all there is to it! | ||
+ | |||
+ | ====== Code ====== | ||
+ | <code php> | ||
+ | <?php | ||
+ | if(!defined(' | ||
+ | if(!defined(' | ||
+ | require_once(DOKU_PLUGIN.' | ||
+ | |||
+ | /** Creates a relative link to the current ' | ||
+ | i.e. a namespace based on current page name (page ID)) | ||
+ | |||
+ | To use: | ||
+ | |||
+ | If current page name is: [[root: | ||
+ | |||
+ | then [[@:new page]] or [[@new page]] | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | License: GPL | ||
+ | */ | ||
+ | | ||
+ | class syntax_plugin_pagespace extends DokuWiki_Syntax_Plugin { | ||
+ | |||
+ | function getInfo() { | ||
+ | return array(' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | |||
+ | function getType() { | ||
+ | return ' | ||
+ | } | ||
+ | |||
+ | function getSort() { | ||
+ | return 239; | ||
+ | } | ||
+ | |||
+ | function connectTo($mode) { | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | function handle($match, | ||
+ | //Swaps the @ symbol for the current page ID | ||
+ | global $ID; | ||
+ | global $conf; | ||
+ | |||
+ | $pagespace = $ID; | ||
+ | $link = $match; | ||
+ | |||
+ | //Ignore the start (root) namespace | ||
+ | if ($pagespace == $conf[' | ||
+ | $pagespace = ''; | ||
+ | } else { | ||
+ | $pagespace .= ':'; | ||
+ | } | ||
+ | |||
+ | // Only replace an initial @ symbol, not elsewhere in link | ||
+ | $link = str_replace(" | ||
+ | dbglog($link); | ||
+ | |||
+ | // Strip the opening and closing markup | ||
+ | $link = substr($link, | ||
+ | | ||
+ | // Split title from URL | ||
+ | $link = preg_split('/ | ||
+ | if ( !isset($link[1]) ) { | ||
+ | $link[1] = NULL; | ||
+ | } | ||
+ | return $link; | ||
+ | } | ||
+ | |||
+ | function render($mode, | ||
+ | if ($mode == ' | ||
+ | $renderer-> | ||
+ | return true; | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ====== History ===== | ||
+ | |||
+ | *2008-01-15: | ||
+ | *2008-02-08: | ||
+ | |||
+ | ====== Discussion ====== | ||
+ | This is only my second plugin, the previous one has not been published (it was a adaption of the explain plugin which allowed the glossary to be a normal wiki page. I found it very useful...anybody interested? | ||
+ | |||
+ | * Yes! //--- hansbkk// | ||
+ | |||
+ | > Okay, I'll make it available sometime.---// | ||
+ | |||
+ | I still have much to learn so any suggestions, | ||
+ | |||
+ | |||
+ | * Does it work with [[plugin: | ||
+ | * Does it work with recent versions of DW? //--- hansbkk// | ||
+ | |||
+ | I really like the idea of using this as the "home page" for a namespace - with all implementations of hierarchical organisation, | ||
+ | |||
+ | > Time...wish I had more of it! I haven' | ||
+ | |||
+ | Kewl, and know what you mean, low priority. In thinking about this, triggered again by [[http:// | ||
+ | |||
+ | I just wanted to add that this plugin seems to be working fine on Release 2014-09-29d " |