Modulo:FunzioniGeneriche: differenze tra le versioni

Vai alla navigazione Vai alla ricerca
New PerformersToSemantic version
(Typo)
(New PerformersToSemantic version)
Riga 293: Riga 293:
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 300:
-- @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.PerformersToSemantic(frame)
function p.PerformersToSemanticOriginal(frame)
local InputString
local InputString
local Character
local Character
Riga 313: Riga 314:
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]
for FullRow in string.gmatch(InputString, "%*.-/n") do
local Character
local Performer
--print (FullRow)
local CountLiks = select(2, string.gsub(FullRow, "%[%[", ""))
--print (CountLiks)
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)
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)

Menu di navigazione