Content deleted Content added
sync from live; |
add empty content |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 5:
|article-name=: Optional alternative text to be displayed for |article-link= link in front of catalog link.
If not specified, |article-link= is used for display as well. If both parameters are not specified, the prefix is omitted completely.
|article-
|link-prefix=: Optional prefix portion of url to external catalog item(s).
|link-
|item-prefix=: Optional text displayed in front of each external link (omitted, if not defined)
|item-
|list-separator=: Optional alternative separator displayed between list items (default: ", ", if not specified). Whitespace must be encoded.
|list-leadout=: Optional alternative leadout text displayed between the last two list items (f.e. "and", "or", "as well as", etc., default is the |list-separator= or ", ".)
|leadout-
This gets added in front of the last list item instead of the default whitespace which is added without this parameter.
This may be necessary if |list-separator= is used not only to define the list separator but also parts of the item prefix
Line 26:
]]
require('
local getArgs = require ('Module:Arguments').getArgs;
local lock_icons = { --icon classes are defined in Module:Citation/CS1/styles.css
['free'] = {'
['registration'] = {'
['limited'] = {'
['subscription'] = {'
}
Line 51:
Makes a wikilinked or plain text label from arguments; when both link and display text is provided, makes a
wikilink in the form [[L|D]]; if only link is provided, makes a wikilinked label in the form [[L]]; if only display
is provided, makes a plain-text label; if neither are provided makes a label from
]=]
local function make_label (link, display,
local label = '';
if is_set (link) then
Line 68:
if is_set (label) then
return table.concat ({label,
else
return
end
end
Line 135:
local label;
local
local link_prefix = args['link-prefix'] or '';
local
local item_prefix = args['item-prefix'] or '';
local
local list_separator = args['list-separator'] or ', ';
local
local list_leadout;
Line 149:
list_leadout = table.concat ({
mw.ustring.gsub (args['list-leadout'], '^(%a)', ' %1'), -- insert leading space if first character is a letter
});
else
Line 155:
end
label = make_label (args['article-link'], args['article-name'],
for k, item in ipairs (args) do -- for each of the positional parameters
Line 164:
link_prefix, -- url prefix
mw.uri.encode (item), -- item is part of url
' ', -- required space between url and label
item_prefix, -- label prefix
item, -- item as label
']' -- close ext link markup
});
Line 188:
item_prefix, -- label prefix
item, -- item as label
});
end
Line 195:
end
out_text = frame:callParserFunction('#tag', {'templatestyles', '', src=table.concat({
'Module:Citation/CS1',
mw.ustring.match(frame:getTitle(), '/sandbox$') or '',
'/styles.css',
})});
if is_set (args['list-leadout']) then
out_text = table.concat ({out_text, label, mw.text.listToText (result, list_separator, list_leadout)});
else
out_text = table.concat ({out_text, label, table.concat (result, list_separator)});
end
end --is_set (args[1])
return out_text
end
|