Modulo:Software: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
fix variazione grave in Wikidata d:Q3238057
disattivo categorie al di fuori del NS0
 
(23 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]]"
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 24 ⟶ 25:
local LICENSE_CAT_SHORTER = "Software %s"
-- "Software freeware"
 
local YEAR_CAT = 'Software del %d'
 
-------------------------------- 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
 
--[[
* @param string WIkidataItemWikidata element
* @TODO ora prende il primo, a prescindere dalla lingua (credo).
* @return string
Line 70 ⟶ 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 112 ⟶ 121:
error("Questa non è una categoria, o è assente la proprietà Wikidata P301")
end
return rawPropertystatementQID(from)
end
 
Line 126 ⟶ 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
 
Riga 161:
function p.hasAProprietaryLicense(frame)
return yesNoNil( p._hasAProprietaryLicense( fromItem(frame) ) )
end
 
function p.languageCategories( frame )
return p._languageCategories( fromItem( frame ) )
end
 
Line 169 ⟶ 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 176 ⟶ 180:
function p.wikidataCategoriesFromMainTopic(frame)
local s = p._wikidataCategories( fromItemMainTopic() )
return s .. string.format('[[Categoria:Voce principale della categoriaP301 %s Wikidata]]', s and 'lettoletta da' or 'assente su')
end
 
Line 196 ⟶ 200:
]]
function p._wikidataCategories(from)
return p._licenseCategories(from) .. p._languageCategories(from) .. p._toolkitCategories(from) .. p._yearsCategories(from)
end
 
Line 213 ⟶ 217:
function p.toolkitCategories(frame)
return p._toolkitCategories( fromItem(frame) )
end
 
--[[
* Categoria legato all'anno di fondazione.
* @return truestring
]]
function p.yearsCategories(frame)
return p._yearsCategories( fromItem(frame), onlySoftwareArguments(frame).DataPrimaVersione )
end
 
Line 241 ⟶ 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 250 ⟶ 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 268 ⟶ 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
else
-- Non ha migliorato niente perchè sono gli stessi valori
s = s .. '[[Categoria:Linguaggio di programmazioneP277 uguale asu Wikidata]]'
end
end
Line 286 ⟶ 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 339 ⟶ 348:
s = s .. UNKNOWN_WD_LANGUAGE
end
if noLanguages and is_free then
s = s .. noLanguageWarning(is_free)FREE_WITHOUT_LANGUAGE
end
end
Line 348 ⟶ 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 377 ⟶ 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 481 ⟶ 488:
]]
function p._specifiesALanguage(args)
return p._templateHasLanguages(args) or mWikidata._getClaims_N({ 'P277' }) > 0
end
 
Line 540 ⟶ 547:
--[[
* Questa licenza è direttamente identificabile?
*
* @TODO: Rewrite in qualche modo più umano.
*
* @param license string Wikidata item
Line 545 ⟶ 554:
]]
function p._singleLicenseType(license)
-- Q3943414Q1156659 free softwareOSI-approved license
-- Q14624820Q5975031 non-free software copyleft license
-- Q3943414 free software license
-- Q31202214 proprietary software license
-- Q218616 proprietary software
-- Q3238057 proprietary license!
 
--[[
Line 554 ⟶ 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 == 'Q14624820Q31202214' or license == 'Q218616' or license == 'Q3238057') and PROPRIETARY
or UNKNOWN
end
 
Line 673 ⟶ 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 680 ⟶ 693:
function p._hasALicenseOfType(type, from)
for _, l in pairs( p._licenses(from) ) do
l = rawPropertystatementQID(l)
if p._licenseType(l) == type then
local retrievedType = p._licenseType(l)
return true
if type ~= UNKNOWN then
return type == retrievedType
elseend
end
end
Line 689 ⟶ 705:
 
--[[
* La voce haè almeno unasotto licenza di software libero in Wikidata?
*
* @param from string|nil Wikidata item
Line 699 ⟶ 715:
 
--[[
* La voce haè almeno unasotto licenza di software proprietario in Wikidata?
*
* @param from string|nil Wikidata item
Line 717 ⟶ 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 742 ⟶ 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 749 ⟶ 765:
end
end
ifelseif vfree then
else
s = noLanguageWarning(free)FREE_WITHOUT_LANGUAGE
end
if missing then
Line 771 ⟶ 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)
Line 805 ⟶ 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
* @return truestring
]]
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