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

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

Last updated on
2011-08-03

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 data 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
$updateVersion = 34;
if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/');
 
if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])){
    $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
} elseif (!empty($_REQUEST['idx'])) {
    $ACT = 'index';
} elseif (isset($_REQUEST['do'])) {
    $ACT = $_REQUEST['do'];
} else {
    $ACT = 'show';
}
require_once(DOKU_INC.'inc/init.php');
 
$_REQUEST['id'] = str_replace("\xC2\xAD",'',$_REQUEST['id']); //soft-hyphen
$QUERY = trim($_REQUEST['id']);
$ID    = getID();
$onlyCode = $_REQUEST['onlyCode'];
 
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));
    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

  • 2011-08-02
    • Initial release
  • 2011-08-03
    • Switched from direct file access to the getRaw function.

Known Bugs and Issues

This script steals its first few lines of code directly from doku.php, so it may have to be modified to work with some versions of DokuWiki. On the up side, it's easy to open doku.php and re-steal the code.

Discussion

plugin/getraw.1333025763.txt.gz · Last modified: 2012-03-29 14:56 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