মডিউল:Index data
এই মডিউলের জন্য মডিউল:Index data/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে
--[[Retrieves the data from the index page and enriches it with Wikidata]]--
local indexToWikidata = {
-- title are specially managed
['subtitle'] = 'P1680',
['volume'] = 'P478',
['issue'] = 'P433',
['edition'] = 'P393',
['author'] = 'P50',
['foreword_author'] = 'P2679',
['afterword_author'] = 'P2680',
['translator'] = 'P655',
['editor'] = 'P98',
['illustrator'] = 'P110',
['lyricist'] = 'P676',
['composer'] = 'P86',
['singer'] = 'P175',
['publisher'] = 'P123',
['printer'] = 'P872',
['address'] = 'P291',
['publishedin'] = 'P1433',
-- ['year'] = 'P577',
}
function indexDataWithWikidata(frame)
--create a clean table of parameters with blank parameters removed
local args = {}
for k,v in pairs(frame.args) do
if v ~= '' then
args[k] = v
end
end
local item = nil
if args.wikidata_item then
item = mw.wikibase.getEntity(args.wikidata_item)
if item == nil then
mw.addWarning('L\'identifiant d\'Wikidata entity [[d:' .. args.wikidata_item .. '|' .. args.wikidata_item .. ']] put in the "Wikidata entity" parameter of the Book page: does not seem valid.')
end
end
if not item then
return {
['args'] = args,
['item'] = nil
}
end
-- image depuis Wikidata
if not args.image then
for _, statement in pairs(item:getBestStatements('P18')) do
if statement.mainsnak.datavalue.value ~= nil then
args.image = statement.mainsnak.datavalue.value
end
end
end
-- title depuis Wikidata
if not args.title then
local value = item:formatStatements('P1476')['value']
if value == '' then
value = item:getLabel() or ''
end
if value ~= '' then
local siteLink = item:getSitelink()
if siteLink then
value = '[[' .. siteLink .. '|' .. value .. ']] [[বিষয়শ্রেণী:নির্ঘণ্ট যার মূল নামস্থানে প্রচ্ছদ পরিভুক্তি হয়েছে|' .. siteLink .. ']]'
end
args.title = value .. ' [[File:OOjs UI icon edit-ltr.svg|উইকিউপাত্তে দেখুন ও সম্পাদনা করুন|10px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '?uselang=bn#P1476]]'
end
end
-- year property
if not args.year then
for _, statement in pairs(item:getBestStatements('P577')) do
if statement.mainsnak.datavalue ~= nil then
local current_year = statement.mainsnak.datavalue.value.time
args['year'] = mw.ustring.sub(current_year, 2, 5)
end
end
end
-- other properties
for arg, propertyId in pairs(indexToWikidata) do
if not args[arg] then
local value = item:formatStatements(propertyId)["value"]
if value ~= '' then
args[arg] = value
end
end
end
return {
['args'] = args,
['item'] = item
}
end
local p = {}
function p.indexDataWithWikidata(frame)
return indexDataWithWikidata(frame)
end
return p