Module:Book: Difference between revisions
From Eli's Software Encyclopedia
mNo edit summary |
mNo edit summary |
||
| Line 15: | Line 15: | ||
local args = frame:getParent().args or {} | local args = frame:getParent().args or {} | ||
local booktitle = args.booktitle | local booktitle = args.booktitle | ||
local authors = args | local authors = args['author'] or '' | ||
local publisher = args.publisher | local publisher = args.publisher | ||
local releaseDate = args.released or args['release date'] | local releaseDate = args.released or args['release date'] | ||
Revision as of 11:41, August 19, 2025
Documentation for this module may be created at Module:Book/doc
local p = {}
local function splitValues(str, sep)
local result = {}
for part in raw:gmatch("[^" .. sep .. "]+") do
part = part:match("^%s*(.-)%s*$")
table.insert(result, part)
end
return result
end
function p.semanticStore(frame)
local titleObj = mw.title.getCurrentTitle()
local args = frame:getParent().args or {}
local booktitle = args.booktitle
local authors = args['author'] or ''
local publisher = args.publisher
local releaseDate = args.released or args['release date']
local genre = args.genre
local isbn = args.ISBN
local lcc = args.LCC
local bookformat = args['format']
local country = args.country
local language = args.language
if not booktitle or booktitle == '' then
booktitle = titleObj.text
end
mw.smw.set{
'Has Title=' .. booktitle,
'Author=' .. authors,
'+sep=,',
'Publisher=' .. publisher,
'Release Date=' .. releaseDate,
'Genre=' .. genre,
'ISBN=' .. isbn,
'LCC=' .. lcc,
'Book Format=' .. bookformat,
'Country=' .. country,
'Language=' .. language
}
end
return p
