মডিউল:Header template
- বিস্তারিত সাহায্যের জন্য সাহায্য:পরিলেখন দেখুন দেখানে <pages index=… /> ট্যাগ সংক্রান্ত সকল বর্ননা আছে
- <pages/> ট্যাগ দ্বারা উৎপন্ন হবে ও টাইটেল বক্স বা শিরনামে আসবে
- নির্ঘণ্ট পাতায় <pages/> ট্যাগ থেকে লিখিত এই টেমপ্লেটের মাধ্যমে নিচের প্যারামিটার গুলি মান্যতা দেবে ও গ্রহণ করা হয়েছে।
- প্যারামিটার গুলি "pages" কে মান্যতা দেবে।
- উদাহরণ :
<pages index="নির্ঘণ্ট ফাইলের নাম" header=1"/>
- প্রযুক্তিগত বিবরণ
This template is implemented in Lua via the মডিউল:Header template . It uses the following parameters defined by the ProofreadPage extension:
Parameter | description |
---|---|
from | the user-defined from value , 1 by default |
displayed_from | the page number to be displayed for the first page (default one defined in Index: page ) |
to | the user-defined to value , defaults to the last page |
displayed_to | the page number to display for the last page (by default the one defined in the Book Index: page) |
current | the name of the link pointing to the current page in the contents of the Book Index: page |
prev | the name of the link pointing to the page preceding the current page in the contents of the Book Index: page |
next | the name of the link pointing to the page following the current page in the contents of the Book Index: page |
value | the value of the header attribute of the <pages/>tag , or toc if neither from nor to are specified |
The other parameters are the names of the fields appearing in the Book index form. Their value is the one that appears in the form, unless the user redefined it in the <pages/> tag , in which case the value of the tag takes precedence over that of the index.
For the type parameter , the value appearing in the drop-down menu of the index page form is converted into a name for internal use according to the following correspondence table:
internal value | drop-down menu value |
---|---|
book | Delivered |
collection | Collection |
journal | Journal or magazine |
Phd thesis | Thesis, report |
dictionary | Dictionary, encyclopedia, reference work |
This is the internal value that is used by the model. Likewise, if the user wishes to redefine the value of the type field inside the <pages /> tag , he must use the internal value.
function errorMessage(text)
-- Return a html formated version of text stylized as an error.
local html = mw.html.create('div')
html:addClass('error')
:wikitext(text)
:wikitext('[[Category:Pages making a wrong call to the author template]]')
return tostring(html)
end
function cleanCoinsParameter( param )
param = string.gsub( param, "%[%[.*|(.*)%]%]", "%1" )
return string.gsub( param, "%[%[(.*)%]%]", "%1" )
end
function toAbsoluteTitle( relative_title, base_title )
--TODO: hacky implementation
return mw.getCurrentFrame():callParserFunction( '#rel2abs', { relative_title, tostring( base_title or mw.title.getCurrentTitle() ) } )
end
function formatString( str, schema_property )
return tostring(mw.html.create('span')
:attr('itemprop', schema_property)
:wikitext(str)
)
end
function formatYear( date, schema_property )
local year = tonumber( date )
if year == nil or year < 1000 then
return tostring(mw.html.create('span')
:attr('itemprop', schema_property)
:wikitext(require('মডিউল:ConvertDigit')._main(date)))
else
return tostring(mw.html.create('time')
:attr('datetime', year)
:attr('itemprop', schema_property)
:wikitext(require('মডিউল:ConvertDigit')._main(date)))
end
end
function formatEditorWithName( name )
return tostring(mw.html.create('span')
:attr('itemprop', 'editor')
:attr('itemscope', '')
:attr('itemtype', 'http://schema.org/Thing') --TODO: better types
:tag('span')
:attr('itemprop', 'name')
:wikitext(name)
:done()
)
end
function formatLink( page, label, schema_property )
local title = mw.title.new( toAbsoluteTitle( page ) )
if title == nil then
return tostring(mw.html.create('span')
:attr('itemprop', schema_property)
:attr('itemscope', '')
:attr('itemtype', 'http://schema.org/Thing') --TODO: better types
:wikitext('[[' .. page .. '|<span itemprop="name">' .. label .. '</span>]]')
)
end
if title.isRedirect then
title = title.redirectTarget
end
local tag = mw.html.create('span')
:attr('itemprop', schema_property)
:attr('itemscope', '')
:attr('itemtype', 'http://schema.org/Thing') --TODO: better types
:wikitext('[[' .. title.fullText .. '|<span itemprop="name">' .. label .. '</span>]]')
:tag('link')
:attr('itemprop', 'mainEntityOfPage')
:attr('href', title:fullUrl(nil, 'canonical'))
:done()
local itemId = mw.wikibase.getEntityIdForTitle(title.fullText)
if itemId ~= nil then
tag:attr('itemid', 'http://www.wikidata.org/entity/' .. itemId)
end
return tostring(tag)
end
function parseLinkWikitext( wikitext, schema_property )
wikitext = mw.ustring.gsub( wikitext, '%[%[([^|]*)|(.*)%]%]', function( page, link )
return formatLink( page, link, schema_property )
end )
wikitext = mw.ustring.gsub( wikitext, '%[%[([^|]*)%]%]', function( page )
return formatLink( page, mw.ustring.gsub( page, '%.*/', '') , schema_property )
end )
return wikitext
end
function formatTitleLink( page, label, schema_property )
local title = mw.title.new( toAbsoluteTitle( page ) )
if title == nil then
return '[[' .. page .. '|' .. label .. ']]'
end
if title.isRedirect then
title = title.redirectTarget
end
local tag = mw.html.create('span')
:attr('itemprop', schema_property)
:attr('itemscope', '')
:attr('itemtype', 'http://schema.org/CreativeWork') --TODO: find a more relenvant type
:wikitext('[[' .. title.fullText .. '|<span itemprop="name">' .. label .. '</span>]]')
:tag('link')
:attr('itemprop', 'mainEntityOfPage')
:attr('href', title:fullUrl(nil, 'canonical'))
:done()
local itemId = mw.wikibase.getEntityIdForTitle(title.fullText)
if itemId ~= nil then
tag:attr('itemid', 'http://www.wikidata.org/entity/' .. itemId)
end
return tostring(tag)
end
function parseTitleWikitext( wikitext, schema_property )
wikitext = mw.ustring.gsub( wikitext, '%[%[([^|]*)|(.*)%]%]', function( page, link )
return formatTitleLink( page, link, schema_property )
end )
wikitext = mw.ustring.gsub( wikitext, '%[%[([^|]*)%]%]', function( page )
return formatTitleLink( page, page, schema_property )
end )
return wikitext
end
function splitFileNameInFileAndPage(title)
local slashPosition = string.find(title.text, "/")
if slashPosition == nil then
return title.text,nil
else
return string.sub(title.text, 1, slashPosition - 1), string.sub(title.text, slashPosition + 1)
end
end
function process_authors(wikidata_item, headertemplate, property_id, estSommaire)
local wikidata_authors = wikidata_item:getBestStatements(property_id)
if next(wikidata_authors) ~= nil then
headertemplate = headertemplate:tag('div')
:addClass('headertemplate-author')
for index, author in pairs(wikidata_authors) do
local author_qid = ''
local author_label = ''
if author.mainsnak.snaktype == 'somevalue' then
author_qid = 'Q4233718'
author_label = 'অজ্ঞাত লেখক'
author_sitelink = 'লেখক:অজ্ঞাত'
else
author_qid = author.mainsnak.datavalue.value.id
author_label = mw.wikibase.getLabel(author_qid)
author_sitelink = mw.wikibase.getEntity(author_qid):getSitelink()
end
local category_name_author = ''
if author_label == 'একাধিক লেখক' or author_label == 'অজ্ঞাত লেখক' then
headertemplate:wikitext(parseLinkWikitext(author_label, 'লেখক'))
category_name_author = author_label
else
headertemplate:wikitext(parseLinkWikitext('[[' .. author_sitelink .. '|' .. author_label .. ']]', 'লেখক'))
category_name_author = mw.ustring.gsub(author_sitelink, 'লেখক:', '')
end
local author_name = mw.title.new( toAbsoluteTitle( 'লেখক:' .. author_label ) )
if author_name.isRedirect then
author_name = author_name.redirectTarget
end
headertemplate:wikitext('[[বিষয়শ্রেণী:' .. category_name_author .. ' রচিত]]')
if wikidata_authors[index + 1] ~= nil then
headertemplate:wikitext(', ')
end
end
headertemplate = headertemplate:done()
end
end
function process_translators(wikidata_item, headertemplate, property_id, estSommaire)
local translator_in = ''
local wikidata_translators = wikidata_item:getBestStatements(property_id)
if next(wikidata_translators) ~= nil then
for index, author in pairs(wikidata_translators) do
local author_qid = ''
local author_label = ''
local category_name_author = ''
if author.mainsnak.snaktype == 'somevalue' then
author_qid = 'Q4233718'
author_label = 'অজ্ঞাত লেখক'
author_sitelink = 'লেখক:অজ্ঞাত'
category_name_author = author_label
else
author_qid = author.mainsnak.datavalue.value.id
author_label = mw.wikibase.getLabel(author_qid)
author_sitelink = mw.wikibase.getEntity(author_qid):getSitelink()
category_name_author = mw.ustring.gsub(author_sitelink, 'লেখক:', '')
end
if mw.title.new('লেখক:' .. author_label).exists then
translator_in = translator_in .. '[[' .. author_sitelink .. '|' .. author_label .. ']]'
else
translator_in = translator_in .. "'''" .. author_label .. "'''"
end
if wikidata_translators[index + 1] ~= nil then
translator_in = translator_in .. ', '
end
headertemplate:wikitext('[[বিষয়শ্রেণী:' .. category_name_author .. ' অনূদিত]] [[বিষয়শ্রেণী:অনুবাদ সাহিত্য]]')
end
end
return translator_in
end
function process_editors(wikidata_item, headertemplate, property_id, estSommaire)
local editor_in = ''
local wikidata_editors = wikidata_item:getBestStatements(property_id)
if next(wikidata_editors) ~= nil then
for index, author in pairs(wikidata_editors) do
local author_qid = ''
local author_label = ''
if author.mainsnak.snaktype == 'somevalue' then
author_qid = 'Q4233718'
author_label = 'অজ্ঞাত লেখক'
else
author_qid = author.mainsnak.datavalue.value.id
author_label = mw.wikibase.getLabel(author_qid)
end
if mw.title.new('লেখক:' .. author_label).exists then
editor_in = editor_in .. '[[লেখক:' .. author_label .. '|' .. author_label .. ']]'
else
editor_in = editor_in .. "'''" .. author_label .. "'''"
end
if wikidata_editors[index + 1] ~= nil then
editor_in = editor_in .. ', '
end
headertemplate:wikitext('[[বিষয়শ্রেণী:' .. author_label .. ' সম্পাদিত]]')
end
end
return editor_in
end
function addBadges(frame, html, wikidata_item)
local badges = mw.wikibase.getBadges(wikidata_item:getId(), 'bnwikisource')
for i, badge in pairs(badges) do
if badge == 'Q20748092' then -- মুদ্রণ সংশোধন করা হয়েছে
html = html:wikitext(frame:expandTemplate{title='Top icon', args={ imagename = 'Wb-badges-proofread.svg', alt = 'মুদ্রণ সংশোধন করা হয়েছে', description = 'মুদ্রণ সংশোধন করা হয়েছে', id = 'proofread-star'}})
elseif badge == 'Q20748091' then -- মুদ্রণ সংশোধন করা হয়নি
html = html:wikitext(frame:expandTemplate{title='Top icon', args={ imagename = 'Wb-badges-notproofread.svg', alt = 'মুদ্রণ সংশোধন করা হয়নি', description = 'মুদ্রণ সংশোধন করা হয়নি', id = 'notproofread-star'}})
elseif badge == 'Q20748093' then -- বৈধকৃত
html = html:wikitext(frame:expandTemplate{title='Top icon', args={ imagename = 'Wb-badges-validated.svg', alt = 'বৈধকৃত', description = 'বৈধকৃত', id = 'validated-star'}})
elseif badge == 'Q17437796' then -- নির্বাচিত
html = html:wikitext(frame:expandTemplate{title='Top icon', args={ imagename = 'Featured article star.svg', alt = 'নির্বাচিত', description = 'নির্বাচিত', id = 'featured-star', maincat = '[[বিষয়শ্রেণী:নির্বাচিত]]'}})
end
end
return html
end
function headerTemplate( frame )
local parentFrame = frame:getParent()
local args = parentFrame.args
local wikidata_item = {}
if args.wikidata_item and args.wikidata_item ~= '' then
wikidata_item = mw.wikibase.getEntity(args.wikidata_item)
end
local subpage_wikidata_item = mw.wikibase.getEntity()
local page = mw.title.getCurrentTitle()
local item = mw.wikibase.getEntity()
local headerType = args.value
if args.header_type and args.header_type ~= '' then
headerType = args.header_type
end
headerType = mw.ustring.lower( headerType ) --Permet d'écrire le type en majuscule ou en minuscule
local estSommaire = (headerType == 'প্রচ্ছদ' or headerType == 'সূচীপত্র')
local estMusique = (headerType == 'গান')
local estFilm = (headerType == 'চলচ্চিত্র')
--Custom page numbers
local from = ''
if args.displayed_from and args.displayed_from ~= '' then
from = args.displayed_from
elseif args.from then
from = args.from
end
local to = ''
if args.displayed_to and args.displayed_to ~= '' then
to = args.displayed_to
elseif args.to then
to = args.to
end
local schema_type = 'http://schema.org/CreativeWork'
if args.type then
if args.type == 'book' then
if estSommaire then
schema_type = 'http://schema.org/Book'
else
schema_type = 'http://schema.org/Chapter'
end
elseif args.type == 'collection' then
if estSommaire then
schema_type = 'https://schema.org/Collection'
end
elseif args.type == 'journal' then
if estSommaire then
schema_type = 'https://schema.org/PublicationVolume'
else
schema_type = 'http://schema.org/Article'
end
elseif args.type == 'phdthesis' then
if estSommaire then
schema_type = 'http://schema.org/Thesis'
else
schema_type = 'http://schema.org/Chapter'
end
end
end
--শীর্ষকের শুরু
local html = mw.html.create()
html = addBadges(frame, html, wikidata_item)
local container = html:tag('div')
:attr('itemscope', '')
:attr('itemtype', schema_type)
:attr('class', 'wikisource-header-template')
if item ~= nil then
container:attr('itemid', 'http://www.wikidata.org/entity/' .. item.id)
end
classement( parentFrame, page, args )
if args.header_type == 'empty' then
if args.remarks then
container:tag( 'div' )
:addClass('ws-summary')
:css('margin-top', '1em')
:newline()
:wikitext(args.remarks)
end
return html
end
local headertemplate_top = container:tag('div')
:attr('id', 'headertemplate')
:addClass('ws-noexport')
:css({display = 'table', width = "98%"})
local headertemplate_left = headertemplate_top:tag('div'):addClass('headertemplate-left'):css({width = "16%", display = "table-cell", ["background-color"] = "#f4f0e5", ["border-top"] = "1px solid #A0A0A0"})
local headertemplate = headertemplate_top:tag('div'):css({display = 'table-cell', width = "66%"})
local headertemplate_right = headertemplate_top:tag('div'):addClass('headertemplate-right'):css({width = "16%", display = "table-cell", ["background-color"] = "#f4f0e5", ["border-top"] = "1px solid #A0A0A0"})
if args.type == 'journal' then
headertemplate:addClass('headertemplate-journal')
else
headertemplate:addClass('headertemplate')
end
--লেখক
if args.author and args.author ~= '' then
headertemplate:tag('div')
:addClass('headertemplate-author')
:wikitext(parseLinkWikitext(args.author, 'লেখক'))
elseif subpage_wikidata_item ~= nil and next(subpage_wikidata_item) ~= nil then
process_authors(subpage_wikidata_item, headertemplate, 'P50', estSommaire)
process_authors(subpage_wikidata_item, headertemplate, 'P676', estSommaire)
process_authors(subpage_wikidata_item, headertemplate, 'P58', estSommaire)
elseif next(wikidata_item) ~= nil then
process_authors(wikidata_item, headertemplate, 'P50', estSommaire)
end
local wikidata_item_for_images = nil
if subpage_wikidata_item ~= nil and next(subpage_wikidata_item) ~= nil then
wikidata_item_for_images = subpage_wikidata_item
elseif next(wikidata_item) ~= nil then
wikidata_item_for_images = wikidata_item
end
if next(wikidata_item_for_images) ~= nil then
local author_images = {}
for _, author in pairs(wikidata_item_for_images:getBestStatements('P50')) do
local author_statement = author.mainsnak
if author_statement.datavalue ~= nil then
local author_images_1 = mw.wikibase.getEntity(author_statement.datavalue.value.id):getBestStatements('P18')
if next( author_images_1 ) ~= nil then
table.insert(author_images, author_images_1[1].mainsnak.datavalue.value)
end
end
end
for _, author in pairs(wikidata_item_for_images:getBestStatements('P655')) do
local author_statement = author.mainsnak
if author_statement.datavalue ~= nil then
local author_images_1 = mw.wikibase.getEntity(author_statement.datavalue.value.id):getBestStatements('P18')
if next( author_images_1 ) ~= nil then
table.insert(author_images, author_images_1[1].mainsnak.datavalue.value)
end
end
end
if author_images[1] ~= nil then
headertemplate_right:wikitext('[[চিত্র:' .. author_images[1] .. '|120px]]')
end
if author_images[2] ~= nil then
headertemplate_left:wikitext('[[চিত্র:' .. author_images[2] .. '|120px]]')
end
end
--title
local title = formatString( page.baseText, 'name' )
local title_link = page.baseText
if not mw.title.new(title_link).exists then -- TODO: is there a more elegant way to handle this?
title_link = mw.title.new(title_link).baseText
end
if args.type == 'collection' then
if args.collection and args.collection ~= '' then
-- Commented to test with only the name of the collection, the title is already in the browser and frequently at the start of the page.
-- title = title .. ' — <i>' .. args.collection .. '</i>'
title = '<i>' .. parseTitleWikitext(args.collection, 'isPartOf') .. '</i>'
elseif args.current then
title = formatString( args.current, 'name' )
else
if estSommaire then
title = formatString( title, 'name' )
else
title = parseTitleWikitext(title, 'isPartOf')
end
end
if args.publication and args.publication ~= '' then
title = title .. ' <span style="font-size:90%;">(' .. args.publication .. ')</span>'
end
elseif args.type == 'journal' then
if estSommaire then
title = formatString( args.title, 'name' )
elseif args.current then
title = formatString( args.current, 'name' )
else
title = parseTitleWikitext(title, 'isPartOf')
end
else
if args.title ~= '' then
title = args.title
elseif next(wikidata_item) ~= nil then
local wikidata_title = wikidata_item:formatPropertyValues('P1476')['value']
if wikidata_title ~= '' then
title = wikidata_title
end
end
raw_title = title
if estSommaire then
title = formatString( title, 'name' )
else
title = parseTitleWikitext(title, 'isPartOf')
title = '[[' .. title_link .. '|' .. title .. ']]'
end
if args.publication and args.publication ~= '' then
title = title .. ' <span style="font-size:90%;">(' .. args.publication .. ')</span>'
end
end
if estSommaire and args['subtitle'] and args['subtitle'] ~= '' then
title = title .. ' <br/><small>' .. args['subtitle'] .. '</small>'
end
if estSommaire and next(wikidata_item) ~= nil and next(wikidata_item:getBestStatements('P629')) ~= nil then
p629statementvalue = wikidata_item:getBestStatements('P629')[1].mainsnak.datavalue.value.id
p629statementlink = mw.wikibase.getEntity(p629statementvalue):getSitelink()
if p629statementlink then
title = title .. ' [[File:Disambig_colour.svg|25px|link=' .. p629statementlink .. '|অন্য সংস্করণ দেখুন]]</small>'
end
end
headertemplate:tag('div')
:addClass('headertemplate-title')
:wikitext(title)
--References
local references = headertemplate:tag('div')
:addClass('headertemplate-reference')
local translator_in = ''
if args.translator and args.translator ~= '' then
translator_in = args.translator
elseif next(wikidata_item) ~= nil then
translator_in = process_translators(wikidata_item, headertemplate, 'P655', estSommaire)
end
if translator_in ~= '' then
references:wikitext(parseLinkWikitext(translator_in, 'translator') .. ' অনূদিত')
:tag('br')
end
local editor_in = ''
if args.editor and args.editor ~= '' then
editor_in = args.editor
elseif next(wikidata_item) ~= nil then
editor_in = process_editors(wikidata_item, headertemplate, 'P98', estSommaire)
end
if editor_in ~= '' then
references:wikitext(parseLinkWikitext(editor_in, 'editor') .. ' সম্পাদিত')
:tag('br')
end
if estSommaire and args.illustrator and args.illustrator ~= '' then
references:wikitext(parseLinkWikitext(args.illustrator, 'illustrator') .. ' অঙ্কিত')
:tag('br')
end
if estMusique == true then
composer_in = process_translators(wikidata_item, headertemplate, 'P86', estSommaire)
performer_in = process_translators(wikidata_item, headertemplate, 'P175', estSommaire)
movie_in = process_translators(wikidata_item, headertemplate, 'P9899', estSommaire)
references:wikitext(parseLinkWikitext(composer_in, 'composer') .. ' সুরারোপিত'):tag('br')
references:wikitext(parseLinkWikitext(performer_in, 'performer') .. ' গীত'):tag('br')
if movie_in ~= '' then
references:wikitext(parseLinkWikitext(movie_in, 'movie') .. ' চলচ্চিত্রে ব্যবহৃত'):tag('br')
end
end
if estFilm == true then
director_in = process_translators(wikidata_item, headertemplate, 'P57', estSommaire)
producer_in = process_translators(wikidata_item, headertemplate, 'P162', estSommaire)
references:wikitext(parseLinkWikitext(director_in, 'director') .. ' পরিচালিত'):tag('br')
references:wikitext(parseLinkWikitext(producer_in, 'producer') .. ' প্রযোজিত'):tag('br')
end
if estSommaire and args.volume and args.volume ~= '' then
references:wikitext( formatString( args.volume, 'খণ্ড' ) )
:tag('br')
end
local infos = {} --List of data to display separated by a comma
if args.type == 'collection' then
if args.title and args.title ~= '' then
table.insert( infos, '<i>' .. parseTitleWikitext(args.title, 'isPartOf') .. '</i>' )
end
if args.scientific_editor and args.scientific_editor ~= '' then
table.insert( infos, 'Texte établi par ' .. parseLinkWikitext( args.scientific_editor, 'সম্পাদক' ) )
end
if args.editor and args.editor ~= '' then
table.insert( infos, formatEditorWithName( args.editor ) )
end
if args.year and args.year ~= '' then
table.insert( infos, formatYear( args.year, 'datePublished' ) )
end
if not estSommaire then
if args.volume and args.volume ~= '' then
table.insert( infos, formatString( args.volume, 'volumeNumber' ) )
end
end
elseif args.type == 'journal' then
if not estSommaire then
table.insert( infos, '<i>' .. parseTitleWikitext( args.title, 'isPartOf' ) .. '</i>' )
if args.volume and args.volume ~= '' then
table.insert( infos, formatString( args.volume, 'volumeNumber' ) )
end
end
if args.year and args.year ~= '' then
table.insert( infos, formatYear( args.year, 'datePublished' ) )
end
else
if args.scientific_editor and args.scientific_editor ~= '' then
table.insert( infos, 'Texte établi par ' .. parseLinkWikitext( args.scientific_editor, 'editor' ) )
end
if args.editor and args.editor ~= '' then
table.insert( infos, formatEditorWithName( args.editor ) .. ' সম্পাদিত' )
end
if args.year and args.year ~= '' then
table.insert( infos, formatYear( args.year, 'datePublished' ) )
elseif next(wikidata_item) ~= nil then
for _, statement in pairs(wikidata_item:getBestStatements('P577')) do
if statement.mainsnak.datavalue ~= nil then
local current_year = mw.ustring.sub(statement.mainsnak.datavalue.value.time, 2, 5)
local year_string = formatYear( current_year, 'datePublished' )
if estSommaire then
year_string = year_string .. "[[বিষয়শ্রেণী:" .. require('মডিউল:ConvertDigit')._main(current_year) .. " খ্রিস্টাব্দে প্রকাশিত]]"
end
table.insert( infos, year_string )
end
end
end
end
local line = ''
if infos ~= {} then
line = table.concat( infos, ', ' )
end
--Parenthesis
if not estSommaire and from ~= '' then
local temp = ''
if args.volume and args.volume ~= '' and args.type ~= 'collection' and args.type ~= 'journal' then
temp = formatString( args.volume, 'volumeNumber' ) .. ', '
end
if from ~= to or from ~= '-' then
temp = temp .. pagination( from, to )
end
if temp ~= '' then
line = line .. ' (' .. temp .. ')'
end
end
if line ~= '' then
references:wikitext(line .. '')
end
local subheader = container:tag('div')
:attr('id', 'subheader')
:addClass('ws-noexport')
:css('margin-bottom', '1.5em')
notes_text = ''
if estSommaire then
notes_text = notes_text .. frame:expandTemplate{title = 'engine', args = { raw_title }}
end
if (args.sectionnotes and args.sectionnotes ~= '') then
notes_text = notes_text .. args.sectionnotes
elseif ((estSommaire or estMusique or estFilm) and args.notes and args.notes ~= '') then
notes_text = notes_text .. args.notes
end
if notes_text ~= '' then
subheader:tag('div')
:addClass('subheader-notes')
:wikitext(notes_text)
end
if (not estSommaire or (args.header_type and args.header_type =='সূচীপত্র')) and ((args.prev and args.prev ~= '') or (args.next and args.next ~= '')) then
local maxwidth = 50
if args.type ~= 'collection' and args.current and args.current ~= '' then
maxwidth = 33
end
local footer = subheader:tag('div')
:addClass('footertemplate')
:addClass('ws-noexport')
local nav = footer:tag('div')
:addClass('footertemplate-content')
nav = nav:tag('div')
:addClass('footertemplate-prev')
:tag('span')
:attr('id', 'headerprevious')
if args.prev and args.prev ~= '' then
nav = nav:tag('span')
:css('color', '#808080')
:wikitext('◄ ')
:done()
:wikitext(parseLinkWikitext(args.prev, 'previousItem'))
else
nav = nav:wikitext(parseLinkWikitext('', 'previousItem'))
end
nav = nav:done():done()
if args.type ~= 'collection' and args.current then
nav:tag('div')
:addClass('footertemplate-cur')
:attr('itemprop', 'name')
:wikitext(args.current)
end
nav = nav:tag('div')
:addClass('footertemplate-next')
:tag('span')
:attr('id', 'headernext')
if args.next and args.next ~= '' then
nav = nav:wikitext(parseLinkWikitext(args.next, 'nextItem'))
:tag('span')
:css('color', '#808080')
:wikitext(' ►')
else
nav = nav:wikitext(parseLinkWikitext('', 'nextItem'))
end
nav = nav:done():done()
footer:tag('div')
:css('clear', 'both')
end
-- Catégories
if estSommaire and (not item or not item['claims'] or not item['claims']['P629']) then
container:wikitext("[[বিষয়শ্রেণী:আইটেমে 'যে সত্তার সংস্করণ অথবা অনুবাদ' বৈশিষ্ট্য প্রয়োজন এমন লেখা]]")
end
if page.isSubpage then
container:wikitext("[[বিষয়শ্রেণী:উপপাতা]]")
end
--form/genre/award
categoryForForm = mw.loadData('মডিউল:Work/form')
categoryForGenre = mw.loadData('মডিউল:Work/genre')
categoryForAward = mw.loadData('মডিউল:Work/award')
if subpage_wikidata_item ~= nil then
if next(subpage_wikidata_item:getBestStatements('P629')) ~= nil then
p629statementvalue = subpage_wikidata_item:getBestStatements('P629')[1].mainsnak.datavalue.value.id
p629statementitem = mw.wikibase.getEntity(p629statementvalue)
for _, statement in pairs(p629statementitem:getBestStatements('P7937')) do
if statement.mainsnak.datavalue ~= nil then
formId = statement.mainsnak.datavalue.value.id
if categoryForForm[formId] == nil then
container:wikitext('[[বিষয়শ্রেণী:Pages using the template Work with a form without Category]]')
elseif categoryForForm[formId] then
container:wikitext('[[বিষয়শ্রেণী:' .. categoryForForm[formId] .. ']]')
end
end
end
for _, statement in pairs(p629statementitem:getBestStatements('P136')) do
if statement.mainsnak.datavalue ~= nil then
genreId = statement.mainsnak.datavalue.value.id
if categoryForGenre[genreId] == nil then
container:wikitext('[[বিষয়শ্রেণী:Pages using the template Work with a genre without Category]]')
elseif categoryForGenre[genreId] then
container:wikitext('[[বিষয়শ্রেণী:' .. categoryForGenre[genreId] .. ']]')
end
end
end
for _, statement in pairs(p629statementitem:getBestStatements('P166')) do
if statement.mainsnak.datavalue ~= nil then
awardId = statement.mainsnak.datavalue.value.id
if categoryForAward[awardId] ~= nil then
container:wikitext(frame:expandTemplate{title='Top icon', args={ imagename = 'BS Icon - Trophy.svg', alt = 'পুরস্কারপ্রাপ্ত লেখা', description = '<i>' .. categoryForAward[awardId] .. '</i>', id = 'awarded-star', maincat = '[[বিষয়শ্রেণী:' .. categoryForAward[awardId] .. ']]'}})
end
end
end
end
end
-- Inclusion de l'épigraphe et du sommaire
if headerType == 'সূচীপত্র' then
if args.epigraphe and args.epigraphe ~= '' then
container:wikitext(args.epigraphe)
:newline()
end
container:tag('div')
:addClass('ws-summary')
:css('margin-top', '1em')
:wikitext(args.remarks)
end
--Métadonnées schema.org supplémentaires
container:tag('link')
:attr('itemprop', 'mainEntityOfPage')
:attr('href', page:fullUrl(nil, 'canonical'))
container:tag('meta')
:attr('itemprop', 'inLanguage')
:attr('content', 'bn') --TODO: que faire pour l'ancien français...
if args.lieu and args.lieu ~= '' then
container:tag('meta')
:attr('itemprop', 'http://purl.org/library/placeOfPublication')
:attr('content', args.lieu) --TODO: is it the best property URI and the best value format?
end
if args.index and args.index ~= '' then
local indexFile = mw.title.makeTitle('File', args.index)
if indexFile ~= nil and indexFile.file.exists then
container:tag('span')
:attr('itemprop', 'associatedMedia')
:attr('itemscope', '')
:attr('itemtype', 'http://schema.org/MediaObject')
:tag('link')
:attr('itemprop', 'mainEntityOfPage')
:attr('href', indexFile:fullUrl(nil, 'canonical'))
:done()
:tag('meta')
:attr('itemprop', 'width')
:attr('content', indexFile.file.width)
:done()
:tag('meta')
:attr('itemprop', 'height')
:attr('content', indexFile.file.height)
:done()
:tag('meta')
:attr('itemprop', 'fileFormat')
:attr('content', indexFile.file.mimeType)
:done()
end
end
-- Métadonnées, see http://ocoins.info/ for coins.
local coins = {}
local uriCoins = 'ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3A'
coins['rft.genre'] = 'unknown'
coins['rfr_id'] = tostring( page:fullUrl( nil, "canonical" ) )
local datahtml = container:tag('div')
:attr('id', 'ws-data')
:addClass('ws-noexport')
:css('display', 'none')
:css('speak', 'none')
if args.type then
datahtml:node( outputMicroformatRow( 'type', args.type ) )
end
if args.type and args.type == 'journal' then
uriCoins = uriCoins .. 'journal'
if estSommaire then
coins['rft.genre'] = 'publication'
coins['rft.jtitle'] = cleanCoinsParameter( title )
else
coins['rft.genre'] = 'article'
coins['rft.atitle'] = cleanCoinsParameter( title )
if args.title then
coins['rft.jtitle'] = cleanCoinsParameter( args.title )
datahtml:node( outputMicroformatRow( 'periodical', cleanCoinsParameter( args.title ) ) )
end
end
else
uriCoins = uriCoins .. 'book'
if estSommaire then
coins['rft.btitle'] = cleanCoinsParameter( title )
else
coins['rft.atitle'] = cleanCoinsParameter( title )
end
if args.type and args.type == 'book' then
if estSommaire then
coins['rft.genre'] = 'book'
else
coins['rft.genre'] = 'bookitem'
end
end
end
datahtml:node( outputMicroformatRow( 'title', title ) )
if args.author and args.author ~= '' then
datahtml:node( outputMicroformatRow( 'author', args.author ) )
coins['rft.au'] = cleanCoinsParameter( args.author )
end
if args.translator and args.translator ~= '' then
datahtml:node( outputMicroformatRow( 'translator', args.translator ) )
end
if args.illustrator and args.illustrator ~= '' then
datahtml:node( outputMicroformatRow( 'illustrator', args.illustrator ) )
end
if args.school and args.school ~= '' then
datahtml:node( outputMicroformatRow( 'school', args.school ) )
end
if args.editor and args.editor ~= '' then
datahtml:node( outputMicroformatRow( 'editor', args.editor ) )
coins['rft.pub'] = cleanCoinsParameter( args.editor )
end
if args.year and args.year ~= '' then
datahtml:node( outputMicroformatRow( 'year', args.year ) )
coins['rft.date'] = args.year
end
if args.lieu and args.lieu ~= '' then
datahtml:node( outputMicroformatRow( 'place', args.lieu ) )
coins['rft.place'] = args.lieu
end
if args.avancement and args.avancement ~= '' then
datahtml:node( outputMicroformatRow( 'progress', args.avancement ) )
end
if args.volume and args.volume ~= '' then
datahtml:node( outputMicroformatRow( 'volume', args.volume ) )
end
if args.current and args.current ~= '' then
datahtml:node( outputMicroformatRow( 'chapter', args.current ) )
end
if args.index then
datahtml:node( outputMicroformatRow( 'scan', args.index ) )
local imageTitle = nil
if tonumber(args.image) ~= nil then
imageTitle = mw.title.new(args.index, "Media"):subPageTitle(args.image)
elseif args.image ~= nil then
imageTitle = mw.title.new(args.image, "Media")
end
if imageTitle ~= nil then
datahtml:node( outputMicroformatRow( 'cover', imageTitle.text ) )
end
end
if from ~= '' and to ~= '' then
if from == to then
datahtml:node( outputMicroformatRow( 'pages', from ) )
else
datahtml:node( outputMicroformatRow( 'pages', from .. '-' .. to ) )
end
coins['rft.spage'] = from
coins['rft.epage'] = to
end
datahtml:tag('span')
:addClass('Z3988')
:attr('title', uriCoins .. '&' .. mw.uri.buildQueryString( coins ))
:wikitext(' ')
return html
end
function classement( frame, page, args )
local classement = require 'Module:Classement'
local key = ''
if args.type and args.type == 'journal' then
key = classement.getSortKey( {args= {page.text}} )
elseif args.type and (args.type == 'dictionary' or args.type == 'collection') then
key = classement.getSortKey( {args= {page.subpageText}} )
elseif not page.isSubpage then
key = classement.getSortKey( {args= {page.text}} )
end
if key ~= '' then
--Evite le parse des paramètres passés à la page.
local child = frame:newChild{ title = page.text, args = {} }
child:preprocess( '{{DEFAULTSORT:' .. key .. '}}\n' )
end
end
function pagination( from, to )
if from ~= '' and to ~= '' then
if from == to then
return '<abbr title="পৃষ্ঠা">পৃ.</abbr> ' .. formatString( from, 'pagination' )
else
return '<abbr title="পৃষ্ঠা">পৃ.</abbr> ' .. formatString( from, 'pageStart' ) .. '-' .. formatString( to, 'pageEnd' )
end
end
end
function outputMicroformatRow( name, value )
return mw.html.create('span')
:addClass('ws-' .. name)
:wikitext(value)
end
local p = {}
function p.headerTemplate( frame )
frame:extensionTag( 'templatestyles', '', { src = "টেমপ্লেট:শীর্ষক.css" } )
return headerTemplate( frame )
end
function p.voirEditions( frame )
local args = frame:getParent().args
if not args[1] or args[1] == '' then
return errorMessage("Le modèle VoirEdition prend en paramètre un lien vers la liste des éditions")
end
local node = mw.html.create('small')
:addClass('ws-noexport')
:css({
['text-align'] = 'center',
['font-style'] = 'italic'
})
:attr('itemscope', '')
:attr('itemtype', 'http://schema.org/CreativeWork')
local itemId = mw.wikibase.getEntityIdForCurrentPage()
if itemId ~= nil then
node:attr('itemid', 'http://www.wikidata.org/entity/' .. itemId)
end
node:wikitext('[[Image:List2.svg|25px|lien=]] Pour les autres éditions de ce texte, voir ')
:wikitext(parseTitleWikitext(args[1], 'exampleOfWork'))
:wikitext('.')
return tostring(node)
end
return p