You can edit almost every page by Creating an account and confirming your email.

Module:R from acronym

From EverybodyWiki Bios & Wiki

Usage

{{#invoke:R from acronym}}

{{#invoke:R from acronym|function_name}}

After tests, this module will implement {{Template:R from acronym}}.



local p = {} -- defines a variable p as an empty table, but *not* nil

function p.main(frame) -- this block defines the table element p[main]
	                   -- as the _function_ listed below

local mRedirect = require("Module:Redirect")
local function noredir(page)
  local link = mw.title.new(page):fullUrl("redirect=no")
  return "<span class=\"plainlinks\">["..link.." "..page.."]</span>"
end
local function process(page)
  return mw.title.new(page).prefixedText
end
local function exists(page)
  return mw.title.new(page).exists
end

local args = require("Module:Arguments").getArgs(frame,{removeBlanks=false})
local thisPage = tostring(mw.title.getCurrentTitle())
local otherPage = args[1] or ""

--Demo parameters, for demonstrating behavior with certain redirect 
--targets and avoiding categorization (do not use in articles)
local thisDemoTarget = args.thistarget
local otherDemoTarget = args.othertarget
local noError = args.noerror
local demo = args.demo or noError or thisDemoTarget or otherDemoTarget

--"Process" pages to remove section links, standardize capitalization, etc.
thisDemoTarget = thisDemoTarget=="" and "" or thisDemoTarget and process(thisDemoTarget)

--Determine redirect targets (getTarget returns nil if page is not a redirect)
local thisTarget = thisDemoTarget or mRedirect.getTarget(thisPage)
--For double redirects
local thisDoubleTarget = thisTarget and mRedirect.getTarget(thisTarget)
-- Allow setting demo parameters to empty string to demonstrate a non-redirect
thisTarget = thisDemoTarget~="" and thisTarget

--Errors
local err
if not thisTarget and exists(thisPage) then --Check existence of thisPage to avoid errors in preview mode
  err = "This page is not a redirect."
elseif thisTarget==thisPage or (not exists(thisTarget) and exists(thisPage)) then
  err = "This is a broken redirect (it redirects to itself or to a non-existing page)."
elseif thisDoubleTarget then
  err = "This is a [[Wikipedia:Double redirects|double redirect]] to [["..thisDoubleTarget.."]]."
end

--Return either redirect template or error
local embed = args.embed
local from, info, cat
if not err or noError then
    from = "an [[acronym]] to a related topic, such as the expansion of the acronym"
    info = "** Remember that an acronym is a special type of [[initialism]] that can be spoken as a word, such as NATO and RADAR."
           .."\n** Use {{[[Template:R from initialism|R from initialism]]}} for abbreviations that have letters that are pronounced separately, such as OAU, and USSR."
    cat = demo and "" or "Redirects from acronyms"

  return frame:expandTemplate({title="Redirect template",
                               args={from=from,info=info,["main category"]=cat,
                                     name=(embed=="yes" and "R from acronym" or nil)}})
  else
    return "<span class=\"error\">Error in [[Module:Sandbox/X. Perry Mentor/Rcat]]: "..err.."</span>"
         ..(demo and "" or "[[Category:Pages with incorrectly transcluded templates]]")
end

end

return p

This module "R from acronym" is from Wikipedia if otherwise notified