-- This module implements the lion's share of (what is currently called) Template:LDS/sandbox.local p =
-- TODO:-- Take out the assert statements and handle errors more gracefully?-- Add support for links to BoM Title page and testimonies of 3/8 witnesses-- Handle situations where the book name parameter is mistakenly left out (e.g.,). If the "bookParam" evaluates to a number, shift all the parameters "down" one (i.e., bookParam->chapterParam, chapterParam->verseParam, etc.) and treat the display text (minus any period or other punctuation) is the bookParam.
--
local bomBooks =
local dcBooks =
local pogpBooks =
local bibleBooks =
-- This table holds the titles of the Standard Works themselves, as found on WSlocal standardWorks =
local wsBaseURL = "" .. displayTextParam .. " 1" elseif chapter
local function handleFewParams(displayTextParam) if not displayTextParam then -- no parameters provided to the template at all return wsBaseURL .. wsStandardWorks .. "|LDS Standard Works]]" end -- otherwise same link but displaying the text they provided return wsBaseURL .. wsStandardWorks .. "|" .. displayTextParam .. "]]"end
local function trimSpaces(arg) if arg then return string.match(arg, "^%s*(.-)%s*$") else return nil endend
local function extractParams(args) local displayTextParam = trimSpaces(args[1]) local bookParam = trimSpaces(args[2]) local chapterParam = trimSpaces(args[3]) local verseParam = trimSpaces(args[4]) local endVerseParam = trimSpaces(args[5]) -- the 6th and 7th parameters, for footnotes and cross-references, have no -- use on Wikisource (and don't seem to work even on CoCJ.org, but whatever) local endVerseFlag = trimSpaces(args[8]) return displayTextParam, bookParam, chapterParam, verseParam, endVerseParam, endVerseFlagend
-- [=======[ ...oooOOOOOOOooo... ]
=] -- -- [=======[ ...oooOOOOOOOooo... ]
-- function p.main(frame)-- This function returns a wikitext link to the cited LDS scripture on Wikisource-- (except for Official Declaration 2, which is copyrighted)function p.main(frame) local args = frame:getParent.args -- the args to the template that invokes this module local displayTextParam, bookParam, chapterParam, verseParam, endVerseParam, endVerseFlag = extractParams(args) local wikiText = "" if not bookParam then --fewer than two parameters provided to the template return handleFewParams(displayTextParam) end local fullBookName = getFullBookName(bookParam) local standardWork = getStandardWork(fullBookName) if fullBookName
"JST Matthew" then fullBookName = "Matthew" end -- Special case for sections of the Doctrine and Covenants if fullBookName
return p