Module:SiteList: Difference between revisions

From Porn Base Central
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:


if siteData then
if siteData then
local url = siteData.url
local url = siteData.default_url
if id ~= '' then
if id ~= '' then
url = siteData.model_url .. id .. '.html'
url = siteData.model_url:gsub('MODEL_ID', id)
elseif sceneid ~= '' then
elseif sceneid ~= '' then
url = siteData.scene_url .. sceneid .. '.html'
url = siteData.scene_url:gsub('SCENE_ID', sceneid)
end
end
local link = '[' .. url .. ' ' .. site .. '] <small>(' .. siteData.category .. ')</small>'
local link = '[' .. url .. ' ' .. site .. '] <small>(' .. siteData.category .. ')</small>'

Revision as of 23:00, 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.default_url
    if id ~= '' then
      url = siteData.model_url:gsub('MODEL_ID', id)
    elseif sceneid ~= '' then
      url = siteData.scene_url:gsub('SCENE_ID', sceneid)
    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