Magic words & parser functions link
Line 136: | Line 136: | ||
}}|##|ul}} | }}|##|ul}} | ||
− | to be noted that the | + | to be noted that both "Page creator" and "Creation date" properties are required, because the parser functions check the affiliation of the page creator within a given time-frame. |
+ | Also, the output produced by the ask query will be a list of page titles separated by the character '##' with the requested properties separated by the '<PROP>' key-word, and the "CI_editors_attribution" parser function will then format it in an unordered list using the same string '##' as divider. | ||
+ | |||
+ | |||
+ | <!-- | ||
<pre class="language-xxxx"> | <pre class="language-xxxx"> | ||
Announcements/European Commission - Supporting the cultural and creative sectors in the ACP countries<PROP>User:Luca.speziale<PROP>User:Admin<MANY>User:Luca.speziale##Announcements/General Secretariat of the Council - Traineeships at the General Secretariat of the Council<PROP>User:Luca.speziale<PROP>User:Admin<MANY>User:Luca.speziale##Announcements/Language school "Praticamente" - Lavoro per un insegnante di inglese in Kazakistan per 3 mesi presso la Scuola di lingua Italiana “Praticamente”<PROP>User:Luca.speziale<PROP>User:Admin<MANY>User:Luca.speziale | Announcements/European Commission - Supporting the cultural and creative sectors in the ACP countries<PROP>User:Luca.speziale<PROP>User:Admin<MANY>User:Luca.speziale##Announcements/General Secretariat of the Council - Traineeships at the General Secretariat of the Council<PROP>User:Luca.speziale<PROP>User:Admin<MANY>User:Luca.speziale##Announcements/Language school "Praticamente" - Lavoro per un insegnante di inglese in Kazakistan per 3 mesi presso la Scuola di lingua Italiana “Praticamente”<PROP>User:Luca.speziale<PROP>User:Admin<MANY>User:Luca.speziale | ||
Line 143: | Line 147: | ||
therefore the function '''CI_editors_attribution''' will parse the output using the standard Semantic Mediawiki <PROP> and <MANY> delimiters and will retrieve the real name and the user affiliation from the username: then, it will return an unordered list as above. | therefore the function '''CI_editors_attribution''' will parse the output using the standard Semantic Mediawiki <PROP> and <MANY> delimiters and will retrieve the real name and the user affiliation from the username: then, it will return an unordered list as above. | ||
− | + | --> | |
Line 172: | Line 176: | ||
}} | }} | ||
+ | <!-- | ||
As above, the output produced by the ask query, will be similar to the following: | As above, the output produced by the ask query, will be similar to the following: | ||
Line 179: | Line 184: | ||
and applies as above with the difference that the output produced by the '''CI_editors_realnames''' function will be a comma separated list of real names of provided usernames. | and applies as above with the difference that the output produced by the '''CI_editors_realnames''' function will be a comma separated list of real names of provided usernames. | ||
+ | |||
+ | --> | ||
+ | |||
+ | Likewise as above, the output produced by the ask query, will be a list of values separated by the key-word '<MANY>', with properties separated by the '<PROP>' key-word, and the "CI_editors_attribution" parser function will | ||
</noinclude> | </noinclude> |
Revision as of 10:59, 5 September 2020
Magic words and Parser functions are a way to empower the wiki text (the specific language through which pages of all wikis are written, thus one can also use Visual editor where available) with some programmatic feature, for instance the ability to add the current date to a page (which will update during subsequent access) or to trigger whatever other function available in the wiki on the server side. They are both completely comparable to templates, with the difference that the second ones are always called with a parameter, and that the logics behind them is not placed within a template or module (so that it can be accessed on the wiki) but is coded server side.
Here is a list of the additional magic words provided by our platform (as usual they are prefixed with the string "CI_" to distinguish them easily from other Mediawiki magic words and parser functions)
name | what it does |
---|---|
CI_userAffiliatedTo | shows the organization to which the logged in user is affiliated |
CI_userRealName | shows the real name of logged in user (by contrast to the username) |
CI_isSysop | returns 1 if the logged in user is an admin ("sysop") |
CI_loggedIn | returns 1 if the page's visitor is logged in |
CI_visitorIsoCode | returns the iso code of country of the visitor |
CI_visitorCountry | returns the country name of the visitor |
and parser functions:
name | what it does |
---|---|
CI_editors_realnames | returns the real names from a list of usernames |
CI_editors_attribution | returns the string "edited by [real name], affiliated to [organization name]" from an ask query returning editors of a page |
CI_noparse_isHTML | prevents Mediawiki from html encoding output |
Instructions of use
Magic words
name | return value | example | result |
---|---|---|---|
CI_userAffiliatedTo | logged in user affiliation | {{CI_userAffiliatedTo}} | |
CI_userRealName | logged in user real name | {{CI_userRealName}} | |
CI_isSysop | whether the logged in user is an administrator or not | {{CI_isSysop}} | |
CI_loggedIn | whether the user is logged in or not | {{CI_loggedIn}} | |
CI_visitorIsoCode | country code of user (based on the ip) | {{CI_visitorIsoCode}} | US |
CI_visitorCountry | country of user (based on the ip) | {{CI_visitorCountry}} | United States |
Parser functions
function | return value | parameter |
---|---|---|
CI_editors_realnames | comma separated real names | list |
CI_editors_attribution | wikicode with links, in the form [[complete path|page name]] followed by a string in the form "created by [editor real name] affiliated to [editor affiliation] | list, delimiter, kind of output (ul or comma separated values) |
Examples
CI_editors_attribution
{{#CI_editors_attribution: {{#ask: [[Category:Reading suggestions]] |format=array |?Page creator |?Creation date |sep=## }}|##|ul}}
will create the following list:
- Alì Ehsani - Stanotte guardiamo le stelle - created by , affiliated to [organization]
- Giacomo Scotti, Mario Licciardi - Non si trova cioccolata - created by , affiliated to [organization]
- Raymond Queneau - Fiori Blu - created by , affiliated to [organization]
- Viviano Domenici - A cena con i cannibali. Taccuino di un giornalista esploratore - created by , affiliated to [organization]
- Yambo (Enrico de’ Conti Novelli da Bertinoro) - L'allevatore di dinosauri ovvero L'uovo di pterodattilo - created by , affiliated to [organization]
to be noted that both "Page creator" and "Creation date" properties are required, because the parser functions check the affiliation of the page creator within a given time-frame.
Also, the output produced by the ask query will be a list of page titles separated by the character '##' with the requested properties separated by the '<PROP>' key-word, and the "CI_editors_attribution" parser function will then format it in an unordered list using the same string '##' as divider.
CI_editors_realnames
{{#CI_editors_realnames: {{#ask: [[{{PAGENAME}}]] |?Page creator |?Page author |format=array |mainlabel=- |sep=## }} }}
will produce the following output:
Likewise as above, the output produced by the ask query, will be a list of values separated by the key-word '<MANY>', with properties separated by the '<PROP>' key-word, and the "CI_editors_attribution" parser function will