User:Barre/MediaWiki/Extensions/kw include file: Difference between revisions
(Extract the doc straight from the source) |
m (make sure we include a shorter (and existing) page) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{User:Barre/Template/Header}} | |||
<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> | <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> | ||
===Examples=== | ===Examples=== | ||
First let's include a | First let's include a [http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/README.txt?root=kwGrid small file]: | ||
<pre> | <pre> | ||
<kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/README.txt?root=kwGrid</kw_include_file> | <kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/README.txt?root=kwGrid</kw_include_file> | ||
Line 10: | Line 11: | ||
<kw_include_file>url=http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/README.txt?root=kwGrid</kw_include_file> | <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 | Now for something more complex: note that the whole documentation above this section is included straight from the [http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb extension code] itself ! Here is how it is done: | ||
<pre> | <pre> | ||
<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> | <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> | ||
</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>. | ||
You can also include the contents of a wiki page (in that example, the [http://public.kitware.com/Wiki?title=User:Barre User:Barre] page): | |||
<pre> | |||
<kw_include_file>url=http://public.kitware.com/Wiki?title=User:Barre&action=raw|pre=0|wiki_markup=1</kw_include_file> | |||
</pre> | |||
<kw_include_file>url=http://public.kitware.com/Wiki?title=User:Barre&action=raw|pre=0|wiki_markup=1</kw_include_file> |
Latest revision as of 15:01, 8 March 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 /* ... */.
You can also include the contents of a wiki page (in that example, the User:Barre page):
<kw_include_file>url=http://public.kitware.com/Wiki?title=User:Barre&action=raw|pre=0|wiki_markup=1</kw_include_file>
<kw_include_file>url=http://public.kitware.com/Wiki?title=User:Barre&action=raw%7Cpre=0%7Cwiki_markup=1</kw_include_file>