«Módulo:Infobox» e «Módulo:Infobox/ca»: Diferenzas entre as páxinas

(Diferenzas entre páxinas)
Páxina 1
Páxina 2
Contido eliminado Contido engadido
+ Classes específicas para label, data en 1 columna i data en 2 columnes
 
copia provisional de ca.wiki
 
Liña 2: Liña 2:
-- This module implements {{Infobox}}
-- This module implements {{Infobox}}
--
--

local p = {}
local p = {}


-- s'usa a renderNavBar(), anul·lat
local navbar = require('Módulo:Navbar')._navbar
-- local navbar = require('Module:Navbar')._navbar


local args = {}
local args = {}
local origArgs
local origArgs
local root
local root

local function notempty( s ) return s and s:match( '%S' ) end

local function fixChildBoxes(sval, tt)
if notempty(sval) then
local marker = '<span class=special_infobox_marker>'
local s = sval
s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker)
if s:match(marker) then
s = mw.ustring.gsub(s, marker .. '%s*' .. marker, '')
s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1')
s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1')
s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1')
end
if s:match(marker) then
local subcells = mw.text.split(s, marker)
s = ''
for k = 1, #subcells do
if k == 1 then
s = s .. subcells[k] .. '</' .. tt .. '></tr>'
elseif k == #subcells then
local rowstyle = ' style="display:none"'
if notempty(subcells[k]) then rowstyle = '' end
s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' .. subcells[k]
elseif notempty(subcells[k]) then
if (k % 2) == 0 then
s = s .. subcells[k]
else
s = s .. '<tr><' .. tt .. ' colspan=2>\n' .. subcells[k] .. '</' .. tt .. '></tr>'
end
end
end
end
-- the next two lines add a newline at the end of lists for the PHP parser
-- https://en.wikipedia.org/w/index.php?title=Template_talk:Infobox_musical_artist&oldid=849054481
-- remove when [[:phab:T191516]] is fixed or OBE
s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n')
s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n')
s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1')
s = mw.ustring.gsub(s, '^(%{%|)', '\n%1')
return s
else
return sval
end
end


