plugin:getraw
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:getraw [2011-09-12 18:09] – 24.61.11.143 | plugin:getraw [2021-07-07 05:54] (current) – [Usability suggestions] dot is not bar-dot beco | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== getraw Plugin ====== | ====== getraw Plugin ====== | ||
- | |||
- | ---- pluginnews ----- | ||
- | headline: | ||
- | style: | ||
- | ----- | ||
---- plugin ---- | ---- plugin ---- | ||
description: | description: | ||
author | author | ||
- | email : | + | email : elifenton@this_is_not_a_real_email.fake |
- | type : | + | type : |
- | lastupdate : 2011-08-03 | + | lastupdate : 2021-07-07 |
- | compatible : 2011-05-25 | + | compatible : angua, rincewind, hrun, detritus, Frusterick Manners, greebo |
depends | depends | ||
conflicts | conflicts | ||
Line 20: | Line 15: | ||
---- | ---- | ||
- | This isn't a standard | + | This isn't a standard |
- | This is a useful utility for plug-ins | + | This is a useful utility for plugins |
- | 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 ===== | ===== Installation ===== | ||
Line 33: | Line 25: | ||
<code php getRaw.php> | <code php getRaw.php> | ||
- | $updateVersion = 34; | + | <?php |
- | if(!defined(' | + | if(!defined(' |
- | + | ||
- | if (isset($_SERVER[' | + | |
- | $ACT = trim(strtolower($_SERVER[' | + | |
- | } elseif (!empty($_REQUEST[' | + | |
- | $ACT = ' | + | |
- | } elseif (isset($_REQUEST[' | + | |
- | $ACT = $_REQUEST[' | + | |
- | } else { | + | |
- | $ACT = ' | + | |
- | } | + | |
require_once(DOKU_INC.' | require_once(DOKU_INC.' | ||
- | $_REQUEST[' | + | $ID = cleanID(getID()); |
- | $QUERY = trim($_REQUEST['id']); | + | $onlyCode |
- | $ID | + | $insideTag |
- | $onlyCode = $_REQUEST['onlyCode']; | + | |
if (empty($conf[' | if (empty($conf[' | ||
- | | + | $file = rawWiki($ID); |
- | if ($onlyCode) | + | if ($onlyCode) |
- | $file = preg_replace('/ | + | $file = preg_replace('/ |
- | print $file; | + | if ($insideTag) |
+ | $file = preg_replace('/ | ||
+ | print $file; | ||
} | } | ||
else | else | ||
- | | + | print " |
+ | ?> | ||
</ | </ | ||
===== Examples/ | ===== Examples/ | ||
+ | |||
+ | === Simple Case === | ||
Let's say you have a wiki page called a:b that looks like this: | Let's say you have a wiki page called a:b that looks like this: | ||
Line 85: | Line 71: | ||
and things, too! | and things, too! | ||
</ | </ | ||
+ | |||
+ | |||
+ | === Use to insert JavaScript on your page ==== | ||
+ | |||
+ | Create a page called //a:b.js//: | ||
+ | < | ||
+ | alert(' | ||
+ | </ | ||
+ | |||
+ | If you want the page to be readable, you can wrap it in code tags and use the onlyCode parameter. On another page, you can include your JavaScript like this, if you've enabled html in your settings: | ||
+ | |||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | |||
Line 91: | Line 93: | ||
=== Change Log === | === Change Log === | ||
+ | * **2021-07-07** | ||
+ | * With a simple regex added to the code < | ||
+ | * **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** | * **2011-08-02** | ||
* Initial release | * Initial release | ||
Line 96: | Line 102: | ||
* Switched from direct file access to the getRaw function. | * 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 | + | ===== Discussion ===== |
+ | ====Request for using default plugin structure | ||
+ | You can implement your feature also by creating an action plugin component in your plugin. | ||
+ | See also [[devel: | ||
+ | An useful event for your case is the [[devel: | ||
- | ===== Discussion | + | (An quite large example, with error handling, is the dw2pdf plugin. See: https:// |
+ | |||
+ | If you use the plugin structure, the advantages are: | ||
+ | * people can update with the Extension Manager | ||
+ | * people can install via the extension manager, without manually copying a file | ||
+ | |||
+ | [[user> | ||
+ | |||
+ | ==== Usability suggestions | ||
+ | For ease of use, you can set up another rewrite rule in your .htaccess so that a user only needs to add .txt to their URL to get the text format. Also, optionally, add .c to the URL to get only the the source inside the code tags. | ||
+ | |||
+ | '' | ||
+ | '' | ||
+ | Also for readability, |
plugin/getraw.1315843766.txt.gz · Last modified: 2011-09-12 18:09 by 24.61.11.143