Module:SiteList: Difference between revisions
Jump to navigation
Jump to search
PeaceDeadC (talk | contribs) No edit summary Tag: Manual revert |
PeaceDeadC (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
local siteDB = require('Module:SiteDatabase') |
|||
⚫ | |||
local function buildRow(siteType, site, id, sceneid, alias, notes) |
|||
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteList'}) |
|||
⚫ | |||
local siteLabel = 'N/A' |
|||
⚫ | |||
⚫ | |||
⚫ | |||
-- проверка наличия sceneid |
|||
local sceneid = args.sceneid or '' |
|||
⚫ | |||
link = string.format(siteInfo.sceneFormat, sceneid) |
|||
⚫ | |||
-- если sceneid нет, проверка наличия id |
|||
⚫ | |||
local siteData = siteDB.sites[site] |
|||
link = string.format(siteInfo.idFormat, id) |
|||
-- если нет и sceneid, и id, использование defaultLink |
|||
⚫ | |||
⚫ | |||
local url = siteData.url |
|||
if id ~= '' then |
|||
url = siteData.model_url .. id .. '.html' |
|||
-- форматирование ссылки для вывода |
|||
⚫ | |||
siteLabel = string.format("[%s %s]", link, siteInfo.name) |
|||
url = siteData.scene_url .. sceneid .. '.html' |
|||
⚫ | |||
siteLabel = siteType |
|||
end |
end |
||
local link = '[' .. url .. ' ' .. site .. '] <small>(' .. siteData.category .. ')</small>' |
|||
if mw.title.getCurrentTitle().namespace == 0 then |
|||
return string.format('|-\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n', siteType, siteLabel, alias or 'N/A', notes or 'N/A') |
|||
link = link .. siteData.model_category |
|||
⚫ | |||
⚫ | |||
return link |
|||
⚫ | |||
⚫ | |||
local args = frame:getParent().args |
|||
return 'None' |
|||
local siteType = args[1] or 'N/A' |
|||
⚫ | |||
local site = args.site or 'N/A' |
|||
-- использование пустых строк вместо 'N/A', если значения не установлены |
|||
⚫ | |||
local sceneid = args.sceneid or '' |
|||
⚫ | |||
⚫ | |||
return buildRow(siteType, site, id, sceneid, alias, notes) |
|||
end |
end |
||
Revision as of 22:52, 21 July 2023
Documentation for this module may be created at Module:SiteList/doc
local p = {} local siteDB = require('Module:SiteDatabase') function p.siteList(frame) local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteList'}) local site = args.site 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 siteData = siteDB.sites[site] if siteData then local url = siteData.url if id ~= '' then url = siteData.model_url .. id .. '.html' elseif sceneid ~= '' then url = siteData.scene_url .. sceneid .. '.html' end local link = '[' .. url .. ' ' .. site .. '] <small>(' .. siteData.category .. ')</small>' if mw.title.getCurrentTitle().namespace == 0 then link = link .. siteData.model_category end return link else return 'None' end end return p