local function union(t1, t2)
local function union(t1, t2)
Liña 107: Liña 57:
:css('text-align', 'center')
:css('text-align', 'center')
:cssText(args.headerstyle)
:cssText(args.headerstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(rowArgs.header)
:wikitext(fixChildBoxes(rowArgs.header, 'th'))
elseif rowArgs.data then
elseif rowArgs.data then
local row = root:tag('tr')
local row = root:tag('tr')
Liña 119: Liña 68:
:attr('scope', 'row')
:attr('scope', 'row')
:attr('id', rowArgs.labelid)
:attr('id', rowArgs.labelid)
:addClass('infobox-label')
:css('text-align', 'left') -- NOU
:cssText(args.labelstyle)
:cssText(args.labelstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(rowArgs.label)
:wikitext(rowArgs.label)
:done()
:done()
Liña 130: Liña 78:
dataCell
dataCell
:attr('colspan', 2)
:attr('colspan', 2)
:addClass('infobox-full-data')
:css('text-align', 'center')
:css('text-align', 'center')
end
end
dataCell
dataCell
:attr('id', rowArgs.dataid)
:attr('id', rowArgs.dataid)
:addClass('infobox-data')
:addClass(rowArgs.class)
:addClass(rowArgs.class)
:cssText(rowArgs.datastyle)
:cssText(rowArgs.datastyle)
:cssText(rowArgs.rowcellstyle)
:newline()
:wikitext(fixChildBoxes(rowArgs.data, 'td'))
:wikitext(rowArgs.data)
end
end
end
end
Liña 149: Liña 95:
:tag('caption')
:tag('caption')
:addClass(args.titleclass)
:addClass(args.titleclass)
:css('font-weight', 'bold') --NOU
:cssText(args.titlestyle)
:cssText(args.titlestyle)
:wikitext(args.title)
:wikitext(args.title)
Liña 165: Liña 112:
:css('font-weight', 'bold')
:css('font-weight', 'bold')
:cssText(args.abovestyle)
:cssText(args.abovestyle)
:wikitext(fixChildBoxes(args.above,'th'))
:wikitext(args.above)
end
end


Liña 178: Liña 125:
:css('text-align', 'center')
:css('text-align', 'center')
:cssText(args.belowstyle)
:cssText(args.belowstyle)
:wikitext(fixChildBoxes(args.below,'td'))
:newline()
:wikitext(args.below)
end
end


Liña 192: Liña 140:
addRow({
addRow({
data = args['subheader' .. tostring(num)],
data = args['subheader' .. tostring(num)],
datastyle = args.subheaderstyle,
datastyle = args.subheaderstyle or args['subheaderstyle' .. tostring(num)],
rowcellstyle = args['subheaderstyle' .. tostring(num)],
class = args.subheaderclass,
class = args.subheaderclass,
rowclass = args['subheaderrowclass' .. tostring(num)]
rowclass = args['subheaderrowclass' .. tostring(num)]
Liña 240: Liña 187:
rowclass = args['rowclass' .. tostring(num)],
rowclass = args['rowclass' .. tostring(num)],
rowstyle = args['rowstyle' .. tostring(num)],
rowstyle = args['rowstyle' .. tostring(num)],
rowcellstyle = args['rowcellstyle' .. tostring(num)],
dataid = args['dataid' .. tostring(num)],
dataid = args['dataid' .. tostring(num)],
labelid = args['labelid' .. tostring(num)],
labelid = args['labelid' .. tostring(num)],
Liña 249: Liña 195:
end
end


-- Substituït per renderLinkWikidata()
local function renderNavBar()
--local function renderNavBar()
if not args.name then return end
-- if not args.name then return end
--
root
-- root
:tag('tr')
:tag('td')
-- :tag('tr')
-- :tag('td')
:attr('colspan', '2')
:css('text-align', 'right')
-- :attr('colspan', '2')
-- :css('text-align', 'right')
:wikitext(navbar{
-- :wikitext(navbar{
args.name,
-- args.name,
mini = 1,
-- mini = 1,
})
-- })
--end

local function renderLinkWikidata() -- Crea un enllaç a Wikidata en la part inferior
local wikibase = require('Mòdul:Wikibase')
local enlacePagina = mw.title.getCurrentTitle().text
local etiquetaPagina = mw.ustring.gsub(enlacePagina,'%s%(.*%)','')
local entidad = args.item or wikibase.id()
local textoPie = ""
if (args.child == 'yes' or args.subbox == 'yes' or args.wikidata == 'no') or (mw.title.getCurrentTitle().namespace ~= 0 and not args.item) then
textoPie = ''
elseif entidad ~= "" and entidad ~= nil then
textoPie = '[[File:Arbcom ru editing.svg|12px|Modifica dades a Wikidata|link=d:' .. tostring(entidad) .. ']]'
if args.item and mw.title.getCurrentTitle().namespace == 0 then
textoPie = textoPie .. '[[Categoria:Articles amb accés arbitrari a Wikidata]]'
end
end
if textoPie ~= '' then
root
:tag('tr')
:tag('td')
:attr('colspan', '2')
:css('text-align', 'right')
:wikitext(textoPie)
end
end
end


Liña 272: Liña 243:
local function renderTrackingCategories()
local function renderTrackingCategories()
if args.decat ~= 'yes' then
if args.decat ~= 'yes' then
if #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
if args.child == 'yes' then
root:wikitext('[[Categoria:Articles amb infotaules sense paràmetres de dades]]')
if args.title then
end
root:wikitext('[[Categoría:Artigos que usan modelos infobox co parámetro título]]')
if args.child == 'yes' and args.title then
end
root:wikitext('[[Categoria:Pàgines que fan servir infotaules incrustades amb el paràmetre del títol]]')
elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
root:wikitext('[[Categoría:Artigos que usan modelos infobox sen filas de datos]]')
end
end
end
end
Liña 289: Liña 259:
root
root
:addClass((args.subbox ~= 'yes') and 'infobox' or nil)
:addClass('infobox')
:addClass(args.bodyclass)
:addClass(args.bodyclass)
Liña 305: Liña 275:
else
else
root
root
:css('width', '22em')
:css('font-size', '90%') --NOU
:css('width', '25em') --CANVIAT
-- :css('width', '22em')
end
end
root
root
Liña 323: Liña 295:
renderRows()
renderRows()
renderBelowRow()
renderBelowRow()
renderNavBar()
--renderNavBar()
renderLinkWikidata()
renderItalicTitle()
renderItalicTitle()
renderTrackingCategories()
renderTrackingCategories()
Liña 346: Liña 319:
-- table if the prefix parameter is present and non-blank.
-- table if the prefix parameter is present and non-blank.
if type(prefixTable) ~= 'table' then
if type(prefixTable) ~= 'table' then
error("Detectouse un valor distinto de table para o prefixo table", 2)
error("Hi ha un valor no-taula per a la taula de prefix", 2)
end
end
if type(step) ~= 'number' then
if type(step) ~= 'number' then
error("Detectouse un valor de paso incorrecto", 2)
error("Hi ha un valor numèric (step) que no és vàlid", 2)
end
end
Liña 355: Liña 328:
for i,v in ipairs(prefixTable) do
for i,v in ipairs(prefixTable) do
if type(v) ~= 'table' or type(v.prefix) ~= "string" or (v.depend and type(v.depend) ~= 'table') then
if type(v) ~= 'table' or type(v.prefix) ~= "string" or (v.depend and type(v.depend) ~= 'table') then
error('Detectouse unha entrada incorrecta na táboa de prefixos "preprocessArgs"', 2)
error('Hi ha una entrada que no és vàlida per a la taula de prefix preprocessArgs', 2)
end
end
preprocessSingleArg(v.prefix)
preprocessSingleArg(v.prefix)
Liña 362: Liña 335:
for j, dependValue in ipairs(v.depend) do
for j, dependValue in ipairs(v.depend) do
if type(dependValue) ~= 'string' then
if type(dependValue) ~= 'string' then
error('Detectouse un valor incorrecto para o parámetro "depend" en preprocessArgs')
error('El valor del paràmetre "depend" detectat en preprocessArgs no és vàlid')
end
end
preprocessSingleArg(dependValue)
preprocessSingleArg(dependValue)
Liña 435: Liña 408:
{prefix = 'rowclass'},
{prefix = 'rowclass'},
{prefix = 'rowstyle'},
{prefix = 'rowstyle'},
{prefix = 'rowcellstyle'},
{prefix = 'class'},
{prefix = 'class'},
{prefix = 'dataid'},
{prefix = 'dataid'},
Liña 452: Liña 424:
args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent
args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent
preprocessSingleArg('decat')
preprocessSingleArg('decat')
preprocessSingleArg('wikidata')
preprocessSingleArg('item')
return _infobox()
return _infobox()