DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:wst

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:wst [2021-05-29 15:22] – [Discussion] turnermmplugin:wst [2024-03-20 18:18] (current) – [Conflict between the move plugin and the wiki style template plugin] 193.138.218.203
Line 1: Line 1:
-====== Wikimedia Style Templates ======+====== Wikimedia Style Templates” Plugin ======
  
 ---- plugin ---- ---- plugin ----
Line 7: Line 7:
 type       : syntax type       : syntax
 lastupdate : 2018-07-22 lastupdate : 2018-07-22
-compatible : 2018-04-22 2017-02-19b 2016-06-26+compatible : Greebo, Hogfather, Igor, Jack Jackrum
 depends    :  depends    : 
 conflicts  conflicts 
-similar    :  +similar    : include 
-tags       : wikimedia,mediawiki,wikipedia,template,command+tags       : wikimedia,mediawiki,wikipedia,template,command,include
  
 downloadurl: https://bitbucket.org/vitalie_ciubotaru/wst/get/HEAD.zip downloadurl: https://bitbucket.org/vitalie_ciubotaru/wst/get/HEAD.zip
Line 21: Line 21:
 ---- ----
  
-This plugin provides a syntax for WikiMedia-style templates.+This plugin provides a syntax for [[wp>Help:Template|WikiMedia-style templates]].
  
 ===== Installation ===== ===== Installation =====
 +
 Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually. Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
 If you install this plugin manually, make sure it is installed in ''lib/plugins/wst''. It might not work if the directory is called differently. If you install this plugin manually, make sure it is installed in ''lib/plugins/wst''. It might not work if the directory is called differently.
 +
 +
 ===== Examples/Usage ===== ===== Examples/Usage =====
 +
 Let's assume that we need to add the same fragment to many articles, something like "The main article for this section is [link]". In order to automate this task, we'll create a template that would accept the link destination and generate the desired text with proper formatting. Let's assume that we need to add the same fragment to many articles, something like "The main article for this section is [link]". In order to automate this task, we'll create a template that would accept the link destination and generate the desired text with proper formatting.
  
 Let's also assume that the default namespace for our templates is set to "template" (you can check your settings in "Admin->Configuration Settings"). Let's also assume that the default namespace for our templates is set to "template" (you can check your settings in "Admin->Configuration Settings").
 +
  
 ==== Minimal example ==== ==== Minimal example ====
Line 36: Line 41:
 First, we create a new page called "template:main" with the following contents: First, we create a new page called "template:main" with the following contents:
  
-<file txt template:main>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</file>+<file txt template:main> 
 +//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.// 
 +</file>
  
 Now go to the desired article and insert the following code: Now go to the desired article and insert the following code:
Line 45: Line 52:
  
 //The main article for this section is **[[:Article_name|Article_name]]**.// //The main article for this section is **[[:Article_name|Article_name]]**.//
 +
  
 ==== Includeonly tag ==== ==== Includeonly tag ====
 +
 The template in the minimal example works fine, but our "template:main" page looks ugly: The template in the minimal example works fine, but our "template:main" page looks ugly:
  
Line 53: Line 62:
 Let's change the template so that the desired text appears on other pages (where the template code **<nowiki>{{wst>main|}}</nowiki>** is inserted), but is hidden from the template page itself. We will wrap the code between **<nowiki><includeonly></nowiki>** and **<nowiki></includeonly></nowiki>** tags, as follows: Let's change the template so that the desired text appears on other pages (where the template code **<nowiki>{{wst>main|}}</nowiki>** is inserted), but is hidden from the template page itself. We will wrap the code between **<nowiki><includeonly></nowiki>** and **<nowiki></includeonly></nowiki>** tags, as follows:
  
-<file txt template:main><includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly></file>+<file txt template:main> 
 +<includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly> 
 +</file>
      
 Now the template page looks empty, although it contains the template code. Now the template page looks empty, although it contains the template code.
  
 ==== Noinclude tag ==== ==== Noinclude tag ====
 +
 Instead of showing the ugly template code (and instead of showing an empty page), let's add some text that would appear on the template page, but not on pages where the code **<nowiki>{{wst>main|}}</nowiki>** is inserted. We will wrap this text between **<nowiki><noinclude></nowiki>** and **<nowiki></noinclude></nowiki>** tags, as follows: Instead of showing the ugly template code (and instead of showing an empty page), let's add some text that would appear on the template page, but not on pages where the code **<nowiki>{{wst>main|}}</nowiki>** is inserted. We will wrap this text between **<nowiki><noinclude></nowiki>** and **<nowiki></noinclude></nowiki>** tags, as follows:
  
