Module:Pagetype: Difference between revisions

Jump to navigation Jump to search
m
1 revision
m (1 revision)
 
m (1 revision)
(One intermediate revision by the same user not shown)
Line 6: Line 6:
--      automatically detects namespaces, and allows for a great deal of customisation.          --
--      automatically detects namespaces, and allows for a great deal of customisation.          --
--      It can easily be ported to other wikis by changing the values in the configuration        --
--      It can easily be ported to other wikis by changing the values in the configuration        --
--      table.
--      table.                                                                                   --
--                                                                                                --
--                                                                                                --
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Line 33: Line 33:
['portal']            = 'portal',
['portal']            = 'portal',
['book']              = 'book',
['book']              = 'book',
['draft']            = 'draft',
['education program'] = 'education program page',
['education program'] = 'education program page',
['timedtext']        = 'Timed Text page',
['timedtext']        = 'Timed Text page',
Line 45: Line 46:


-- This table holds the names of the namespaces to be looked up from cry.pagetypes if cfg.defaultnsExtended is set.
-- This table holds the names of the namespaces to be looked up from cry.pagetypes if cfg.defaultnsExtended is set.
cfg.extendedNamespaces = {'main', 'user', 'project', 'file', 'mediawiki', 'template', 'category', 'help', 'portal', 'module', 'book'}
cfg.extendedNamespaces = {'main', 'user', 'project', 'file', 'mediawiki', 'template', 'category', 'help', 'portal', 'module', 'book', 'draft'}


-- The parameter name to set which default namespace values to be looked up from cfg.pagetypes.
-- The parameter name to set which default namespace values to be looked up from cfg.pagetypes.
Line 94: Line 95:


-- Load required modules.
-- Load required modules.
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local yesno = require('Module:Yesno')
local nsDetectModule = require('Module:Namespace detect')
local nsDetectModule = require('Module:Namespace detect')
Line 228: Line 230:


function p.main(frame)
function p.main(frame)
-- If called via #invoke, use the args passed into the invoking template, or the args passed to #invoke if any exist.
local args = getArgs(frame)
-- Otherwise assume args are being passed directly in from the debug console or from another Lua module.
local origArgs
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
for k, v in pairs(frame.args) do
origArgs = frame.args
break
end
else
origArgs = frame
end
-- Trim whitespace and remove blank arguments.
local args = {}
for k, v in pairs(origArgs) do
if type(v) == 'string' then
v = mw.text.trim(v)
end
if v ~= '' then
args[k] = v
end
end
return p._main(args)
return p._main(args)
end
end


return p
return p
14,061

edits

Navigation menu