Media wiki Orphan plugin.
authorDavid Marec <DavidMarec@users.noreply.github.com>
Fri, 3 Apr 2020 21:16:29 +0000 (23:16 +0200)
committerDavid Marec <DavidMarec@users.noreply.github.com>
Fri, 3 Apr 2020 21:16:29 +0000 (23:16 +0200)
Review syntax.
make it work with dokuwiki "greebo"

conf/default.php [new file with mode: 0644]
conf/metadata.php [new file with mode: 0644]
manager.dat [new file with mode: 0644]
plugin.info.txt [new file with mode: 0644]
syntax.php [new file with mode: 0644]

diff --git a/conf/default.php b/conf/default.php
new file mode 100644 (file)
index 0000000..52ed36d
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+/*
+ * Choosing the manpages you want with manlink.
+ */
+$conf['mantarget'] = 'FreeBSD';
+
+//Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/conf/metadata.php b/conf/metadata.php
new file mode 100644 (file)
index 0000000..e70a29d
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+/*
+ * Metadata statement for the target of the manpage links.
+ */
+$meta['mantarget'] = array('multichoice', '_choices' => array('NetBSD', 'OpenBSD', 'FreeBSD', 'DragonFlyBSD'));
+//Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/manager.dat b/manager.dat
new file mode 100644 (file)
index 0000000..a947c11
--- /dev/null
@@ -0,0 +1,2 @@
+downloadurl=https://komkon2.de/manlink/manlink.tgz
+installed=Wed, 08 May 2019 12:55:20 +0000
diff --git a/plugin.info.txt b/plugin.info.txt
new file mode 100644 (file)
index 0000000..ca12af9
--- /dev/null
@@ -0,0 +1,7 @@
+base   manlink\r
+author Julian Fagir\r
+email  gnrp@KomKon2.de\r
+date   2012-11-25\r
+name   Manpage link plugin\r
+desc   Transforms manpage descriptions to manpage links\r
+url    http://www.komkon2.de/dokuwiki/doku.php?id=projects:manlink\r
diff --git a/syntax.php b/syntax.php
new file mode 100644 (file)
index 0000000..cee0a2a
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/*
+ * Manlinks plugin: convert manpage descriptions to links to the manpages.
+ */
+
+if(!defined('DOKU_INC')) die();
+if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
+require_once(DOKU_PLUGIN.'syntax.php');
+
+class syntax_plugin_manlink extends DokuWiki_Syntax_Plugin {
+
+       function getType() { return 'substition'; }
+       function getPType() { return 'normal'; }
+       function getSort() { return 361; }
+
+       function connectTo($mode) {
+               $this->Lexer->addSpecialPattern(
+                       '\!?[a-zA-Z0-9_.+\[\]-]*\([0-9]\)',
+                       $mode,
+                       'plugin_manlink');
+       }
+
+       function handle($match, $state, $pos, Doku_Handler $handler){
+               if ($state != DOKU_LEXER_SPECIAL)
+                       return false;
+
+               if (substr($match, 0, 1) == "!") {
+                       $handler->_addCall('cdata', array(substr($match, 1)), $pos);
+                       return true;
+               }
+
+               $mantarget = $this->getconf('mantarget');
+               $manpage = preg_replace('/^([a-zA-Z0-9_+\[\].-]*)\(([0-9])\)$/', '\1', $match);
+               $section = preg_replace('/^([a-zA-Z0-9_+\[\].-]*)\(([0-9])\)$/', '\2', $match);
+
+               if ($mantarget == 'NetBSD')
+                       $target = 'http://mdoc.su/n/'.$manpage.'.'.$section;
+               elseif ($mantarget == 'FreeBSD')
+                       $target = 'http://mdoc.su/f/'.$manpage.'.'.$section;
+               elseif ($mantarget == 'OpenBSD')
+                       $target = 'http://mdoc.su/o/'.$manpage.'.'.$section;
+               elseif ($mantarget == 'DragonFlyBSD')
+                       $target = 'http://mdoc.su/d/'.$manpage.'.'.$section;
+
+               $handler->_addCall('externallink', array($target, $match), $pos);
+               return true;
+       }
+
+       function render($format, Doku_Renderer $renderer, $data) {
+               return true;
+       }
+}
+
+?>