Difference between revisions of "Mediawiki RawFile"

From YobiWiki
Jump to navigation Jump to search
m (New page: ==Introduction== The idea is to be able to download directly a portion of code as a file. <br>I've numerous code examples in my wiki and I wast an easy way to download them, easier than a ...)
 
Line 13: Line 13:
 
* http://www.mediawiki.org/wiki/Manual:Hooks/RawPageViewBeforeOutput
 
* http://www.mediawiki.org/wiki/Manual:Hooks/RawPageViewBeforeOutput
 
==Syntax==
 
==Syntax==
<code><nowiki>{{#rawsnippet: <filename>}}</nowiki></code>
+
<code><nowiki>{{#rawsnippet: myscript.sh}}</nowiki></code>
 
<br>Do we need a MIME type?
 
<br>Do we need a MIME type?
 
<br>Transformation:
 
<br>Transformation:
<br><code><nowiki>[]</nowiki></code>
+
<br><code><nowiki>[{{fullurl:{{PAGENAME}}|action=raw&filename=myscript.sh}} save it as myscript.sh]</nowiki></code>
[[{{PAGENAME}}?action=raw&filename=localserver.php|save it as localserver.php]]
 

Revision as of 22:50, 30 March 2008

Introduction

The idea is to be able to download directly a portion of code as a file.
I've numerous code examples in my wiki and I wast an easy way to download them, easier than a copy/paste!

  • It must work with pre, nowiki, js, css, code, source, so let's make it general: take the tag that comes after the parser function we'll create and select data up to the closing tag.

2 parts:

  • the parser magic word that will be converted into a "Save it as <filename>"
  • an extended action=raw that will strip the raw output to keep the desired code

Documentation

Syntax

{{#rawsnippet: myscript.sh}}
Do we need a MIME type?
Transformation:
[{{fullurl:{{PAGENAME}}|action=raw&filename=myscript.sh}} save it as myscript.sh]