Bahaipedia
Bahaipedia
Menu
About Bahaipedia
Ask a question
General help
Random page
Recent changes
In other projects
Tools
What links here
Related changes
Upload file
Special pages
Printable version
Permanent link
Page information
Module
Discussion
View history
Talk
Contributions
Create account
Log in
Navigation
About Bahaipedia
Ask a question
General help
Random page
Recent changes
In other projects
Learn more
Core topics
Bahá’í Faith
Central Figures
Teachings
Practices
Tools
What links here
Related changes
Upload file
Special pages
Printable version
Permanent link
Page information
Translations

Module:AmericanBahai

From Bahaipedia
Jump to:navigation, search
Module documentation[view] [edit] [history] [purge]

Note: If you make changes to this module please also update Module:AmericanBahai on bahai.media.

The above documentation is transcluded from Module:AmericanBahai/doc. (edit | history)
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.

local module = {}

-- Define a list of issues which have two pages stitched together
-- [0202] = 8 means Volume 2 Issue 2 pages 8 and 9 are combined
local pdfDoublePage_map = {
    [0202] = 8,
    [0203] = 8,
    [0204] = 6,
    [0808] = 4,
    [1006] = 10,
    [1011] = 10,
    [1404] = 14,
    [1512] = 14,
    [3002] = 16,
    [3102] = 16,
    [3501] = 18,
}
	
-- Define a list of issues where the PDF page and publication page are different
-- For example starting in volume 35 there is a front page which requires offseting by 1
pdfOffset_map = {
    [351] = 1,
}

local publicationDate_map = {
    [1] = "1970",
    [2] = "1971",
    [3] = "1972",
    [4] = "1973",
    [5] = "1974",
    [6] = "1975",
    [7] = "1976",
    [8] = "1977",
    [9] = "1978",
    [10] = "1979",
    [11] = "1980",
    [12] = "1981",
    [13] = "1982",
    [14] = "1983",
    [15] = "1984",
    [16] = "1985",
    [17] = "1986",
    [18] = "1987",
    [19] = "1988",
    [20] = "1989",
    [21] = "1990",
    [22] = "1991",
    [23] = "1992",
    [24] = "1993",
    [25] = "1994",
    [26] = "1995",
    [27] = "1996",
    [28] = "1997",
    [29] = "1998",
    [30] = "1999",
    [31] = "2000",
    [32] = "2001",
}

-- Define a table mapping special titles to other text
local specialInfo_map = {
	["The_American_Bahá’í_February_1978_Extra"] = { title = "Extra!", date = "February, 1978" },
    ["The_American_Bahá’í_March_1978_Extra"] = { title = "Extra!", date = "March, 1978" },
    ["The_American_Bahá’í_August_1978_Special"] = { title = "Special Issue", date = "August, 1978" },
    ["The_American_Bahá’í_September_1978_Special"] = { title = "Special Teaching Edition", date = "September, 1978" },
    ["The_American_Bahá’í_October_1978_Special"] = { title = "Special Teaching Edition", date = "October, 1978" },
    ["The_American_Bahá’í_February_1979_Special"] = { title = "Special Issue", date = "February, 1979" },
    ["The_American_Bahá’í_March_1979_Extra"] = { title = "Extra!", date = "March, 1979" },
    ["The_American_Bahá’í_December_1985_Special"] = { title = "Special issue!", date = "December, 1985" },
    ["The_American_Bahá’í_Vol22_No11-Special"] = { title = "Bahá’í World Congress Special Edition", date = "November, 1991" },
    ["The_American_Bahá’í_Vol23_No13a"] = { title = "The Right of God, Huqúqu’lláh, Special Edition", date = "September 8, 1992" },
}

-- Function to retrieve text based on the provided title
function module.getSpecialInfoTitle(frame)
    local key = frame.args[1]
    local info = specialInfo_map[key]
    if info then
        return info.title
    else
        return "Title not found for key: " .. key
    end
end

function module.getSpecialInfoDate(frame)
    local key = frame.args[1]
    local info = specialInfo_map[key]
    if info then
        return info.date
    else
        return "Date not found for key: " .. key
    end
end

-- Accept the input as the volume number, issue number, and return date published
function module.publicationDate(frame)
    local volNumber = tonumber(frame.args[1])
    return publicationDate_map[volNumber]
end

-- Accept the input as the volume number, issue number, and return date published
function module.publicationDate(frame)
    local volNumber = tonumber(frame.args[1])
    return publicationDate_map[volNumber]
end

-- Accept the input as volume number, issue number, and page number
function module.pdfOffset(frame)
    local volumeNumber = tonumber(frame.args[1]) or 0
    local issueNumber = tonumber(frame.args[2]) or 0
    local pageNumber = tonumber(frame.args[3]) or 0 -- The actual publication page number

    -- Get the double-page offset if specified in pdfDoublePage_map
    local doublePageKey = string.format("%02d%02d", volumeNumber, issueNumber)
    local doublePageValue = pdfDoublePage_map[tonumber(doublePageKey)] or 0

    -- Check if there is an entry in pdfOffset_map (the base offset for PDF vs publication pages)
    local offsetMapKey = string.format("%02d%02d", volumeNumber, issueNumber)
    local offsetMapValue = pdfOffset_map[tonumber(offsetMapKey)] or 0

    -- If there's a double-page defined
    if doublePageValue > 0 then
        -- If the page number is before or equal to the double page (no offset needed yet)
        if pageNumber <= doublePageValue then
            return offsetMapValue -- Return the base offset
        else
            -- If the page is after the double page, subtract 1 to account for the double-page loss
            return offsetMapValue - 1 -- Shift by -1 due to the double page
        end
    else
        -- No double-page scenario, just return the base offset
        return offsetMapValue
    end
end

return module
Retrieved from "https://bahaipedia.org/index.php?title=Module:AmericanBahai&oldid=138684"
This page was last edited on 11 January 2025, at 23:24.
Text is available under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.
Privacy policy
About Bahaipedia
Disclaimers
Powered by MediaWiki