Module:Infobox ship: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1:
require('Module:No globalsstrict');
 
local utilities = require ('Module:WPSHIPS_utilities');
Line 37:
check parameters supplyed in <template> against known parameters for that template. Emit preview warning when
a parameter is unknown.
 
TODO: move styling to styles.css
 
]]
Line 46 ⟶ 44:
local param = k:gsub ('%d+$', '#'); -- for enumerated parameters, replace enumerator with '#'
if not known_params_t[param] then -- add warning message when <param> is not known for <template>
mw.addWarning (string.format (data.warning_fmt_str, data.warn_span_style, data.warn_code_style, template, template, data.warn_code_style, k, v));
mw.addWarning ('<span style="color:#d33"><code style="color: inherit; background: inherit; border: none; padding: inherit;">&#123;{'.. template .. '}}</code>: unknown parameter: <code style="color: inherit; background: inherit; border: none; padding: inherit;">|' .. k .. '=' .. v .. '</code></span>');
has_unknown_params = (0 == namespace); -- add unknown params category when infobox is rendered; mainspace only
end
Line 60 ⟶ 58:
 
local function infobox_ship_begin (args_t, infobox_ship_t, frame)
local name = mw.title.getCurrentTitle().text;
 
infobox_ship_t['bodystyle'] = data.styles_t.mainbox;
if args_t.infobox_caption then
local name = mw.title.getCurrentTitle().text;
if 'yes' == args_t.infobox_caption then -- format article title as infobox caption
infobox_ship_t.title = ship_name_format ({name=name, adj='off', showerrs=args_t.showerrs, sclass=args_t.sclass});
Line 74 ⟶ 73:
end
 
if args_t.display_title and ('none' ~= args_t.display_title) then -- any value but 'none'
if 'ital' == args_t.display_title then -- use {{italic title}} template
infobox_ship_t.title = infobox_ship_t.title .. frame:expandTemplate ({title='italic title'});
else elseif ('none' ~= args_t.display_title) then -- any value but 'none' use value in |display_title= for {{DISPLAYTITLE}} magic word
infobox_ship_t.title = infobox_ship_t.title .. frame:preprocess ('{{DISPLAYTITLE:' .. args_t.display_title .. '}}');
end
else -- |display_title= empty or omitted, use article title
infobox_ship_t.title = infobox_ship_t.title .. frame:preprocess ('{{DISPLAYTITLE:' .. ship_name_format ({name=name, sclass=args_t.sclass}) .. '}}');
end
end
Line 94 ⟶ 95:
local function infobox_ship_image (frame)
local args_t = get_args (frame);
 
if not args_t.image then
return; -- if no image specified, abandon
end
local infobox_ship_t = {
child = args_t.child or 'yes'; -- default to child
Line 224 ⟶ 230:
i = i + 1; -- bump the enumerator
end
 
synonym_check (args_t, 'total_ships_cancelled', 'total_ships_canceled', nil); -- error if both synonymous parameters set
 
line_items (args_t, data.infobox_class_overview_params_t, infobox_ship_t, i, frame); -- go do all of the other infobox parameters