Difference between revisions of "Mediawiki RawFile"
Jump to navigation
Jump to search
m (→Syntax) |
m (→Syntax) |
||
Line 17: | Line 17: | ||
<br>Transformation: |
<br>Transformation: |
||
<br><code><nowiki>[{{fullurl:{{PAGENAME}}|action=raw&filename=myscript.sh}} save it as myscript.sh]</nowiki></code> |
<br><code><nowiki>[{{fullurl:{{PAGENAME}}|action=raw&filename=myscript.sh}} save it as myscript.sh]</nowiki></code> |
||
− | <br> Test: [{{fullurl:{{PAGENAME}}|action=raw&filename=myscript.sh}} |
+ | <br> Test: save the following code as [{{fullurl:{{PAGENAME}}|action=raw&filename=myscript.sh}} myscript.sh] |
<source lang=bash> |
<source lang=bash> |
||
#!/bin/bash |
#!/bin/bash |
||
Line 24: | Line 24: | ||
exit 0 |
exit 0 |
||
</source> |
</source> |
||
+ | |||
==Hook on Raw== |
==Hook on Raw== |
||
* Must extract the right paragraph |
* Must extract the right paragraph |
Revision as of 23:00, 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
- http://www.mediawiki.org/wiki/Manual:Extensions
- http://www.mediawiki.org/wiki/Manual:Magic_words
- http://www.mediawiki.org/wiki/Manual:Parser_functions
- http://meta.wikimedia.org/wiki/Help:Parser_function
- http://www.mediawiki.org/wiki/Manual:Hooks/RawPageViewBeforeOutput
Syntax
{{#rawsnippet: myscript.sh}}
Do we need a MIME type?
Transformation:
[{{fullurl:{{PAGENAME}}|action=raw&filename=myscript.sh}} save it as myscript.sh]
Test: save the following code as myscript.sh
#!/bin/bash
echo 'Hello world!'
exit 0
Hook on Raw
- Must extract the right paragraph
- Must provide the filename to the browser