67 692
contributi
Nessun oggetto della modifica |
mNessun oggetto della modifica |
||
(44 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 79: | Riga 79: | ||
Cell:node(List) | Cell:node(List) | ||
else | else | ||
Cell | if type(Field[1]) == "table" then | ||
:wikitext(Field[1]) | Cell | ||
:wikitext(Field[1][1]) | |||
else | |||
Cell | |||
:wikitext(Field[1]) | |||
end | |||
end | end | ||
end | end | ||
Riga 241: | Riga 246: | ||
end | end | ||
--Removes suffix | --Removes suffix year or number specification | ||
FullName = FullName:gsub("%s%(%d+%)", "") | |||
--Removes suffix registry number | |||
FullName = FullName:gsub("%s[^%s]+$", "") | FullName = FullName:gsub("%s[^%s]+$", "") | ||
Riga 270: | Riga 277: | ||
local PropName | local PropName | ||
local PropValue | local PropValue | ||
local LIPattern | |||
if frame.args[1] == nil then | if frame.args[1] == nil then | ||
Riga 279: | Riga 287: | ||
else | else | ||
ParaString = frame.args[2] | ParaString = frame.args[2] | ||
if string.find(ParaString, "<li>") | if string.find(ParaString, "<li>") == nil then | ||
-- | -- Add dummy tags to use a single process afterwards | ||
ParaString = "<li>" .. ParaString .. "</li>" | |||
end | |||
if string.find(ParaString, "%[%[") == nil then | |||
-- There is no wikilink, plain text | |||
LIPattern = "<li>(.-)</li>" | |||
else | else | ||
-- | -- A wikilink is present, discard surrounding text | ||
LIPattern = "<li>.-%[%[(.-)%]%].-</li>" | |||
end | end | ||
-- Determine if property is Assignment, so process a string like: | |||
-- [[Timeline 2267|2267]] <i>[[USS Enterprise NCC-1701|USS Enterprise]]</i> | |||
if PropName == "Assegnazione" then | |||
-- then remove italic | |||
ParaString = string.gsub(ParaString, "<i>", "") | |||
ParaString = string.gsub(ParaString, "</i>", "") | |||
-- then remove Timeline | |||
ParaString = string.gsub(ParaString, "(%[%[Timeline.-%]%])", "") | |||
end | |||
--Process UL or OL | |||
for Item in string.gmatch(ParaString, LIPattern) do | |||
Item = string.gsub(Item, "(|.*)", "") | |||
table.insert(FinalArray, Item) | |||
end | |||
PropValue = table.concat(FinalArray, Separator) .. SepDeclaration | |||
end | end | ||
end | end | ||
Riga 336: | Riga 362: | ||
local Character | local Character | ||
local Performer | local Performer | ||
--Remove italic | |||
FullRow = string.gsub(FullRow, "<i>", "") | |||
FullRow = string.gsub(FullRow, "</i>", "") | |||
--print (FullRow) | --print (FullRow) | ||
local CountLiks = select(2, string.gsub(FullRow, "%[%[", "")) | local CountLiks = select(2, string.gsub(FullRow, "%[%[", "")) | ||
Riga 377: | Riga 407: | ||
end | end | ||
return mw.text.nowiki(table.concat(FinalArray, Separator) .. SepDeclaration) | return mw.text.nowiki(table.concat(FinalArray, Separator) .. SepDeclaration) | ||
end | |||
--- Check if a file is SVG and validate it | |||
-- | |||
-- @param frame The interface to the parameters passed to {{#invoke:}} | |||
-- @return Processed string | |||
function p.SVGValidate(frame) | |||
local ValidateURI = "http://validator.w3.org/check?uri=" | |||
local FileTitle | |||
local MediaURI | |||
FileTitle = mw.title.getCurrentTitle() | |||
if string.lower(string.sub(FileTitle.fullText, -4)) == ".svg" then | |||
--file is Scalable Vector Graphics | |||
MediaURI = frame:callParserFunction('filepath:' .. string.sub(FileTitle.fullText, 6)) | |||
--return FileTitle.fullText .. "<br />" .. FileTitle:fullUrl() .. "<br />" .. FileTitle:localUrl() .. "<br />" .. FileTitle:canonicalUrl() .. "<br />" .. MediaURI | |||
return "\n== Validazione ==\n" .. "[[File:Valid SVG 1.1.svg|88px|link=" .. ValidateURI .. mw.uri.encode(MediaURI, "PATH") .. "]]" | |||
else | |||
return nil | |||
end | |||
end | end | ||
return p | return p |