Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/BrownHairedGirl/IrelandByCountyCatNav
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 = {} function make_cat_link(catname, disp) local displaytext if (disp ~= "") then displaytext = disp else displaytext = catname end local link = "[[:Category:" .. catname .. "|" .. displaytext .. "]]" local fmtlink local linktitle = mw.title.new( catname, "Category" ) if (linktitle.exists) then fmtlink = link else fmtlink = "<span style=\"color:#888\">" .. displaytext .. "</span>" end return fmtlink end local p = {} function boolify(s) if (s == nil or s == '') then return false end s = s:lower() if (s == 'y' or s == 'yes') then return true end return false end function make_cat_name(countyname, prefix, suffix, nospace, nocounty) local this_cat_name = ''; if not (prefix == nil or prefix == '') then this_cat_name = this_cat_name .. prefix if not (boolify(nospace)) then this_cat_name = this_cat_name .. ' '; end end if not (boolify(nocounty)) then this_cat_name = this_cat_name .. 'County '; end this_cat_name = this_cat_name .. countyname if not (suffix == nil or suffix == '') then if not (boolify(nospace)) then this_cat_name = this_cat_name .. ' '; end this_cat_name = this_cat_name .. suffix end return this_cat_name end -- Named arguments, used like: {{#invoke:IrelandByCountyCatNav|before=foo|after=|nospace=y}} function p.main(frame) local p_before = frame.args.before local p_after = frame.args.after local p_nospace = frame.args.nospace local p_nocounty = frame.args.nocounty local retval = ""; retval = retval .. "<pre>" retval = retval .. '\nbefore=[' .. p_before .. ']' .. '\nafter=[' .. p_after .. ']' .. '\nnospace=[' .. p_nospace .. ']' .. '\nnocounty=[' .. p_nocounty .. ']' retval = retval .. "</pre>" retval = retval .. "\n\n'''-->'''\n\n* Cat = [" .. make_cat_name("Mayo", p_before, p_after, p_nospace, p_nocounty) .. "]\n" retval = retval .. "* Catlink = " .. make_cat_link(make_cat_name("Mayo", p_before, p_after, p_nospace, p_nocounty), "Mayo") local thispage = mw.title.getCurrentTitle() local pagename = thispage.text retval = retval .. "\n* thispage" retval = retval .. "\n**pagename = [" .. pagename .."]" retval = retval .. "\n**namespace = [" .. thispage.namespace .."]" retval = retval .. "\n**namespace as text = [" .. thispage.nsText .."]" retval = retval .. "\n**is it a cat? = " if (thispage:inNamespace(14)) then retval = retval .. "yes" else retval = retval .. "no" end return retval end return p
Summary:
Please note that all contributions to Stockhub 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
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/BrownHairedGirl/IrelandByCountyCatNav/doc
(
edit
)