DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:getraw

This is an old revision of the document!


getraw Plugin

Compatible with DokuWiki

angua, rincewind, hrun

plugin Creates a url to get raw contents of a wiki, with authorization.

Last updated on
2015-06-09

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.

Tagged with data, raw, text

This isn't a standard plug-in. Rather, it's a php script that lets you request the source of a wiki page (what you'd see in the editor) with a url. The request is authorized the same way as a normal dokuwiki page.

This is a useful utility for plug-ins that create urls. For example, a syntax plug-in might produce an iframe for some other script, which wants to do something with the data of the current page. With this plug-in, you can pass in a url that gives you the data you need.

This plug-in allows you to request only what's inside of a code block, so you could have a wiki page that describes a block of code, and that could could easily be imported by another script.

Another use is to store arbitrary text files in your wiki. For example, if you call a wiki page a:b.js and use this script to fetch the page, it will act like a javascript file.

Installation

Create the following file in your base DokuWiki directory:

getRaw.php
<?php
if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/');
require_once(DOKU_INC.'inc/init.php');
 
$ID = cleanID(getID());
$onlyCode = $INPUT->str('onlyCode');
$insideTag = $INPUT->str('insideTag');
 
if (empty($conf['useacl']) || auth_quickaclcheck($ID) >= AUTH_READ) {
	$file = rawWiki($ID);
	if ($onlyCode)
		$file = preg_replace('/[\s\S]*<code>/m', '', preg_replace('/<\/code>[\s\S]*/m', '', $file));
	if ($insideTag)
		$file = preg_replace('/[\s\S]*<' . $insideTag . '[^>]*>/m', '', preg_replace('/<\/' . $insideTag . '>[\s\S]*/m', '', $file));
	print $file;
}
else
	print "Unauthorized";

Examples/Usage

Let's say you have a wiki page called a:b that looks like this:

  ==== My Wiki ====
  And here's some code!
  <code>
     Stuff!
     and things, too!
  </ code>

This url:

/doku/getRaw.php?id=a:b

will get you all the wiki content. It will not be rendered as HTML.

This url:

/doku/getRaw.php?onlyCode=true&id=a:b

will get you just what's inside the code tags:

     Stuff!
     and things, too!

Development

Change Log

  • 2015-06-19
    • Removed some unnecessary code from the script. This plugin is no longer dependent on the version of DokuWiki. Tested with DokuWiki Hrun.
  • 2011-08-02
    • Initial release
  • 2011-08-03
    • Switched from direct file access to the getRaw function.

Discussion

plugin/getraw.1434739286.txt.gz · Last modified: 2015-06-19 20:41 by zioth

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