Mediawiki: Difference between revisions
Line 101: | Line 101: | ||
[http://wiki.yobi.be/wiki/Mediawiki_RawFile RawFile] is an extension made by Philippe Teuwen to allow downloading directly text in <tt><pre></tt> or <tt><source></tt> block as a file. |
[http://wiki.yobi.be/wiki/Mediawiki_RawFile RawFile] is an extension made by Philippe Teuwen to allow downloading directly text in <tt><pre></tt> or <tt><source></tt> block as a file. |
||
==== Patch v0.2 → v0.3 ==== |
|||
The patch below adds an optional parameter to hook <tt><nowiki>{{#filelink}}</nowiki></tt>. With 1 param, the file is fetched from the current page as usual: |
The patch below adds an optional parameter to hook <tt><nowiki>{{#filelink}}</nowiki></tt>. With 1 param, the file is fetched from the current page as usual: |
||
Line 136: | Line 136: | ||
}} |
}} |
||
====Patch v0.3 → v0.4==== |
|||
Changes: |
|||
* File ''anchor'' can be specified using html '''class''' attribute |
|||
* New syntax for file links '''<code><nowiki><file name="..." [anchor="..."] [tag="..."] [title="..."] >...</file></nowiki></code>''' |
|||
* Ignore <nowiki><br></nowiki> tag. |
|||
The extension introduces 3 elements: |
|||
This patch allows for specifying the file anchor using an html '''class''' attribute instead of using <code><nowiki>{{#fileanchor}}</nowiki></code>. It also introduces a new syntax for file links, and allows for specifying the tag of the block to return (instead of returning the first encountered block after the link). For instance: |
|||
* '''anchor''' elements |
|||
: Used to flag that the next code block in the wiki text belongs to a specific file. The code block can be any wiki block (such as '''<pre>''', '''<code>''', '''<tt>''', '''<source>'''...). '''<br>''' tags are ignored. Note that anchors are invisible in the wiki display. |
|||
* '''File link''' elements |
|||
: They are transformed by the extension into links that will allow for downloading all blocks associated with the specified file. |
|||
* '''anchor-link combo''' elements |
|||
: A shortcut notation mixing both an anchor and download link, handy for regular use, when a single code block is used and when the download link can be at the same position as the anchor |
|||
Old syntax: |
|||
{| class="wikitable" |
|||
!Element!!Syntax and description |
|||
|- |
|||
|'''anchor''' |
|||
|<pre><nowiki>{{#fileAnchor: filename}}</nowiki></pre> |
|||
Indicates that the next wiki block belongs to file ''filename''. The content of that block will be downloaded (possibly appended with other blocks if there are multiple anchors with same name) when a file link is clicked on. |
|||
; filename |
|||
: The name of the file to which the next wiki block belongs |
|||
|- |
|||
|'''file link''' |
|||
|<pre><nowiki> |
|||
[{{#fileLink: filename}} link text] |
|||
[{{#fileLink: filename|pagetitle}} link text] |
|||
</nowiki></pre> |
|||
Creates a link to download all blocks that are flagged with an anchor ''filename''. |
|||
; filename |
|||
: The name of the file to download. |
|||
; pagetitle |
|||
: ''Optional'' - Indicates that the blocks to download are on the wiki page titled ''pagetitle''. If absent, blocks are looked for on the current page. |
|||
; link text |
|||
: The text of links as it will be rendered on the display. |
|||
|- |
|||
|'''anchor-link combo''' |
|||
|<pre><nowiki> |
|||
[{{#file: filename}} link text] |
|||
</nowiki></pre> |
|||
Creates a link to download the next wiki block as a file named ''filename''. |
|||
; filename |
|||
: The name of the file to download. |
|||
; link text |
|||
: The text of the link as it will be rendered on the display. |
|||
|} |
|||
Version 0.4 introduces a simpler syntax that extends the set of wiki tags. Note that elements of both syntaxes can be mixed in a same page. |
|||
{| class="wikitable" |
|||
!Element!!Syntax and description |
|||
|- |
|||
|'''anchor''' |
|||
|<pre><nowiki> |
|||
<pre class="anchorname">...</pre> |
|||
<code class="anchorname">...</code> |
|||
<code class="cssclass anchorname">...</code> |
|||
... |
|||
</nowiki></pre> |
|||
To add an anchor ''anchorname'' to a wiki block, simply add a tag attribute <code>class="anchorname"</code> to it. The content of that block will be downloaded (possibly appended with other blocks if there are multiple anchors with same name) when a file link is clicked on. The extension supports multi-class specification, meaning that a same block can be associated to different files, and that the <code>class</code> attribute can still be used to specify custom CSS properties as in standard wiki text. |
|||
|- |
|||
|'''file link'''<br><br><br>'''anchor-link combo''' |
|||
|<pre><nowiki> |
|||
<file [name="filename"] [anchor="anchorname"] [tag="tagname"] [title="titlename"]>link text</file> |
|||
</nowiki></pre> |
|||
The same syntax is used to indicate a '''file link''' or a '''file-anchor combo''' element. The tag <code><nowiki><file></nowiki></code> is a '''file-anchor combo''' element if the attribute <code>name</code> is specified and if there is no block associated with the specified anchor name. In that case, the attribute <code>tag</code> can be used to specify the ''tagname'' of the first subsequent block that must be downloaded.<br> |
|||
;name="''filename''" |
|||
:''Optional'' - Specifies the name of the file to download. If absent, the attribute <code>anchor</code> must be present, and ''anchorname'' is then used as the name of the file to download. |
|||
;anchor="''anchorname''" |
|||
:''Optional'' - Specifies the name of the anchor to look for. Use this attribute if you want to have several files on the same page with different content but with the same file name. If absent, the attribute <code>name</code> must be present, and ''filename'' is then used as the name of the anchor to look for. |
|||
;tag="''tagname''" |
|||
:''Optional'' - This attribute is only used for '''file-anchor combo''' link. It is ignored otherwise. The first block after the link element whose name matches the given ''tagname'' is downloaded when the link is activated. If absent, the first encountered block following the link is downloaded (same behavior as in the old syntax). |
|||
;tag="''titlename''" |
|||
: ''Optional'' - Indicates that the blocks to download are on the wiki page titled ''pagetitle''. If absent, blocks are looked for on the current page. |
|||
; link text |
|||
: The text of the link as it will be rendered on the display. |
|||
|} |
|||
<pre><nowiki> |
<pre><nowiki> |
||
Line 146: | Line 220: | ||
* '''Method 2''': Indicates the block(s) with anchors. Save [{{#filelink: method2.txt}} this file] (but not this <code>code text</code>):<br> |
* '''Method 2''': Indicates the block(s) with anchors. Save [{{#filelink: method2.txt}} this file] (but not this <code>code text</code>):<br> |
||
:{{#fileanchor: method2.txt}}<code>We can then</code> very easily {{#fileanchor: method2.txt}}<code>interleave |
:{{#fileanchor: method2.txt}}<code>We can then </code> very easily {{#fileanchor: method2.txt}}<code>interleave downloadable text with wiki comments</code> |
||
* '''Method 3''': Same as above, but using html attribute 'class'. Save [{{#filelink: method3.txt}} this file] (but not this <code>code text</code>):<br> |
* '''Method 3''': Same as above, but using html attribute 'class'. Save [{{#filelink: method3.txt}} this file] (but not this <code>code text</code>):<br> |
||
:{{#fileanchor: method3.txt}}<code>We can |
:{{#fileanchor: method3.txt}}<code>We can still </code> very easily <code class="method3.txt">interleave downloadable text with wiki comments but with less typing</code> |
||
<code class="method3.txt"> |
|||
Obviously, there is absolutely |
|||
no limitation |
|||
on the size of the |
|||
text |
|||
</code> |
|||
* '''Method 4''': Same as method 1, but using new syntax (custom wiki tag). Save <file name="method4.txt">'''this''' file</file>: <code>Hello, World!</code> |
* '''Method 4''': Same as method 1, but using new syntax (custom wiki tag). Save <file name="method4.txt">'''this''' file</file>: <code>Hello, World!</code> |
||
Line 158: | Line 238: | ||
* '''Method 6''': Same as method 2 / 3, but using new syntax (custom wiki tag). Save <filelink name="method6.txt">this file</filelink>. Of course the old syntax <code>{{#fileanchor}}</code> for anchor is still supported.<br> |
* '''Method 6''': Same as method 2 / 3, but using new syntax (custom wiki tag). Save <filelink name="method6.txt">this file</filelink>. Of course the old syntax <code>{{#fileanchor}}</code> for anchor is still supported.<br> |
||
:{{#fileanchor: method6.txt}}<code>Again, we can </code> |
:{{#fileanchor: method6.txt}}<code>Again, we can </code>also very easily <code class="method6.txt">interleave downloadable code with wiki text while using the new syntax</code> |
||
</nowiki></pre> |
</nowiki></pre> |
||
Line 168: | Line 248: | ||
* '''Method 2''': Indicates the block(s) with anchors. Save [{{#filelink: method2.txt}} this file] (but not this <code>code text</code>):<br> |
* '''Method 2''': Indicates the block(s) with anchors. Save [{{#filelink: method2.txt}} this file] (but not this <code>code text</code>):<br> |
||
:{{#fileanchor: method2.txt}}<code>We can then</code> very easily {{#fileanchor: method2.txt}}<code>interleave |
:{{#fileanchor: method2.txt}}<code>We can then </code> very easily {{#fileanchor: method2.txt}}<code>interleave downloadable text with wiki comments</code> |
||
* '''Method 3''': Same as above, but using html attribute 'class'. Save [{{#filelink: method3.txt}} this file] (but not this <code>code text</code>):<br> |
* '''Method 3''': Same as above, but using html attribute 'class'. Save [{{#filelink: method3.txt}} this file] (but not this <code>code text</code>):<br> |
||
:{{#fileanchor: method3.txt}}<code>We can |
:{{#fileanchor: method3.txt}}<code>We can still </code> very easily <code class="method3.txt">interleave downloadable text with wiki comments but with less typing</code> |
||
<code class="method3.txt"> |
|||
Obviously, there is absolutely |
|||
no limitation |
|||
on the size of the |
|||
text |
|||
</code> |
|||
* '''Method 4''': Same as method 1, but using new syntax (custom wiki tag). Save <file name="method4.txt">'''this''' file</file>: <code>Hello, World!</code> |
* '''Method 4''': Same as method 1, but using new syntax (custom wiki tag). Save <file name="method4.txt">'''this''' file</file>: <code>Hello, World!</code> |
||
Line 180: | Line 266: | ||
* '''Method 6''': Same as method 2 / 3, but using new syntax (custom wiki tag). Save <filelink name="method6.txt">this file</filelink>. Of course the old syntax <code>{{#fileanchor}}</code> for anchor is still supported.<br> |
* '''Method 6''': Same as method 2 / 3, but using new syntax (custom wiki tag). Save <filelink name="method6.txt">this file</filelink>. Of course the old syntax <code>{{#fileanchor}}</code> for anchor is still supported.<br> |
||
:{{#fileanchor: method6.txt}}<code>Again, we can </code> |
:{{#fileanchor: method6.txt}}<code>Again, we can </code>also very easily <code class="method6.txt">interleave downloadable code with wiki text while using the new syntax</code> |
||
References: |
References: |
Revision as of 23:25, 25 November 2009
Hints and Tips
- Purge wiki page cache
- When changing templates, purge the browser & mediawiki cache. To purge the cache of a single page, add &action=purge to the URL (see [1] for more)
Keyboard shortcuts
- Reference page in wikipedia
- Page explaining how to change keyboard shortcut using user custom stylesheet.
- Most frequently-used HTML access keys (default access-key shortcut is alt+shift for Firefox and shift+Esc for Opera):
Action | Key |
---|---|
accesskey-edit | e |
accesskey-preview | p |
accesskey-save | s |
accesskey-search | f |
Access Restriction
See these pages for implementing access restriction in MediaWiki:
- A page that implement per-page access restriction [2].
- Another way to hide pages [3].
- See sourceforge project.
- Yet another extension [4].
- Security problem with access restriction extension:
- Some information on how to create custom namespaces [7].
Miscellaneous
- Page Special:Version produces a complete list of all extensions installed on the wiki.
Extensions
SyntaxHighlight GeSHi
This extension adds the <source> tag to present formatted source code. See official page.
Restoring 1.0.7.# output - solving <pre> formatting problem
- Since at least version r24298 (July 21, 2007) (with GeSHi version 1.0.8), <source> tag does not match usual formatting applied for <pre> tags. This is because the extension applies by default the new GeSHi header style GESHI_HEADER_PRE_VALID. The following patch allows to restore the old formatting when there is no attribute line. It also introduces a new option valid to attribute enclose to force application of header style GESHI_HEADER_PRE_VALID
--- SyntaxHighlight_GeSHi.class.php.old 2008-09-07 23:24:37.000000000 +0200
+++ SyntaxHighlight_GeSHi.class.php 2008-09-07 23:33:15.000000000 +0200
@@ -39,7 +39,7 @@
// "Enclose" parameter
if ( isset( $args['enclose'] ) && $args['enclose'] == 'div' ) {
$enclose = GESHI_HEADER_DIV;
- } elseif ( defined('GESHI_HEADER_PRE_VALID') ) {
+ } elseif ( (isset( $args['line'] ) || isset( $args['enclose'] ) && $args['enclose'] == 'valid' ) && defined('GESHI_HEADER_PRE_VALID') ) {
// Since version 1.0.8 geshi can produce valid pre, but we need to check for it
$enclose = GESHI_HEADER_PRE_VALID;
} elseif( isset( $args['line'] ) ) {
- Example: the following code
After the following command, <source lang="bash" enclose="valid"> % cat ~/hello.c</source> you'll get the following output <source lang="c"> #include <stdio.h> int main(int,int) { printf("Hello, World!\n"); return 0; } </source>
gives:
After the following command, % cat ~/hello.c
#include <stdio.h>
int main(int,int)
{
printf("Hello, World!\n");
return 0;
}
|
- Another solution is discussed here. The proposed solution is to edit file "SyntaxHighlight_GeSHi.class.php". Go to line 192, which should look like
$css[] = ".source-$lang {line-height: normal;}";
Change this to
$css[] = ".source-$lang {padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em;}";
and you have restored the pre css formatting.
RawFile
RawFile is an extension made by Philippe Teuwen to allow downloading directly text in <pre> or <source> block as a file.
Patch v0.2 → v0.3
The patch below adds an optional parameter to hook {{#filelink}}. With 1 param, the file is fetched from the current page as usual:
Save [{{#filelink: fstab}} this file] in your <tt>/etc</tt> directory.
With 2 param, the 2nd param is telling which page to fetch the file from:
Save [{{#filelink: fstab|Config files - fstab}} this file] in your <tt>/etc</tt> directory.
{{{content}}}
Patch v0.3 → v0.4
Changes:
- File anchor can be specified using html class attribute
- New syntax for file links
<file name="..." [anchor="..."] [tag="..."] [title="..."] >...</file>
- Ignore <br> tag.
The extension introduces 3 elements:
- anchor elements
- Used to flag that the next code block in the wiki text belongs to a specific file. The code block can be any wiki block (such as <pre>, <code>, <tt>, <source>...). <br> tags are ignored. Note that anchors are invisible in the wiki display.
- File link elements
- They are transformed by the extension into links that will allow for downloading all blocks associated with the specified file.
- anchor-link combo elements
- A shortcut notation mixing both an anchor and download link, handy for regular use, when a single code block is used and when the download link can be at the same position as the anchor
Old syntax:
Element | Syntax and description |
---|---|
anchor | {{#fileAnchor: filename}} Indicates that the next wiki block belongs to file filename. The content of that block will be downloaded (possibly appended with other blocks if there are multiple anchors with same name) when a file link is clicked on.
|
file link | [{{#fileLink: filename}} link text] [{{#fileLink: filename|pagetitle}} link text] Creates a link to download all blocks that are flagged with an anchor filename.
|
anchor-link combo | [{{#file: filename}} link text] Creates a link to download the next wiki block as a file named filename.
|
Version 0.4 introduces a simpler syntax that extends the set of wiki tags. Note that elements of both syntaxes can be mixed in a same page.
Element | Syntax and description |
---|---|
anchor | <pre class="anchorname">...</pre> <code class="anchorname">...</code> <code class="cssclass anchorname">...</code> ... To add an anchor anchorname to a wiki block, simply add a tag attribute |
file link anchor-link combo |
<file [name="filename"] [anchor="anchorname"] [tag="tagname"] [title="titlename"]>link text</file> The same syntax is used to indicate a file link or a file-anchor combo element. The tag
|
* '''Method 1''': Returns the block that immediately follows. Save [{{#file: method1.txt}} this file]: <code>Hello, World!</code> : But this other example fails because of the <br> tag... So save [{{#file: method1-fail.txt}} this file]:<br> :<code>Hello, World!</code>. * '''Method 2''': Indicates the block(s) with anchors. Save [{{#filelink: method2.txt}} this file] (but not this <code>code text</code>):<br> :{{#fileanchor: method2.txt}}<code>We can then </code> very easily {{#fileanchor: method2.txt}}<code>interleave downloadable text with wiki comments</code> * '''Method 3''': Same as above, but using html attribute 'class'. Save [{{#filelink: method3.txt}} this file] (but not this <code>code text</code>):<br> :{{#fileanchor: method3.txt}}<code>We can still </code> very easily <code class="method3.txt">interleave downloadable text with wiki comments but with less typing</code> <code class="method3.txt"> Obviously, there is absolutely no limitation on the size of the text </code> * '''Method 4''': Same as method 1, but using new syntax (custom wiki tag). Save <file name="method4.txt">'''this''' file</file>: <code>Hello, World!</code> * '''Method 5''': Same as above, but specifying which tag to include. Save ''<file name="method5.txt" tag="code">this file</file>'': <source lang="text">This text is skipped.</source> :<code>This is the text that will be returned...</code> * '''Method 6''': Same as method 2 / 3, but using new syntax (custom wiki tag). Save <filelink name="method6.txt">this file</filelink>. Of course the old syntax <code>{{#fileanchor}}</code> for anchor is still supported.<br> :{{#fileanchor: method6.txt}}<code>Again, we can </code>also very easily <code class="method6.txt">interleave downloadable code with wiki text while using the new syntax</code>
This gives:
- Method 1: Returns the block that immediately follows. Save [{{#file: method1.txt}} this file]:
Hello, World!
- But this other example fails because of the <br> tag... So save [{{#file: method1-fail.txt}} this file]:
Hello, World!
.
- Method 2: Indicates the block(s) with anchors. Save [{{#filelink: method2.txt}} this file] (but not this
code text
):
- {{#fileanchor: method2.txt}}
We can then
very easily {{#fileanchor: method2.txt}}interleave downloadable text with wiki comments
- Method 3: Same as above, but using html attribute 'class'. Save [{{#filelink: method3.txt}} this file] (but not this
code text
):
- {{#fileanchor: method3.txt}}
We can still
very easilyinterleave downloadable text with wiki comments but with less typing
Obviously, there is absolutely
no limitation
on the size of the
text
- Method 4: Same as method 1, but using new syntax (custom wiki tag). Save <file name="method4.txt">this file</file>:
Hello, World!
- Method 5: Same as above, but specifying which tag to include. Save <file name="method5.txt" tag="code">this file</file>:
This text is skipped.
This is the text that will be returned...
- Method 6: Same as method 2 / 3, but using new syntax (custom wiki tag). Save <filelink name="method6.txt">this file</filelink>. Of course the old syntax
{{#fileanchor}}
for anchor is still supported.
- {{#fileanchor: method6.txt}}
Again, we can
also very easilyinterleave downloadable code with wiki text while using the new syntax
References:
{{{content}}}