benda

La documentation pour ce module peut être créée à Module:Benda/doc

--Cél modulo ègzécute los modèlos de benda.  --Estandardisacion de les bendes ([[Catègorie:Modèlo de benda]]). --Fâre na fonccion èxportâbla por lo modèlo {{Benda}} (ns:all). --Fâre na fonccion èxportâbla por les bendes d’articllo (ns:0). --Fâre na fonccion èxportâbla por les bendes de sèccion (ns:0). --Fâre na fonccion èxportâbla por les bendes de començon (ns:0). --Fâre na fonccion èxportâbla por les bendes de discussion (ns:1). --Fâre na fonccion èxportâbla por les bendes de sistèmo (ns:8). --Fâre marchiér les émâges multiples.  local p = {}  local trim = require('Module:Outils').trim local yesno = require('Module:yesno') local class = mw.loadData('Module:Benda/Class') local moduloComencon = 'Module:Benda/Començon' -- local paramComencon = mw.loadData('Module:Benda/Començon') -- serat chargiê ren que por na benda de començon.  local cfg = { forma = 'benda-simpla', nivel = 'benda-nivel-netro', formatLim = '[[Fichiér:%s|%spx|alt=%s|class=noviewer]]', talyeIcona = '45x45', fotaArgument = 'Paramètro |%s= entrovâblo', fotaComenconParam = 'lo tèmo « %s » du modèlo [[Modèlo:Començon|{{començon}}]] est pas [[Éde:Començon/Éde paramètros|dèfeni]].', fotaComenconTipo = 'lo tèmo « %s » dêt aparêtre en téta de lista du modèlo [[Modèlo:Començon|{{començon}}]].', comenconEmage = '%s', comenconTitro = '%s est un [[Éde:Començon|començon]].', comenconTitroChousa = '%s est un [[Éde:Començon|començon]] que regârde %s.', comenconCateg = '[[Catègorie:Vouiquipèdia:començon %s]]', }  -- CSS inline por èvitar FOUC sus lo seto enfatâblo local rustinaFoucMobile = { ['display'] = 'table-cell', ['padding-right'] = '0.5em', }  local function fota(texto, formatstring, tag) local res = mw.html.create(tag or 'span') res:addClass('fota') :wikitext('Fôta : ')  if formatstring then res:wikitext(formatstring:format(texto)) else res:wikitext(texto) end  return tostring(res) end  function p._benda(args) local res = mw.html.create('div') local cells = mw.html.create() local icona = trim(args.emage) or trim(args['icôna']) local backgroundIcona = class.icones[icona] or false local texto = (trim(args.texto) or fota('texto', cfg.fotaArgument))  res:attr{ id = args.id } :addClass('benda-container') :addClass(class.formes[args.forma] or cfg.forma) :addClass(class.nivel[args.nivel] or cfg.nivel) :addClass('plainlinks') :addClass(args.class) :cssText(args.style)  if yesno(args.centrar) then cells = mw.html.create('div') :addClass('benda-centrar') elseif trim(args.dreta) then cells = mw.html.create('div') :css{ display = 'table', width = '100%' } end  if args['icôna bea'] == 'ouè' then cells:wikitext( mw.getCurrentFrame():expandTemplate{ title = 'Bea' } ) end  if icona and not backgroundIcona then local iconaVouiqui = icona if not icona:match('%[') then local alt = args.alt or args['lègenda'] or '' if yesno( args['domêno publico'] ) then alt = alt .. '|link=' end local talye = args['talye icôna'] or cfg.talyeIcona iconaVouiqui = cfg.formatLim:format(icona, talye, alt) end cells :tag('div') :addClass('benda-cell benda-icona') :css(rustinaFoucMobile) :wikitext(iconaVouiqui) :done() end  -- por que lo tèxto comence sus na novèla legne (parsâjo vouiquicode "*", etc.) -- (et solament dens cél câs de figura, ôtrament lo tèxto sè retrôve encâdrâ per un 

ôtomatico) if texto:match('^[*#;:]') then texto = '\n' .. texto end cells :tag('div') :addClass('benda-cell') :css(rustinaFoucMobile) :addClass(backgroundIcona and ('benda-icona-css ' .. backgroundIcona) or nil) :wikitext(texto) :newline() -- pas suprimar, sèrvét a la g·ènèracion ôtomatica de

