DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:getraw

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:getraw [2017-11-07 03:43] 68.186.200.178plugin:getraw [2021-07-07 05:54] (current) – [Usability suggestions] dot is not bar-dot beco
Line 6: Line 6:
 email      : elifenton@this_is_not_a_real_email.fake email      : elifenton@this_is_not_a_real_email.fake
 type       :  type       : 
-lastupdate : 2015-06-09 +lastupdate : 2021-07-07 
-compatible : angua, rincewind, hrun, detritus, Frusterick Manners+compatible : angua, rincewind, hrun, detritus, Frusterick Manners, greebo
 depends    :  depends    : 
 conflicts  conflicts 
Line 36: Line 36:
  $file = rawWiki($ID);  $file = rawWiki($ID);
  if ($onlyCode)  if ($onlyCode)
- $file = preg_replace('/[\s\S]*<code>/m', '', preg_replace('/<\/code>[\s\S]*/m', '', $file));+ $file = preg_replace('/[\s\S]*<code( \w>|>)/m', '', preg_replace('/<\/code>[\s\S]*/m', '', $file));
  if ($insideTag)  if ($insideTag)
  $file = preg_replace('/[\s\S]*<' . $insideTag . '[^>]*>/m', '', preg_replace('/<\/' . $insideTag . '>[\s\S]*/m', '', $file));  $file = preg_replace('/[\s\S]*<' . $insideTag . '[^>]*>/m', '', preg_replace('/<\/' . $insideTag . '>[\s\S]*/m', '', $file));
Line 43: Line 43:
 else else
  print "Unauthorized";  print "Unauthorized";
 +?>
 </code> </code>
  
Line 92: Line 93:
 === Change Log === === Change Log ===
  
 +  * **2021-07-07**
 +    * With a simple regex added to the code <code>'/[\s\S]*<code( \w>|>)/m'</code> now it accepts tags with languages declared. For example <nowiki><code c></nowiki>. To make things even more interesting, check the ''.htaccess'' suggestion below. --- [[user>beco|beco]] //2021-07-07 05:40//
   * **2015-06-19**   * **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.     * Removed some unnecessary code from the script. This plugin is no longer dependent on the version of DokuWiki. Tested with DokuWiki Hrun.
Line 116: Line 119:
  
 ==== Usability suggestions ==== ==== 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:+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. 
  
-''RewriteRule ^(.*).txt$                getRaw.php?id=$1  [L]''+''RewriteRule ^(.*)\.txt$                getRaw.php?id=$1  [L]''\\ 
 +''RewriteRule ^(.*)\.c$                 getRaw.php?id=$1&onlyCode=1 [L]''
  
-Also for readability, throw a ''header('Content-Type: text/plain');'' in line 4, and the browser will know to interpret the newlines instead of eating them like HTML.  --- [[user>NReilingh|NReilingh]] //2015-11-29 07:30//+Also for readability, throw a ''header('Content-Type: text/plain');'' in line 4, and the browser will know to interpret the newlines instead of eating them like HTML.  --- [[user>NReilingh|NReilingh]] //2015-11-29 07:30// --- [[user>beco|beco]] //2021-07-07 05:48//
plugin/getraw.1510022611.txt.gz · Last modified: 2017-11-07 03:43 by 68.186.200.178

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