-<file txt template:main><noinclude>Plugin syntax: {{wst>main|Article_name}}</noinlcude>+<file txt template:main> 
 +<noinclude>Plugin syntax: {{wst>main|Article_name}}</noinlcude>
  
-<includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly></file>+<includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly> 
 +</file>
  
 ==== Template complete with documentation ==== ==== Template complete with documentation ====
 +
 When creating a template, it would be nice to also create a documentation for the users. One way to create documentation is to create another template, say "main_doc" or "main/doc". The documentation template will only show the template syntax and the resulting text. When creating a template, it would be nice to also create a documentation for the users. One way to create documentation is to create another template, say "main_doc" or "main/doc". The documentation template will only show the template syntax and the resulting text.
  
-<file txt template:main_doc>====== Documentation: main ======+<file txt template:main_doc> 
 +====== Documentation: main ====== 
 <noinclude><< [[template:main|Main]]</noinclude> <noinclude><< [[template:main|Main]]</noinclude>
 +
 ===== Syntax ===== ===== Syntax =====
 +
 <nowiki>{{wst>main|Article_name}}</nowiki> <nowiki>{{wst>main|Article_name}}</nowiki>
 +
 ===== Output ===== ===== Output =====
-//Main article for this section is **[[category:article|Article_name]]**.//</file> 
  
-<file txt template:main><noinclude>{{wst>main_doc}}</noinclude>+//Main article for this section is **[[category:article|Article_name]]**.// 
 +</file>
  
-<includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly></file>+<file txt template:main> 
 +<noinclude>{{wst>main_doc}}</noinclude> 
 + 
 +<includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly> 
 +</file>
  
 ===== Syntax ===== ===== Syntax =====
 +
 A basic syntax for templates created with WST plugin is: A basic syntax for templates created with WST plugin is:
  
-<code>{{wst>template_name|argument_1|argument_2}}</code>+  {{wst>template_name|argument_1|argument_2}} 
 where: where:
   * the template code is always wrapped between double curled brackets;   * the template code is always wrapped between double curled brackets;
Line 89: Line 115:
  
 ==== Named and numbered parameters ==== ==== Named and numbered parameters ====
 +
 By default, each argument can be referred by its ordinal number, i.e. <nowiki>{{{1}}}</nowiki> refers to the first argument, <nowiki>{{{2}}}</nowiki> to the second etc. It is possible to explicitly specify the number of the argument: By default, each argument can be referred by its ordinal number, i.e. <nowiki>{{{1}}}</nowiki> refers to the first argument, <nowiki>{{{2}}}</nowiki> to the second etc. It is possible to explicitly specify the number of the argument:
  
-<code>{{wst>template_name|1 = argument_1|2 = argument_2}}</code>+  {{wst>template_name|1 = argument_1|2 = argument_2}}
  
 In this notation, the actual order of arguments does not matter any more. In this notation, the actual order of arguments does not matter any more.
Line 97: Line 124:
 Besides this, arguments can be referred to by a name. For example, in the following code Besides this, arguments can be referred to by a name. For example, in the following code
  
-<code>{{wst>template_name|a = argument}}</code>+  {{wst>template_name|a = argument}}
  
