Module:SiteList: Difference between revisions

From Porn Base Central
Jump to navigation Jump to search
No edit summary
Tag: Manual revert
No edit summary
Line 1: Line 1:
local p = {}
local p = {}
local siteDB = require('Module:SiteDatabase')


function p.siteList(frame)
local function buildRow(siteType, site, id, sceneid, alias, notes)
local siteInfo = mw.loadData('Module:SiteDictionary')[site:lower()]
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteList'})
local link = 'N/A'
local siteLabel = 'N/A'


local site = args.site
if siteInfo then
local id = args.id or ''
-- проверка наличия sceneid
if sceneid ~= "" then
local sceneid = args.sceneid or ''
local alias = args.alias or mw.title.getCurrentTitle().text
link = string.format(siteInfo.sceneFormat, sceneid)
local notes = args.notes or 'N/A'
-- если sceneid нет, проверка наличия id

elseif id ~= "" then
local siteData = siteDB.sites[site]
link = string.format(siteInfo.idFormat, id)

-- если нет и sceneid, и id, использование defaultLink
if siteData then
else
link = siteInfo.defaultLink
local url = siteData.url
end
if id ~= '' then
url = siteData.model_url .. id .. '.html'
-- форматирование ссылки для вывода
elseif sceneid ~= '' then
siteLabel = string.format("[%s %s]", link, siteInfo.name)
url = siteData.scene_url .. sceneid .. '.html'
else
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
end
end


return link
function p.siteList(frame)
else
local args = frame:getParent().args
return 'None'
local siteType = args[1] or 'N/A'
end
local site = args.site or 'N/A'
-- использование пустых строк вместо 'N/A', если значения не установлены
local id = args.id or ''
local sceneid = args.sceneid or ''
local alias = args.alias or 'N/A'
local notes = args.notes or 'N/A'
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