Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 189: | Zeile 189: | ||
As a self contained function, there are not parameters that can be passed through. | As a self contained function, there are not parameters that can be passed through. | ||
== | ==Verfügbare Symbole== | ||
{{#invoke:Symbole| | {{#invoke:Symbole|documentation}} | ||
{{clear}} | {{clear}} | ||
In addition, all abbreviations supported by {{tl|Abb}} can be used to produce an icon for the corresponding game. | In addition, all abbreviations supported by {{tl|Abb}} can be used to produce an icon for the corresponding game. | ||
Version vom 17. August 2023, 08:49 Uhr
| Diese Seite enthält Informationen zur Verwendung für Modul:Symbole/Doku. |
Eine Bibliothek von Funktionen für die Anzeige von Symbolen auf Seiten oder in anderen Vorlagen. Für beste Leistung, eine Kette von Symbolen (in einer Reihe sitzen, ohne dass dazwischen etwas ist)sollte mit einem einzigen Anruf erledigt werden.
Funktionen
Dieses Modul basiert auf exists() und trim(), die in Module:Util enthalten sind. Allen Funktionsaufrufen von diesem Modul wird util vorangestellt, z. B. util.exists().
_generate()
Diese Funktion ist nur intern und das Hauptarbeitspferd für p.Icons() und p.innerIcon(). Diese Funktion erstellt die Funktionsliste. Die erste Aufgabe besteht darin, die Größe der Symbole zu bestimmen.
if util.exists(iconSetting) then
iconSetting = util.trim(iconSetting)
if util.exists(iconSize[iconSetting]) then
iconSetting = iconSize[iconSetting]
end
else
iconSetting = iconSize["medium"]
end
-- This is for calls from other Lua modules as the above will result in nil
if util.exists(iconSetting) == false then
if util.exists(iconSize) then
iconSetting = iconSize
else
iconSetting = iconSize["medium"]
end
endIn WikiText Markup währe das equivalent zu:
{{#ifeq:{{{iconSetting}}}|medium|{{#switch:{{{iconSetting}}}|a = x14px |b = 16px| c= 20px|...|#default = {{{iconSize|x14px}}}}}}}
Der nächste Schritt besteht darin, die durch Kommas getrennten Listen in eine Tabelle aufzuteilen:
if util.exists(iconLinks) then
iconLinks = mw.text.split(iconLinks, ",")
end
if util.exists(tipOverride) then
tipOverride = mw.text.split(tipOverride, ",")
end
if util.exists(iconClass)then
iconClass = "|class=" .. tostring(iconClass);
else
iconClass = ""
endDies wäre gleichbedeutend mit der Verwendung mehrerer {{#explode:}}-Funktionen und -Variablen, um jedes Element als eigenes zu speichern.
Sobald die Daten vorverarbeitet wurden, wird eine Schleife verwendet, um jedes Element in der Liste zu durchlaufen und die Symbolsammlung zu generieren:
for k, v in ipairs(iconList) do
newIcon = iconData[util.trim(v)]
if util.exists(newIcon) then
currentIcon = newIcon.icon
if util.exists(tipOverride, k) then
currentTip = tipOverride[k]
else
if util.exists(iconLinks, k) then
currentTip = iconLinks[k]
else
currentTip = newIcon.tip
end
end
else
currentIcon = "Icon question.png"
currentTip = "Unbekannter Symbolname"
result = result .. "[[Kategorue:Module mit ungültigen Parametern]]"
end
--Create wikitext icon
dataLine = '[[File:' .. currentIcon .. '|' .. iconSetting
if util.exists(iconLinks, k) then
dataLine = dataLine .. '|link=' .. iconLinks[k]
else
dataLine = dataLine .. '|link='
end
if currentTip ~= nil then
dataLine = dataLine .. '|' .. currentTip
end
dataLine = dataLine .. iconClass .. ']]'
createTip = mw.html.create('span')
createTip:addClass( 'va-icon' )
:attr('title', currentTip)
:wikitext(dataLine)
result = result .. tostring(createTip)
if k < table.getn(iconList) then
result = result .. " "
end
endZeile 2 überprüft die Datenliste unter Module:Symbole/daten auf die Daten, die sich auf den Symbol-Shortcode beziehen, und gibt ein Ergebnis oder nil (existiert nicht) zurück, je nachdem, ob ein Ergebnis gefunden wurde Der Code wird fortgesetzt. Wenn es keine Übereinstimmung gibt, wird in den Zeilen 14/15 ein Dummy-Symbol bereitgestellt und in Zeile 16 eine Wartungskategorie hinzugefügt.
Wenn eine Übereinstimmung gefunden wird, besteht die nächste Aufgabe darin, zu prüfen, ob der Tooltip überschrieben wird. Wenn er nicht überschrieben wird, wird geprüft, ob ein alternativer Seitenlink bereitgestellt wurde. Andernfalls wird auf den Standard-Tooltip zurückgegriffen.
Das Wikitext-Äquivalent wäre:
{{{tipOverride|{{{iconLinks|default}}}}}}
Nachdem nun das richtige Symbol, der richtige Tooltip und der richtige Link vorliegen, erstellen die Zeilen 21-31 die Bilddatei im Format
[[File:<icon>|<size>|link=<link>|<tooltip>|class=<class>]].
Die Zeilen 33–37 erstellen den <span />, der das Symbol enthält und das Symbol darin einfügt. Beim Rendern wird dies als <nowik><span class="va-icon" title="<tooltip>">Symbol</nowiki> angezeigt.
Schließlich prüfen die Zeilen 39–41, ob das zu erstellende Element das letzte in der Liste ist, das erstellt wird. Andernfalls wird am Ende der Zeichenfolge ein Leerzeichen eingefügt, sodass zwischen den Symbolen auf der Seite nach Fertigstellung Platz bleibt.
Aufrufparameter
Die Aufrufparameter werden von p.Icons(frame) oder p.innerIcon(iconList, iconSetting, iconLinks, tipOverride, iconClass, iconSize) übergeben. Die Variablen stimmen zwischen diesen drei Funktionen überein und das Folgende sollte als Erklärung für alle drei verstanden werden.
| Name | Parameter | Variable | Beschreibung | Erforderlich | Beispiel |
|---|---|---|---|---|---|
| Icons | 1 | iconList | Eine Zeichenfolgenliste mit Symbol-Funktionscodes, die an das Modul weitergeleitet werden. Wenn mehrere Codes übergeben werden, sollten diese durch ein Komma (,) getrennt werden. | fo76,ww | |
| Icon Size | 2 | iconSetting | Die Bildgröße, die an alle Symbole in der Liste übergeben werden soll. Es kann eine benutzerdefinierte Größe eingestellt werden (z. B. x26px) oder eine der Standardgrößen angewendet werden:
Um sicherzustellen, dass alle Symbole eine einheitliche Größe haben, wird empfohlen, die Höhe (z. B. „x“ 14 Pixel) und nicht die Breite (z. B. 14 Pixel) zu steuern. |
- Standardeinstellungen sind integriert | |
| Link | 3 | iconLinks | Die Seite(n), auf die das/die Symbol(e) verlinkt. Bei mehreren Seiten werden Artikelnamen durch ein Komma (,) getrennt. | Fallout 76,Wild Wasteland | |
| Tooltip | 4 | tipOverride | Die Tooltips, die angezeigt werden, wenn Sie mit der Maus über das/die Symbol(e) fahren. Bei mehreren Symbolen können die Tooltips durch ein Komma (') getrennt werden. | - Defaults are built in | Fire, EMP |
| CSS Class | 4 | iconClass | CSS-Klassen, die auf die Symbole angewendet werden sollen. Wenn dies festgelegt ist, gilt es für alle Symbole in der Gruppe. Klassen werden ohne die Komponente class= geschrieben. |
va-icon va-icon-blue |
p.Icons() und p.innerIcon()
Diese beiden Funktionen sind Durchleitungsfunktionen an _generate(). Vor dem Durchlaufen wird die Liste der mitgelieferten Icons geteilt.
Der Unterschied zwischen den Funktionen besteht darin, wo sie verwendet werden sollten und dass p.innerIcon() keine Tabelle mit Symbolgrößen durchläuft, sondern nur eine vorgegebene Größe und nur von anderen Lua-Modulen aufgerufen werden kann. p.Icons() gilt für alle anderen Namespaces und kann nicht von einem anderen Modul aufgerufen werden.
Aufrufparameter
Aufgrund der Nähe dieser beiden Funktionen und _generate() sind die Aufrufparameter dieselben wie oben aufgeführt.
p.platforms()
p.platforms() uses the same data set as the other functions, but only returns results for icons that have been marked as being a platform in the data set. In addition to this, it also uses Semantic Mediawiki so the data returned can be queried in Special:Ask.
Once the function has confirmed the icon in the list is a valid platform, it will create a hidden <span /> holding the semantic tag advising of the platform assigned from the default tooltip [[Has platform::<platform>]]. The code then largely follows that of _generate() to create the icon, with a blank link attribute. The two spans are then joined together before checking for the next platform.
If no platforms are found the code will return <sup>[Platforms needed]</sup>[[Category:Platforms needed]].
Invocation parameters
The only parameter taken by this function is the iconList parameter, holding the string of short codes.
p.documentation()
p.documentation() is self generating documentation to display the icon produced by each short code. It first takes all the datasets available and sorts them into alphabetical order and creates a table header allowing for 3 icons in a row. For each short code it will put the short code in the first, third or fifth column and the icon in the second, fourth or sixth column based on where in the sorted dataset it resides.
Due to the ever expanding icon list, this function does run the risk of becoming oversized with time. If the character size is exceeded it may need splitting into two functions.
Invocation parameters
As a self contained function, there are not parameters that can be passed through.
Verfügbare Symbole
In addition, all abbreviations supported by {{Abb}} can be used to produce an icon for the corresponding game.