Module:Cite EHLL
Appearance
| This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing. |
This module provides some simple service functions for {{Cite EHLL}}.
Usage
[edit]{{#invoke:Cite EHLL|getVolumeNumber|TITLE}}
This function gets the volume number automatically from the page title:
- A-F
- G-O
- P-Z
It should of course only be used for EHLL articles that appear in the printed version.
{{#invoke:Cite EHLL|getArchiveUrl|TITLE|PAGE}}
This function gets a hyperlink to the appropriate EHLL volume and page in the Internet Archive.
It should of course only be used for EHLL articles that appear in the printed version.
-- This module helps linking to the correct archived volume of the
-- Encyclopedia of Hebrew Language and Linguistics.
local getArgs = require('Module:Arguments').getArgs
local p = {}
local ia_volume_url = {
[1] = 'https://archive.org/details/encyclopediaofhe0001unse_f9g4',
[2] = 'https://archive.org/details/encyclopediaofhe0002unse_u9w7',
[3] = 'https://archive.org/details/encyclopediaofhe0003unse',
[4] = 'https://archive.org/details/encyclopediaofhe0004unse',
}
function p._getArchiveUrl(title, page)
return ia_volume_url[p._getVolumeNumber(title)] .. '/page/' .. page .. '/mode/2up'
end
function p.getArchiveUrl(frame)
local args = getArgs(frame)
return p._getArchiveUrl(args[1], args[2])
end
function p._getVolumeNumber(title)
local volume_patterns = {
["[A-F]"] = 1,
["[G-O]"] = 2,
["[P-Z]"] = 3,
}
local first_letter = mw.ustring.sub(title, 1, 1)
for pattern, volume in pairs(volume_patterns) do
if (string.match(first_letter, pattern))
then
return volume
end
end
return 'Error getting EHLL volume number from title ' .. title
end
function p.getVolumeNumber(frame)
local args = getArgs(frame)
return p._getVolumeNumber(args[1])
end
return p