Module:Sourdant/infoboesse
I gn a nén co di dzo-pådje /doc pol notule d’ esplikêyes. Clitchîz cial po l’ ahiver.
-- {{#invoke:Sourdant|infoboesse|E89}}
-- to display informations about ref E89 into infobox
-- Used in Sourdant namespace (not yet a namespace)
local p = {}
local builder = require("Module:Builder")
local sourdant = require("Module:Sourdant")
local lingaedje = require("Module:Lingaedje")
function p.infoboesse(frame)
builder.init(frame, "Årtikes avou ene flotche dins modele sourdant-info")
-- get args from parent modele
local modele = mw.getCurrentFrame():getParent()
local args = modele.args
local refID = args[1]
if not refID then
builder.error("i gn a pont d' limero d' sourdant")
return builder.get_content()
end
local ref = sourdant.get_reference(refID)
if not ref then
builder.error("nole dinêye pol sourdant « "..refID.." »")
return builder.get_content()
end
-- image
local image = "Book important2.svg"
local is_def_image = true
if ref.image ~= nil and ref.image ~= "" then
local image_name = mw.title.makeTitle("File", ref.image)
if image_name.fileExists then
image = image_name.text
is_def_image = false
end
end
-- author(s)
local div_author = nil
local aname = nil
if ref.author ~= nil then
aname = ref.author
elseif ref.authors ~= nil then
aname = frame:newParserValue( ref.authors ).expand()
elseif ref.id_author ~= nil and ref.id_author == "sn" then
aname = true
end
if aname then
div_author = mw.html.create( 'div' )
div_author:css({
["margin-bottom"] = "0.5em"
})
if ref.title then
if ref.id_author ~= nil then
if ref.id_author == "sn" then
div_author:wikitext( 'Sins no' )
else
div_author:wikitext( "[[Sourdant:".. ref.id_author .."|".. aname .."]]" )
--builder.add_category("Sicrijhaedjes da ".. aname)
end
else
div_author:wikitext( sourdant.get_authors_list(aname,true) )
end
else
div_author:wikitext( "'''" .. aname .."'''" )
end
if ref.aka then
div_author:wikitext( ' (<abbr title="no d’ pene">n.p.</abbr> ' .. ref.aka ..')' )
end
end
-- title
local div_title = nil
if ref.title then
div_title = mw.html.create( 'div' )
if ref.name then
div_title = mw.html.create( 'div' )
div_title:wikitext( "''".. ref.title .."''<br>("..ref.name..")" )
else
div_title:wikitext( "''".. ref.title .."''" )
end
end
-- publication
local div_pub = mw.html.create( 'div' )
div_pub:css({
["margin-top"] = "0.5em"
})
if ref.year ~= nil and ref.year ~= "" then
div_pub:wikitext(ref.year )
end
if ref.publication ~= nil and ref.publication ~= "" then
local pub = frame:newParserValue( ref.publication )
div_pub:wikitext( ", ".. pub.expand() )
elseif ref.alt_publication ~= nil and ref.alt_publication ~= "" then
local pub = frame:newParserValue( ref.alt_publication )
div_pub:wikitext( pub.expand() )
end
-- lang
local div_lang = nil
if ref.lang ~= nil then
local l = require("Module:Lingaedje")
local lname = l.get_name(ref.lang)
local lobj = mw.language.new( 'wa' )
if lname ~= nil then
div_lang = mw.html.create( 'div' )
div_lang:css({
["margin"] = "0.5em 0"
})
div_lang:wikitext( "Lingaedje : [[:Categoreye:".. lobj:ucfirst(lname) .."|" .. lname .."]]" )
end
end
-- ref id
local li_num = mw.html.create( 'li' )
local span_num_link = mw.html.create( 'span' )
span_num_link:css({
["font-size"] = "0.8em"
})
:wikitext( " ([[Aidance:Sourdants#Rahoucas|Cwè çki c' est ?]])" )
li_num:wikitext( "Rahouca : '''".. refID .."'''" )
li_num:node( span_num_link )
-- left column
local div_col_left = mw.html.create( 'div' )
div_col_left:addClass("info-sc1")
:node( div_author )
:node( div_title )
:node( div_pub )
:node( div_lang )
-- right column
local ul_col_right = mw.html.create( 'ul' )
ul_col_right:node( li_num )
-- aliases
if(ref.aliases ~= nil) then
local li_aliases = mw.html.create( 'li' )
li_aliases:wikitext( "Alias : " )
for k, a in pairs(ref.aliases) do
if k > 1 then
li_aliases:wikitext( " ; ")
end
li_aliases:wikitext( "'''"..a.id.."'''")
if a.description ~= nil then
li_aliases:wikitext( " ("..a.description..")")
end
end
ul_col_right:node(li_aliases)
end
-- isbn
if(ref.isbn13 ~= nil or ref.isbn10 ~= nil) then
local isbn = ""
if ref.isbn13 ~= nil then
isbn = ref.isbn13
else
isbn = ref.isbn10
end
local li_isbn = mw.html.create( 'li' )
li_isbn:wikitext( "ISBN : [[Special:BookSources/"..isbn.."|"..isbn.."]]" )
ul_col_right:node(li_isbn)
end
-- wikipedia
if ref.wikipedia ~= nil then
local wikipedia = ref.wikipedia
if ref.wikipedia.title ~= nil then wikipedia = ref.wikipedia.title end
local li_wikipedia = mw.html.create( 'li' )
li_wikipedia:wikitext( "[[:w:".. wikipedia .."|Wikipedia]]" )
ul_col_right:node( li_wikipedia )
--builder.add_category("Sourdants prezintés so Wikipedia")
end
-- wikisource
if ref.wikisource ~= nil then
local ws_NS = "Index"
local ws_link = ""
local ws_link_text = ""
if ref.wikisource.book ~= nil then
ws_link = ws_NS..":"..ref.wikisource.book
ws_link_text = ref.wikisource.book
if ref.wikisource.title ~= nil then
ws_link = ref.wikisource.title
ws_link = string.gsub(ws_link, '/__WORD__', '')
ws_link_text = ws_link
end
-- cover from book
if is_def_image and ref.wikisource.coverpage ~= nil then
image = ref.wikisource.book .. '|page='..ref.wikisource.coverpage
end
--builder.add_category("Sourdants so Wikisourd")
elseif type(ref.wikisource) == "string" then
ws_NS = "Oteur:" -- todi so wikisourd e walon ?
if string.match(ref.wikisource, 'Oteur:') then
ws_NS = ''
end
ws_link = ws_NS..ref.wikisource
ws_link_text = ref.author
end
if ref.wikisource.lang ~= "wa" and ref.wikisource.lang ~= nil then
ws_link = ref.wikisource.lang .. ":" ..ws_link
end
local li_wikisource = mw.html.create( 'li' )
li_wikisource:wikitext( "[[:s:".. ws_link .."|Wikisourd]]" )
ul_col_right:node( li_wikisource )
end
-- wikidata
if ref.wikidata ~= nil and ref.wikidata ~= "" then
local li_wikidata = mw.html.create( 'li' )
li_wikidata:wikitext( "[[:d:".. ref.wikidata .."|Wikidata]]")
ul_col_right:node( li_wikidata)
end
-- extarnal ressource
if ref.external ~= nil and ref.external.link ~= nil then
local ref_ext_name = mw.uri.new(ref.external.link).host
local li_external = mw.html.create( 'li' )
li_external:css({
["word-break"] = "break-all"
})
:wikitext( "Sol daegntoele : [".. ref.external.link .." " ..ref_ext_name .."]")
ul_col_right:node( li_external )
end
-- image link
image = '[[File:'..image..'|left|128px]]'
-- columns container
local div_columns = mw.html.create( 'div' )
div_columns:addClass("info-sc")
:node( div_col_left )
:node( ul_col_right )
-- categories container
local div_cats = nil
if ref.title ~= nil and args.cat ~= "neni" then
div_cats = mw.html.create( 'div' )
div_cats:addClass("info-cat")
:wikitext( "Tos les mots di ci [[sourdant]] ci k' ont ddja stî [[rahoukî]]s sol Wiccionaire sont dins ''[[:Categoreye:Mots ki sont dins ".. ref.id .."|cisse categoreye cial]]''." )
local cat_name_prov = mw.title.makeTitle("Categoreye", "Spots ki sont dins ".. ref.id .."")
if cat_name_prov.exists then
div_cats:wikitext( " Po les [[spot|spots]] loukîz dins ''[[:Categoreye:Spots ki sont dins ".. ref.id .."|cisse categoreye cial]]''." )
end
local cat_name_expr = mw.title.makeTitle("Categoreye", "Dijhêyes ki sont dins ".. ref.id .."")
if cat_name_expr.exists then
div_cats:wikitext( " Po les [[dijhêye|dijhêyes]] loukîz dins ''[[:Categoreye:Dijhêyes ki sont dins ".. ref.id .."|cisse categoreye cial]]''." )
end
end
-- categoreye po les sourdants sorlon li lingaedje
-- nén possibe avou Wikidata
--[[local srclang = "wa"
if ref.srclang ~= nil and ref.srclang ~= "" then srclang = ref.srclang end
builder.add_category(lingaedje.grammar({args={'Sourdants', srclang, '', vowel='1'}}), 102)
--]]
builder.add_category('Sourdants', 102)
-- change link row
local div_row_change = mw.html.create( 'div' )
div_row_change:addClass("mw-editsection")
:node( "[ [[Module:Sourdant/".. refID .."|candjî]] ]" )
-- main container
local div = mw.html.create( 'div' )
div :addClass("info-sourdant")
:node( div_row_change )
:wikitext( image )
:node( div_columns )
:node( div_cats )
builder.add_content(tostring(div))
return builder.get_content()
end
return p