Modulo:Software: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m fix cat
disattivo categorie al di fuori del NS0
 
(12 versioni intermedie di 6 utenti non mostrate)
Riga 15:
local UNKNOWN_WD_LICENSE = ""
local UNKNOWN_WD_TOOLKIT = "[[Categoria:Toolkit o framework dell'interfaccia grafica non previsto]]"
returnlocal freeFREE_WITHOUT_LANGUAGE and= '[[Categoria:Software libero senza linguaggio]]' or '[[Categoria:Software senza linguaggio]]'
 
local TEMPLATE_UNKNOWN_ARG_WARN = "&nbsp;<span style=\"font-size:75%\">(non&nbsp;in&nbsp;[[Template:Software#Linguaggi|lista]])</span>"
Line 29 ⟶ 30:
-------------------------------- Sgabuzzino ------------------------------------
 
--[[
local function rawProperty(property)
* Get the ID from a statement (claim) of type wikibase-id
return mWikidata._formatStatement(property, {formatting = 'raw'})
* @param table Wikibase claim
* @return string|nil
]]
local function rawPropertystatementQID(property claim )
return claim.mainsnak.datavalue and claim.mainsnak.datavalue.value.id
end
 
Line 72 ⟶ 79:
* Poi non ditemi che PHP fa schifo. asd.
* Sembra che l'operatore "#" ogni tanto non vada col Modulo:Wikidata.
* 00:28, 28 feb 2017‎2017 Valerio Bozzolan
]]
local function count(t)
Line 114 ⟶ 121:
error("Questa non è una categoria, o è assente la proprietà Wikidata P301")
end
return rawPropertystatementQID(from)
end
 
Line 128 ⟶ 135:
local colon = man and ':' or ''
return "[[" .. colon .. "Categoria:" .. string.format(category, part) .. "]]"
end
 
--[[
* Categorie di errore nel caso non ci siano linguaggi.
* @param free boolean|nil È software libero?
]]
local function noLanguageWarning(free)
return free and '[[Categoria:Software libero senza linguaggio]]' or '[[Categoria:Software senza linguaggio]]'
end
 
Line 163 ⟶ 161:
function p.hasAProprietaryLicense(frame)
return yesNoNil( p._hasAProprietaryLicense( fromItem(frame) ) )
end
 
function p.languageCategories( frame )
return p._languageCategories( fromItem( frame ) )
end
 
Line 251 ⟶ 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 260 ⟶ 262:
if wd_languages then
for i, language in pairs(wd_languages) do
local languageId = rawPropertystatementQID(language)
if languageId then
language = conf.language[languageId]
if language then = conf.language[languageId]
outputLanguages[languageId] = outputLanguage(
shortWikidataLabel(languageId),
language and p._languageCategory(language, is_free)
)
noLanguages = false
improved = true
else
wd_allFound = false
end
end
Line 278 ⟶ 277:
if tl_has then
-- Wikidata ha migliorato il template e il template aveva già altri valori
s = s .. '[[Categoria:Linguaggio di programmazioneP277 differente dasu Wikidata]]'
else
-- Wikidata ha migliorato il template che era vuoto
s = s .. '[[Categoria:LinguaggioP277 di programmazione lettoletta da Wikidata]]'
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:Linguaggio di programmazioneP277 differente dasu Wikidata]]'
elseif count(wd_languages) ~= 0 then
-- Non ha migliorato niente perchè sono gli stessi valori
s = s .. '[[Categoria:Linguaggio di programmazioneP277 uguale asu Wikidata]]'
end
end
Line 296 ⟶ 295:
if tl_has and nszero then
-- solo se il template specifica linguaggi ma Wikidata no
s = s .. '[[Categoria:Linguaggio di programmazioneP277 assente su Wikidata]]'
end
end
Line 349 ⟶ 348:
s = s .. UNKNOWN_WD_LANGUAGE
end
if noLanguages and is_free then
s = s .. noLanguageWarning(is_free)FREE_WITHOUT_LANGUAGE
end
end
Line 387 ⟶ 386:
]]
function p._categorize(args)
local ns = mw.title.getCurrentTitle().namespace
local v = args['Categorie']
return ns == 0 and (v == nil or mw.ustring.lower(v) ~= 'no')
if v then
return mw.ustring.lower(v) ~= 'no'
end
return true
end
 
Line 491 ⟶ 488:
]]
function p._specifiesALanguage(args)
return p._templateHasLanguages(args) or mWikidata._getClaims_N({ 'P277' }) > 0
end
 
Line 550 ⟶ 547:
--[[
* Questa licenza è direttamente identificabile?
*
* @TODO: Rewrite in qualche modo più umano.
*
* @param license string Wikidata item
Line 555 ⟶ 554:
]]
function p._singleLicenseType(license)
-- Q1156659 OSI-approved license
-- Q5975031 free software copyleft license
-- Q3943414 free software license
-- Q31202214 proprietary software license
Line 564 ⟶ 565:
* le prossime tre righe riassumino l'*unica* parte piacevole del Lua.
]]
return (license == 'Q3943414' or license == 'Q5975031' or license == 'Q1156659') and FREE
or (license == 'Q31202214' or license == 'Q218616' or license == 'Q3238057') and PROPRIETARY
or UNKNOWN
end
 
Line 692 ⟶ 693:
function p._hasALicenseOfType(type, from)
for _, l in pairs( p._licenses(from) ) do
l = rawPropertystatementQID(l)
if vl then
local retrievedType = p._licenseType(l)
if type ~= UNKNOWN then
returnif type ~== retrievedTypeUNKNOWN then
return type == retrievedType
elseend
end
end
Line 730 ⟶ 733:
local s = ''
for i, l in pairs( p._licenses( from ) ) do
local id = rawPropertystatementQID( l ) -- can be nil but don't care
local name = conf.licenseCategory[ id ]
if name then
local cat = conf.licenseCategoryShorter[id] and LICENSE_CAT_SHORTER or LICENSE_CAT
Line 755 ⟶ 758:
if languages then
for _, l in pairs( languages ) do
l = conf.language[ rawPropertystatementQID(l) ]
if l then
s = s .. p._languageCategory(l, free)
Line 762 ⟶ 765:
end
end
elseif free then
else
s = noLanguageWarning(free)FREE_WITHOUT_LANGUAGE
end
if missing then
Line 784 ⟶ 787:
if toolkits then
for _, t in pairs( toolkits ) do
t = conf.language[ rawPropertystatementQID( t ) ] -- the ID can be nil but don't care
if t then
s = s .. p._languageCategory(t, free)