Modulo:Software: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
probabilmente ora è possibile #Categorizzare le categorie |
separato p.categories() con p.wikidataCategories() e aggiunto p.wikidataCategoriesFromMainTopic() per #Categorizzare le categorie |
||
Riga 59:
end
return i
end
local function rawProperty(property)
return mWikidata._formatStatement(property, {formatting = 'raw'})
end
Line 74 ⟶ 78:
--[[
* Restituisce SOLO l'argomento `from` da dare in pasto a varie funzioni del Modulo:Wikidata
* @param frame table
* @return string|nil
]]
local function fromItem(frame)
return getArgs(frame).from
end
--[[
* Analogo a fromItem() ma viene recuperato da Property:P301 (category's main topic).
*
* @return string|nil
]]
local function fromItemMainTopic()
local from = mWikidata._getClaims('P301')
from = from and from[1]
if not from then
error("Quest non è una categoria, o è assente la proprietà Wikidata P301")
end
return rawProperty(from)
end
Line 105 ⟶ 123:
--[[
* Categorizza una voce.
* @return string|nil
]]
function p.categories(frame)
end
--[[
* Categorizza una pagina qualsiasi.
* @return string|nil
]]
function p.wikidataCategories(frame)
return p._wikidataCategories( fromItem(frame) )
end
function p.wikidataCategoriesFromMainTopic(frame)
return p._wikidataCategories( fromItemMainTopic() )
end
Line 121 ⟶ 147:
]]
function p.licenseCategories(frame)
return p._licenseCategories( fromItem(frame) )
end
--[[
* Licenze.
*
* @return string
]]
Line 140 ⟶ 159:
for i, l in pairs( p._licenses( fromItem(frame) ) ) do
local space = i == 1 and '' or '<br />'
s = s .. space ..
end
return s
Line 176 ⟶ 195:
if wd_languages then
for i, language in pairs(wd_languages) do
local wikidataID =
language = conf.wikidataToLanguageSlug[wikidataID]
if language then
Line 248 ⟶ 267:
-------------------------------- Backend ---------------------------------------
--[[
* Categorizzare?
*
* @return true|false
]]
function p._categorize(args)
local v = args['Categorie']
if v then
return mw.ustring.lower(v) ~= 'no'
end
return true
end
--[[
Line 546 ⟶ 578:
function p._hasALicenseOfType(type, from)
for _, l in pairs( p._licenses(from) ) do
l = rawProperty(l)
if p._licenseType(l) == type then
return true
Line 573 ⟶ 605:
return p._hasALicenseOfType(PROPRIETARY, from)
end
--[[
* Tutte le categorie applicabili da Wikidata.
*
* Per ora ci sono solo le licenze, ma qui ci devono andare anche i linguaggi.
*
* @param from string|nil Wikidata Item
* @return string
]]
function p._wikidataCategories(from)
return p._licenseCategories(from)
end
--[[
* Categorie legate alle licenze da Wikidata.
*
* @param from string|nil Wikidata Item
* @return string
]]
function p._licenseCategories(from)
local s = ''
for i, l in pairs( p._licenses( from ) ) do
l = rawProperty(l)
l = conf.licenseCategory[l]
if l then
s = s .. string.format("[[Categoria:Software in licenza %s]]", l)
end
end
return s
end
--------------------------- Non usate. Perchè? Boh. ----------------------------
Line 597 ⟶ 662:
function p.languageSlugToWikidata(frame)
return p._languageSlugToWikidata( getArgs(frame)[1] )
end
|