Module:Book: Difference between revisions

From Eli's Software Encyclopedia
mNo edit summary
Tag: Reverted
mNo edit summary
Tag: Manual revert
Line 1: Line 1:
local p = {}
local p = {}
local function getData(frame)
  local parent = frame and frame:getParent()
  if not parent then return {} end
  local args = parent.args or {}
  return args
end
function p.semanticStore(infobox)
end


function p.semanticStore(frame)
function p.semanticStore(frame)


local titleObj    = mw.title.getCurrentTitle()
local titleObj    = mw.title.getCurrentTitle()
local data = getData(frame)
local args        = frame:getParent().args or {}
local booktitle  = args['booktitle'] or titleObj.text
local authors    = args['author'] or ''
local publisher   = args['publisher'] or ''
local releaseDate = args['released'] or args['release date']  or ''
local genre   = args['genre']  or ''
local isbn        = args['ISBN']  or ''
local lcc        = args['LCC']  or ''
local bookformat  = args['format']  or ''
local country    = args['country']  or ''
local language   = args['language']  or ''


     local props = {
     local data = {
     'Has Title=' .. data.booktitle,
     'Has Title=' .. booktitle,
     'Author=' .. data.authors,
     'Author=' .. authors,
     '+sep=,',
     '+sep=,',
     'Publisher=' .. data.publisher,
     'Publisher=' .. publisher,
     'Release Date=' .. data.releaseDate,
     'Release Date=' .. releaseDate,
     'Genre=' .. data.genre,
     'Genre=' .. genre,
     'ISBN=' .. data.isbn,
     'ISBN=' .. isbn,
     'LCC=' .. data.lcc,
     'LCC=' .. lcc,
     'Book Format=' .. data.bookformat,
     'Book Format=' .. bookformat,
     'Country=' .. data.country,
     'Country=' .. country,
     'Language=' .. data.language
     'Language=' .. language
}
}
mw.smw.set( data )
mw.smw.set( data )

Revision as of 12:10, August 19, 2025

Documentation for this module may be created at Module:Book/doc

local p = {}

function p.semanticStore(frame)

	local titleObj    = mw.title.getCurrentTitle()
	local args        = frame:getParent().args or {}
	local booktitle   = args['booktitle'] or titleObj.text
	local authors     = args['author'] or ''
	local publisher	  = args['publisher'] or ''
	local releaseDate = args['released'] or args['release date']  or ''
	local genre		  = args['genre']  or ''
	local isbn        = args['ISBN']  or ''
	local lcc         = args['LCC']  or ''
	local bookformat  = args['format']  or ''
	local country     = args['country']  or ''
	local language	  = args['language']  or ''

    local data = {
    	'Has Title=' .. booktitle,
    	'Author=' .. authors,
    	'+sep=,',
    	'Publisher=' .. publisher,
    	'Release Date=' .. releaseDate,
    	'Genre=' .. genre,
    	'ISBN=' .. isbn,
    	'LCC=' .. lcc,
    	'Book Format=' .. bookformat,
    	'Country=' .. country,
    	'Language=' .. language
	}
	mw.smw.set( data )

end

return p