Module:Short title
Module for generating short-title links and entries, in relation to English and United Kingdom style legislation.
Usage
[edit]Parameters
[edit]s - Actual short title
c - Chapter number detail for display text
y - Calendar Year (number) (optional as some early laws don't have a year)
the - include text "The" (yes | no)
link - Generate internal wikilink of "{{{Short-title}}} {{{Year}}}" style (yes|no)
a - anchor - Link to specfic point in legislation mentioned.
comma - Adds comma between name and year (yes|no)
sn - Side note style to add Regnal Monarch, Chapter sidenotes. (Currently defined, none | left | right | sn)
chapter - Chapter for sidenote text.
regnal - used with style none, to determine format.(yes | no)
r - regnal year for sidenote text. (Note that for after the 1960s this will be a calendar year)
m - Monarch. (optional)
Sidenotes styles are...:
none - Generates text directly if regnal=yes used; generates example form "2 Wales c.3"
left - Sidenote on left hand-side; text is of example form "2 Wales c.3"
right - Sidenote on right-hand side; text is of example form"2 Wales c.3"
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.main(frame)
local args = getArgs(frame, {wrappers = 'Template:Short-title', valueFunc = function(k, v)
if v then
v = mw.text.trim(v)
end
if v ~= '' or k == 'sn' or k == 'm' then
return v
end
end })
if not args.s then
return '<span class="error">Error: No title passed to {{[[Template:Short-title|Short-title]]}}</span>'
end
local retval
if false then -- if args.style == 'ref' then
-- The original template has an error in its code that prevents this from ever working, so I'm not going to bother converting it for now.
-- {{tag:ref|{{#if: {{{c|}}}|[[{{#if: {{{y|}}}|{{{s}}} {{{y}}}|{{{s}}} }}{{!}}{{{c}}}]]|{{#if: {{{the|}}}|The |}}{{#if: {{{link|}}}|[[{{#if: {{{y|}}}|{{{s}}} {{{y}}}|{{{s}}}}}{{!}}{{{s}}} {{#if: {{{y|}}}|{{#ifeq: {{{comma}}}|yes|,|}} {{{y}}}|}}]]| {{{s}}} {{#if: {{{y|}}}|{{#ifeq: {{{comma}}}|yes|,|}} {{{y}}}|}}}}}}}}
else
if args.c then
retval = string.format('[[%s %s%s%s|%s]]',
args.s,
args.y or '',
args.a and '#' or '',
args.a or '',
args.c
)
else
local maybeThe = args.the and 'The ' or ''
local maybeComma = args.comma == 'yes' and ',' or ''
local maybeDisambig = not (args.j == nil)
if args.link then
retval = string.format('%s[[%s %s|%s%s]]',
maybeThe,
args.s,
args.y or '', -- Needs a disambig insertion here for (Scotland, N.I., B.I, etc.) --
args.s,
args.y and string.format('%s %s', maybeComma, args.y) or ''
)
else if args.page then
retval = string.format('%s[[%s|%s%s]]',
maybeThe,
args.page,
args.s,
args.y and string.format('%s %s', maybeComma, args.y) or ''
)
else
retval = string.format('%s%s %s',
maybeThe,
args.s,
args.y and string.format('%s %s', maybeComma, args.y) or ''
)
end
end
end
end
if not args.sn or args.sn == 'none' then
if args.regnal == 'yes' then
retval = string.format('%s (%s%s c.%s)', retval, args.r, args.m, args.chapter)
end
-- Code that would have interacted with the cl-act-p family, which was never fully implemented or worked correctly.
-- elseif args.sn == 'cl' then
-- retval = retval .. frame:expandTemplate{title = 'cl-act-title', args = {
-- '',
-- string.format('%s%s c.%s', args.r, args.m, args.chapter),
-- layout = args.layout or ''
-- }}
elseif args.sn ~= '' then
retval = retval .. frame:expandTemplate{title = args.sn .. ' sidenote' , args = {
string.format('%s c.%s', args.r, args.chapter)
}}
end
if args.style then retval = string.format('%s[[Category:Pages using Module:Short title with style|%s]]', retval, args.style) end
return retval
end
return p