Module:WOL
How to add this template to your wiki
- Go to Special:Import on your wiki (for example, if your wiki was meta.miraheze.org, you would go to meta.miraheze.org/wiki/Special:Import)
- Scroll until you see "
Import from another wiki
" - In "
Source wiki:
", press the dropdown box, and select "dev" - In "
Source page:
", write "Module:WOL
" - Leave the other settings as they are and press "
Import
"
==Usage==
{{WOL|b= |c= |v= |to= |version= |view=yes}}
Parameters
- This template has six (optional) parameters to build the external link:
It uses the following link: https://wol.jw.org/en/wol/b/r1/lp-e/
- version: Bible translation abbreviation (optional)
- b: Book abbreviation (optional)
- c: Chapter number (optional)
- v: Verse number (optional)
- to: Optional parameter for the ending verse in a range (optional)
The link to the corresponding Wiki article will be put behind the scripture with the following parameter:
- view: Parameter to control the display of the internal WikiLink (Only use "yes") (optional)
{{WOL |b{{=}}''abbr.'' |c{{=}}''chapter'' |v{{=}}''Verse'' |to{{=}}''Optional parameter'' |version{{=}}''translation'' |view{{=}}''Display parameter'' }}
- Shorthand can be used for the names, such as 1Sa, 1ch, ps or De. See the "names and order of the books" in your bible or look at the Chicago Manual of Style for other acceptable abbreviations.
- Verse references may be simplified (for example, no range or entire chapter).
- If chosen "yes" behind |view=, the following will be put behind the scripture
nwtsty = (nwt Study Bible) nwt = (nwt 2013) bi10 = (KJV) bi12 = (nwt 1984) bi22 = (ASV) by = (Byington) Rbi8 = (Reference Bible) rh = (Rotherham) int = (Interlinear)
The above abbreviations are also necessary for the external link.
-- Module:WOL is needed for [[Template:WOL]]
-- Expanded upon existing code from [[User:Br.Bruno]]'s Template:Bible on jwiki.miraheze.org
-- [[User:Rodejong|Robert de Jong]]
local p = {}
-- Custom encoding function
local function customEncode(str)
return str:gsub(" ", "_"):gsub("[^%w_]", function(c)
return string.format("%%%02X", string.byte(c))
end)
end
-- [END]
-- Function to prompt the user to choose a book
local function chooseBook(options)
local userInput = mw.text.trim(options)
local bookAliases = {
['ge'] = 'Genesis', ['gen'] = 'Genesis', ['Ge'] = 'Genesis', ['Gen'] = 'Genesis',
['ex'] = 'Exodus', ['Ex'] = 'Exodus',
['le'] = 'Leviticus', ['lev'] = 'Leviticus', ['Le'] = 'Leviticus', ['Lev'] = 'Leviticus',
['nu'] = 'Numbers', ['num'] = 'Numbers', ['Nu'] = 'Numbers', ['Num'] = 'Numbers',
['de'] = 'Deuteronomy', ['deu'] = 'Deuteronomy', ['deut'] = 'Deuteronomy', ['De'] = 'Deuteronomy', ['Deu'] = 'Deuteronomy', ['Deut'] = 'Deuteronomy',
['jos'] = 'Joshua', ['josh'] = 'Joshua', ['Jos'] = 'Joshua', ['Josh'] = 'Joshua',
['jg'] = 'Judges', ['judg'] = 'Judges', ['Jg'] = 'Judges', ['Judg'] = 'Judges',
['ru'] = 'Ruth', ['rut'] = 'Ruth', ['ruth'] = 'Ruth', ['rt'] = 'Ruth', ['Ru'] = 'Ruth', ['Rut'] = 'Ruth', ['Rt'] = 'Ruth',
['1sa'] = '1_Samuel', ['1sam'] = '1_Samuel', ['1Sa'] = '1_Samuel', ['1Sam'] = '1_Samuel',
['2sa'] = '2_Samuel', ['2sam'] = '2_Samuel', ['2Sa'] = '2_Samuel', ['2Sam'] = '2_Samuel',
['1ki'] = '1_Kings', ['1king'] = '1_Kings', ['1kings'] = '1_Kings', ['1Ki'] = '1_Kings', ['1King'] = '1_Kings',
['2ki'] = '2_Kings', ['2king'] = '2_Kings', ['2kings'] = '2_Kings', ['2Ki'] = '2_Kings', ['2King'] = '2_Kings',
['1ch'] = '1_Chronicles', ['1chr'] = '1_Chronicles', ['1Ch'] = '1_Chronicles', ['1Chr'] = '1_Chronicles',
['2ch'] = '2_Chronicles', ['2chr'] = '2_Chronicles', ['2Ch'] = '2_Chronicles', ['2Chr'] = '2_Chronicles',
['ezr'] = 'Ezra', ['ezra'] = 'Ezra', ['Ezr'] = 'Ezra',
['ne'] = 'Nehemiah', ['neh'] = 'Nehemiah', ['Ne'] = 'Nehemiah', ['Neh'] = 'Nehemiah',
['es'] = 'Esther', ['est'] = 'Esther', ['Es'] = 'Esther', ['Est'] = 'Esther',
['jb'] = 'Job', ['job'] = 'Job', ['Jb'] = 'Job',
['ps'] = 'Psalms', ['psalm'] = 'Psalms', ['psalms'] = 'Psalms', ['Ps'] = 'Psalms', ['Psalm'] = 'Psalms',
['pr'] = 'Proverbs', ['prov'] = 'Proverbs', ['Pr'] = 'Proverbs', ['Prov'] = 'Proverbs',
['ec'] = 'Ecclesiastes', ['eccl'] = 'Ecclesiastes', ['Ec'] = 'Ecclesiastes', ['Eccl'] = 'Ecclesiastes',
['ca'] = 'Song of Solomon', ['canticles'] = 'Song of Solomon', ['song'] = 'Song of Solomon', ['songs'] = 'Song of Solomon', ['Ca'] = 'Song of Solomon', ['Canticles'] = 'Song of Solomon', ['Song'] = 'Song of Solomon', ['Songs'] = 'Song of Solomon',
['is'] = 'Isaiah', ['isa'] = 'Isaiah', ['Is'] = 'Isaiah', ['Isa'] = 'Isaiah',
['jr'] = 'Jeremiah', ['jer'] = 'Jeremiah', ['Jr'] = 'Jeremiah', ['Jer'] = 'Jeremiah',
['la'] = 'Lamentations', ['lam'] = 'Lamentations', ['La'] = 'Lamentations', ['Lam'] = 'Lamentations',
['ez'] = 'Ezekiel', ['eze'] = 'Ezekiel', ['ezek'] = 'Ezekiel', ['Ez'] = 'Ezekiel', ['Eze'] = 'Ezekiel', ['Ezek'] = 'Ezekiel',
['da'] = 'Daniel', ['dan'] = 'Daniel', ['Da'] = 'Daniel', ['Dan'] = 'Daniel',
['ho'] = 'Hosea', ['hos'] = 'Hosea', ['Ho'] = 'Hosea', ['Hos'] = 'Hosea',
['jl'] = 'Joel', ['joe'] = 'Joel', ['joel'] = 'Joel', ['Jl'] = 'Joel', ['Joe'] = 'Joel',
['am'] = 'Amos', ['amos'] = 'Amos', ['Am'] = 'Amos',
['ob'] = 'Obadiah', ['obad'] = 'Obadiah', ['Ob'] = 'Obadiah', ['Obad'] = 'Obadiah',
['jon'] = 'Jonah', ['Jon'] = 'Jonah',
['mi'] = 'Micah', ['mic'] = 'Micah', ['Mi'] = 'Micah', ['Mic'] = 'Micah',
['na'] = 'Nahum', ['nah'] = 'Nahum', ['Na'] = 'Nahum', ['Nah'] = 'Nahum',
['hb'] = 'Habakkuk', ['hab'] = 'Habakkuk', ['Hb'] = 'Habakkuk', ['Hab'] = 'Habakkuk',
['zep'] = 'Zephaniah', ['zeph'] = 'Zephaniah', ['Zep'] = 'Zephaniah', ['Zeph'] = 'Zephaniah',
['hg'] = 'Haggai', ['hag'] = 'Haggai', ['Hg'] = 'Haggai', ['Hag'] = 'Haggai',
['zec'] = 'Zechariah', ['zech'] = 'Zechariah', ['Zec'] = 'Zechariah', ['Zech'] = 'Zechariah',
['mal'] = 'Malachi', ['Mal'] = 'Malachi',
['mt'] = 'Matthew', ['matt'] = 'Matthew', ['Mt'] = 'Matthew', ['Matt'] = 'Matthew',
['mk'] = 'Mark', ['mr'] = 'Mark', ['Mk'] = 'Mark', ['Mr'] = 'Mark',
['lk'] = 'Luke', ['lu'] = 'Luke', ['luk'] = 'Luke', ['Lk'] = 'Luke', ['Lu'] = 'Luke', ['Luk'] = 'Luke',
['joh'] = 'John', ['john'] = 'John', ['Joh'] = 'John',
['ac'] = 'Acts', ['acts'] = 'Acts', ['Ac'] = 'Acts',
['ro'] = 'Romans', ['rom'] = 'Romans', ['Ro'] = 'Romans', ['Rom'] = 'Romans',
['1co'] = '1_Corinthians', ['1cor'] = '1_Corinthians', ['1Co'] = '1_Corinthians', ['1Cor'] = '1_Corinthians',
['2co'] = '2_Corinthians', ['2cor'] = '2_Corinthians', ['2Co'] = '2_Corinthians', ['2Cor'] = '2_Corinthians',
['ga'] = 'Galatians', ['gal'] = 'Galatians', ['Ga'] = 'Galatians', ['Gal'] = 'Galatians',
['ep'] = 'Ephesians', ['eph'] = 'Ephesians', ['Ep'] = 'Ephesians', ['Eph'] = 'Ephesians',
['php'] = 'Philippians', ['phil'] = 'Philippians', ['Php'] = 'Philippians', ['Phil'] = 'Philippians',
['col'] = 'Colossians', ['Col'] = 'Colossians',
['1th'] = '1_Thessalonians', ['1thess'] = '1_Thessalonians', ['1thes'] = '1_Thessalonians', ['1Th'] = '1_Thessalonians', ['1Thess'] = '1_Thessalonians', ['1Thes'] = '1_Thessalonians',
['2th'] = '2_Thessalonians', ['2thess'] = '2_Thessalonians', ['2thes'] = '2_Thessalonians', ['2Th'] = '2_Thessalonians', ['2Thess'] = '2_Thessalonians', ['2Thes'] = '2_Thessalonians',
['1ti'] = '1_Timothy', ['1tm'] = '1_Timothy', ['1tim'] = '1_Timothy', ['1Ti'] = '1_Timothy', ['1Tm'] = '1_Timothy', ['1Tim'] = '1_Timothy',
['2ti'] = '2_Timothy', ['2tm'] = '2_Timothy', ['2tim'] = '2_Timothy', ['2Ti'] = '2_Timothy', ['2Tm'] = '2_Timothy', ['2Tim'] = '2_Timothy',
['tit'] = 'Titus', ['Tit'] = 'Titus',
['phm'] = 'Philemon', ['philem'] = 'Philemon', ['Phm'] = 'Philemon', ['Philem'] = 'Philemon',
['he'] = 'Hebrews', ['heb'] = 'Hebrews', ['hebr'] = 'Hebrews', ['He'] = 'Hebrews', ['Heb'] = 'Hebrews', ['Hebr'] = 'Hebrews',
['jas'] = 'James', ['jms'] = 'James', ['Jas'] = 'James', ['Jms'] = 'James',
['1pe'] = '1_Peter', ['1pet'] = '1_Peter', ['1pt'] = '1_Peter', ['1Pe'] = '1_Peter', ['1Pet'] = '1_Peter', ['1Pt'] = '1_Peter',
['2pe'] = '2_Peter', ['2pet'] = '2_Peter', ['2pt'] = '2_Peter', ['2Pe'] = '2_Peter', ['2Pet'] = '2_Peter', ['2Pt'] = '2_Peter',
['1jo'] = '1_John', ['1joh'] = '1_John', ['1john'] = '1_John', ['1Jo'] = '1_John', ['1Joh'] = '1_John', ['1John'] = '1_John',
['2jo'] = '2_John', ['2joh'] = '2_John', ['2john'] = '2_John', ['2Jo'] = '2_John', ['2Joh'] = '2_John', ['2John'] = '2_John',
['3jo'] = '3_John', ['3joh'] = '3_John', ['3john'] = '3_John', ['3Jo'] = '3_John', ['3Joh'] = '3_John', ['3John'] = '3_John',
['jd'] = 'Jude', ['jude'] = 'Jude', ['Jd'] = 'Jude',
['re'] = 'Revelation', ['rev'] = 'Revelation', ['rv'] = 'Revelation', ['Re'] = 'Revelation', ['Rev'] = 'Revelation', ['Rv'] = 'Revelation',
}
return bookAliases[userInput] or userInput
end
-- [END]
-- Conversion table for Bible books and their corresponding numbers
local bookConversionTable = {
['Genesis'] = '1', ['Exodus'] = '2', ['Leviticus'] = '3', ['Numbers'] = '4', ['Deuteronomy'] = '5',
['Joshua'] = '6', ['Judges'] = '7', ['Ruth'] = '8', ['1_Samuel'] = '9', ['2_Samuel'] = '10',
['1_Kings'] = '11', ['2_Kings'] = '12', ['1_Chronicles'] = '13', ['2_Chronicles'] = '14', ['Ezra'] = '15',
['Nehemiah'] = '16', ['Esther'] = '17', ['Job'] = '18', ['Psalms'] = '19', ['Proverbs'] = '20',
['Ecclesiastes'] = '21', ['Song_of_Solomon'] = '22', ['Isaiah'] = '23', ['Jeremiah'] = '24', ['Lamentations'] = '25',
['Ezekiel'] = '26', ['Daniel'] = '27', ['Hosea'] = '28', ['Joel'] = '29', ['Amos'] = '30',
['Obadiah'] = '31', ['Jonah'] = '32', ['Micah'] = '33', ['Nahum'] = '34', ['Habakkuk'] = '35',
['Zephaniah'] = '36', ['Haggai'] = '37', ['Zechariah'] = '38', ['Malachi'] = '39', ['Matthew'] = '40',
['Mark'] = '41', ['Luke'] = '42', ['John'] = '43', ['Acts'] = '44', ['Romans'] = '45',
['1_Corinthians'] = '46', ['2_Corinthians'] = '47', ['Galatians'] = '48', ['Ephesians'] = '49', ['Philippians'] = '50',
['Colossians'] = '51', ['1_Thessalonians'] = '52', ['2_Thessalonians'] = '53', ['1_Timothy'] = '54', ['2_Timothy'] = '55',
['Titus'] = '56', ['Philemon'] = '57', ['Hebrews'] = '58', ['James'] = '59', ['1_Peter'] = '60',
['2_Peter'] = '61', ['1_John'] = '62', ['2_John'] = '63', ['3_John'] = '64', ['Jude'] = '65', ['Revelation'] = '66',
}
-- Function to convert Bible book name to URL-friendly format
local function convertBookToURL(book)
return bookConversionTable[book] or customEncode(book)
end
-- [END]
-- External link function
function p.link(frame)
local args = frame.args
-- Add bookOptions
local bookOptions = 'ge, Ge, gen, Gen, ex, Ex, le, lev, Le, Lev, nu, num, Nu, Num, de, deu, deut, De, Deu, Deut, jos, josh, Jos, Josh, jg, judg, Jg, Judg, ru, rut, ruth, rt, Ru, Rut, Rt, 1sa, 2sa, 1sam, 2sam, 1Sa, 2Sa, 1Sam, 2Sam, 1ki, 2ki, 1king, 2king, 1kings, 2kings, 1Ki, 2Ki, 1King, 2King, 1ch, 2ch, 1chr, 2chr, 1Ch, 2Ch, 1Chr, 2Chr, ezr, ezra, Ezr, ne, neh, Ne, Neh, es, est, Es, Est, jb, job, Jb, ps, psalm, psalms, Ps, Psalm, pr, prov, Pr, Prov, ec, eccl, Ec, Eccl, ca, canticles, song, songs, Ca, Canticles, Song, Songs, is, isa, Is, Isa, jr, jer, Jr, Jer, la, lam, La, Lam, ez, eze, ezek, Ez, Eze, Ezek, da, dan, Da, Dan, ho, hos, Ho, Hos, jl, joe, joel, Jl, Joe, am, amos, Am, ob, obad, Ob, Obad, jon, Jon, mi, mic, Mi, Mic, na, nah, Na, Nah, hb, hab, Hb, Hab, zep, zeph, Zep, Zeph, hg, hag, Hg, Hag, zec, zech, Zec, Zech, mal, Mal, mt, matt, Mt, Matt, mk, mr, Mk, Mr, lk, lu, luk, Lk, Lu, Luk, joh, john, Joh, ac, acts, Ac, ro, rom, Ro, Rom, 1co, 2co, 1cor, 2cor, 1Co, 2Co, 1Cor, 2Cor, ga, Ga, gal, Gal, ep, eph, Ep, Eph, php, phil, Php, Phil, col, Col, 1th, 2th, 1thes, 2thes, 1thess, 2thess, 1Th, 2Th, 1Thes, 2Thes, 1Thess, 2Thess, 1ti, 2ti, 1tm, 2tm, 1tim, 2tim, 1Ti, 2Ti, 1Tm, 2Tm, 1Tim, 2Tim, tit, Tit, phm, philem, Phm, Philem, he, heb, hebr, He, Heb, Hebr, jas, jms, Jas, Jms, 1pe, 2pe, 1pet, 2pet, 1pt, 2pt, 1Pe, 2Pe, 1Pet, 2Pet, 1Pt, 2Pt, 1jo, 2jo, 3jo, 1joh, 2joh, 3joh, 1john, 2john, 3john, 1Jo, 2Jo, 3Jo, 1Joh, 2Joh, 3Joh, 1John, 2John, 3John, jd, jude, Jd, re, rev, rv, Re, Rev, Rv' -- Add other book options
local chosenBook = chooseBook(args.b or mw.text.trim(frame:preprocess(bookOptions)))
local book = chosenBook
local chapter = args.c or '1'
local verse = args.v or '1'
local to = args.to
local version = args.version
local url = 'https://wol.jw.org/en/wol/b/r1/lp-e/'
-- Set the default version to NWT Study Bible if not specified
if version == 'bi10' then
url = url .. 'bi10/'
elseif version == 'bi22' then
url = url .. 'bi22/'
elseif version == 'by' then
url = url .. 'by/'
elseif version == 'int' then
url = url .. 'int/'
elseif version == 'nwt' then
url = url .. 'nwt/'
elseif version == 'rh' then
url = url .. 'rh/'
elseif version == 'Rbi8' then
url = url .. 'Rbi8/'
else
-- Default to NWT Study Bible
url = url .. 'nwtsty/'
end
-- Convert Bible book name to URL-friendly format
local encodedBook = convertBookToURL(book)
url = url .. encodedBook
-- Continue with chapter and verse
url = url .. '/' .. chapter
if verse then
url = url .. '#v=' .. encodedBook .. ':' .. chapter .. ':' .. verse
if to and to ~= '' then
url = url .. '-' .. encodedBook .. ':' .. chapter .. ':' .. to
end
end
-- Call wol_version function to get the version link
local versionLink = p.wol_version(frame)
-- Return the external link with version
return '<span class="plainlinks"><span>[' .. url .. ' <font color=green>' .. book .. ' ' .. chapter .. ':' .. verse .. '</font>]' .. versionLink .. '</span></span>'
end
-- Creating the internal WikiLink and setting the default version to NWT Study Bible if not specified
-- Function to handle WOL version
function p.wol_version(frame)
local args = frame.args
local version = args.version or "nwtsty"
local view = args.view
local translations = {
-- Added all available translations in this table
nwtsty = '<span title="New World Translation of the Holy Scriptures ─ Study Bible">[[New World Translation of the Holy Scriptures|<sup style="font-size: 70%; color: green;">(nwt Study Bible)</sup>]]</span>',
nwt = '<span title="New World Translation of the Holy Scriptures ─ 2013 revision">[[New World Translation of the Holy Scriptures|<sup style="font-size: 70%; color: green;">(nwt 2013)</sup>]]</span>',
bi10 = '<span title="King James Version">[[King James Version|<sup style="font-size: 70%; color: green;">(KJV)</sup>]]</span>',
bi12 = '<span title="New World Translation of the Holy Scriptures ─ 1984 revision">[[New World Translation of the Holy Scriptures|<sup style="font-size: 70%; color: green;">(nwt 1984)</sup>]]</span>',
bi22 = '<span title="American Standard Version">[[American Standard Version|<sup style="font-size: 70%; color: green;">(ASV)</sup>]]</span>',
by = '<span title="Bible in Living English ─ Byington">[[Bible in Living English|<sup style="font-size: 70%; color: green;">(Byington)</sup>]]</span>',
Rbi8 = '<span title="New World Translation of the Holy Scriptures ─ Reference Bible">[[New World Translation of the Holy Scriptures|<sup style="font-size: 70%; color: green;">(Reference Bible)</sup>]]</span>',
rh = '<span title="The Emphasized Bible ─ Rotherham">[[The Emphasized Bible|<sup style="font-size: 70%; color: green;">(Rotherham)</sup>]]</span>',
int = '<span title="The Kingdom Interlinear Translation of the Greek Scriptures">[[The Kingdom Interlinear Translation of the Greek Scriptures|<sup style="font-size: 70%; color: green;">(Interlinear)</sup>]]</span>'
}
local result = translations[version] or translations["nwtsty"]
-- Function to choose whether to show the bible version at the end:
if view == "yes" then
return result
else
return ""
end
end
return p
-- [END]