Anonimo

Modulo:DTGenerico: differenze tra le versioni

Da Wikitrek.
Link to HT Sezione ID
mNessun oggetto della modifica
(Link to HT Sezione ID)
(194 versioni intermedie di uno stesso utente non sono mostrate)
Riga 7: Riga 7:
--local OperatorTree = require('Modulo:DTFunzioniComuni').OperatorTree
--local OperatorTree = require('Modulo:DTFunzioniComuni').OperatorTree
local PropertiesOnTree = require('Modulo:DTFunzioniComuni').PropertiesOnTree
local PropertiesOnTree = require('Modulo:DTFunzioniComuni').PropertiesOnTree
 
local ShipNameCore = require('Modulo:FunzioniGeneriche').ShipNameCore
local p = {}
local p = {}
function p.QFromP(Property)
function p.QFromP(Property)
Riga 19: Riga 20:
function p.DIVImage(frame)
function p.DIVImage(frame)
local ImageFileName
local ImageFileName
local ImageProperties = {"P11", "P37"}
local Item = mw.wikibase.getEntity()
local Item = mw.wikibase.getEntity()
Riga 25: Riga 27:
end
end
local Markup
local Markup = ""
if Item['claims']['P37'] then
local FileTitle = "File:" .. Item['claims']['P37'][1].mainsnak.datavalue['value']
-- TODO
local FileCaption = frame:expandTemplate{title = FileTitle}
-- If there are multiple images, then create a carousel
--Markup = "<div class='separatorebox'>'''Immagine'''</div>" ..  "<div class='contenitoreimgbox'>[[File:" .. Item['claims']['P37'][1].mainsnak.datavalue['value'] .. "|100%]]</div>"
-- Example from https://data.wikitrek.org/wiki/Item:Q5641
--Markup = "<div class='separatorebox'>'''Immagine'''</div>" .. "<div class='contenitoreimgbox'>[[" .. FileTitle .. "|alt={{" .. FileTitle .. "}}|{{" .. FileTitle .. "}}" .. "]]</div>"
-- <gallery mode="slideshow" widths=100% heights=350px>
Markup = "<div class='separatorebox'>'''Immagine'''</div>" ..  "<div class='contenitoreimgbox'>[[" .. FileTitle .. "|alt=" .. FileCaption .. "|" .. FileCaption .. "]]<br /><span style='font-size: smaller;'>" .. FileCaption .. "</span></div>"
-- File:Dis1x3 discovery1031.jpg|caption|alt=alt language
else
-- File:Dis3x6 discovery1031a.jpg|caption|alt=alt language
Markup = ""
-- </gallery>
for _, Property in pairs(ImageProperties) do
if Item['claims'][Property] then
local FileTitle
local FileCaption
local FileName = Item['claims'][Property][1].mainsnak.datavalue['value']
File = mw.title.new( FileName, "File" )
FileTitle = "File:" .. FileName
if File.exists then
FileCaption = frame:expandTemplate{title = FileTitle}
else
FileCaption = "Immagine da Commons"
end
Markup = Markup .. "<div class='separatorebox'>'''Immagine'''</div>" ..  "<div class='contenitoreimgbox'>[[" .. FileTitle .. "|alt=" .. FileCaption .. Property .. "|" .. FileCaption .. "]]<br /><span style='font-size: smaller;'>" .. FileCaption .. "</span></div>"
end
end
end
return Markup
return Markup
end
end
function p.Title(frame)
function p.Title(frame)
Riga 65: Riga 83:
local HTMLTable
local HTMLTable
local CollectionTable = ''
local CollectionTable = ''
local ExcludeP = {P3 = true, P14 = false, P26 = true, P30 = true, P37 = true, P58 = true, P68 = true, P52 = true, P79 = true, P90 = true}
local ExcludeP = {}
local POnTree = {}
local POnTree = {}
local Item = mw.wikibase.getEntity()
local Item = mw.wikibase.getEntity()
local ItemQ = mw.wikibase.getEntityIdForCurrentPage()
local ItemQ = mw.wikibase.getEntityIdForCurrentPage()
local InstanceQ
local IsEpisode = false
local OperatorName = ""
local AstroRA = nil
local AstroD = nil
local ListProp = {}
local PageName
if not Item then
if not Item then
Item = mw.wikibase.getEntity('Q1')
Item = mw.wikibase.getEntity('Q1')
Riga 76: Riga 102:
AddSemantic = true
AddSemantic = true
end
end
if frame.args['IsEpisode'] ~= nil then
IsEpisode = frame.args['IsEpisode']
end
ExcludeP = {P3 = true, P7 = true, P8 = true, P11 = true, P21 = IsEpisode, P23 = true, P26 = true, P37 = true,  P46 = true, P58 = true, P68 = true, P52 = true, P79 = true, P90 = true, P104 = true, P162 = true}
AllP = mw.wikibase.orderProperties(Item:getProperties())
AllP = mw.wikibase.orderProperties(Item:getProperties())
Riga 84: Riga 116:
PageTitle =  mw.title.getCurrentTitle()
PageTitle =  mw.title.getCurrentTitle()
if (mw.wikibase.getLabelByLang(ItemQ, 'en')) and (mw.wikibase.getLabelByLang(ItemQ, 'en')) ~= PageTitle.text then
if (mw.wikibase.getLabelByLang(ItemQ, 'en')) and (mw.wikibase.getLabelByLang(ItemQ, 'en')) ~= PageTitle.text then
AllRows[#AllRows + 1] = {AddSemantic .. "In originale:", {mw.wikibase.getLabelByLang(ItemQ, 'en')}}
AllRows[#AllRows + 1] = {"In originale:", {mw.wikibase.getLabelByLang(ItemQ, 'en')}}
end
end
if (mw.wikibase.getLabelByLang(ItemQ, 'it')) and (mw.wikibase.getLabelByLang(ItemQ, 'it')) ~= PageTitle.text then
if (mw.wikibase.getLabelByLang(ItemQ, 'it')) then
AllRows[#AllRows + 1] = {"In italiano:", {mw.wikibase.getLabelByLang(ItemQ, 'it')}}
local ITLabel
local ITValue
if IsEpisode or IsBook or IsFilm then
ITLabel = "Titolo italiano"
else
ITLabel = "In italiano"
end
ITValue = mw.wikibase.getLabelByLang(ItemQ, 'it')
if AddSemantic then
mw.smw.set(ITLabel .. "=" .. ITValue)
end
PageName = ITValue
if (mw.wikibase.getLabelByLang(ItemQ, 'it')) ~= PageTitle.text then
AllRows[#AllRows + 1] = {ITLabel .. ":", {ITValue}}
end
end
end
for _, Property in pairs(AllP) do
--Process AKA
if Item.aliases ~= nil and Item.aliases["it"] ~= nil then
local AccValues = {}
for _, Alias in pairs(Item.aliases["it"]) do
table.insert(AccValues, Alias.value)
end
table.insert(AllRows, {"Alias:", AccValues})
end
--mw.smw.set("AllP=" .. table.concat(AllP, ","))
for _, Property in ipairs(AllP) do
table.insert(ListProp, Property)
if (not ExcludeP[Property]) and Item.claims[Property][1].mainsnak.datatype ~= 'external-id' then
if (not ExcludeP[Property]) and Item.claims[Property][1].mainsnak.datatype ~= 'external-id' then
-- START specific property
if Property == "P46" then
if Property == "P46" then
-- Collection
-- Collection
Riga 96: Riga 155:
elseif (Property == "P7" or Property == "P23") and CollectionTable == '' then
elseif (Property == "P7" or Property == "P23") and CollectionTable == '' then
--Previous or Next
--Previous or Next
CollectionTable = string.char(10) .. MakeNavTable(Item.claims, Item.claims[Property][1].mainsnak.datavalue.value)
CollectionTable = string.char(10) .. MakeNavTable(Item.claims, nil)
elseif (Property == "P80" or Property == "P82") then
--Right Ascension or Declination
if Property == "P80" then
--Right ascension
AstroRA = Item.claims[Property][1].mainsnak.datavalue.value.amount
else
--Declination
AstroD = Item.claims[Property][1].mainsnak.datavalue.value.amount
end
if (AstroRA ~= nil and AstroD ~= nil) then
AllRows[#AllRows + 1] = {{"P80 e P82", "Coordinate celesti"}, {p.SkyMapLink(AstroRA, AstroD)}}
end
elseif Property == "P14" then
elseif Property == "P14" then
--Instance
--Instance
POnTree = {{"P40", 3, false}, {"P41", 3, false}, {"P88", 3, false}}
POnTree = {{"P40", 3, false}, {"P41", 3, false}, {"P88", 3, false}}
for _, Prop in pairs(POnTree) do
for _, Prop in pairs(POnTree) do
local PropValue = table.concat(PropertiesOnTree(Prop[1], Prop[2], Prop[3], true))
--local PropValue = table.concat(PropertiesOnTree(Prop[1], Prop[2], Prop[3], true))
local PropValue = PropertiesOnTree(Prop[1], Prop[2], Prop[3], true)
if (PropValue ~= nil) and (PropValue ~= "") then
if (PropValue ~= nil) and (PropValue ~= "") then
local PropName = mw.wikibase.getLabelByLang(Prop[1], 'it') or mw.wikibase.getLabel(Prop[1])
local PropName = mw.wikibase.getLabelByLang(Prop[1], 'it') or mw.wikibase.getLabel(Prop[1])
AllRows[#AllRows + 1] = {{Prop[1], PropName .. ":"}, {PropValue}}
--AllRows[#AllRows + 1] = {{Prop[1], PropName .. ":"}, {PropValue}}
AllRows[#AllRows + 1] = {{Prop[1], PropName}, {PropValue}}
if Prop[1] == "P41" then
--String to be used with P88 Naval Class
--OperatorName = string.sub(PropValue, 2, -2)
--OperatorName = string.sub("[[Flotta Stellare]]", 3, -3)
--OperatorName = string.gsub("[[Flotta Stellare|Flotta Stellare]]", "|.+]]", ""):gsub("%[%[", "") .. " - "
OperatorName = string.gsub(PropValue, "|.+]]", ""):gsub("%[%[", "") .. " - "
--mw.smw.set("OperatorName1=" .. OperatorName)
end
if AddSemantic then
if AddSemantic then
mw.smw.set(PropName .. "=" .. PropValue)
--mw.smw.set(PropName .. "=" .. PropValue)
end
end
end
end
end
InstanceQ = Item.claims[Property][1].mainsnak.datavalue.value.id
if InstanceQ == "Q876" or InstanceQ == "Q78" then
--Spaceship or starship
mw.smw.set("Nome=" .. ShipNameCore(PageName))
end
end
Riga 118: Riga 207:
mw.smw.set("Operatore=" .. OperatorTree(frame))
mw.smw.set("Operatore=" .. OperatorTree(frame))
end]==]
end]==]
--mw.smw.set("OperatorName2=" .. OperatorName)
-- END specific property
else
else
local Header = {Property, (mw.wikibase.getLabelByLang(Property, 'it') or mw.wikibase.getLabel(Property)) .. ":"} -- or {Property, mw.wikibase.getLabel(Property) .. ":"} --'-' .. Property .. ":"}
-- START Unspecified Property
local Header = {Property, (mw.wikibase.getLabelByLang(Property, 'it') or mw.wikibase.getLabel(Property))} -- .. ":"} -- or {Property, mw.wikibase.getLabel(Property) .. ":"} --'-' .. Property .. ":"}
local Values = Item['claims'][Property]
local Values = Item['claims'][Property]
local AccValues = {}
local AccValues = {}
for _, SnakValue in pairs(Values) do
local Year = ""
--mw.smw.set("OperatorName3=" .. OperatorName)
for _, SnakValue in ipairs(Values) do
local Value = SnakValue.mainsnak.datavalue['value']
local Value = SnakValue.mainsnak.datavalue['value']
--mw.smw.set("OperatorName4=" .. OperatorName)
if (type(Value) == "table") then
if (type(Value) == "table") then
if Property == "P72" then --CASE Assigments
-- DataValue is an array
if Property == "P72" then
--CASE Assigments
local Assignment = ""
local Assignment = ""
local AssLabel = ""
if SnakValue.qualifiers ~= nil then
if SnakValue.qualifiers ~= nil then
if SnakValue.qualifiers['P73'] ~= nil then --Year
-- Timeline year
Assignment = LabelOrLink(SnakValue.qualifiers['P73'][1].datavalue.value['id']) .. " "
if SnakValue.qualifiers['P73'] ~= nil then
Year = LabelOrLink(SnakValue.qualifiers['P73'][1].datavalue.value['id'])
Assignment = Year .. " "
end
-- Prefix
if SnakValue.qualifiers['P15'] ~= nil then
Assignment = Assignment .. SnakValue.qualifiers['P15'][1].datavalue.value .. " "
end
end
end
if SnakValue.qualifiers['P15'] ~= nil then
-- If Wikitrek label (P20) is present, force it
Assignment = Assignment .. SnakValue.qualifiers['P15'][1].datavalue.value .. " "
if SnakValue.qualifiers ~= nil and SnakValue.qualifiers['P20'] ~= nil then
AssLabel = SnakValue.qualifiers['P20'][1].datavalue.value
end
end
if AddSemantic then
Assignment = Assignment .. LabelOrLink(Value['id'], "Assegnazione", true, AssLabel)
else
Assignment = Assignment .. LabelOrLink(Value['id'], "", false, AssLabel)
end
end
Assignment = Assignment .. LabelOrLink(Value['id'])
if SnakValue.qualifiers ~= nil then
if SnakValue.qualifiers ~= nil then
if SnakValue.qualifiers['P76'] then --Rank
-- Suffix
Assignment = Assignment .. ", " .. LabelOrLink(SnakValue.qualifiers['P76'][1].datavalue.value['id'])
if SnakValue.qualifiers['P19'] ~= nil then
end
Assignment = Assignment .. " " .. SnakValue.qualifiers['P19'][1].datavalue.value --.. " "
if SnakValue.qualifiers['P77'] then --Occupation
end
Assignment = Assignment .. ", " .. LabelOrLink(SnakValue.qualifiers['P77'][1].datavalue.value['id'])
-- Rank
end
if SnakValue.qualifiers['P76'] then
Assignment = Assignment .. ", " .. LabelOrLink(SnakValue.qualifiers['P76'][1].datavalue.value['id'])
end
--Occupation
if SnakValue.qualifiers['P77'] then
Assignment = Assignment .. ", " .. LabelOrLink(SnakValue.qualifiers['P77'][1].datavalue.value['id'])
end
end
end
--AccValues[#AccValues + 1] = LabelOrLink(SnakValue.qualifiers['P73'][1].datavalue.value['id']) .. " " .. LabelOrLink(Value['id']) .. ", " .. LabelOrLink(SnakValue.qualifiers['P76'][1].datavalue.value['id']) .. ", " .. LabelOrLink(SnakValue.qualifiers['P77'][1].datavalue.value['id'])
--AccValues[#AccValues + 1] = LabelOrLink(SnakValue.qualifiers['P73'][1].datavalue.value['id']) .. " " .. LabelOrLink(Value['id']) .. ", " .. LabelOrLink(SnakValue.qualifiers['P76'][1].datavalue.value['id']) .. ", " .. LabelOrLink(SnakValue.qualifiers['P77'][1].datavalue.value['id'])
AccValues[#AccValues + 1] = Assignment
--AccValues[#AccValues + 1] = Assignment
table.insert(AccValues, Assignment)
table.sort(AccValues)
elseif Value['entity-type'] == 'item' then
elseif Value['entity-type'] == 'item' then
--mw.smw.set("OperatorName5=" .. OperatorName)
-- Process a generic Item
local GenericItem
local GenericItem
if AddSemantic then
if AddSemantic then
GenericItem = LabelOrLink(Value['id'], Header[2])
GenericItem = LabelOrLink(Value['id'], Header[2], true)
else
else
GenericItem = LabelOrLink(Value['id'])
GenericItem = LabelOrLink(Value['id'])
end
end
--mw.smw.set("OperatorName6=" .. OperatorName)
-- Prefix
if SnakValue.qualifiers and SnakValue.qualifiers['P15'] then
if SnakValue.qualifiers and SnakValue.qualifiers['P15'] then
GenericItem = SnakValue.qualifiers['P15'][1].datavalue.value .. " " .. GenericItem
GenericItem = SnakValue.qualifiers['P15'][1].datavalue.value .. " " .. GenericItem
end
end
AccValues[#AccValues + 1] = GenericItem
--mw.smw.set("OperatorName7=" .. OperatorName .. " ( " .. Property)
--Naval class
if Property == "P88" then
--mw.smw.set("OperatorName8=" .. OperatorName .. " ( " .. Property)
GenericItem = GenericItem .. "[[Category:" .. OperatorName .. mw.wikibase.getEntity(Value['id']).labels['it'].value .. "]]"
--GenericItem = mw.text.nowiki(GenericItem) .. " -" .. mw.text.nowiki(OperatorName) .. "- "
end
--mw.smw.set("OperatorName9=" .. OperatorName)
--P141 - Related Category
--Category needs to be linked, not added to the page
if Property == "P141" then
GenericItem = string.gsub(GenericItem, "%[%[", "[[:")
end
-- Suffix
if SnakValue.qualifiers and SnakValue.qualifiers['P19'] then
GenericItem = GenericItem .. " " .. SnakValue.qualifiers['P19'][1].datavalue.value
end
if SnakValue.qualifiers and SnakValue.qualifiers['P73'] ~= nil and Year == "" then
GenericItem = GenericItem .. " (" .. LabelOrLink(SnakValue.qualifiers['P73'][1].datavalue.value['id']) .. ")"
end
AccValues[#AccValues + 1] = GenericItem --.. "|" .. Header[2] .. "|" .. tostring(AddSemantic)
elseif SnakValue.mainsnak.datavalue['type'] == 'time' then
elseif SnakValue.mainsnak.datavalue['type'] == 'time' then
-- "+2367-00-00T00:00:00Z"
--local Instant = Value['time']
local Instant = string.sub(Value['time'], 1, 11)
local OutputFormat = "ITMedia"
local YearLink = ""
local PrintDate
local QualiString = ""
if string.sub(Instant, 7, 8) == "00" or string.sub(Instant, 10, 11) == "00" then
Instant = Instant:sub(1, 5) .. "-01-01"
OutputFormat = "SoloAnno"
end
PrintDate = frame:expandTemplate{title = 'TimeL', args = {Tipo=OutputFormat, Istante=Instant}}
if SnakValue.qualifiers ~= nil then
if SnakValue.qualifiers['P73'] ~= nil then
--P73 - Timeline
YearLink = LabelOrLink(SnakValue.qualifiers['P73'][1].datavalue.value['id'], nil, nil, PrintDate)
--mw.smw.set("Anno della timeline=" .. Instant)
elseif SnakValue.qualifiers['P74'] ~= nil then
--P74 - Event
YearLink = LabelOrLink(SnakValue.qualifiers['P74'][1].datavalue.value['id'], nil, nil, PrintDate)
end
QualiString = " " .. "(" .. p.ProcessQualifiers(SnakValue) .. ")"
end
if YearLink == "" then
AccValues[#AccValues + 1] = PrintDate .. QualiString
else
AccValues[#AccValues + 1] = YearLink .. QualiString
end
if AddSemantic then
if AddSemantic then
AccValues[#AccValues + 1] = "[[" .. Header[2] .. "::" .. Value['time'] .. "|" .. frame:expandTemplate{title = 'TimeL', args = {Tipo='ITEstesa', Istante=Value['time']}} .. "]]"
--AccValues[#AccValues + 1] = "[[" .. Header[2] .. "::" .. Value['time'] .. "|" .. frame:expandTemplate{title = 'TimeL', args = {Tipo='ITEstesa', Istante=Value['time']}} .. "]]"
else
--AccValues[#AccValues + 1] = "[[" .. Header[2] .. "::" .. Instant .. "|" .. frame:expandTemplate{title = 'TimeL', args = {Tipo=OutputFormat, Istante=Instant}} .. "]]"
AccValues[#AccValues + 1] = frame:expandTemplate{title = 'TimeL', args = {Tipo='ITEstesa', Istante=Value['time']}}
--AccValues[#AccValues + 1] = "[[" .. Header[2] .. "::" .. Instant .. "|" .. PrintDate .. "]]"
mw.smw.set(Header[2] .. "=" .. Instant)
--else
--AccValues[#AccValues + 1] = frame:expandTemplate{title = 'TimeL', args = {Tipo='ITEstesa', Istante=Value['time']}}
--AccValues[#AccValues + 1] = frame:expandTemplate{title = 'TimeL', args = {Tipo=OutputFormat, Istante=Instant}}
--AccValues[#AccValues + 1] = PrintDate
end
end
elseif SnakValue.mainsnak.datavalue.type == 'quantity' then
elseif SnakValue.mainsnak.datavalue.type == 'quantity' then
local StringValue
local StringValue
StringValue = string.format('%u', SnakValue.mainsnak.datavalue.value.amount)
StringValue = string.format('%G', SnakValue.mainsnak.datavalue.value.amount)
if AddSemantic then
mw.smw.set(Header[2] .. "=" .. StringValue)
end
local Unit = SnakValue.mainsnak.datavalue.value.unit
if string.len(Unit) > 5 then
StringValue = StringValue .. " " .. LabelOrLink(string.sub(Unit, string.find(Unit, "Q"), -1))
end
AccValues[#AccValues + 1] = StringValue
elseif SnakValue.mainsnak.datavalue.type == 'string' then
-- String values
local StringValue
StringValue = SnakValue.mainsnak.datavalue.value.amount
if AddSemantic then
if AddSemantic then
--mw.smw.set(Header[2] .. "::" .. StringValue)
mw.smw.set(Header[2] .. "=" .. StringValue)
mw.smw.set(Header[2] .. "=" .. StringValue)
end
end
Riga 177: Riga 375:
AccValues[#AccValues + 1] = StringValue
AccValues[#AccValues + 1] = StringValue
else
else
AccValues[#AccValues + 1] = 'TABLE'
AccValues[#AccValues + 1] = 'Unspecified TABLE'
end
end
elseif SnakValue.mainsnak.datatype == 'url' then
--URL, URI or URN
local URLString
URLString = SnakValue.mainsnak.datavalue.value
if SnakValue.qualifiers['P20'][1].datavalue.value ~= nil then
--Label is present
URLString = "[" .. URLString .. " " .. mw.text.nowiki(SnakValue.qualifiers['P20'][1].datavalue.value) .. "]"
end
table.insert(AccValues, URLString)
else
else
-- String items
AccValues[#AccValues + 1] = Value
AccValues[#AccValues + 1] = Value
if AddSemantic then
mw.smw.set(Header[2] .. "=" .. Value)
end
end
end
end
end
AllRows[#AllRows + 1] = {Header, AccValues}
AllRows[#AllRows + 1] = {Header, AccValues}
-- END Unspecified Property
end
end
end
end
end
end
mw.smw.set("ListProp=" .. table.concat(ListProp, ", "))
HTMLTable = TableFromArray(AllRows)
HTMLTable = TableFromArray(AllRows)
Riga 195: Riga 409:
-- return HTMLTable
-- return HTMLTable
return tostring(HTMLTable) .. CollectionTable
return tostring(HTMLTable) .. CollectionTable
end
function p.ProcessNavigators(frame)
local CollectionTable = nil
local Item = mw.wikibase.getEntity()
local ItemQ = mw.wikibase.getEntityIdForCurrentPage()
if not Item then
Item = mw.wikibase.getEntity('Q1')
end
if Item.claims['P7'] or Item.claims['P23'] then
--Previous or Next
CollectionTable = MakeNavTable(Item.claims, nil)
end
if Item.claims['P46'] then
-- Arc
if CollectionTable == nil then
CollectionTable = ""
end
CollectionTable = CollectionTable .. string.char(10) .. MakeNavTable(Item.claims["P46"][1].qualifiers, "Arco: " .. Item.claims["P46"][1].mainsnak.datavalue.value)
end
if CollectionTable ~= nil then
CollectionTable = "<div class='separatorebox'>'''Navigatore'''</div>" .. CollectionTable
end
return CollectionTable
end
end
function p.Incipit(frame)
function p.Incipit(frame)
Riga 208: Riga 449:
end
end
end
end
 
--- Function to expand template contained within description,
--- Function to query for HyperTrek migration data and to construct a proper box
-- if present
-- to show them, if present
-- @param frame Data from MW session
-- @return String Text containing URL to SkyMap
function p.SkyMapLink(RA, D)
-- Example
-- http://my.sky-map.org/v2?ra=0.709946185638474&de=41.22867547300068&zoom=5&show_grid=1&show_constellation_lines=1&show_constellation_boundaries=1&show_const_names=0&show_galaxies=1&show_box=1&box_ra=0.71166664&box_de=41.266666&box_width=682.6667008&box_height=682.6667008&box_var_size=1
-- https://secure.sky-map.org/v2
-- return "https://secure.sky-map.org/v2?ra=" .. RA .. "&de=" .. D
local URI
local Int
local Frac
local DMS = {}
-- Zoom value 7 is the standard one when searching object in WikiSky
URI = "http://www.wikisky.org/v2?ra=" .. RA .. "&de=" .. D .. "&zoom=7"
for _, Coord in pairs({RA, D}) do
Int, Frac = math.modf(Coord)
table.insert(DMS, Int)
Int, Frac = math.modf(math.abs(Frac) * 60)
table.insert(DMS, Int)
Int, Frac = math.modf(math.abs(Frac) * 60)
if Frac > 0.5 then
Int = Int + 1
end
table.insert(DMS, Int)
end
--return "[" .. URI .. " " ..  table.concat(DMS, "<sup>s</sup> ") .. "]"
return "[" .. URI .. " " .. DMS[1] .. "<sup>h</sup> " .. DMS[2] .. "<sup>m</sup> " .. DMS[3] .. "<sup>s</sup>, " .. DMS[4] .. "° " .. DMS[5] .. "′ " .. DMS[6] .. "″]"
end
--- Function to expand template contained within description,
-- if present
-- @param frame Data from MW session
-- @param frame Data from MW session
-- @return Description with expanded template
-- @return String Text containing expanded template
function p.DescrWithTemplate(frame)
function p.DescrWithTemplate(frame)
local RawDescription = mw.wikibase.getDescription()
local RawDescription = mw.wikibase.getDescription()
local Pattern = "{{.*}}"
local Pattern = "{{.-}}"
--[==[
--[==[
Riga 237: Riga 510:
function ExpTemplHelper(match, frame)
function ExpTemplHelper(match, frame)
return frame:expandTemplate{title = match}
return frame:expandTemplate{title = match}
end
--- Function to query for HyperTrek migration data and to construct a proper box
-- to show them, if present
-- @param Snak The Snak the qualifiers belongs to
-- @return String or link with qualifiers value processed
function p.ProcessQualifiers(SnakValue)
local QualiValue = {}
for _, Qualifier in pairs(SnakValue.qualifiers) do
if Qualifier[1].property == "P4" then
--Broadcaster
QualiValue[#QualiValue + 1] = Qualifier[1].datavalue.value
end
end
return table.concat(QualiValue, ", ") --string.char(10))
--[=[
if SnakValue.qualifiers['P73'] ~= nil then
--P73 - Timeline
YearLink = LabelOrLink(SnakValue.qualifiers['P73'][1].datavalue.value['id'], nil, nil, PrintDate)
--mw.smw.set("Anno della timeline=" .. Instant)
elseif SnakValue.qualifiers['P74'] ~= nil then
--P74 - Event
YearLink = LabelOrLink(SnakValue.qualifiers['P74'][1].datavalue.value['id'], nil, nil, PrintDate)
end
]=]
end
end


Riga 262: Riga 563:
ImageString = "[[File:Menu.png|left|middle|30px|HyperTrek logo]]"
ImageString = "[[File:Menu.png|left|middle|30px|HyperTrek logo]]"
--DataString = "Informazioni originali lette dal database di '''HyperTrek''' datato " .. frame:expandTemplate{title = 'TimeL', args = {Tipo='ITMedia', Istante=HTNodes.mainsnak.datavalue.value.time}} .. " con i seguenti dettagli: "
DataString = "Informazioni originali lette dal database di <h2 class='hiddenheaderbold'>HyperTrek</h2> datato " .. frame:expandTemplate{title = 'TimeL', args = {Tipo='ITMedia', Istante=HTNodes.mainsnak.datavalue.value.time}} .. " con i seguenti dettagli: "
DataString = "Informazioni originali lette dal database di <h2 class='hiddenheaderbold'>HyperTrek</h2> datato " .. frame:expandTemplate{title = 'TimeL', args = {Tipo='ITMedia', Istante=HTNodes.mainsnak.datavalue.value.time}} .. " con i seguenti dettagli: "
if AddSemantic then
mw.smw.set(mw.wikibase.getLabelByLang('P79', 'it') .. "=" .. Item.claims['P79'][1].mainsnak.datavalue.value.time)
end
 
 
for _, Qualifier in pairs(HTNodes.qualifiers) do
for _, Qualifier in pairs(HTNodes.qualifiers) do
Riga 270: Riga 574:
local QualiValue = Qualifier[1].datavalue.value
local QualiValue = Qualifier[1].datavalue.value
--QualiString = QualiString .. "<li " .. "title='" .. Qualifier[1].property .. "'>'''" .. mw.wikibase.getLabelByLang(Qualifier[1].property, 'it') .. "''': " .. Qualifier[1].datavalue.value .. "</li>"
--QualiString = QualiString .. "<li " .. "title='" .. Qualifier[1].property .. "'>'''" .. mw.wikibase.getLabelByLang(Qualifier[1].property, 'it') .. "''': " .. Qualifier[1].datavalue.value .. "</li>"
QualiString = QualiString .. "<li " .. "title='" .. QualiProp .. "'>'''" .. QualiName .. "''': " .. QualiValue .. "</li>"
if QualiProp == "P84" then
--Istante di importazione
QualiValue = frame:expandTemplate{title = 'TimeL', args = {Tipo='ITEstesa', Istante=QualiValue}}
end
if AddSemantic then
if AddSemantic then
mw.smw.set(QualiName .. "=" .. QualiValue)
mw.smw.set(QualiName .. "=" .. QualiValue)
end
end
if QualiProp == "P86" then
--Sezione ID, add link to page
QualiValue = frame:expandTemplate{title = 'HTSezioneID', args = {QualiValue}}
end
QualiString = QualiString .. "<li " .. "title='" .. QualiProp .. "'>'''" .. string.gsub(QualiName, "HyperTrek", "HT") .. "''': " .. QualiValue .. "</li>"
end
end
Riga 279: Riga 593:
:attr('id', 'htdata')
:attr('id', 'htdata')
:addClass('htcontainer')
:addClass('htcontainer')
:wikitext(ImageString .. DataString .. "<ul>" .. QualiString .. "</ul>" .. "[[Categoria:Pagine originariamente convertite da HT]]") --.. string.char(10) .. "[[Categoria:Pagine originariamente convertite da HT]]")
:wikitext(ImageString .. DataString .. "<ul>" .. QualiString .. "</ul>" .. "[[Categoria:Pagine originariamente convertite da HT]]" .. "[[Categoria:Nuovo box HT]]") --.. string.char(10) .. "[[Categoria:Pagine originariamente convertite da HT]]")
return tostring(DIV)
return tostring(DIV)
else
else