Zum Inhalt springen

„Wikipedia:Lua/Modul/Pinging/en“ – Versionsunterschied

aus Wikipedia, der freien Enzyklopädie
Inhalt gelöscht Inhalt hinzugefügt
+
+
Zeile 7: Zeile 7:
Whitespace ahead and after any content is ignored.
Whitespace ahead and after any content is ignored.


: Common option parameters for all user list functions:
=== Common optional parameters ===
All functions listing users ([[#ping|ping]], [[#noping|noping]], [[#massmessage|massmessage]]) support common optional parameters. They may be provided both with <code>#invoke</code> as default for a certain template as well as for a particular transclusion – the latter takes precedence.
:; &#58;
; &#58;
:: postfix character/string
: Postfix character/string.
:: ''default:'' <code>:</code>
: ''Default:'' <code>:</code>
:: empty assignment makes it disappear
: Empty assignment makes it disappear.
:; p
:: like <code>:</code> (legacy)
: Terminating or leading <code>_</code> will be displayed as simple space.
:; @
; p
: Like <code>:</code> (legacy).
:: prefix character/string
; @
:: ''default:'' <code>@</code>
: Prefix character/string.
:: empty assignment makes it disappear
: ''Default:'' <code>@</code>
:; /
: Empty assignment makes it disappear.
:: separator character/string
: Terminating or leading <code>_</code> will be displayed as simple space.
:: ''default:'' <code>&amp;nbsp;|_</code>
; /
:: May be set both in template and <code>#invoke</code>. Assignment in template takes precedence.
: Separator character/string.
:: Terminating or leading <code>_</code> will be displayed as space which might be escaped by HTML entity.
:: <code>&amp;#10;</code> will be turned into line breaks.
: ''Default:'' like <code>&amp;nbsp;|_</code>
: Terminating or leading <code>_</code> will be displayed as simple space.
: <code>&amp;#10;</code> will be turned into line breaks.


=== ping ===
=== ping ===
Zeile 35: Zeile 37:
: Legacy for enwiki.
: Legacy for enwiki.
; max
; max
: <code>0</code> – Do not show error message if [[#maxecho|maxecho]] exceeded.
: <code>0</code> – Do not show error message if ''[[#maxecho|maxecho]]'' exceeded.
: Chose another limit than by system.
: Chose another limit than by system.
: May turn user name list into linklist for other purposes.
: May turn user name list into linklist for other purposes.
: Available for both <code>#invoke</code> and template transclusion; the latter takes precedence.
: Available for both <code>#invoke</code> and template transclusion; the latter takes precedence.
: ''default:'' Show error if ''{{#invoke:Pinging|maxecho}}'' exceeded.
: ''Default:'' Show error if ''{{#invoke:Pinging|maxecho}}'' exceeded.


=== noping ===
=== noping ===
Zeile 51: Zeile 53:
: Source page, one of
: Source page, one of
:* local page name
:* local page name
:* heading <code>#</code>, followed by curid (pageid) surviving page moves
:* heading <code>#</code>, followed by curid (pageid) surviving page moves.
: Available for <code>#invoke</code> only.
: ''mandatory''
: ''Mandatory''.
; 2
; 2
: List title
: List title, will be linked to source page.
: Must not contain links
: Must not contain links.
: Members will be shown if omitted
: Members will be shown if omitted.
: If <code>_</code> provided nothing visual will be displayed.
: Available for <code>#invoke</code> only.
; @
; @
: Parameter may be used to show both list title and members
: Parameter may be used to show both list title and members.
; max
; max
: <code>0</code> – Do not show error message if [[#maxecho|maxecho]] exceeded
: <code>0</code> – Do not show error message if ''[[#maxecho|maxecho]]'' exceeded.
: Chose another limit than by system.
: Chose another limit than by system.
: May turn user name list into linklist for other purposes.
: May turn user name list into linklist for other purposes.
: Available for both <code>#invoke</code> and template transclusion; the latter takes precedence.
: Available for both <code>#invoke</code> and template transclusion; the latter takes precedence.
: ''default:'' Show error if ''{{#invoke:Pinging|maxecho}}'' exceeded.
: ''Default:'' Show error if ''{{#invoke:Pinging|maxecho}}'' exceeded.
; subst
; subst
: Requires that <code>#invoke</code> is directly preceeded by <code>subst:</code> if set in any mode.
: Requires that <code>#invoke</code> is directly preceeded by <code>subst:</code> if set in any mode.
Zeile 87: Zeile 92:


== {{Anker|Lua}} Functions for Lua modules (API) ==
== {{Anker|Lua}} Functions for Lua modules (API) ==
Some functions may be used by other modules:

<syntaxhighlight lang="lua">
Currently none.
local lucky, Pinging = pcall( require, "Module:Pinging" )
if type( Pinging ) == "table" then
mw.log( Pinging.maxecho() )
else
-- error; Pinging contains error message
return "<span class=\"error\">" .. Pinging .. "</span>"
end
</syntaxhighlight>
If succeeded there are available:
; [[#failsafe|failsafe]]()
: Returns ''string'' with ID.
; [[#massmessage|massmessage]]( args, args2 )
: args – ''table'' with parameters for <code>#invoke</code> as listed above
: args2 – optional ''table'' with parameters like for a transclusion
: Returns ''string''.
; [[#maxecho|maxecho]]()
: Returns ''string'' with digits.


== Usage ==
== Usage ==

Version vom 31. Oktober 2015, 21:32 Uhr

Vorlagenprogrammierung Diskussionen Lua Test Unterseiten
Modul Deutsch English

Modul: Dokumentation

Pinging – Module with functions for any kind of user lists, especially for echo pings.

Functions for templates

All functions expect the parameter list from the template transclusion which will embed them. #invoke has no parameters, if not explicitly mentioned. Anything is optional if not explicitly mentioned.

Whitespace ahead and after any content is ignored.

Common optional parameters

All functions listing users (ping, noping, massmessage) support common optional parameters. They may be provided both with #invoke as default for a certain template as well as for a particular transclusion – the latter takes precedence.

:
Postfix character/string.
Default: :
Empty assignment makes it disappear.
Terminating or leading _ will be displayed as simple space.
p
Like : (legacy).
@
Prefix character/string.
Default: @
Empty assignment makes it disappear.
Terminating or leading _ will be displayed as simple space.
/
Separator character/string.
Default: like &nbsp;|_
Terminating or leading _ will be displayed as simple space.
&#10; will be turned into line breaks.

ping

Create a list of user page links from a list of nicks, which should trigger echo mention if occurring in a signed section.

1
User nick (no leading user:).
2 3 4 5 6 7 8 9 ...
Any number of user nicks.
labeln
Assign different displayed link title to nick n.
Legacy for enwiki.
max
0 – Do not show error message if maxecho exceeded.
Chose another limit than by system.
May turn user name list into linklist for other purposes.
Available for both #invoke and template transclusion; the latter takes precedence.
Default: Show error if 50 exceeded.

noping

Like ping, but all links as URL. No mentioning by echo, therefore max out of scope.

massmessage

Retrieve a list of recipients from a list of massmessage targets. This function is „expensive“. The usage of expensive functions per page is limited to 500.

1
Source page, one of
  • local page name
  • heading #, followed by curid (pageid) surviving page moves.
Available for #invoke only.
Mandatory.
2
List title, will be linked to source page.
Must not contain links.
Members will be shown if omitted.
If _ provided nothing visual will be displayed.
Available for #invoke only.
@
Parameter may be used to show both list title and members.
max
0 – Do not show error message if maxecho exceeded.
Chose another limit than by system.
May turn user name list into linklist for other purposes.
Available for both #invoke and template transclusion; the latter takes precedence.
Default: Show error if 50 exceeded.
subst
Requires that #invoke is directly preceeded by subst: if set in any mode.
Available for #invoke only.
Supposed to be the name of the top including page (template title) which will be shown in error message.

On defining pages, the parser function call {{#target: is supposed to be downcased, with no spaces within.

The parser functions need to be present within the page source itself, not indirectly via templates.

{{#target:Benutzer:PerfektesChaos}}
{{#target:Project:Noticeboard|en.wikipedia.org}}

maxecho

Just tell the current limitation for pinged users by a single edit: 50

failsafe

Version identification on this wiki: 2022-11-14

Examples (test page)

A test page illustrates practical use.

Functions for Lua modules (API)

Some functions may be used by other modules:

local lucky, Pinging = pcall( require, "Module:Pinging" )
if type( Pinging ) == "table" then
    mw.log( Pinging.maxecho() )
else
    -- error; Pinging contains error message
    return "<span class=\"error\">" .. Pinging .. "</span>"
end

If succeeded there are available:

failsafe()
Returns string with ID.
massmessage( args, args2 )
args – table with parameters for #invoke as listed above
args2 – optional table with parameters like for a transclusion
Returns string.
maxecho()
Returns string with digits.

Usage

General library; no limitations.

Dependencies

None.