Module:ForumCitation

From BIONICLEsector01

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

local websiteCitation = require("Module:WebsiteCitation")
local p = {}

-- The text to place in a citation's main link to indicate a particular
-- reply in a forum topic
local POST_TEXT = "post"

-- Return the text to place in the main citation link for a forum citation.
-- Assumes that topicTitle is not nil.
local function getMainLinkText(topicTitle, postId)
	if postId ~= nil then
		return "\"" .. topicTitle .. "\", " .. POST_TEXT .. " " .. postId
	end
	
	return "\"" .. topicTitle .. "\""
end

-- Build and return the desired forum citation.
-- Asserts that websiteTitle and topicTitle are not nil,
-- and that at least one of originalUrl, archiveUrl, or brokenUrl is not nil.
function p.getForumCitation(websiteTitle, topicTitle, originalUrl, archiveUrl, brokenUrl, postId)
	assert(websiteTitle ~= nil)
	assert(topicTitle ~= nil)
	assert(originalUrl ~= nil or archiveUrl ~= nil or brokenUrl ~= nil)
	
	local mainLinkText = getMainLinkText(topicTitle, postId)
	return websiteCitation.getWebsiteCitation(websiteTitle, mainLinkText, originalUrl, archiveUrl, brokenUrl)
end

return p