Module:SiteList: Difference between revisions
Jump to navigation
Jump to search
PeaceDeadC (talk | contribs) No edit summary |
PeaceDeadC (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
local function createURL(site, id, sceneid) |
local function createURL(site, id, sceneid) |
||
site = string.lower(site) -- приводим имя сайта к нижнему регистру |
|||
local site_data = mw.loadData('Module:SiteDictionary')[site] |
local site_data = mw.loadData('Module:SiteDictionary')[site] |
||
if site_data then |
|||
local url = site_data.base_url |
local url = site_data.base_url |
||
if sceneid then |
if sceneid then |
||
url = url .. string.format(site_data.scene_url, sceneid) |
url = url .. string.format(site_data.scene_url, sceneid) |
||
elseif id then |
elseif id then |
||
url = url .. string.format(site_data.id_url, id) |
url = url .. string.format(site_data.id_url, id) |
||
end |
end |
||
return url |
return url |
||
else |
|||
return '' |
|||
end |
|||
end |
end |
||
Revision as of 16:53, 21 July 2023
Documentation for this module may be created at Module:SiteList/doc
local p = {} local function createURL(site, id, sceneid) site = string.lower(site) -- приводим имя сайта к нижнему регистру local site_data = mw.loadData('Module:SiteDictionary')[site] if site_data then local url = site_data.base_url if sceneid then url = url .. string.format(site_data.scene_url, sceneid) elseif id then url = url .. string.format(site_data.id_url, id) end return url else return '' end end function p.siteList(frame) local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteList'}) local site = args.site or "" local id = args.id or "" local sceneid = args.sceneid or "" local alias = args.alias or mw.title.getCurrentTitle().text local notes = args.notes or "N/A" local url = createURL(site, id, sceneid) local output = '<tr><td>' .. site .. '</td><td><a href="' .. url .. '">' .. site .. '</a></td><td>' .. alias .. '</td><td>' .. notes .. '</td></tr>' return output end return p