Module:Canon note

local Notice = {} --- imported libraries -- Parses invocation and template parameters, trims whitespace, and removes blanks. local getArgs = require('Dev:Arguments').getArgs -- Wikitext lists local List = require('Dev:List') -- Smarter boolean logic local yesno = require( 'Dev:Yesno' )

--- local data local sources = { ['aq'] = "Al-Qadim: The Genie's Curse game.", ['b&m'] = "Blood & Magic game.", ['bg'] = "Baldur's Gate series of games.", ['da'] = "Dark Alliance series of games.", ['dd'] = "Dungeons & Dragons: Daggerdale game.", ['ddo'] = "Dungeons & Dragons Online game.", ['ds'] = "Forgotten Realms: Demon Stone game.", ['dtu'] = "Descent to Undermountain game.", ['eotb'] = "Eye of the Beholder series of games.", ['hf'] = "Hillsfar game.", ['ic'] = "Idle Champions of the Forgotten Realms game.", ['iwd'] = "Icewind Dale series of games.", ['mz'] = "Menzoberranzan game.", ['nw'] = "Neverwinter game.", ['nwn'] = "Neverwinter Nights series of games.", ['por'] = "Pool of Radiance series of games.", ['pst'] = "Planescape: Torment game.", ['sf'] = "Savage Frontier series of games.", ['sj'] = "Spelljammer: Pirates of Realmspace game.", ['scl'] = "Sword Coast Legends game.", ['wow'] = "Warriors of Waterdeep game." }

local function boxcontent(args) local listitems, output = {}, {} local adaptation

-- Puts only the arguments called in the article in a list, unless it's an adaptation. for _,v in ipairs(args) do   if v == 'adap' then adaptation = true elseif sources[v] then table.insert(listitems, sources[v]) end end --- Defines output if adaptation == true then table.insert(output, "This article or section is about elements from adapted material from a different or generic setting. Although officially licensed, this information is not confirmed to be part of the greater Forgotten Realms continuity.") elseif #listitems == 0 then -- Error message if there are no arguments table.insert(output, 'Please specify at least one argument.') else table.insert(output, "This article or section is about elements from the") -- Makes the wikitext / HTML list table.insert(output, List.makeList('bulleted', listitems)) table.insert(output, "Video games are considered canon unless they contradict content in some other Forgotten Realms publication.") end return output end

-- function Notice.CanonNote (frame) -- interprets parameters local args = getArgs(frame) -- calls the internal function that does most of the work -- sends the result back to the template / article return Notice._CanonNote(args) end

-- function Notice.CanonNoteBox (frame) -- interprets parameters local args = getArgs(frame) -- calls the internal function that does most of the work --- Creates the content as a subroutine local output = boxcontent(args) -- sends the result back to the template / article return frame:expandTemplate{ title = 'Border box', args = {       theme = 'logo', content = table.concat(output,'\n'), contentalign = 'left', width = '90%' }  } end

-- creates a "canon note" function Notice._CanonNote (args) --- Creates the content as a subroutine local output = boxcontent(args)

--- Defines the HTML wrapper, including the output result local notice = mw.html.create('div') :addClass('canon-note-container') :css('overflow','auto') :tag('div'):addClass('canon-note-image') :wikitext('') :done :tag('div'):addClass('canon-note') :wikitext(table.concat(output,'\n')) :allDone

--- Sends the result back return tostring(notice) end

return Notice