encâdrent lo contegnu :done() if trim(args.dreta) then cells :tag('div') :addClass('benda-cell') :css(rustinaFoucMobile) :css( 'padding-left', '1em' ) :newline() :wikitext(args.dreta) :done() end res:node(cells) if trim(args['quârque-ren de més']) then res:tag('p') :wikitext(args['quârque-ren de més']) :done() end return tostring(res) end function p._bendaSemonce(args) local htmlTexto = mw.html.create() local titro = trim(args.titro) or fota('titro', cfg.fotaArgument) local sufixoData = trim(args.date) if sufixoData then -- por rendre pas sècâblo, solament se lo paramètro semble franc étre na dâta valida sufixoData = (require 'Module:Dâta').modeloData{sufixoData, nolinks=true, onerror='input'} titro = titro:gsub('%.$', '') sufixoData = ' (' .. sufixoData .. ').' elseif not titro:match('[.,;:!?]$') then titro = titro .. '.' end htmlTexto :tag('strong') :addClass('benda-titro') :wikitext(titro) :done() :wikitext(sufixoData) :newline():newline() :wikitext(args.texto) local parametros = { forma = 'articllo', nivel = args.nivel, id = args.id, class = 'benda-container metadata ambox ' .. ( args.class or '' ), ['icôna'] = trim(args['icôna']) or trim(args['icôna-complicâye']) or args.nivel, alt = args.alt or args['lègenda'], ['domêno publico'] = args['domêno publico'], texto = tostring(htmlTexto), ['icôna bea'] = args['icôna bea'], ['quârque-ren de més'] = args['quârque-ren de més'] } return p._benda(parametros) end --[[ TODO - fusionar cetes doves mètodes : * p._benda() avouéc forma=seccion * p._bendaSeccion() ]]-- function p._bendaSeccion(args) local res = mw.html.create('div') local icona = trim(args.emage) or trim(args['icôna']) local backgroundIcona = class.icones[icona] or false local texto = (trim(args.texto) or fota('texto', cfg.fotaArgument)) res:addClass('benda-container benda-seccion metadata') :addClass(class.nivel[args.nivel] or cfg.nivel) if icona and not backgroundIcona then local iconaVouiqui = icona if not icona:match('%[') then local alt = args.alt or args['lègenda'] or '' if yesno( args['domêno publico'] ) then alt = alt .. '|link=' end iconaVouiqui = cfg.formatLim:format(icona, 'text-top|20x17', alt) end res:tag('div') :addClass('benda-cell benda-icona') :wikitext(iconaVouiqui) :done() end res:tag('div') :addClass('benda-cell') :addClass(backgroundIcona and ('benda-icona-css ' .. backgroundIcona) or nil) :wikitext(texto) :done() return tostring(res) end -- fonccion qu’envèrse la câssa du premiér caractèro d’una chêna local function enversarCassa( str ) if type( str ) == 'string' then local premierCar = mw.ustring.sub( str, 1, 1 ) if mw.ustring.lower( premierCar ) == premierCar then return mw.ustring.upper( premierCar ) .. mw.ustring.sub( str, 2 ) else return mw.ustring.lower( premierCar ) .. mw.ustring.sub( str, 2 ) end end end -- fonccion que rècupère la ou ben les trâbles de començon corrèspondent u tèmo local function getComenconTable( paramComencon, theme, femenin ) -- suprime les mârques de dirèccion ltr theme = theme:gsub( '\226\128\142', '' ):gsub( '_', ' ' ) -- rècupère los paramètros liyês u tèmo, dês lo module:Benda/Començon local params = {} local comencon = paramComencon[ theme ] or paramComencon[ enversarCassa( theme ) ] if not comencon and theme:find( ' ' ) then -- èprôve se yon des mots du tèmo corrèspond a un adjèctif ègzistent for adj in theme:gmatch( ' ([^ ]+)' ) do paramsAdj = getComenconTable( paramComencon, adj, femenin ) if paramsAdj and paramsAdj.adjectif == true then local nom = theme:gsub( ' ' .. adj:gsub( '(%p)', '%%%1'), '' ) params = getComenconTable( paramComencon, nom, femenin ) if params then return params, paramsAdj end end end -- nion mot corrèspond a un adjèctif, tâchiêvont un’ôtra mètoda por trovar na corrèspondence avouéc un mouél de mots if theme:find( ' .+ ' ) then for adj, paramsAdj in pairs( paramComencon ) do if paramsAdj.adjectif == true and theme:find( ' ' .. adj, 2, true ) then local nom = theme:gsub( ' ' .. adj:gsub( '(%p)', '%%%1'), '' ) params = getComenconTable( paramComencon, nom, femenin ) if params then return params, paramsAdj end end end end end if femenin and comencon and comencon.femenin then comencon = paramComencon[ comencon.femenin ] end if comencon then for n, v in pairs( comencon ) do params[ n ] = v end else params = nil end return params, nil end p.getComenconTable = getComenconTable local function femeninFromWikidata() local entity = mw.wikibase.getEntity() if entity then local p31 = entity:getBestStatements( 'P31' ) local estHomo = type( p31 ) == 'table' and #p31 == 1 and type( p31[ 1 ].mainsnak ) == 'table' and type( p31[ 1 ].mainsnak.datavalue ) == 'table' and type( p31[ 1 ].mainsnak.datavalue.value ) == 'table' and p31[ 1 ].mainsnak.datavalue.value['numeric-id'] == 5 local p21 = entity:getBestStatements( 'P21' ) local estFemenin = type( p21 ) == 'table' and #p21 == 1 and type( p21[ 1 ].mainsnak ) == 'table' and type( p21[ 1 ].mainsnak.datavalue ) == 'table' and type( p21[ 1 ].mainsnak.datavalue.value ) == 'table' and p21[ 1 ].mainsnak.datavalue.value['numeric-id'] == 6581072 return estHomo, estFemenin end return false, false end p['_començon'] = function (args) local paramComencon = mw.loadData( moduloComencon ) local page = mw.title.getCurrentTitle() local comencons, maneyanceFota = {}, {} local homo, femenin = femeninFromWikidata() femenin = yesno( args["femenin"], true, false ) or femenin local estFemenin -- fonccion que revire la valor de param por lo començon i, ou ben na valor per dèfôt local comenconParam = function( i, param ) return comencons[ i ] and comencons[ i ][ param ] or paramComencon[''][ param ] end -- rècupèracion des paramètros de tôs los tèmos for i, theme in ipairs( args ) do theme = trim( theme ) if theme then local t, tAdj = getComenconTable( paramComencon, theme, femenin ) if t then table.insert( comencons, t ) table.insert( comencons, tAdj ) else table.insert( maneyanceFota, fota(theme, cfg.fotaComenconParam, 'div' ) ) end end end -- rècupèracion des difèrents titros, émâges et catègories local emages, titros, categs = {}, {}, {} local talyeIcona = '45x35' if #comencons > 3 then talyeIcona = '35x25' end for i, comencon in ipairs(comencons ) do -- crèacion du lim de l’émâge local alt = '' if comencon.icona then local emage = cfg.formatLim:format( comencon.icona, talyeIcona, alt ) table.insert( emages, emage ) end if math.fmod( #comencons, 3 ) == 1 and ( #comencons - i ) == 2 or math.fmod( i, 3 ) == 0 and ( #comencons - i ) > 1 then -- sus un mouél de legnes s’y at pas més de 3 émâges, avouéc u muens doves émâges sus la dèrriére legne table.insert( emages, '
'
) end if i > 1 and comencon.type and comencon.type ~= paramComencon[''].type then -- remplace "Cél articllo" per "Cél portâl" ou ben ôtro d’aprés lo premiér tèmo. table.insert( maneyanceFota, fota(comencon.nom, cfg.fotaComenconTipo, 'div') ) end -- rècupère los difèrents noms de tèmo if comencon.adjectif and #titros > 0 then local chousa = comencon.chousa or comencon.nom if estFemenin then chousa = comencon.chousaF or chousa:gsub( comencon.nom:gsub( '(%p)', '%%%1') .. '%f[%W]', comencon.femenin ) end -- aponsa de la chousa de l’adjèctif dedens la chousa du començon devant local titro, subst = titros[ #titros ]:gsub( '<(adj[^>]*)>', { adjectif = chousa, adj = comencon.nom, adjF = comencon.femenin } ) if subst > 0 then titros[ #titros ] = titro else titros[ #titros ] = titro .. ' ' .. chousa end else table.insert( titros, comencon.chousa ) estFemenin = comencon.estFemenin or ( comencon.chousa == '' and estFemenin ) end -- mês’en fôrma de les catègories if comencon.adjectif then -- tentativa d’aponsa du nom de l’adjèctif dedens les catègories devant local chang = false for k, v in ipairs( categs ) do local cat, subst = v:gsub( '<(adj[^>]*)>', { adj = comencon.nom, adjF = comencon.femenin, adjectif = comencon.nom } ) if subst == 0 then cat = v .. ' ' .. comencon.nom end if mw.title.new( 'Catègorie:Vouiquipèdia:començon ' .. cat ).exists then categs[ k ] = cat chang = true end end if not chang and homo and mw.title.new( 'Catègorie:Vouiquipèdia:començon pèrsonalitât ' .. comencon.femenin ).exists then table.insert( categs, 'pèrsonalitât ' .. comencon.femenin ) end end table.insert( categs, comencon.categ ) end -- mês’en fôrma de les émâges local emage if trim( args['icôna'] ) then local theme = getComenconTable( paramComencon, args['icôna'] ) if theme and theme.icona then emage = cfg.formatLim:format( theme.icona, talyeIcona, theme.altIcona or ( 'émâge ilustrent ' .. theme.chousa ) ) end elseif #emages == 1 then emage = emages[ 1 ] elseif #emages > 1 then emage = cfg.comenconEmage:format( table.concat( emages, ' ' ) ) end -- mês’en fôrma du titro local titro if #titros > 0 then titro = cfg.comenconTitroChousa:format( comenconParam( 1, 'tipo' ), mw.text.listToText( titros ) ) else titro = cfg.comenconTitro:format( comenconParam( 1, 'tipo' ) ) end -- mês’en fôrma du tèxto local texto if #comencons == 0 then texto = ( comenconParam( 1, 'messajo' ) ) .. '.' else local messajo = comenconParam( 1, 'messajo' ) local dapres = comenconParam( 1, 'd’apres' ) -- aponsa d’un pouent se lo paramètro d’aprés comence per un retôrn legne ou ben na granta lètra if messajo:sub( -1 ) == ')' and ( dapres:sub( 1, 3 ) == ' or mw.ustring.match( dapres, '^%u' ) ) then texto = ( comenconParam( 1, 'messajo' ) ) .. '. ' .. ( comenconParam( 1, 'd’apres' ) ) .. '.' else texto = ( comenconParam( 1, 'messajo' ) ) .. ' ' .. ( comenconParam( 1, 'd’apres' ) ) .. '.' end end -- aponsa d’un tèxto s’y at na lista de tâches local todo = page.talkPageTitle and mw.title.new( page.talkPageTitle.fullText .. '/A fâre' ) or nil if todo and todo.exists then texto = texto .. '\n\n' .. 'Vêde la lista de les tâches a acomplir en [[' .. page.talkPageTitle.prefixedText .. '|pâge de discussion]].' end -- paramètros por la benda local parametros = { nivel = 'començon', ['icôna'] = emage, titro = titro:gsub( ' ]*>', '' ), ['tèxto'] = texto, id = args.id } -- concatènacion de les difèrentes catègories (pas de catègorisacion se nocat, ou ben pâge de discussion, ou ben èspâço utilisator) local categ = '' local messajoFota = table.concat( maneyanceFota ) if not ( yesno( args.nocat, true, false ) or page.isTalkPage or page.namespace == 2 ) then for i = 1, #categs do categs[ i ] = cfg.comenconCateg:format( categs[ i ] ) end categ = table.concat( categs ):gsub( ' <[^>]*>', '' ) if categ == '' then categ = cfg.comenconCateg:format('') end if #maneyanceFota > 0 then messajoFota = messajoFota .. '[[Catègorie:Començon encognu]]' end end return p._bendaSemonce( parametros ) .. messajoFota .. categ end --- -- Fonccion que revire un paramètro d’una trâbla de començon. -- El est prèviua por étre apelâye tot drêt per #invoke: -- avouéc por paramètros lo tèmo et lo paramètro dèsirâ -- Cela fonccion est surtot dèstinâye a la pâge d’éde. function p.parametroComencon( frame ) local paramComencon = mw.loadData( moduloComencon ) local theme = frame.args[1] local param = frame.args[2] if paramComencon[ theme ] then return paramComencon[ theme ][ param ] elseif paramComencon[ enversarCassa( theme ) ] then return paramComencon[ enversarCassa( theme ) ][ param ] end end --- -- Fonccion que revire lo femenin d’un tèmo de començon. -- El est prèviua por étre apelâye tot drêt per #invoke: -- avouéc por paramètros lo tèmo et lo paramètro dèsirâ -- Cela fonccion est surtot dèstinâye u modèlo {{Catègoria de començon}}, donc na valor est pas reveriêe que se les catègories sont pariéres. function p.femeninComencon( frame ) local paramComencon = mw.loadData( moduloComencon ) local theme = frame.args[1] local themeF if theme then local t = getComenconTable( paramComencon, theme ) local tF, tAdjF = getComenconTable( paramComencon, theme, true ) if t.femenin and tF.categ == t.categ then if tAdjF then themeF = tF.nom .. ' ' .. tAdjF.femenin elseif tF then themeF = tF.nom end return themeF end end end --- -- Fonccion que construit doves grelyes rècapitulatives de l’ensemblo des paramètros de començon. function p.tableParametrosComencons( frame ) local paramComencon = mw.loadData( moduloComencon ) local currentFrame = mw.getCurrentFrame() local languageObj = mw.getContentLanguage() function pagesInCategory( category ) return languageObj:formatNum( tonumber( currentFrame:callParserFunction( 'PAGESINCATEGORY', { category, 'R' } ) ) ) end local params, paramAdj, paramTipo = {}, {}, {} for cllaf, comencon in pairs( paramComencon ) do local kComencon = {} for k, v in pairs( comencon ) do kComencon[ k ] = v end kComencon.cllaf = cllaf if comencon.type then table.insert( paramTipo, kComencon ) elseif comencon.adjectif then if cllaf == comencon.nom or cllaf ~= comencon.femenin then table.insert( paramAdj, kComencon ) end else table.insert( params, kComencon ) end end local comp = function( eb1, eb2 ) return eb1.cllaf < eb2.cllaf end table.sort( params, comp ) table.sort( paramAdj, comp ) table.sort( paramTipo, comp ) local wikiTab = { '