-the parameter can be referred to by <nowiki>{{{a}}}</nowiki>.+the parameter can be referred to by ''<nowiki>{{{a}}}</nowiki>''.
  
 ==== Tags ==== ==== Tags ====
 +
   * **<nowiki><noinclude>...</noinclude></nowiki>** -- the text will be displayed on a page (e.g. a template page), but will not be shown on pages that call the template.   * **<nowiki><noinclude>...</noinclude></nowiki>** -- the text will be displayed on a page (e.g. a template page), but will not be shown on pages that call the template.
   * **<nowiki><includeonly>...</includeonly></nowiki>** -- the text will be displayed only on pages that call a template, but not on a template page itself.   * **<nowiki><includeonly>...</includeonly></nowiki>** -- the text will be displayed only on pages that call a template, but not on a template page itself.
 +
 ===== Configuration and Settings ===== ===== Configuration and Settings =====
 +
 The only setting available is "Default namespace for Wikimedia-style templates", which defaults to "template". Leaving the default value should be OK for most installations. If this namespace is already used by another template, just provide another value. The only setting available is "Default namespace for Wikimedia-style templates", which defaults to "template". Leaving the default value should be OK for most installations. If this namespace is already used by another template, just provide another value.
  
 ===== Development ===== ===== Development =====
  
-//[downloadable blocks, development comments]// 
  
-=== Change Log === 
  
-//[preferable GitHub RSS feed or similar]//+=== Change Log ===
  
   * **2017-04-17**   * **2017-04-17**
Line 120: Line 148:
 === Known Bugs and Issues === === Known Bugs and Issues ===
  
-//[this section might not be needed in case of external bug manager, or use RSS feed]//+
  
 === ToDo/Wish List === === ToDo/Wish List ===
Line 128: Line 156:
 ===== FAQ ===== ===== FAQ =====
  
-//[discussions should ideally be deleted and turned into FAQ entries along the way]//+  * [[~:l10n|Localization]]
  
 ===== Discussion ===== ===== Discussion =====
-Does this only work for links.  What if the user has a paragraph marked for H1 and wants to change it to H2?  What would the template look like?+ 
 +Does this only work for links.  What if the user has a paragraph marked for H1 and wants to change it to H2?  What would the template look like? Or am I misunderstanding how this works? 
 + 
 +This plugin is not supporting backlinks, so there is no way to use dokuwiki backlinks functionality for links in templates. Also because of that there is no way of knowing which pages include template page. \\ -- //lopar4ever [at] gmail// 
 + 
 +> It's worth mentioning in the discussion that this isn't always an undesirable feature, for instance when creating inter page link lists etc that would muddle the meaning of a page-link by adding links all over the place. 
 +
 +> Also, you can find the usage of a template with the search engine. It will hit ''"{{wst>..."'' just like any other text on the pages. I also suspect plugins like the PageQuery plugin might be able to do that programmatically. 
 + 
 + 
 +==== Localization, GitHub, Enhancement ==== 
 + 
 +I am the current maintainer of [[plugin:templater|Templater]]. WST is everything I wanted. If I had found it earlier, I wouldn't have adopted the Templater. I'm amazed that after 5, almost 6, years it still works without the need for a patch. Yes, tested in **Jack Jackrum** today, right now. 
 + 
 +Could the developer: 
 +  - Add this plugin to https://translate.dokuwiki.org for easier translation? If not possible, could developer add my translation to source? Download here [[https://drive.google.com/uc?export=download&id=1fwAZTaahvDF94XjU0sA8UPx1io-P9vm7|pt-br]] (Google Drive). 
 +  - Move this to GitHub instead of BitBucket? 
 +  - In ''plugin.info.txt'', is better to change **url** to ''%%https://www.dokuwiki.org/plugin:wst%%'' instead of ''%%https://bitbucket.org/vitalie_ciubotaru/wst%%''. All plugins do this way. 
 + 
 + --- [[user>nerun|Daniel D. Rodrigues]] //2023-12-08 20:29// 
 + 
 +==== ParserFunctions ==== 
 +Please, try my [[ParserFunctions]] plugin, it's a perfect companion for WST and [[Templater]]. 
 + 
 + --- [[user>nerun|Daniel D. Rodrigues]] //2023-12-10 21:13// 
 + 
 + 
 +==== Conflict between the move plugin and the wiki style template plugin ==== 
 + 
 +I reported [[https://github.com/michitux/dokuwiki-plugin-move/issues/272|a bug]] when [[plugin:move|the move plugin]] scrambles variable inserts in WST-templates, but reading through the page for the move plugin it seems the WST plugin might need to implement some management for moves and move events. 
 + 
 +I'm reporting this here because there doesn't seem to be any other place? 
 + 
 + 
 + 
plugin/wst.1622294522.txt.gz · Last modified: 2021-05-29 15:22 by turnermm

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki