User:Barre/MediaWiki/Extensions/kw include file: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(→‎Examples: add example)
(→‎Examples: wiki page test)
Line 16: Line 16:
</pre>
</pre>
The hairy URL is followed by several options. The <tt>pre=0</tt> parameter means that we do not want the text to be inserted verbatim inside PRE.../PRE tags. The <tt>wiki_markup=1</tt> parameter specifies that the text is to be interpreted as Wiki markup. The (optional) <tt>collapse_par=1</tt> parameter helps the Wiki engine by collapsing lines into paragraphs. The <tt>preg_match</tt> parameter specificies a regular expression that is used to extract only the documentation portion of the remote file: nothing fancy here, we are just looking for the string starting with <tt>==</tt> right inside a PHP comment <tt>/*</tt> ... <tt>*/</tt>.
The hairy URL is followed by several options. The <tt>pre=0</tt> parameter means that we do not want the text to be inserted verbatim inside PRE.../PRE tags. The <tt>wiki_markup=1</tt> parameter specifies that the text is to be interpreted as Wiki markup. The (optional) <tt>collapse_par=1</tt> parameter helps the Wiki engine by collapsing lines into paragraphs. The <tt>preg_match</tt> parameter specificies a regular expression that is used to extract only the documentation portion of the remote file: nothing fancy here, we are just looking for the string starting with <tt>==</tt> right inside a PHP comment <tt>/*</tt> ... <tt>*/</tt>.
Including a wiki page:
<nowiki><kw_include_file>url=http://babylon5.wikicities.com/index.php?title=Book_list&action=raw|pre=0|wiki_markup=1</kw_include_file></nowiki>
<kw_include_file>url=http://babylon5.wikicities.com/index.php?title=Book_list&action=raw|pre=0|wiki_markup=1</kw_include_file>

Revision as of 09:09, 22 February 2005

<kw_bread_crumbs>prefix=» |small=1|bgcolor=F9F9F9|trim_prefix=User:|on_top_hack=1</kw_bread_crumbs> <kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb%7Cpre=0%7Cwiki_markup=1%7Ccollapse_par=1%7Cpreg_match=/.*\/\*\s*(==.*?)^\*\//sm</kw_include_file>

Examples

First let's include a small file:

<kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/README.txt?root=kwGrid</kw_include_file>

...is rendered as: <kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/README.txt?root=kwGrid</kw_include_file>

Now for something more complex. Note that the whole documentation above this section is included straight from the extension code itself ! Here is how it is done:

<kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb|pre=0|wiki_markup=1|collapse_par=1|preg_match=/.*\/\*\s*(==.*?)^\*\//sm</kw_include_file>

The hairy URL is followed by several options. The pre=0 parameter means that we do not want the text to be inserted verbatim inside PRE.../PRE tags. The wiki_markup=1 parameter specifies that the text is to be interpreted as Wiki markup. The (optional) collapse_par=1 parameter helps the Wiki engine by collapsing lines into paragraphs. The preg_match parameter specificies a regular expression that is used to extract only the documentation portion of the remote file: nothing fancy here, we are just looking for the string starting with == right inside a PHP comment /* ... */.

Including a wiki page:

<kw_include_file>url=http://babylon5.wikicities.com/index.php?title=Book_list&action=raw|pre=0|wiki_markup=1</kw_include_file>


<kw_include_file>url=http://babylon5.wikicities.com/index.php?title=Book_list&action=raw%7Cpre=0%7Cwiki_markup=1</kw_include_file>