Module:Purge

From Brighter Shores Wiki
Jump to navigation Jump to search
Module documentation
This documentation is transcluded from Module:Purge/doc. [edit] [history] [purge]
Module:Purge is required by Module:Products.

Provides a purge link. Can be customised if used by lua, or lesser customisation via Template:Purge.

This module is a helper module to be used by other modules; it may not designed to be invoked directly. See Brighter Shores:Lua/Helper modules for a full list and more information. For a full list of modules using this helper click here

FunctionTypeUse
_purge( anchor, text, tag, noinplace )string/table, string, string, booleanGenerates a purge link

All args are optional.

  • anchor - The ID of the tag, used for an anchor link; default res
  • text - Link text; default (wrong?)
  • tag - HTML tag to use; default sup
  • noinplace - If defined, will suppress the addition of the jsPurgeLink class, which makes the link do an in-place purge rather than going to a purge confirmation
Example:
local purge = require( 'Module:Purge' )._purge

local refreshLink = purge( nil, 'refresh' )
-- Or
local refreshLink = purge{ text = 'refresh' }

-- <nowiki>
-- Implements Template:Purge
--

local p = {}

function p._purge(anchor, text, tag, noinplace)
	if type( anchor ) == 'table' then -- Allow function to be called with named argruments
		text = anchor.text
		tag = anchor.tag
		noinplace = anchor.noinplace
		anchor = anchor.anchor
	end
	local page_title = mw.title.getCurrentTitle().fullText
	local link = string.format('[%s#%s %s]',tostring(mw.uri.fullUrl(page_title,'action=purge')),anchor or 'res', text or '(wrong?)')
	link = string.format('<%s class="plainlinks%s" id="res" title="If this information seems incorrect, click here to force an update.">%s</%s>', 
		tag or 'sup', (noinplace and '') or ' jsPurgeLink', link, tag or 'sup')
	return link
end

function p.purge(frame)
	return p._purge(frame:getParent().args.anchor)
end

return p