Modulo:Software: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m refactoring p._licenseCategories() |
disattivo categorie al di fuori del NS0 |
||
(25 versioni intermedie di 7 utenti non mostrate) | |||
Riga 15:
local UNKNOWN_WD_LICENSE = ""
local UNKNOWN_WD_TOOLKIT = "[[Categoria:Toolkit o framework dell'interfaccia grafica non previsto]]"
local TEMPLATE_UNKNOWN_ARG_WARN = " <span style=\"font-size:75%\">(non in [[Template:Software#Linguaggi|lista]])</span>"
Line 24 ⟶ 25:
local LICENSE_CAT_SHORTER = "Software %s"
-- "Software freeware"
local YEAR_CAT = 'Software del %d'
-------------------------------- Sgabuzzino ------------------------------------
--[[▼
* Get the ID from a statement (claim) of type wikibase-id
*▼
* @param table Wikibase claim
* @return string|nil
]]▼
if statement == entityId then▼
return claim.mainsnak.datavalue and claim.mainsnak.datavalue.value.id
end▼
end▼
end▼
end▼
return false▼
end▼
▲local function rawProperty(property)
end
--[[
* @param string
* @TODO ora prende il primo, a prescindere dalla lingua (credo).
* @return string
Line 85 ⟶ 79:
* Poi non ditemi che PHP fa schifo. asd.
* Sembra che l'operatore "#" ogni tanto non vada col Modulo:Wikidata.
* 00:28, 28 feb
]]
local function count(t)
Line 127 ⟶ 121:
error("Questa non è una categoria, o è assente la proprietà Wikidata P301")
end
return
end
Line 141 ⟶ 135:
local colon = man and ':' or ''
return "[[" .. colon .. "Categoria:" .. string.format(category, part) .. "]]"
▲--[[
▲*
▲]]
▲ return free and '[[Categoria:Software libero senza linguaggio]]' or '[[Categoria:Software senza linguaggio]]'
end
Line 176 ⟶ 161:
function p.hasAProprietaryLicense(frame)
return yesNoNil( p._hasAProprietaryLicense( fromItem(frame) ) )
function p.languageCategories( frame )
return p._languageCategories( fromItem( frame ) )
end
Line 184 ⟶ 173:
function p.categories(frame)
if p._categorize( onlySoftwareArguments(frame) ) then
return p.licenseCategories(frame) .. p.toolkitCategories(frame) .. p.yearsCategories(frame)
end
return nil
Line 191 ⟶ 180:
function p.wikidataCategoriesFromMainTopic(frame)
local s = p._wikidataCategories( fromItemMainTopic() )
return s .. string.format('[[Categoria:
end
Line 211 ⟶ 200:
]]
function p._wikidataCategories(from)
return p._licenseCategories(from) .. p._languageCategories(from) .. p._toolkitCategories(from) .. p._yearsCategories(from)
end
Line 228 ⟶ 217:
function p.toolkitCategories(frame)
return p._toolkitCategories( fromItem(frame) )
--[[
* Categoria legato all'anno di fondazione.
]]
function p.yearsCategories(frame)
return p._yearsCategories( fromItem(frame), onlySoftwareArguments(frame).DataPrimaVersione )
end
Line 256 ⟶ 253:
-- Il template non mostra alcun linguaggio?
local noLanguages = not tl_has and not wd_languages
local outputLanguages = {} -- {key = {label1, category1}, key = {label2, category2}}
Line 265 ⟶ 262:
if wd_languages then
for i, language in pairs(wd_languages) do
local languageId =
if languageId then
outputLanguages[languageId] = outputLanguage(
shortWikidataLabel(languageId),
language and p._languageCategory(language, is_free)
)
improved = true
end
end
Line 283 ⟶ 277:
if tl_has then
-- Wikidata ha migliorato il template e il template aveva già altri valori
s = s .. '[[Categoria:
else
-- Wikidata ha migliorato il template che era vuoto
s = s .. '[[Categoria:
end
else
if p._templateHasExtraInformations(args) or count(tl_languages) > count(wd_languages) then
-- Nel template c'è qualcosa in più rispetto a Wikidata
s = s .. '[[Categoria:
elseif count(wd_languages) ~= 0 then
-- Non ha migliorato niente perchè sono gli stessi valori
s = s .. '[[Categoria:
end
end
Line 301 ⟶ 295:
if tl_has and nszero then
-- solo se il template specifica linguaggi ma Wikidata no
s = s .. '[[Categoria:
end
end
Line 354 ⟶ 348:
s = s .. UNKNOWN_WD_LANGUAGE
end
if noLanguages and is_free then
s = s ..
end
end
Line 363 ⟶ 357:
function p.manLanguages(frame)
local s = '<table class="wikitable"><tr><th>Parametro</th><th>Risultato</th><th>Categoria automatica</th></tr>'
local TD = '<td>%s</td>'
for id, language in pairs( conf.language ) do
Line 392 ⟶ 386:
]]
function p._categorize(args)
local ns = mw.title.getCurrentTitle().namespace
local v = args['Categorie']
if v then▼
▲ return mw.ustring.lower(v) ~= 'no'
return true▼
end
Line 496 ⟶ 488:
]]
function p._specifiesALanguage(args)
return p._templateHasLanguages(args) or mWikidata.
end
Line 555 ⟶ 547:
--[[
* Questa licenza è direttamente identificabile?
*
* @TODO: Rewrite in qualche modo più umano.
*
* @param license string Wikidata item
Line 560 ⟶ 554:
]]
function p._singleLicenseType(license)
--
--
-- Q3943414 free software license
-- Q31202214 proprietary software license
-- Q218616 proprietary software
-- Q3238057 proprietary license!
--[[
Line 568 ⟶ 565:
* le prossime tre righe riassumino l'*unica* parte piacevole del Lua.
]]
return (license == 'Q3943414' or license == 'Q5975031' or license ==
or (license == '
or UNKNOWN
end
Line 687 ⟶ 684:
--[[
* Ha un certo tipo di licenza?
*
* Per motivi di performance dal 29 luglio 2017 si cerca solo fino alla prima licenza identificabile.
*
* @param type FREE|PROPRIETARY|UNKNOWN
Line 694 ⟶ 693:
function p._hasALicenseOfType(type, from)
for _, l in pairs( p._licenses(from) ) do
l =
if
local retrievedType = p._licenseType(l)
return type == retrievedType
end
end
Line 703 ⟶ 705:
--[[
* La voce
*
* @param from string|nil Wikidata item
Line 713 ⟶ 715:
--[[
* La voce
*
* @param from string|nil Wikidata item
Line 731 ⟶ 733:
local s = ''
for i, l in pairs( p._licenses( from ) ) do
local id =
local name = conf.licenseCategory[ id ]
if name then
local cat = conf.licenseCategoryShorter[id] and LICENSE_CAT_SHORTER or LICENSE_CAT
Line 756 ⟶ 758:
if languages then
for _, l in pairs( languages ) do
l = conf.language[
if l then
s = s .. p._languageCategory(l, free)
Line 763 ⟶ 765:
end
end
s =
end
if missing then
Line 785 ⟶ 787:
if toolkits then
for _, t in pairs( toolkits ) do
t = conf.language[
if t then
s = s .. p._languageCategory(t, free)
Line 819 ⟶ 821:
end
return s or default or ''
▲end
--[[
* Categoria legata alla data di fondazione.
* @todo Capire quale deve prevalere fra data di pubblicazione e data di creazione
* @param from string|nil Wikidata Item
* @param value string|nil Local value
]]
function p._yearsCategories(from, value)
local mCategoryByYear = require('Modulo:Categoria per anno')._main
local creation = mCategoryByYear( { YEAR_CAT, from = from, value = value, raw = true } )
if '' == creation then
return mCategoryByYear( { YEAR_CAT, from = from, value = value, prop = 'P577', checkCat = 'Data di pubblicazione', checkGenre = 'fs' } )
▲ end
return mCategoryByYear( { YEAR_CAT, from = from, value = value } )
end
|