Jump to content

Module:Bibleverse

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jfhutson (talk | contribs) at 21:35, 22 September 2016 (Created page with 'local p = {} function p.main( frame ) local pframe = frame:getParent() local args = pframe.args local urlpat = "http://bible.oremus....'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

function p.main( frame )
    local pframe     = frame:getParent()
    local args         = pframe.args
    local urlpat     = "http://bible.oremus.org/passage=%book+%s_chap:%s_vers&version=%version"
    local book        = args[1]
    local ref        = args[2]
    local defver    = "nrsv"
    local text        = args[4]
    
    colon = mw.ustring.match( ref, ":" )
    reflen = mw.ustring.len( ref )
    s_chap = mw.ustring.sub( ref, 1, colon )
    s_vers = mw.ustring.sub( ref, colon + 1, reflen - colon )

    version = args [3] or defver
    
    url_w_bk = mw.ustring.gmatch( urlpat, "%book", book )
    url_w_s_chap = mw.ustring.gmatch( url_w_bk, "%s_chap", s_chap )
    url_w_s_vers = mw.ustring.gmatch( url_w_s_chap, "%s_vers", s_vers )
    url_w_version = mw.ustring.gmatch( url_w_s_vers, "%s_chap", version )
    url = url_w_version
    
    fulllink = "[" .. url .. " " .. text .. "]"
    
    return fulllink
end

return p