Module:SiteList: Difference between revisions
Jump to navigation
Jump to search
PeaceDeadC (talk | contribs) No edit summary |
PeaceDeadC (talk | contribs) No edit summary |
||
Line 6: | Line 6: | ||
aliases = {'website1', 'website1.com', 'website1com'}, |
aliases = {'website1', 'website1.com', 'website1com'}, |
||
url = 'https://website1.com/', |
url = 'https://website1.com/', |
||
sceneUrl = 'https://website1.com/updates/', |
|||
modelUrl = 'https://website1.com/models/', |
|||
suffix = '.html', |
suffix = '.html', |
||
category = 'Website 1 models', |
category = 'Website 1 models', |
||
Line 16: | Line 16: | ||
aliases = {'website2', 'website2.com', 'website2com'}, |
aliases = {'website2', 'website2.com', 'website2com'}, |
||
url = 'https://website2.com/', |
url = 'https://website2.com/', |
||
sceneUrl = 'https://website2.com/scene/', |
|||
modelUrl = 'https://website2.com/people/', |
|||
suffix = '', |
suffix = '', |
||
category = 'Website 2 models', |
category = 'Website 2 models', |
||
Line 26: | Line 26: | ||
aliases = {'website3', 'website3.com', 'website3com'}, |
aliases = {'website3', 'website3.com', 'website3com'}, |
||
url = 'https://website3.com/', |
url = 'https://website3.com/', |
||
sceneUrl = 'https://website3.com/videos/', |
|||
modelUrl = 'https://website3.com/performers/', |
|||
suffix = '.html', |
suffix = '.html', |
||
category = 'Website 3 models', |
category = 'Website 3 models', |
||
Line 36: | Line 36: | ||
aliases = {'website4', 'website4.com', 'website4com'}, |
aliases = {'website4', 'website4.com', 'website4com'}, |
||
url = 'https://website4.com/', |
url = 'https://website4.com/', |
||
sceneUrl = 'https://website4.com/videos/', |
|||
modelUrl = 'https://website4.com/performers/', |
|||
suffix = '.html', |
suffix = '.html', |
||
category = 'Website 4 models', |
category = 'Website 4 models', |
||
Line 46: | Line 46: | ||
aliases = {'website5', 'website5.com', 'website5com'}, |
aliases = {'website5', 'website5.com', 'website5com'}, |
||
url = 'https://website5.com/', |
url = 'https://website5.com/', |
||
sceneUrl = '', |
|||
modelUrl = 'https://website5.com/models/', |
|||
suffix = '', |
suffix = '', |
||
category = 'Website 5 models', |
category = 'Website 5 models', |
||
Line 56: | Line 56: | ||
aliases = {'website6', 'website6.com', 'website6com'}, |
aliases = {'website6', 'website6.com', 'website6com'}, |
||
url = 'https://website6.com/', |
url = 'https://website6.com/', |
||
sceneUrl = 'https://website6.com/updates/', |
|||
modelUrl = '', |
|||
suffix = '', |
suffix = '', |
||
category = 'Website 6 models', |
category = 'Website 6 models', |
||
Line 70: | Line 70: | ||
if site then |
if site then |
||
local url = site.url |
local url = site.url |
||
if args.sceneid and site. |
if args.sceneid and site.sceneUrl ~= '' then |
||
url = site. |
url = site.sceneUrl .. args.sceneid .. site.suffix |
||
elseif args.id and site. |
elseif args.id and site.modelUrl ~= '' then |
||
url = site. |
url = site.modelUrl .. args.id .. site.suffix |
||
end |
end |
||
Revision as of 20:02, 22 July 2023
Documentation for this module may be created at Module:SiteList/doc
local p = {} local sites = { website1 = { label = 'Website 1', aliases = {'website1', 'website1.com', 'website1com'}, url = 'https://website1.com/', sceneUrl = 'https://website1.com/updates/', modelUrl = 'https://website1.com/models/', suffix = '.html', category = 'Website 1 models', network = 'Network1 Network', }, website2 = { label = 'Website 2', aliases = {'website2', 'website2.com', 'website2com'}, url = 'https://website2.com/', sceneUrl = 'https://website2.com/scene/', modelUrl = 'https://website2.com/people/', suffix = '', category = 'Website 2 models', network = 'Network2 Network', }, website3 = { label = 'Website 3', aliases = {'website3', 'website3.com', 'website3com'}, url = 'https://website3.com/', sceneUrl = 'https://website3.com/videos/', modelUrl = 'https://website3.com/performers/', suffix = '.html', category = 'Website 3 models', network = 'Network3 Network', }, website4 = { label = 'Website 4', aliases = {'website4', 'website4.com', 'website4com'}, url = 'https://website4.com/', sceneUrl = 'https://website4.com/videos/', modelUrl = 'https://website4.com/performers/', suffix = '.html', category = 'Website 4 models', network = '', }, website5 = { label = 'Website 5', aliases = {'website5', 'website5.com', 'website5com'}, url = 'https://website5.com/', sceneUrl = '', modelUrl = 'https://website5.com/models/', suffix = '', category = 'Website 5 models', network = 'Network5 Network', }, website6 = { label = 'Website 6', aliases = {'website6', 'website6.com', 'website6com'}, url = 'https://website6.com/', sceneUrl = 'https://website6.com/updates/', modelUrl = '', suffix = '', category = 'Website 6 models', network = 'Network6 Network', }, } function p.site(frame) local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteList'}) local site = getSite(args.site) if site then local url = site.url if args.sceneid and site.sceneUrl ~= '' then url = site.sceneUrl .. args.sceneid .. site.suffix elseif args.id and site.modelUrl ~= '' then url = site.modelUrl .. args.id .. site.suffix end local alias = args.alias or mw.title.getCurrentTitle().text local notes = args.notes and '<div style="font-size: 0.875em;">' .. args.notes .. '</div>' or '<div style="font-size: 0.875em;">N/A</div>' local categoryLink = site.network and site.network ~= '' and string.format(' <small>([[:Category:%s|%s]])</small>', site.network, site.network) or '' local style if args[1] == 'Studio' then style = 'background-color:#DADADA;text-align:center;color:black' else style = 'background-color:#E7E7E7;text-align:center;color:black' end local result = string.format( '|-\n| style="%s" | %s\n| style="text-align:center;vertical-align:middle;" | %s%s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="width: 0px; padding: 0px; border: none;" |\n', style, args[1] == 'Studio' and 'Studio' or 'Website', string.format('[%s %s]', url, site.label), categoryLink, alias, notes ) local ns = mw.title.getCurrentTitle().namespace if ns == 0 then result = result .. '[[Category:' .. site.category .. ']]' result = result .. '[[Category:Articles in the mainspace using Template:SiteList]]' elseif ns == 2 then result = result .. '[[Category:Articles in the userspace using Template:SiteList]]' elseif ns == 118 then result = result .. '[[Category:Drafts using Template:SiteList]]' end return result else return string.format('|-\n| colspan="4" style="text-align:center;vertical-align:middle;color:red;font-weight:bold;" | Error: invalid site parameter: %s. See [[PBC:SiteList|PBC:SiteList for documentation]] \n| style="width: 0px; padding: 0px; border: none;" |\n', args.site) end end function table.contains(table, element) for _, value in pairs(table) do if value == element then return true end end return false end function getSite(name) for _, site in pairs(sites) do if site.label:lower() == name:lower() or table.contains(site.aliases, name:lower()) then return site end end return nil end return p