Obrovská poptávka po plynových turbínách zapříčinila, že datová centra začala používat v generátorech dodávajících energii pro provoz AI staré dobré proudové letecké motory, konvertované na plyn. Jejich výhodou je, že jsou menší, lehčí a lépe udržovatelné než jejich průmyslové protějšky. Proto jsou ideální pro dočasné nebo mobilní použití.
Typst byl vydán ve verzi 0.14. Jedná se o rozšiřitelný značkovací jazyk a překladač pro vytváření dokumentů včetně odborných textů s matematickými vzorci, diagramy či bibliografií.
Specialisté společnosti ESET zaznamenali útočnou kampaň, která cílí na uživatele a uživatelky v Česku a na Slovensku. Útočníci po telefonu zmanipulují oběť ke stažení falešné aplikace údajně od České národní banky (ČNB) nebo Národní banky Slovenska (NBS), přiložení platební karty k telefonu a zadání PINu. Malware poté v reálném čase přenese data z karty útočníkovi, který je bezkontaktně zneužije u bankomatu nebo na platebním terminálu.
V Ubuntu 25.10 byl balíček základních nástrojů gnu-coreutils nahrazen balíčkem rust-coreutils se základními nástroji přepsanými do Rustu. Ukázalo se, že nový "date" znefunkčnil automatickou aktualizaci. Pro obnovu je nutno balíček rust-coreutils manuálně aktualizovat.
VST 3 je nově pod licencí MIT. S verzí 3.8.0 proběhlo přelicencování zdrojových kódů z licencí "Proprietary Steinberg VST3 License" a "General Public License (GPL) Version 3". VST (Virtual Studio Technology, Wikipedie) je softwarové rozhraní pro komunikaci mezi hostitelským programem a zásuvnými moduly (pluginy), kde tyto moduly slouží ke generování a úpravě digitálního audio signálu.
Open source 3D herní a simulační engine Open 3D Engine (O3DE) byl vydán v nové verzi 25.10. Podrobný přehled novinek v poznámkách k vydání.
V Londýně probíhá dvoudenní Ubuntu Summit 25.10. Na programu je řada zajímavých přednášek. Zhlédnout je lze také na YouTube (23. 10. a 24. 10.).
Gemini CLI umožňuje používání AI Gemini přímo v terminálu. Vydána byla verze 0.10.0.
Konference OpenAlt 2025 proběhne již příští víkend 1. a 2. listopadu v Brně. Nabídne přibližně 80 přednášek a workshopů rozdělených do 7 tematických tracků. Program se může ještě mírně měnit až do samotné konference, a to s ohledem na opožděné úpravy abstraktů i případné podzimní virózy. Díky partnerům je vstup na konferenci zdarma. Registrace není nutná. Vyplnění formuláře však pomůže s lepším plánováním dalších ročníků konference.
Samsung představil headset Galaxy XR se 4K Micro-OLED displeji, procesorem Snapdragon XR2+ Gen 2, 16 GB RAM, 256 GB úložištěm, operačním systémem Android XR a Gemini AI.
Mediawiki má filozofii, co neexistuje, to vytvoř. Novou stránku v Mediawiki tedy nevytvoříme tak, že někde budeme hledat tlačítko "přidat", ale tak, že zadáme zmíněný termín do vyhledávače, a pokud tento termín / název nebude existovat, tak nám vyhledávač nabídne jen červený text, na který když ťukneme, tak začneme vytvářet zmíněnou stránku.
Vpravo můžeme vidět dvě možnosti editace."Editovat", což je VisualEditor a pak "Editovat zdroj", což je editace stránky přímým zadáváním wiki syntaxe.
Dokud stránku neuložíme, tak se obsah ani stránka taktéž neuloží. Tj. nedělá se nějaké průběžné ukládání na pozadí během editace.
Stránku naplníme daty. Formátování si nevymýšlíme (neplácáme nikde vlastní mezery, odsazení, neděláme milion apostrofů všude možně apod.). Veškeré formátování je dáno rozhraním a měli bychom se jej držet. Je to důležité z několika věcí :
Výsledný příklad (vlevo můžete vidět automaticky generovaný "Obsah" na základě nadpisů):
Instalace rozšíření je jednoduchá. Jen upozorním na obezřetnost, tj. neinstaluji hlouposti, které nepotřebuji a mají vysokou pravděpodobnost, že nebudou udržovány. Rozšíření se instalují tak, že obsah rozšíření rozbalím do "/var/www/mediawiki/extensions", povolím rozšíření v konfiguraci wikiny a zavoláme update. Každé rozšíření má na svém webu popis, jak jej aktivovat + případně, jak jej nastavit (pokud vyžaduje / umožňuje dodatečná nastavení). Příklad instalace rozšíření, které později použijeme pro tvorbu šablon. Konkrétně tedy Extension:TemplateStyles. Vždy stahujeme verzi určenou pro naší verzi wikiny. V opačném případě může nastat nějaký problém.
# vstoupíme do adresáře s rozšířeními cd /var/www/mediawiki/extensions # stáhneme wget -c https://extdist.wmflabs.org/dist/extensions/TemplateStyles-REL1_39-f09fb72.tar.gz # rozbalíme tar xvf TemplateStyles-REL1_39-f09fb72.tar.gz # fix práv chown -R root:root TemplateStyles # aktivujeme rozšíření nano /var/www/mediawiki/LocalSettings.php ... wfLoadExtension( 'TemplateStyles' ); # provedeme update cd /var/www/mediawiki/maintenance/ php update.php
Další rozšíření, která se nám v budoucnu hodí, jsou již součástí Mediawikii. Konkrétně to jsou tyto:
cd /var/www/mediawiki/extensions ... wfLoadExtension( 'SyntaxHighlight_GeSHi' ); wfLoadExtension( 'TemplateData' ); wfLoadExtension( 'Scribunto' ); wfLoadExtension( 'ParserFunctions' ); # provedeme update cd /var/www/mediawiki/maintenance/ php update.php
Přehled a verze Mediawiki a rozšíření a dalších věcí můžete vidět v sekci "Speciální:Verze", viz:
Šablony jsou jen další stránky v Mediawiki, nic víc. Všechny šablony jsou ukryty pod odkazem "....index.php/Šablona:NázevŠablony". Jak vidíte, pokud máme Mediawiki v češtině, tak jsou i odkazy v češtině. Pokud bychom měli anglickou lokalizaci jako výchozí, bude url "....index.php/Template:NázevŠablony". Oficiální dokumentace viz: Help:Templates
Začneme malými příklady. Chceme mít např. šablonu "Barva", která nám bude obarvovat text. Vytvoříme jí tedy zadáním url: "https://wiki.devaine.cz/index.php/Šablona:Barva" a následně dáme "Založit zdroj" a vložíme kód naší šablony:
<span style="color:{{{1|red}}}">{{{2}}}</span><noinclude>
{{Dokumentace}}
<templatedata>
{
"params": {
"1": {
"aliases": [
"barva"
],
"example": "#DCDCDC",
"required": true
},
"2": {
"aliases": [
"Text"
],
"example": "Text",
"required": true
}
}
}
</templatedata>
</noinclude>
Poté stránku uložíme:
A šablonu si pak můžeme vyzkoušet
Takto pomocí wikieditoru:
{{Barva|red|Obarvený textíček}}
Nebo takto pomocí VisualEditoru (Vložit -> Šablona -> Barva):
Výsledek pak bude vypadat takto:
Podobně jako barva si můžeme vytvořit šablonu na zvýraznění pozadí textu "https://wiki.devaine.cz/index.php/Šablona:Zvýrazňovač":
<span style="background-color:{{{1|red}}}">{{{2}}}</span><noinclude>
{{Dokumentace}}
<templatedata>
{
"params": {
"1": {
"aliases": [
"Zvýrazňovač"
],
"example": "#DCDCDC",
"required": true
},
"2": {
"aliases": [
"Text"
],
"example": "Text",
"required": true
}
}
}
</templatedata>
</noinclude>
Syntaxe je pak podobná jako u barvy, tj. dva parametry, prvním je barva pozadí, druhým je text:
{{Zvýrazňovač|Green|Příklad texty}}
Jdeme na něco složitějšího. Chceme rozšíření, které nám bude zobrazovat klávesové zkratky jako obrázky kláves. Toto je oficiální šablona. Pokud nějakou šablonu najdeme na webu Mediawiki, můžeme si jí jednoduše zkopírovat. Oficiální dokumentace šablony včetně kódu je na: Template:Key_press. Vpravo nahoře můžete vidět, že stránka vyžaduje rozšíření "TemplateStyles" (již jsme si ho nainstalovali a aktivovali výše), protože se využívá externí css soubor. Šablonu zkopírujeme následovně:
Nejdříve si přeneseme hlavní šablonu, tj. ťukneme si na zdroj oficiálního template
Template:Key_press&action=edit
a obsah přeneseme do naší wiki do stejné url
"https://wiki.devaine.cz/index.php/Šablona:Key_press"
<templatestyles src="Key press/styles.css"/>{{key press/core|{{{1|}}}}}<!--
-->{{#if:{{{2|}}}|{{{chain first|{{{chain|+}}}}}}{{key press/core|{{{2}}}}}}}<!--
-->{{#if:{{{3|}}}|{{{chain second|{{{chain|+}}}}}}{{key press/core|{{{3}}}}}}}<!--
-->{{#if:{{{4|}}}|{{{chain third|{{{chain|+}}}}}}{{key press/core|{{{4}}}}}}}<!--
-->{{#if:{{{5|}}}|{{{chain fourth|{{{chain|+}}}}}}{{key press/core|{{{5}}}}}}}<!--
-->{{#if:{{{6|}}}|{{{chain fifth|{{{chain|+}}}}}}{{key press/core|{{{6}}}}}}}<!--
-->{{#if:{{{7|}}}|{{{chain sixth|{{{chain|+}}}}}}{{key press/core|{{{7}}}}}}}<!--
-->{{#if:{{{8|}}}|{{{chain seventh|{{{chain|+}}}}}}{{key press/core|{{{8}}}}}}}<!--
-->{{#if:{{{9|}}}|{{{chain eighth|{{{chain|+}}}}}}{{key press/core|{{{9}}}}}}}<!--
-->{{#if:{{{10|}}}|{{{chain ninth|{{{chain|+}}}}}}{{key press/core|{{{10}}}}}}}<!--
-->{{#if:{{{11|}}}|[[Category:Wikipedia keypress template parameter needs fixing]]}}<noinclude>
{{documentation}}
<!-- add category and language links to the /doc sub-page, not here -->
</noinclude>
Následně přeneseme stejným způsobem chybějící css styl, tj. ťukneme na odkaz Template:Key_press/styles.css, stejnou url si vytvoříme v naší wikině, tj. "https://wiki.devaine.cz/index.php/Šablona:Key_press/styles.css" a copy-paste překopírujeme obsah css stylu:
.keyboard-key {
border: 1px solid #aaa;
border-radius: 0.2em;
box-shadow: 0.1em 0.2em 0.2em #ddd;
background-image: linear-gradient(to bottom, #eee, #f9f9f9, #eee);
padding: 0.1em 0.3em;
font-family: inherit;
font-size: 0.85em;
}
Můžeme si všimnout, že pro toto rozšíření je potřeba ještě "Šablona:Key press/core", takže tu také zkopírujeme z url: Template:Key_press/core k nám do wiki do "https://wiki.devaine.cz/index.php/Šablona:Key_press/core"
<kbd class="keyboard-key nowrap">{{#switch:{{lc:{{{1}}}}}
| caps lock = ⇪ Caps Lock
| [[caps lock]] = ⇪ [[Caps Lock]]
| shift = ⇧ Shift
| [[shift key|shift]] = ⇧ [[Shift key|Shift]]
| enter = ↵ Enter
| [[enter key|enter]] = ↵ [[Enter key|Enter]]
| cmd = ⌘ Cmd
| [[cmd key|cmd]]
| [[command key|cmd]] = ⌘ [[Command key|Cmd]]
| command = ⌘ Command
| [[cmd key|command]]
| [[command key|command]] = |⌘ [[Command key|Command]]
| opt = ⌥ Opt
| [[opt key|opt]]
| [[option key|opt]] = ⌥ [[Option key|Opt]]
| option = ⌥ Option
| [[option key]]
| [[opt key|option]]
| [[option key|option]] = ⌥ [[Option key|Option]]
| tab = Tab ↹
| [[tab key|tab]] = [[Tab key|Tab]] ↹
| backspace = ← Backspace
| [[backspace]] = ← [[Backspace]]
| win = ⊞ Win
| [[win key|win]]
| [[windows key|win]] = ⊞ [[Windows key|Win]]
| menu = ≣ Menu
| [[menu key|menu]] = ≣ [[Menu key|Menu]]
| up = ↑
| [[arrow keys|up]] = [[Arrow keys|↑]]
| down = ↓
| [[arrow keys|down]] = [[Arrow keys|↓]]
| left = ←
| [[arrow keys|left]] = [[Arrow keys|←]]
| right = →
| [[arrow keys|right]] = [[Arrow keys|→]]
| *
| asterisk = <nowiki>*</nowiki>
| #
| hash = <nowiki>#</nowiki>
| [[#]] = [[Number sign|#]]
| :
| colon = <nowiki>:</nowiki>
| [[:]] = [[Colon (punctuation)|:]]
| pipe = <nowiki>|</nowiki>
| [[|]] = [[Pipe symbol|<nowiki>|</nowiki>]]
| ;
| semicolon = <nowiki>;</nowiki>
| [[;]] = [[Semi-colon|<nowiki>;</nowiki>]]
| equals = <nowiki>=</nowiki>
<!-- Left & right analog sticks -->
| l-up
| l up = L↑
| l-down
| l down = L↓
| l-left
| l left = L←
| l-right
| l right = L→
| l-ne
| l ne = L↗
| l-se
| l se = L↘
| l-nw
| l nw = L↖
| l-sw
| l sw = L↙
| r-up
| r up = R↑
| r-down
| r down = R↓
| r-left
| r left = R←
| r-right
| r right = R→
| r-ne
| r ne = R↗
| r-se
| r se = R↘
| r-nw
| r nw = R↖
| r-sw
| r sw = R↙
<!-- PlayStation -->
| ps x
| ex = ×
| ps c
| circle = ○
| ps s
| square = □
| ps t
| triangle = △
<!-- Nintendo 64 & GameCube -->
| c-up
| c up = C↑
| c-down
| c down = C↓
| c-left
| c left = C←
| c-right
| c right = C→
| c-ne
| c ne = C↗
| c-se
| c se = C↘
| c-nw
| c nw = C↖
| c-sw
| c sw = C↙
<!-- default -->
| #default = {{{1}}}
}}</kbd><noinclude>
{{documentation|content=
See {{ll|Template:Key press}}
}}
</noinclude>
Nyní už by měla šablona fungovat. Zkusíme tedy oblíbený ctrl + alt + del. Syntaxe tedy:
{{key press|Ctrl|Alt|Del}}
Přes VisualEditor pak takto
Výsledek je pak:
Další zajímavou šablonou může být Button. Oficiální stránka: Template:Button tj. my si vytvoříme: "https://wiki.devaine.cz/index.php/Šablona:Button"
<!--
--><span class="nowrap" title="This is not a clickable button; it illustrates the button one should find." style="padding:{{{padTB|.2em}}} {{{padLR|.6em}}}; border:1px solid; border-color:#AAA #555 #555 #AAA; border-radius: 3px; background-color: {{{bgcolor|#F2F2F2}}}; background-image: linear-gradient(to bottom, #FCFCFC, #E0E0E0); {{#ifeq:{{{format|}}}|bold|font-weight: bold;}} {{{style|}}}">{{{text|{{{1|Hello, World!}}}}}}</span><!--
--><noinclude>
{{documentation}}
</noinclude>
Syntaxe je pak:
{{Button|Text tlačítka}}
Ve VisualEditoru pak takto:
Opět trochu přiostříme. V Mediawiki lze psát moduly v Lua a ty pak volat. K tomu slouží rozšíření Scribunto, které je součástí wikiny, a které jsme si výše už povolili. Oficiální stránky této šablony jsou: Template:Clickable_button_2.
Abychom tuto šablonu rozfungovali, musíme si vytvořit moduly Yesno, Arguments a Clickable_button_2, který pak budeme volat v šabloně Clickable button 2. Moduly jsou, podobně jako šablony a jiné věci, prosté stránky. Tj. moduly opět vytvoříme přes url. Jdeme na to.
Module:Yesno
https://wiki.devaine.cz/index.php/Modul:Yesno
-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{yesno}}.
return function (val, default)
-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
-- should replace "val:lower()" with "mw.ustring.lower(val)" in the
-- following line.
val = type(val) == 'string' and val:lower() or val
if val == nil then
return nil
elseif val == true
or val == 'yes'
or val == 'y'
or val == 'true'
or val == 't'
or val == 'on'
or tonumber(val) == 1
then
return true
elseif val == false
or val == 'no'
or val == 'n'
or val == 'false'
or val == 'f'
or val == 'off'
or tonumber(val) == 0
then
return false
else
return default
end
end
Module:Arguments
https://wiki.devaine.cz/index.php/Modul:Arguments
-- This module provides easy processing of arguments passed to Scribunto from
-- #invoke. It is intended for use by other Lua modules, and should not be
-- called from #invoke directly.
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local arguments = {}
-- Generate four different tidyVal functions, so that we don't have to check the
-- options every time we call it.
local function tidyValDefault(key, val)
if type(val) == 'string' then
val = val:match('^%s*(.-)%s*$')
if val == '' then
return nil
else
return val
end
else
return val
end
end
local function tidyValTrimOnly(key, val)
if type(val) == 'string' then
return val:match('^%s*(.-)%s*$')
else
return val
end
end
local function tidyValRemoveBlanksOnly(key, val)
if type(val) == 'string' then
if val:find('%S') then
return val
else
return nil
end
else
return val
end
end
local function tidyValNoChange(key, val)
return val
end
local function matchesTitle(given, title)
local tp = type( given )
return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title
end
local translate_mt = { __index = function(t, k) return k end }
function arguments.getArgs(frame, options)
checkType('getArgs', 1, frame, 'table', true)
checkType('getArgs', 2, options, 'table', true)
frame = frame or {}
options = options or {}
--[[
-- Set up argument translation.
--]]
options.translate = options.translate or {}
if getmetatable(options.translate) == nil then
setmetatable(options.translate, translate_mt)
end
if options.backtranslate == nil then
options.backtranslate = {}
for k,v in pairs(options.translate) do
options.backtranslate[v] = k
end
end
if options.backtranslate and getmetatable(options.backtranslate) == nil then
setmetatable(options.backtranslate, {
__index = function(t, k)
if options.translate[k] ~= k then
return nil
else
return k
end
end
})
end
--[[
-- Get the argument tables. If we were passed a valid frame object, get the
-- frame arguments (fargs) and the parent frame arguments (pargs), depending
-- on the options set and on the parent frame's availability. If we weren't
-- passed a valid frame object, we are being called from another Lua module
-- or from the debug console, so assume that we were passed a table of args
-- directly, and assign it to a new variable (luaArgs).
--]]
local fargs, pargs, luaArgs
if type(frame.args) == 'table' and type(frame.getParent) == 'function' then
if options.wrappers then
--[[
-- The wrappers option makes Module:Arguments look up arguments in
-- either the frame argument table or the parent argument table, but
-- not both. This means that users can use either the #invoke syntax
-- or a wrapper template without the loss of performance associated
-- with looking arguments up in both the frame and the parent frame.
-- Module:Arguments will look up arguments in the parent frame
-- if it finds the parent frame's title in options.wrapper;
-- otherwise it will look up arguments in the frame object passed
-- to getArgs.
--]]
local parent = frame:getParent()
if not parent then
fargs = frame.args
else
local title = parent:getTitle():gsub('/sandbox$', '')
local found = false
if matchesTitle(options.wrappers, title) then
found = true
elseif type(options.wrappers) == 'table' then
for _,v in pairs(options.wrappers) do
if matchesTitle(v, title) then
found = true
break
end
end
end
-- We test for false specifically here so that nil (the default) acts like true.
if found or options.frameOnly == false then
pargs = parent.args
end
if not found or options.parentOnly == false then
fargs = frame.args
end
end
else
-- options.wrapper isn't set, so check the other options.
if not options.parentOnly then
fargs = frame.args
end
if not options.frameOnly then
local parent = frame:getParent()
pargs = parent and parent.args or nil
end
end
if options.parentFirst then
fargs, pargs = pargs, fargs
end
else
luaArgs = frame
end
-- Set the order of precedence of the argument tables. If the variables are
-- nil, nothing will be added to the table, which is how we avoid clashes
-- between the frame/parent args and the Lua args.
local argTables = {fargs}
argTables[#argTables + 1] = pargs
argTables[#argTables + 1] = luaArgs
--[[
-- Generate the tidyVal function. If it has been specified by the user, we
-- use that; if not, we choose one of four functions depending on the
-- options chosen. This is so that we don't have to call the options table
-- every time the function is called.
--]]
local tidyVal = options.valueFunc
if tidyVal then
if type(tidyVal) ~= 'function' then
error(
"bad value assigned to option 'valueFunc'"
.. '(function expected, got '
.. type(tidyVal)
.. ')',
2
)
end
elseif options.trim ~= false then
if options.removeBlanks ~= false then
tidyVal = tidyValDefault
else
tidyVal = tidyValTrimOnly
end
else
if options.removeBlanks ~= false then
tidyVal = tidyValRemoveBlanksOnly
else
tidyVal = tidyValNoChange
end
end
--[[
-- Set up the args, metaArgs and nilArgs tables. args will be the one
-- accessed from functions, and metaArgs will hold the actual arguments. Nil
-- arguments are memoized in nilArgs, and the metatable connects all of them
-- together.
--]]
local args, metaArgs, nilArgs, metatable = {}, {}, {}, {}
setmetatable(args, metatable)
local function mergeArgs(tables)
--[[
-- Accepts multiple tables as input and merges their keys and values
-- into one table. If a value is already present it is not overwritten;
-- tables listed earlier have precedence. We are also memoizing nil
-- values, which can be overwritten if they are 's' (soft).
--]]
for _, t in ipairs(tables) do
for key, val in pairs(t) do
if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
local tidiedVal = tidyVal(key, val)
if tidiedVal == nil then
nilArgs[key] = 's'
else
metaArgs[key] = tidiedVal
end
end
end
end
end
--[[
-- Define metatable behaviour. Arguments are memoized in the metaArgs table,
-- and are only fetched from the argument tables once. Fetching arguments
-- from the argument tables is the most resource-intensive step in this
-- module, so we try and avoid it where possible. For this reason, nil
-- arguments are also memoized, in the nilArgs table. Also, we keep a record
-- in the metatable of when pairs and ipairs have been called, so we do not
-- run pairs and ipairs on the argument tables more than once. We also do
-- not run ipairs on fargs and pargs if pairs has already been run, as all
-- the arguments will already have been copied over.
--]]
metatable.__index = function (t, key)
--[[
-- Fetches an argument when the args table is indexed. First we check
-- to see if the value is memoized, and if not we try and fetch it from
-- the argument tables. When we check memoization, we need to check
-- metaArgs before nilArgs, as both can be non-nil at the same time.
-- If the argument is not present in metaArgs, we also check whether
-- pairs has been run yet. If pairs has already been run, we return nil.
-- This is because all the arguments will have already been copied into
-- metaArgs by the mergeArgs function, meaning that any other arguments
-- must be nil.
--]]
if type(key) == 'string' then
key = options.translate[key]
end
local val = metaArgs[key]
if val ~= nil then
return val
elseif metatable.donePairs or nilArgs[key] then
return nil
end
for _, argTable in ipairs(argTables) do
local argTableVal = tidyVal(key, argTable[key])
if argTableVal ~= nil then
metaArgs[key] = argTableVal
return argTableVal
end
end
nilArgs[key] = 'h'
return nil
end
metatable.__newindex = function (t, key, val)
-- This function is called when a module tries to add a new value to the
-- args table, or tries to change an existing value.
if type(key) == 'string' then
key = options.translate[key]
end
if options.readOnly then
error(
'could not write to argument table key "'
.. tostring(key)
.. '"; the table is read-only',
2
)
elseif options.noOverwrite and args[key] ~= nil then
error(
'could not write to argument table key "'
.. tostring(key)
.. '"; overwriting existing arguments is not permitted',
2
)
elseif val == nil then
--[[
-- If the argument is to be overwritten with nil, we need to erase
-- the value in metaArgs, so that __index, __pairs and __ipairs do
-- not use a previous existing value, if present; and we also need
-- to memoize the nil in nilArgs, so that the value isn't looked
-- up in the argument tables if it is accessed again.
--]]
metaArgs[key] = nil
nilArgs[key] = 'h'
else
metaArgs[key] = val
end
end
local function translatenext(invariant)
local k, v = next(invariant.t, invariant.k)
invariant.k = k
if k == nil then
return nil
elseif type(k) ~= 'string' or not options.backtranslate then
return k, v
else
local backtranslate = options.backtranslate[k]
if backtranslate == nil then
-- Skip this one. This is a tail call, so this won't cause stack overflow
return translatenext(invariant)
else
return backtranslate, v
end
end
end
metatable.__pairs = function ()
-- Called when pairs is run on the args table.
if not metatable.donePairs then
mergeArgs(argTables)
metatable.donePairs = true
end
return translatenext, { t = metaArgs }
end
local function inext(t, i)
-- This uses our __index metamethod
local v = t[i + 1]
if v ~= nil then
return i + 1, v
end
end
metatable.__ipairs = function (t)
-- Called when ipairs is run on the args table.
return inext, t, 0
end
return args
end
return arguments
Module:Clickable_button_2
https://wiki.devaine.cz/index.php/Modul:Clickable_button_2
-- This module implements {{clickable button 2}}.
local yesno = require('Module:Yesno')
local p = {}
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Clickable button 2'
})
return p.luaMain(args)
end
function p.luaMain(args)
if not args[1] and not args.url then
return ''
end
local data = p.makeLinkData(args)
local link = p.renderLink(data)
local trackingCategories = p.renderTrackingCategories(args)
return link .. trackingCategories
end
function p.makeLinkData(args)
local data = {}
-- Get the link and display values, and find whether we are outputting a
-- wikilink or a URL.
if args.url then
data.isUrl = true
data.link = args.url
if args[1] then
data.display = args[1]
else
data.display = args.url
end
else
data.isUrl = false
data.link = args[1]
if args[2] then
data.display = args[2]
else
data.display = args[1]
end
end
-- Classes
local class = args.class and args.class:lower()
data.classes = {}
if class == 'ui-button-green'
or class == 'ui-button-blue'
or class == 'ui-button-red'
then
table.insert(
data.classes,
'submit ui-button ui-widget ui-state-default ui-corner-all'
.. ' ui-button-text-only ui-button-text'
)
else
table.insert(data.classes, 'mw-ui-button')
end
if class then
table.insert(data.classes, class)
end
-- Styles
do
--[[
-- Check whether we are on the same page as we have specified in
-- args[1], but not if we are using a URL link, as then args[1] is only
-- a display value. If we are currently on the page specified in
-- args[1] make the button colour darker so that it stands out from
-- other buttons on the page.
--]]
local success, linkTitle, currentTitle
if not data.isUrl then
currentTitle = mw.title.getCurrentTitle()
success, linkTitle = pcall(mw.title.new, args[1])
end
if success
and linkTitle
and mw.title.equals(currentTitle, linkTitle)
then
if class == 'ui-button-blue'
or class == 'mw-ui-progressive'
or class == 'mw-ui-constructive'
then
data.backgroundColor = '#2962CB'
elseif class == 'ui-button-green' then
data.backgroundColor = '#008B6D'
elseif class == 'ui-button-red' or class == 'mw-ui-destructive' then
data.backgroundColor = '#A6170F'
else
data.backgroundColor = '#CCC'
data.color = '#666'
end
end
-- Add user-specified styles.
data.style = args.style
end
return data
end
function p.renderLink(data)
-- Render the display span tag.
local display
do
local displaySpan = mw.html.create('span')
for i, class in ipairs(data.classes or {}) do
displaySpan:addClass(class)
end
displaySpan
:attr('role', 'button')
:attr('aria-disabled', 'false')
:css{
['background-color'] = data.backgroundColor,
color = data.color
}
if data.style then
displaySpan:cssText(data.style)
end
displaySpan:wikitext(data.display)
display = tostring(displaySpan)
end
-- Render the link
local link
if data.isUrl then
link = string.format('[%s %s]', data.link, display)
else
link = string.format('[[%s|%s]]', data.link, display)
end
return string.format('<span class="plainlinks">%s</span>', link)
end
function p.renderTrackingCategories(args)
if yesno(args.category) == false then
return ''
end
local class = args.class and args.class:lower()
if class == 'ui-button-green'
or class == 'ui-button-blue'
or class == 'ui-button-red'
then
return '[[Category:Pages using old style ui-button-color]]'
else
return ''
end
end
return p
Template:Clickable_button_2
https://wiki.devaine.cz/index.php/Šablona:Clickable button 2
{{#invoke:Clickable button 2|main}}<noinclude>
{{documentation}}
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. -->
</noinclude>
Otestovat pak můžeme takto. Syntaxe:
# interní url
{{Clickable button 2|Main Page}}
# externí někam ven
{{Clickable button 2|Main Page|url=http://en.wikipedia.org}}
Visual editor
Zde můžete vidět, jak všech pět šablon vypadá:
Dnes jsme si tedy ukázali základní pravidla pro práci ve wikině. Dále jsme si ukázali, jak jednoduše vytvářet šablony, jak je kopírovat z jiných wikin, že lze mít jako další stránku i vlastní css styl, nebo jak fungují moduly psané v Lua. Vše je opis z mé interní dokumentace a postupy jsem otestoval v testovací VM, tak snad není nikde technická chyba.
Zdar Max
Tiskni
Sdílej:
gcc -march=native -E -v - </dev/null 2>&1 | grep cc1 | grep -o -P "(?<=march=)[^ ]+"Keď použijem šablónu, tak zobrazí len "
grep cc1", zbytok pred tým aj za tým šablóna zahodí:
{{Command|1 = gcc -march=native -E -v - </dev/null 2>&1 | grep cc1 | grep -o -P "(?<=march=)[^ ]+"}}
Ako tam dostať tú rúru?
{{Command|1 = gcc -march=native -E -v - </dev/null 2>&1 {{!}} grep cc1 {{!}} grep -o -P "(?<=march=)[^ ]+"}}
.lidi jako Max, Jenda a Want stojí za úpadkem ábíčka
Kdyby to nekdo vlastnil tak je tady bambilion reklam, prevazne nijak nesouvisejicich s IT, idealne sracky od google-ad. Takto to vsem vyhovuje: