Modul:Vorlage:Dokumentation: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
te>PerfektesChaos (2017-11-07) |
K (11 Versionen importiert) |
||
(6 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
− | --[=[ | + | --[=[ 2019-07-29 |
{{Dokumentation}} | {{Dokumentation}} | ||
]=] | ]=] | ||
+ | |||
+ | |||
+ | |||
+ | local Current = mw.title.getCurrentTitle() | ||
Zeile 19: | Zeile 23: | ||
return tostring( e ) | return tostring( e ) | ||
end -- fake() | end -- fake() | ||
+ | |||
+ | |||
+ | |||
+ | local function fatal( amend ) | ||
+ | local s = "Wikipedia:Vorlagenfehler/Vorlage:Dokumentation" | ||
+ | if amend then | ||
+ | s = string.format( "%s/%s", s, amend ) | ||
+ | end | ||
+ | return string.format( "[[Kategorie:%s]]", s ) | ||
+ | end -- fatal() | ||
Zeile 59: | Zeile 73: | ||
− | local function furnish( area ) | + | local function furnish( area, frame ) |
local i = area:find( "==", 1, true ) | local i = area:find( "==", 1, true ) | ||
local r | local r | ||
Zeile 86: | Zeile 100: | ||
r = "__NOTOC__\n" .. area | r = "__NOTOC__\n" .. area | ||
elseif n == 2 then | elseif n == 2 then | ||
− | local toc = mw.html.create( "div" ) | + | local src = "TOC nonum/styles.css" |
− | + | local toc = mw.html.create( "div" ) | |
− | + | :newline() | |
− | + | :addClass( "nonumtoc" ) | |
− | + | :wikitext( "__TOC__" ) | |
− | toc = tostring( toc ) | + | :newline() |
+ | local styles = frame:extensionTag( "templatestyles", | ||
+ | nil, | ||
+ | { src = src } ) | ||
+ | toc = styles .. tostring( toc ) | ||
if init == 1 then | if init == 1 then | ||
r = toc .. area | r = toc .. area | ||
else | else | ||
r = string.format( "%s%s%s", | r = string.format( "%s%s%s", | ||
+ | area:sub( 1, init - 1 ), | ||
toc, | toc, | ||
− | |||
area:sub( init ) ) | area:sub( init ) ) | ||
end | end | ||
Zeile 109: | Zeile 127: | ||
local function f( frame ) | local function f( frame ) | ||
local bottom = { } | local bottom = { } | ||
− | + | local doku = mw.title.makeTitle( Current.namespace, | |
− | local doku = mw.title.makeTitle( | + | Current.text .. "/Doku" ) |
− | + | local sub = Current.prefixedText .. "/Doku" | |
− | local sub = | ||
local r | local r | ||
if doku.exists then | if doku.exists then | ||
Zeile 118: | Zeile 135: | ||
if not findeSchalter( r ) then | if not findeSchalter( r ) then | ||
if not findeTemplateDataTOC( r ) then | if not findeTemplateDataTOC( r ) then | ||
− | r = furnish( r ) | + | r = furnish( r, frame ) |
end | end | ||
end | end | ||
Zeile 137: | Zeile 154: | ||
if mw.site.server:match( "%.beta%.wmflabs%.org$" ) then | if mw.site.server:match( "%.beta%.wmflabs%.org$" ) then | ||
r = r .. fake( frame, sub ) | r = r .. fake( frame, sub ) | ||
− | elseif | + | elseif Current.namespace == 10 then |
r = string.format( "%s[[Kategorie:%s]]", | r = string.format( "%s[[Kategorie:%s]]", | ||
r, | r, | ||
Zeile 145: | Zeile 162: | ||
r = r .. frame:expandTemplate{ title = "Dokumentation/footer", | r = r .. frame:expandTemplate{ title = "Dokumentation/footer", | ||
args = bottom } | args = bottom } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
return r | return r | ||
end -- f() | end -- f() | ||
Zeile 160: | Zeile 168: | ||
local p = {} | local p = {} | ||
+ | |||
+ | function p.hastemplate( frame ) | ||
+ | -- OBSOLETING | ||
+ | local r = Current.text:gsub( "/Doku$", "" ) | ||
+ | :gsub( " ", "_" ) | ||
+ | :gsub( "\"", """ ) | ||
+ | if Current.namespace ~= 10 then | ||
+ | r = string.format( "%s:%s", | ||
+ | mw.site.namespaces[ Current.namespace ].name, | ||
+ | r ) | ||
+ | end | ||
+ | return string.format( "hastemplate:%s+", r ) | ||
+ | end -- p.hastemplate() | ||
+ | |||
+ | |||
+ | |||
+ | function p.transcludes() | ||
+ | local s = Current.text:gsub( "/Doku$", "" ) | ||
+ | :gsub( " ", "_" ) | ||
+ | :gsub( "\"", """ ) | ||
+ | local t = mw.title.new( "Suche", -1 ) | ||
+ | if Current.namespace ~= 10 then | ||
+ | s = string.format( "%s:%s", | ||
+ | mw.site.namespaces[ Current.namespace ].name, | ||
+ | s ) | ||
+ | end | ||
+ | s = string.format( "hastemplate:%s ", s ) | ||
+ | return t:fullUrl( { search = s } ) | ||
+ | end -- p.transcludes() | ||
+ | |||
+ | |||
function p.f( frame ) | function p.f( frame ) | ||
Zeile 167: | Zeile 206: | ||
:attr( "class", "error" ) | :attr( "class", "error" ) | ||
:wikitext( r ) | :wikitext( r ) | ||
− | r = | + | r = tostring( e ) .. fatal( "Intern" ) |
− | |||
− | |||
− | |||
end | end | ||
return r | return r |
Aktuelle Version vom 6. September 2019, 12:27 Uhr
--[=[ 2019-07-29
Documentation
Lua-Fehler: Der Prozess konnte nicht erstellt werden: proc_open(/dev/null): failed to open stream: Operation not permitted ]=]
local Current = mw.title.getCurrentTitle()
local function fake( frame, access )
local s = string.format( "[%s/%s %s]", "https://de.wikipedia.org/wiki", mw.uri.encode( access, "WIKI" ), "Doku in der echten deWP" ) local e = mw.html.create( "div" ) e:css( "border", "#A000A0 2px solid" ) :css( "padding", "1em" ) :wikitext( "#REDIRECT" ) :node( mw.html.create( "span" ) :addClass( "redirectText" ) :wikitext( s ) ) return tostring( e )
end -- fake()
local function fatal( amend )
local s = "Wikipedia:Vorlagenfehler/Vorlage:Dokumentation" if amend then s = string.format( "%s/%s", s, amend ) end return string.format( "", s )
end -- fatal()
local function findeSchalter( area )
local i = area:find( "__", 1, true ) local r if i then
r = area:find( "
", i, true ) or
area:find( "", i, true ) or area:find( "", i, true ) or area:find( "", i, true ) or area:find( "", i, true ) end return r
end -- findeSchalter()
local function findeTemplateDataTOC( area )
local i = area:find( "emplateData", 3, true ) local r if i then if area:find( "TOC", i + 11, true ) then local k if i > 100 then i = i - 100 else i = 1 end i, k = area:find( "%{%{%s*[tT]emplateData%s*|", i ) if i then r = area:find( "|%s*TOC%s*=%s*1%s*[|}]", k - 1 ) end end end return r
end -- findeTemplateDataTOC()
local function furnish( area, frame )
local i = area:find( "==", 1, true ) local r if i then local seek = "==[^\n]+==\n" local init, k, n if i == 1 then i, k = area:find( seek, 1 ) if i == 1 then n = 1 end end seek = "\n" .. seek if i and not n then i, k = area:find( seek, i - 1 ) end if i then n = 1 init = i i, k = area:find( seek, k - 1 ) if i then n = 2 end end if n == 1 then r = "\n" .. area elseif n == 2 then local src = "TOC nonum/styles.css" local toc = mw.html.create( "div" ) :newline() :addClass( "nonumtoc" ) :wikitext( "" ) :newline() local styles = frame:extensionTag( "templatestyles", nil, { src = src } ) toc = styles .. tostring( toc ) if init == 1 then r = toc .. area else r = string.format( "%s%s%s", area:sub( 1, init - 1 ), toc, area:sub( init ) ) end end end return r or area
end -- furnish()
local function f( frame )
local bottom = { } local doku = mw.title.makeTitle( Current.namespace, Current.text .. "/Doku" ) local sub = Current.prefixedText .. "/Doku" local r if doku.exists then r = frame:expandTemplate{ title = sub } if not findeSchalter( r ) then if not findeTemplateDataTOC( r ) then r = furnish( r, frame ) end end bottom.lonely = "1" else local create = { action = "edit", preload = "Vorlage:Dokumentation/preload-doku", summary = "Neu angelegt", redlink = "1" } local path = { sub, mw.uri.buildQueryString( create ) } local setup = frame:callParserFunction( "fullurl", path ) local button = { Typ = "progressive", ["Groß"] = "1", Link = setup, Text = "Neue Doku-Unterseite anlegen" } r = frame:expandTemplate{ title = "MediaWiki-Button", args = button } if mw.site.server:match( "%.beta%.wmflabs%.org$" ) then r = r .. fake( frame, sub ) elseif Current.namespace == 10 then r = string.format( "%s", r, "Vorlage:nicht dokumentiert" ) end end r = r .. frame:expandTemplate{ title = "Dokumentation/footer", args = bottom } return r
end -- f()
local p = {}
function p.hastemplate( frame )
-- OBSOLETING local r = Current.text:gsub( "/Doku$", "" ) :gsub( " ", "_" ) :gsub( "\"", """ ) if Current.namespace ~= 10 then r = string.format( "%s:%s", mw.site.namespaces[ Current.namespace ].name, r ) end return string.format( "hastemplate:%s+", r )
end -- p.hastemplate()
function p.transcludes()
local s = Current.text:gsub( "/Doku$", "" ) :gsub( " ", "_" ) :gsub( "\"", """ ) local t = mw.title.new( "Suche", -1 ) if Current.namespace ~= 10 then s = string.format( "%s:%s", mw.site.namespaces[ Current.namespace ].name, s ) end s = string.format( "hastemplate:%s ", s ) return t:fullUrl( { search = s } )
end -- p.transcludes()
function p.f( frame )
local lucky, r = pcall( f, frame ) if not lucky then local e = mw.html.create( "span" ) :attr( "class", "error" ) :wikitext( r ) r = tostring( e ) .. fatal( "Intern" ) end return r
end -- p.f()
return p