Module:Book: Difference between revisions

From Eli's Software Encyclopedia
mNo edit summary
mNo edit summary
Line 30: Line 30:


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



Revision as of 11:39, 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
	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