Importer, Bürokraten, Moderatoren (CommentStreams), Strukturierte-Diskussionen-Bots, Oberflächenadministratoren, Push-Abonnementverwalter, Oversighter, Administratoren, Kampagnenbearbeiter (Hochladeassistent)
855
Bearbeitungen
w>Schniggendiller (c/p aus https://de.wikipedia.beta.wmflabs.org/w/index.php?title=Modul:WLink&oldid=22453 (gemäß Spezial:PermaLink/179296556/1× c&p TIA)) |
K (35 Versionen von wikivoyage:Modul:WLink importiert) |
||
| (15 dazwischenliegende Versionen von 9 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
local WLink = { suite = "WLink", | local WLink = { suite = "WLink", | ||
serial = " | serial = "2016-10-05" }; | ||
--[=[ | --[=[ | ||
ansiPercent() | ansiPercent() | ||
| Zeile 13: | Zeile 12: | ||
getLanguage() | getLanguage() | ||
getNamespace() | getNamespace() | ||
getPlain() | getPlain() | ||
getProject() | getProject() | ||
getTarget() | getTarget() | ||
getTargetPage() | getTargetPage() | ||
getTitle() | getTitle() | ||
| Zeile 28: | Zeile 25: | ||
isInterwiki() | isInterwiki() | ||
isMedia() | isMedia() | ||
isTitledLink() | isTitledLink() | ||
isValidLink() | isValidLink() | ||
| Zeile 337: | Zeile 333: | ||
end | end | ||
end -- for --i | end -- for --i | ||
r = mw.ustring.gsub(r, '^%*', '%%2A') | |||
return r; | return r; | ||
end -- WLink.ansiPercent() | end -- WLink.ansiPercent() | ||
| Zeile 439: | Zeile 436: | ||
return r; | return r; | ||
end -- WLink.getBaseTitle() | end -- WLink.getBaseTitle() | ||
function WLink.getEscapedTitle( attempt ) | function WLink.getEscapedTitle( attempt ) | ||
| Zeile 448: | Zeile 443: | ||
-- Postcondition: | -- Postcondition: | ||
-- Returns string, with suitable link title | -- Returns string, with suitable link title | ||
return | local s = mw.text.trim( attempt ); | ||
return s:gsub( "\n", " " ) | |||
:gsub( "%[", "[" ) | |||
:gsub( "%]", "]" ) | |||
:gsub( "|", "|" ); | |||
end -- WLink.getEscapedTitle() | end -- WLink.getEscapedTitle() | ||
function WLink.getExtension( attempt ) | function WLink.getExtension( attempt ) | ||
| Zeile 598: | Zeile 592: | ||
return r; | return r; | ||
end -- WLink.getNamespace() | end -- WLink.getNamespace() | ||
| Zeile 647: | Zeile 603: | ||
local r = attempt; | local r = attempt; | ||
local i = 1; | local i = 1; | ||
local j, k, n, lean, s, shift | local j, k, n, lean, s, shift, space, suffix; | ||
while ( true ) do | while ( true ) do | ||
j = r:find( "[", i, true ); | j = r:find( "[", i, true ); | ||
| Zeile 686: | Zeile 642: | ||
end | end | ||
else | else | ||
s, shift = extractExtlink( suffix ); | |||
if | if not s then | ||
s = ""; | |||
end | |||
if not shift then | |||
shift = ""; | |||
shift = | |||
end | end | ||
i = i - 1; | i = i - 1; | ||
| Zeile 733: | Zeile 688: | ||
return r; | return r; | ||
end -- WLink.getProject() | end -- WLink.getProject() | ||
| Zeile 870: | Zeile 800: | ||
end | end | ||
if URLutil.isResourceURL( attempt ) then | if URLutil.isResourceURL( attempt ) then | ||
local site | local site = URLutil.getAuthority( attempt ); | ||
local show; | local show; | ||
if #attempt == #site then | if #attempt == #site then | ||
| Zeile 878: | Zeile 807: | ||
show = URLutil.getTop3domain( "//" .. site ); | show = URLutil.getTop3domain( "//" .. site ); | ||
if show then | if show then | ||
local scan = "[%./](%a | local scan = "[%./](%a+)(%.%l%l%.)(%a+)$"; | ||
local search = "." .. show; | local search = "." .. show; | ||
local s1, s2, s3 = search:match( scan ); | local s1, s2, s3 = search:match( scan ); | ||
if s2 then | if s2 then | ||
if not second:find( s2, 1, true ) then | if not second:find( s2, 1, true ) then | ||
show = string.format( "%s%s", | show = string.format( "%s.%s", s2, s3 ); | ||
end | end | ||
else | else | ||
| Zeile 895: | Zeile 824: | ||
end | end | ||
end | end | ||
r = string.format( "[%s %s]", attempt, show ); | |||
r = string.format( "[%s %s]", | |||
else | else | ||
r = attempt; | r = attempt; | ||
| Zeile 1.037: | Zeile 963: | ||
return r; | return r; | ||
end -- WLink.isMedia() | end -- WLink.isMedia() | ||
| Zeile 1.127: | Zeile 1.031: | ||
-- Postcondition: | -- Postcondition: | ||
-- Returns table or false | -- Returns table or false | ||
-- table of assignments with { type, value } | -- table of assignments with { type, value} | ||
-- type is one of "lead", | -- type is one of "lead", | ||
-- "project", "lang", | -- "project", "lang", | ||
| Zeile 1.201: | Zeile 1.105: | ||
-- Retrieve versioning and check for compliance | -- Retrieve versioning and check for compliance | ||
-- Precondition: | -- Precondition: | ||
-- assert -- string, with required version | -- assert -- string, with required version, or false | ||
-- Postcondition: | -- Postcondition: | ||
-- Returns string with appropriate version, or false | -- Returns string with appropriate version, or false | ||
local r; | local r; | ||
if | if assert and assert > WLink.serial then | ||
r = false; | |||
else | |||
r = WLink.serial; | |||
end | end | ||
return r | return r | ||
end -- WLink.failsafe() | end -- WLink.failsafe() | ||
| Zeile 1.255: | Zeile 1.139: | ||
s = mw.text.trim( v ); | s = mw.text.trim( v ); | ||
end | end | ||
elseif | elseif action == "ansiPercent" and k == "space" then | ||
if v ~= "" then | if v ~= "" then | ||
space = v; | space = v; | ||
| Zeile 1.287: | Zeile 1.170: | ||
end | end | ||
else | else | ||
r = string.format( "<span class=\"error\">%s</span>", r ); | |||
end | end | ||
return r; | return r; | ||
| Zeile 1.331: | Zeile 1.212: | ||
p.getNamespace = function ( frame ) | p.getNamespace = function ( frame ) | ||
return tostring( Template( frame, "getNamespace" ) ); | return tostring( Template( frame, "getNamespace" ) ); | ||
end | end | ||
p.getPlain = function ( frame ) | p.getPlain = function ( frame ) | ||
| Zeile 1.340: | Zeile 1.218: | ||
p.getProject = function ( frame ) | p.getProject = function ( frame ) | ||
return Template( frame, "getProject" ); | return Template( frame, "getProject" ); | ||
end | end | ||
p.getTarget = function ( frame ) | p.getTarget = function ( frame ) | ||
| Zeile 1.376: | Zeile 1.251: | ||
p.isMedia = function ( frame ) | p.isMedia = function ( frame ) | ||
return Template( frame, "isMedia" ); | return Template( frame, "isMedia" ); | ||
end | end | ||
p.isTitledLink = function ( frame ) | p.isTitledLink = function ( frame ) | ||
| Zeile 1.393: | Zeile 1.265: | ||
end | end | ||
p.failsafe = function ( frame ) | p.failsafe = function ( frame ) | ||
local since = frame.args[ 1 ]; | |||
local | |||
if since then | if since then | ||
since = mw.text.trim( since ); | since = mw.text.trim( since ); | ||