Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Editing Module:TNT

From WikiOasis Meta
Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 33: Line 33:
--        if the current page is Template:Graph:Lines/doc
--        if the current page is Template:Graph:Lines/doc
--
--
local config = (function()
local ok, res = pcall(mw.loadData, "Module:TNT/config");
return ok and res or {};
end)();


local p = {}
local p = {}
Line 94: Line 89:
function p.doc(frame)
function p.doc(frame)
local dataset = sanitizeDataset(frame.args[1])
local dataset = sanitizeDataset(frame.args[1])
local json, dataPage, categories = implGetTemplateData(nil, dataset, frame.args)
local json, dataPage, categories = implGetTemplateData(dataset)
return frame:extensionTag('templatedata', json) ..
return frame:extensionTag('templatedata', json) ..
formatMessage(i18nDataset, 'edit_doc', {link(dataPage)}) ..
formatMessage(i18nDataset, 'edit_doc', {link(dataPage)}) ..
Line 101: Line 96:


function p.getTemplateData(dataset)
function p.getTemplateData(dataset)
local data = implGetTemplateData(true, dataset);
local data = implGetTemplateData(dataset, true);
return data;
return data;
end
end


function p.getTemplateDataNew(...)
function implGetTemplateData(dataset, legacy)
return implGetTemplateData(nil, ...);
end
 
function implGetTemplateData(legacy, dataset, args)
-- TODO: add '_' parameter once lua starts reindexing properly for "all" languages
-- TODO: add '_' parameter once lua starts reindexing properly for "all" languages
local data, dataPage, categories = loadData(
local data, dataPage, categories = loadData(
Line 155: Line 146:
paramOrder=paramOrder,
paramOrder=paramOrder,
description=data.description,
description=data.description,
-- TODO: Store this in a dataset:
format = (args and args.format or nil),
})
})


Line 203: Line 192:
data = mw.ext.data.get('Templatedata/' .. dataset, lang);
data = mw.ext.data.get('Templatedata/' .. dataset, lang);
if data ~= false then
if data ~= false then
local legacyTemplateDataCategoryName = config.legacyTemplateDataCategoryName;
categories = '[[Category:Templates using legacy global TemplateData table name]]';
if legacyTemplateDataCategoryName ~= false then
categories = string.format(
'[[Category:%s%s]]',
legacyTemplateDataCategoryName or "Templates using legacy global TemplateData table name",
config.translatableCategoryLink and mw.getCurrentFrame():callParserFunction("#translation:") or ""
);
end
dataPage = 'Templatedata/' .. dataset;
dataPage = 'Templatedata/' .. dataset;
end
end
Line 223: Line 205:
error('Missing Commons dataset ' .. i18nDataset)
error('Missing Commons dataset ' .. i18nDataset)
else
else
error(formatMessage(i18nDataset, 'error_bad_dataset', {link(dataPage)}))
error(formatMessage(i18nDataset, 'error_bad_dataset', {link(dataset)}))
end
end
end
end
return data, dataPage, categories;
return data, dataPage, categories
end
end


Please note that all contributions to WikiOasis Meta are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) (see Meta:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

 

Page included on this page:

Cookies help us deliver our services. By using our services, you agree to our use of cookies.