Module:Catalog lookup link/sandbox: Difference between revisions

Content deleted Content added
tweak formatting
Implement url-access
Line 66:
 
function p.main (frame)
local args = getArgs (frame);
local resultout_text = {}'';
if is_set(args[1]) then
local result = {};
if is_set(args[1]) then
local article;
local result = {};
local article_postfix = args['article-postfix'] or '';
local link_prefix = args['link-prefix'] or '';
local lock_icons = {
local link_postfix = args['link-postfix'] or '';
['free'] = '[[File:Lock-green.svg|9px|link=|alt=Freely accessible|Freely accessible]]',
local item_prefix = args['item-prefix'] or '';
['registration'] = '[[File:Lock-blue-alt-2.svg|9px|link=|alt=Free registration required|Free registration required]]',
local item_postfix = args['item-postfix'] or '';
['limited'] = '[[File:Lock-blue-alt-2.svg|9px|link=|alt=Free access subject to limited trial, subscription normally required|Free access subject to limited trial, subscription normally required]]',
local list_separator = args['list-separator'] or ', ';
['subscription'] = '[[File:Lock-red-alt.svg|9px|link=|alt=Paid subscription required|Paid subscription required]]',
local leadout_postfix = args['leadout-postfix'] or ' ';
});
local list_leadout;
if local is_setarticle_postfix = (args['listarticle-leadoutpostfix']) thenor '';
local link_prefix = args['link-prefix'] or '';
list_leadout = table.concat ({
mw.ustring.match(mw.ustring.sub(local link_postfix = args['listlink-leadoutpostfix'],1,1), '[%a]') and ' ' or '',;
local item_prefix = args['listitem-leadoutprefix'], or '';
local link_postfixitem_postfix = args['linkitem-postfix'] or '';
leadout_postfix,
local item_prefixlist_separator = args['itemlist-prefixseparator'] or ', ';
});
local item_postfixleadout_postfix = args['itemleadout-postfix'] or ' ';
else
local url_access = lock_icons[mw.text.trim(args['url-access'] or '')] or '';
list_leadout = '';
local list_leadout;
end
if args['article-link'] oris_set (args['articlelist-nameleadout']) then end
list_leadout = table.concat ({
mw.ustring.match(mw.ustring.sub(args['list-leadout'],1,1), '[%a]') and ' ' or '',
args['list-leadout'],
leadout_postfix,
});
else
list_leadout = '';
end
article = make_wikilink (args['article-link'], args['article-name']);
if is_set (article) then
Line 112 ⟶ 120:
item_postfix, -- item postfix
']' -- close ext link markup
});
if is_set (url_access) then
item = table.concat ({
item,
'<span style="padding-left:0.15em;">',
url_access,
'</span>'
});
end
else
item = table.concat ({ -- create an unlinked item
Line 118 ⟶ 135:
item, -- item as label
item_postfix, -- item postfix
});
end
Line 125 ⟶ 142:
if is_set (args['list-leadout']) then
returnout_text = table.concat ({article, mw.text.listToText (result, list_separator, list_leadout)});
else
returnout_text = table.concat ({article, table.concat (result, list_separator)});
end
if is_set (url_access) then
out_text = mw.html.create('span')
:addClass('plainlinks')
:wikitext(out)
end
else
return ''
end
return ''out_text
end