'}wikiTab.insert=function(t,value)table.insert(t,value)returntendwikiTab:insert('\n=== Començons normals ===\n'):insert(''):insert(''):insert(''):insert(''):insert(''):insert(''):insert('')fork,comenconinipairs(params)dowikiTab:insert('')endwikiTab:insert('
Lista des paramètros de començon
nom i chousa catègoria comptor d’aprés
') :insert( comencon.cllaf ) :insert('') if comencon.icona then wikiTab:insert( cfg.formatLim:format( comencon.icona, '45x35', comencon.altIcona or '' ) ) end wikiTab :insert('') :insert( comencon.chousa ) :insert('') if comencon.categ then wikiTab :insert( '[[:Catègorie:Vouiquipèdia:començon ' .. comencon.categ .. '|' .. comencon.categ .. ']]' ) end wikiTab :insert('') if comencon.categ then wikiTab :insert( pagesInCategory( 'Vouiquipèdia:començon ' .. comencon.categ ) ) end wikiTab :insert('') :insert( comencon.dapres ) :insert('
'
) -- seconda grelye por los adjèctifs wikiTab :insert('\n=== Adjèctifs ===\n') :insert(''):insert(''):insert(''):insert(''):insert(''):insert(''):insert(''):insert('')fork,comenconinipairs(paramAdj)dowikiTab:insert('')endwikiTab:insert('
Lista des adjèctifs
adjèctif femenin icôna chousa chousa femenena catègoria
') :insert( comencon.cllaf ) :insert('') :insert( comencon.femenin ) :insert('') if comencon.icona then wikiTab :insert( cfg.formatLim:format( comencon.icona, '45x35', comencon.altIcona or '' ) ) end wikiTab :insert('') :insert( comencon.chousa ) :insert('') :insert( comencon.chousaF or comencon.chousa:gsub( comencon.nom .. '%f[%W]', comencon.femenin ) ) :insert('') if comencon.categ then wikiTab :insert( '[[:Catègorie:Vouiquipèdia:començon ' .. comencon.categ .. '|' .. comencon.categ .. ']]' ) end wikiTab :insert('
'
) -- trêsiéma grelye por los tipos wikiTab :insert('\n=== Tipos ===\n') :insert(''):insert(''):insert(''):insert(''):insert(''):insert(''):insert(''):insert('')fork,comenconinipairs(paramTipo)dowikiTab:insert('')endwikiTab:insert('
Lista des paramètros de tipo
nom icôna tipo chousa catègoria mèssâjo
') :insert( comencon.cllaf ) :insert('') if comencon.icona then wikiTab:insert( cfg.formatLim:format( comencon.icona, '45x35', comencon.altIcona or '' ) ) end wikiTab :insert('') :insert ( comencon.type ) :insert('') :insert( comencon.chousa ) :insert('') if comencon.categ then wikiTab:insert( '[[:Catègorie:Vouiquipèdia:començon ' .. comencon.categ .. '|' .. comencon.categ .. ']]' ) end wikiTab :insert('') :insert( comencon.messajo ) :insert('
'
) return table.concat( wikiTab ):gsub( ' ', '' ) end -- Fonccion dèstinâye a l’outil [[MediaWiki:Outil-BendaComençons.js]] function p.listaComencons( frame ) local paramComencon = mw.loadData( moduloComencon ) local lista = {} for k in pairs( paramComencon ) do if k ~= "" then table.insert( lista, k ) end end table.sort( lista ) return table.concat( lista, '\n' ) end -- Entrebetâ dedens la grelye p de les fonccions apelâyes per los -- modèlos avouéc un adaptior de fonccion. local function adaptior(nomFonccion) return function (frame) local args if frame.args.texto or frame.args.titro then args = frame.args else args = frame:getParent().args end return p[nomFonccion](args) end end local nomsFonccion = {'benda', 'bendaSemonce', 'bendaSeccion', 'començon' } for _, nomFonccion in ipairs(nomsFonccion) do p[nomFonccion] = adaptior('_' .. nomFonccion) end return p

Tags:

🔥 Trending searches on Wiki Arpetan:

GuèrraOzbèquistan2RoumanchoTwitter1914SâlvengAbayie Sant-Mechiél-de-la-CllusaÈmirats arabos unis1940Reyômo-UniBiblaDrêtSeto VouèbeDick Cheney1746Antiles nêrlandêsesAnna StuartMathias ReynardRizomoLista des prèsidents des Ètats-Unis d’Amèrica201028 mârsLe CotiôJapon5 de fevriérAvignonNha TrangDamâsc4 de jouinNig·èrLa Voix des AllobrogesBahamasSeconda Guèrra mondiâlaPayis nordicosBiologia19192020SportHifaGenroVeles du KazacstanAnatoliaRouandaFacebookAstronomia25 de j·ulyètTuvaluPremiéra Guèrra mondiâlaLacionBasile LuyetNatura6 de novembroSèrbiaVela mondiâlaEnde6 de fevriérAfrica de BiseChinMartegnéSingaporGeorge Walker BushJohn LeguizamoArpetaniaEntreprêsesEBurkina FasôQueenItalieÈtats-Unis🡆 More