66 575
contributi
(Typo) |
mNessun oggetto della modifica |
||
(55 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 | ||
mw.smw.set(PropName .. " = " .. PropValue) | mw.smw.set(PropName .. " = " .. PropValue) | ||
end | end | ||
--- Process the value assigned to "EpisodioPersonaggi" of the "old-style" | --- OLD simpler original version | ||
-- Process the value assigned to "EpisodioPersonaggi" of the "old-style" | |||
-- template (pre-DataTrek) to sanitize it and pass it as clean value to | -- template (pre-DataTrek) to sanitize it and pass it as clean value to | ||
-- SMW property using the #set function | -- SMW property using the #set function | ||
Riga 299: | Riga 327: | ||
-- @param frame The interface to the parameters passed to {{#invoke:}} | -- @param frame The interface to the parameters passed to {{#invoke:}} | ||
-- No return @return Sanitized string representing one or more property values | -- No return @return Sanitized string representing one or more property values | ||
function p. | function p.PerformersToSemanticOriginal(frame) | ||
local InputString | local InputString | ||
local Character | local Character | ||
Riga 313: | Riga 341: | ||
Character = string.gsub(Character, "|.*","") | Character = string.gsub(Character, "|.*","") | ||
--print("Character: " .. Character, "Performer: " .. Performer) | --print("Character: " .. Character, "Performer: " .. Performer) | ||
mw.smw.set("Personaggio=" .. Character) | |||
mw.smw.set("Interprete=" .. Performer) | |||
mw.smw.set(Performer .. " = " .. Character) | |||
end | |||
end | |||
--- NEW improved version | |||
-- Process the values assigned to "EpisodioPersonaggi" parameter of the | |||
-- "old-style" template (pre-DataTrek) to sanitize it and pass it | |||
-- as clean value to SMW property using the #set function | |||
-- | |||
-- @param frame The interface to the parameters passed to {{#invoke:}} | |||
-- No return @return Sanitized string representing one or more property values | |||
function p.PerformersToSemantic(frame) | |||
local InputString | |||
local Pattern | |||
InputString = frame.args[1] .. "\n" | |||
for FullRow in string.gmatch(InputString, "%*.-\n") do | |||
local Character | |||
local Performer | |||
--Remove italic | |||
FullRow = string.gsub(FullRow, "<i>", "") | |||
FullRow = string.gsub(FullRow, "</i>", "") | |||
--print (FullRow) | |||
local CountLiks = select(2, string.gsub(FullRow, "%[%[", "")) | |||
--print (CountLiks) | |||
if string.find(FullRow, ":") == nil then | |||
--Character only, unknown performer | |||
Pattern = "%*.-%[%[(.-)%]%].-" | |||
_, _, Character = string.find(FullRow, Pattern) | |||
Performer = "Interprete non accreditato" | |||
else | |||
if CountLiks == 2 then | |||
--Two links in the string, process both | |||
--print("Two links") | |||
Pattern = "%*.-%[%[(.-)%]%].-:%s?%[%[(.-)%]%]" | |||
elseif CountLiks == 1 then | |||
--Character is not a linked entity | |||
--print("One link") | |||
Pattern = "%*%s?(.-)%s?:%s?%[%[(.-)%]%]" | |||
else | |||
--error no links on either side | |||
Pattern = "%*%s?(.-)%s?:%s?(.-)%s?\n" | |||
end | |||
_, _, Character, Performer = string.find(FullRow, Pattern) | |||
end | |||
Character = string.gsub(Character, "|.*","") | |||
--print(" Character: " .. Character, "Performer: " .. Performer) | |||
--print(string.rep("-",100)) | |||
mw.smw.set("Personaggio=" .. Character) | mw.smw.set("Personaggio=" .. Character) | ||
mw.smw.set("Interprete=" .. Performer) | mw.smw.set("Interprete=" .. Performer) | ||
Riga 328: | 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 |