Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:CIA World Factbook
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local getArgs = require('Module:Arguments').getArgs -- prefix of all World Factbook pages local factbookPrefix = 'https://www.cia.gov/the-world-factbook/' -- Format of archive link. Both %d represent the year of the archive local archiveFormat = ' [https://www.cia.gov/the-world-factbook/about/archives/download/factbook-%d.zip (Archived %d edition.)]' -- Function to turn a string into a URL fragment appropriate for CIA website local function parseFragment(s) if not s then return '' end s = mw.ustring.lower(s) s = mw.ustring.gsub(s,' ','-') s = mw.ustring.gsub(s,',','') return s end -- Function to fill in factbook link: -- Arguments: -- args.country: topic of page (optional) -- args.section: section of page (optional) -- Returns: -- link to World Factbook page about country, with section anchor function p._country(args) if not args.country then return factbookPrefix end local result = factbookPrefix..'countries/'..parseFragment(args.country) if args.section then return result..'/#'..parseFragment(args.section) end return result end -- Function to fill in archive link: -- Arguments: -- args.archive: if non-empty, return nil -- args.year: else if this is non-empty, use it for year -- args.date: else if this is non-empty, parse it for a year -- Returns: -- the link, above, filled in with the year, or nil function p._archive(args) if args.archive then return nil end local year = nil if args.year then year = tonumber(args.year) elseif args.date then i, j = mw.ustring.find(args.date,'20%d%d') if i and j then year = tonumber(mw.ustring.sub(args.date,i,j)) end end if not year then return year end if year >= tonumber(os.date('%Y'))-1 then return false end return mw.ustring.format(archiveFormat, year, year) end function p.country(frame) local args = getArgs(frame) return p._country(args) end function p.archive(frame) local args = getArgs(frame) return p._archive(args) or '' end return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Error
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Para
(
edit
)
Template:Pp
(
edit
)
Template:Protection padlock
(
edit
)
Template:Sandbox other
(
edit
)
Template:Template link
(
edit
)
Template:Tl
(
edit
)
Module:CIA World Factbook/doc
(
edit
)
Module:Error
(
edit
)
Module:File link
(
edit
)
Module:Message box
(
edit
)
Module:Protection banner
(
edit
)
Module:String
(
edit
)