Module:SiteList: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
PeaceDeadC (talk | contribs) No edit summary Tag: Manual revert |
PeaceDeadC (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
function |
local function createURL(site, id, sceneid) |
||
local |
local site_data = mw.loadData('Module:SiteDictionary')[site] |
||
local |
local url = site_data.base_url |
||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
local notes = args['notes'] or 'N/A' |
|||
| ⚫ | |||
-- Создаем словарь соответствий для сайтов |
|||
url = url .. string.format(site_data.scene_url, sceneid) |
|||
local siteData = mw.loadData('Module:SiteDictionary') |
|||
elseif id then |
|||
local siteInfo = siteData[site] |
|||
url = url .. string.format(site_data.id_url, id) |
|||
local websiteText = "None" |
|||
| ⚫ | |||
websiteText = string.format( |
|||
siteInfo.template, |
|||
sceneid ~= '' and sceneid or id ~= '' and id or '', |
|||
siteInfo.name |
|||
) |
|||
end |
end |
||
return url |
|||
-- Выбираем тип и форматируем данные |
|||
| ⚫ | |||
local typeText = '' |
|||
local backgroundColor = '' |
|||
function p.siteList(frame) |
|||
if string.lower(siteType) == 'website' then |
|||
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteList'}) |
|||
typeText = 'Website' |
|||
| ⚫ | |||
backgroundColor = '#E7E7E7' |
|||
| ⚫ | |||
elseif string.lower(siteType) == 'studio' then |
|||
| ⚫ | |||
typeText = 'Studio' |
|||
| ⚫ | |||
backgroundColor = '#DADADA' |
|||
| ⚫ | |||
else |
|||
typeText = siteType |
|||
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>' |
|||
-- Строим результат |
|||
local result = string.format([[ |
|||
|- |
|||
| style="text-align:center;vertical-align:middle; background-color:%s;text-align:center;color:black" | '''%s''' |
|||
| style="text-align:center;vertical-align:middle;" | %s |
|||
| style="text-align:center;vertical-align:middle;" | %s |
|||
| style="text-align:center;vertical-align:middle;" | <small>%s</small> |
|||
| ⚫ | |||
return |
return output |
||
end |
end |
||
Revision as of 13:47, 21 July 2023
Documentation for this module may be created at Module:SiteList/doc
local p = {}
local function createURL(site, id, sceneid)
local site_data = mw.loadData('Module:SiteDictionary')[site]
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
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