Jump to content

Do not begin to migrate content here, it may be wiped without notice. More info.

Template:Action: Difference between revisions

From Debian Wiki
Created page with "<pre><onlyinclude>{{#switch: {{{Action|{{{1|}}}}}} |edit = <span class="plainlinks">[{{fullurl:{{FULLPAGENAME}}|action=edit}} {{{Text|{{{2|edit page}}}}}}]</span> |info = <span class="plainlinks">[{{fullurl:{{FULLPAGENAME}}|action=history}} {{{Text|{{{2|page history}}}}}}]</span> |recoverpass = {{{Text|{{{2|reset your password}}}}}} |subscribe = <span class="plainlinks">[{{fullurl:{{FULLPAGENAME}}|action=watch}} {{{Text|{{{2|watc..."
 
Give the template some actual documentation and flesh out the functionality with parameterized control over action, link target and text
Tag: 2017 source edit
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
<pre><onlyinclude>{{#switch: {{{Action|{{{1|}}}}}}
<span class="plainlinks">{{#switch:{{{action|{{{1|}}}}}}
|edit        = <span class="plainlinks">[{{fullurl:{{FULLPAGENAME}}|action=edit}} {{{Text|{{{2|edit page}}}}}}]</span>
| info | history | log    = [{{fullurl:{{{page|{{{2|{{FULLPAGENAME}}}}}}}}|action=history}} {{{text|{{{3|view history}}}}}}]
|info        = <span class="plainlinks">[{{fullurl:{{FULLPAGENAME}}|action=history}} {{{Text|{{{2|page history}}}}}}]</span>
| recoverpass | login    = [https://salsa.debian.org/users/sign_in {{{text|{{{3|reset password}}}}}}]
|recoverpass = [[Special:PasswordReset|{{{Text|{{{2|reset your password}}}}}}]]
| subscribe | watch      = [{{fullurl:{{{page|{{{2|{{FULLPAGENAME}}}}}}}}|action=watch}} {{{text|{{{3|add to watchlist}}}}}}]
|subscribe  = <span class="plainlinks">[{{fullurl:{{FULLPAGENAME}}|action=watch}} {{{Text|{{{2|watch this page}}}}}}]</span>
| userprefs | preferences = [[Special:Preferences|{{{text|{{{3|preferences}}}}}}]]
|userprefs  = [[Special:Preferences|{{{Text|{{{2|user preferences}}}}}}]]
| edit | #default        = [{{fullurl:{{{page|{{{2|{{FULLPAGENAME}}}}}}}}|action=edit}} {{{text|{{{3|edit page}}}}}}]
}}</onlyinclude></pre>
}}</span><noinclude><div style="clear: both;"></div>
This template, <code style="background: transparent; border: hidden; font-weight: 600;">&lbrace;&lbrace;[[Template:Action|Action]]&rbrace;&rbrace;</code>, produces links that perform an action on the target page through the use of URL query parameters. The design goal is to provide equivalent functionality to MoinMoin's <kbd><<Action()>></kbd> macro. Note that this only replicates functionality that existed on the Debian wiki at the time of migration—other actions may be supported by MoinMoin itself.


<templatedata>
== Usage ==
{
The baseline behavior for the template is to produce a link to edit the page it appears on, using the text: {{Action}}; when invoked with no parameters that will always be the result.
    "description": "MoinMoin-style action",
    "params": {
        "Action": {
            "type": "line",
            "required": true,
            "description": "Action to take",
            "aliases": ["1"],
            "suggestedvalues": [
                "edit",
                "info",
                "recoverpass",
                "subscribe",
                "userprefs"
            ]
        },
        "text": {
            "type": "line",
            "required": false,
            "description": "Link text",
            "aliases": ["2"]
        }
    }
}
</templatedata>


Provides equivalent functionality to MoinMoin's old <kbd><<Action()>></kbd> macro. Note that this only replicates functionality that existed on the Debian wiki at the time of migration - other actions may be supported by MoinMoin itself.
=== Parameters ===
This template currently accepts three parameter values, though none of them are strictly required. They are each independent of the others and can be used individually or in any combination to suit the situation. They may be used either by name or as unnamed positional parameters, but beware that the latter style requires that parameters always be defined in tandem with any others that precede them in the positional sequence (i.e., you can only set the second parameter along with the first, and only set the third after the other two). The loophole in that scenario is that the preceding positional parameters do not need to be used, per se, since null (empty) values are accepted as valid.
 
{| class="wikitable" style="text-align: center;"
! Position
! style="min-width: 8rem;" | Name
! Description
|-
| 1<sup>st</sup>
| <code>&verbar;action=</code>
| style="text-align: left;" | One of a set of keywords that specify the desired page action to trigger, with <code>edit</code> as the default when not defined. The list of valid keywords can be found in the [[#TemplateData|§ TemplateData]] section below.
|-
| 2<sup>nd</sup>
| <code>&verbar;page=</code>
| style="text-align: left;" | The name of the page to perform the action on, ''including the namespace'' if not in Main. If <code>&verbar;action=<<var>login</var>&verbar;<var>preferences</var>&verbar;<var>recoverpass</var>&verbar;<var>userprefs</var>></code>, this parameter is ignored.
|-
| 3<sup>rd</sup>
| <code>&verbar;text=</code>
| style="text-align: left;" | The text to be linked to the page action; when undefined sensible defaults are used.
|}
 
=== Link text ===
The default link text used by each of the action keywords is as follows:
{| class="wikitable" style="text-align: center;"
|+ Default values for <code>&verbar;text=</code>/<code>&verbar;3=</code> based on <code>&verbar;action=</code>/<code>&verbar;1=</code>
! scope="col" style="min-width: 14rem;" | Action keyword
! scope="col" style="min-width: 12rem;" | Default text
|-
! scope="row" | <code>edit</code>
| {{Action|edit}}
|-
! scope="row" | <code>history</code>, <code>info</code>, <code>log</code>
| {{Action|info}}
|-
! scope="row" | <code>login</code>, <code>recoverpass</code>
| {{Action|login}}
|-
! scope="row" | <code>preferences</code>, <code>userprefs</code>
| {{Action|userprefs}}
|-
! scope="row" | <code>subscribe</code>, <code>watch</code>
  | {{Action|watch}}
|}
 
== TemplateData ==
<templatedata>{
"description": "Produces linked text that triggers an action on the target page through the use of URL query parameters; specifically designed as a drop-in replacement for MoinMoin-style action behaviors",
"format": "inline",
"paramOrder": [
"action",
"page",
"text"
],
"params": {
"action": {
"label": "Page action",
"description": "The action to trigger on the target page",
"type": "line",
"aliases": [
"1"
],
"default": "edit",
"example": "history",
"suggestedvalues": [
"edit",
"history",
"info",
"log",
"login",
"preferences",
"recoverpass",
"subscribe",
"userprefs",
"watch"
],
"required": true
},
"page": {
"label": "Target page",
"description": "The page to perform the action on, defaults to the transcluding page if omitted.",
"type": "wiki-page-name",
"aliases": [
"2"
],
"default": "{{FULLPAGENAME}}",
"example": "Doc-base",
"suggested": true
},
"text": {
"label": "Link text",
"description": "The displayed text that will be linked to the page action; sensible defaults will be used if omitted.",
"type": "line",
"aliases": [
"3"
],
"example": "Edit me!",
"required": false
}
}
}</templatedata>
 
== Template demo / sandbox ==
A demonstration page for its feature set is available at [[ExampleForAction]].
 
 
[[Category:MoinMarkup]]
</noinclude>

Latest revision as of 09:53, 17 April 2026

edit page

This template, {{Action}}, produces links that perform an action on the target page through the use of URL query parameters. The design goal is to provide equivalent functionality to MoinMoin's <<Action()>> macro. Note that this only replicates functionality that existed on the Debian wiki at the time of migration—other actions may be supported by MoinMoin itself.

Usage

The baseline behavior for the template is to produce a link to edit the page it appears on, using the text: edit page; when invoked with no parameters that will always be the result.

Parameters

This template currently accepts three parameter values, though none of them are strictly required. They are each independent of the others and can be used individually or in any combination to suit the situation. They may be used either by name or as unnamed positional parameters, but beware that the latter style requires that parameters always be defined in tandem with any others that precede them in the positional sequence (i.e., you can only set the second parameter along with the first, and only set the third after the other two). The loophole in that scenario is that the preceding positional parameters do not need to be used, per se, since null (empty) values are accepted as valid.

Position Name Description
1st |action= One of a set of keywords that specify the desired page action to trigger, with edit as the default when not defined. The list of valid keywords can be found in the § TemplateData section below.
2nd |page= The name of the page to perform the action on, including the namespace if not in Main. If |action=<login|preferences|recoverpass|userprefs>, this parameter is ignored.
3rd |text= The text to be linked to the page action; when undefined sensible defaults are used.

Link text

The default link text used by each of the action keywords is as follows:

Default values for |text=/|3= based on |action=/|1=
Action keyword Default text
edit edit page
history, info, log view history
login, recoverpass reset password
preferences, userprefs preferences
subscribe, watch add to watchlist

TemplateData

Produces linked text that triggers an action on the target page through the use of URL query parameters; specifically designed as a drop-in replacement for MoinMoin-style action behaviors

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Page actionaction 1

The action to trigger on the target page

Suggested values
edit history info log login preferences recoverpass subscribe userprefs watch
Default
edit
Example
history
Linerequired
Target pagepage 2

The page to perform the action on, defaults to the transcluding page if omitted.

Default
{{FULLPAGENAME}}
Example
Doc-base
Page namesuggested
Link texttext 3

The displayed text that will be linked to the page action; sensible defaults will be used if omitted.

Example
Edit me!
Lineoptional

Template demo / sandbox

A demonstration page for its feature set is available at ExampleForAction.