Content deleted Content added
add class=noviewer to images to hide from mediaviewer |
Jackmcbarn (talk | contribs) use mw.html and other fixes from sandbox |
||
Line 4:
-- The portal image data is kept in submodules of [[Module:Portal/images]], listed below:
-- [[Module:Portal/images/a]]
-- [[Module:Portal/images/b]]
-- [[Module:Portal/images/c]]
-- [[Module:Portal/images/d]]
-- [[Module:Portal/images/e]]
-- [[Module:Portal/images/f]]
-- [[Module:Portal/images/g]]
-- [[Module:Portal/images/h]]
-- [[Module:Portal/images/i]]
-- [[Module:Portal/images/j]]
-- [[Module:Portal/images/k]]
-- [[Module:Portal/images/l]]
-- [[Module:Portal/images/m]]
-- [[Module:Portal/images/n]]
-- [[Module:Portal/images/o]]
-- [[Module:Portal/images/p]]
-- [[Module:Portal/images/q]]
-- [[Module:Portal/images/r]]
-- [[Module:Portal/images/s]]
-- [[Module:Portal/images/t]]
-- [[Module:Portal/images/u]]
-- [[Module:Portal/images/v]]
-- [[Module:Portal/images/w]]
-- [[Module:Portal/images/x]]
-- [[Module:Portal/images/y]]
-- [[Module:Portal/images/z]]
-- [[Module:Portal/images/other]]
--
-- [[Module:Portal/images/aliases]]
--
--
-- The images data pages are separated by the first letter to reduce server load when images are added, changed, or removed.
Line 39:
-- 5,000,000 pages using this module needed to be refreshed every time an image was added or removed.
]==]
local p = {}
Line 53 ⟶ 51:
imagePage = 'Module:Portal/images/' .. firstLetter
else
imagePage = 'Module:Portal/images/other'
local images = mw.loadData(imagePage)▼
end
end
Line 80 ⟶ 74:
end
s = mw.ustring.lower(s)
end
function p._portal(portals, args)
-- This function builds the portal box used by the {{portal}} template.
local root =
▲ .addClass('portal')
▲ .css('border', 'solid #aaa 1px')
▲ .css('margin', args.margin or (args.left == 'yes' and '0.5em 1em 0.5em 0') or '0.5em 0 0.5em 1em')
▲ .newline()
-- Start the table. This corresponds to the start of the wikitext table in the old [[Template:Portal]].
local tableroot = root
-- If no portals have been specified, display an error and add the page to a tracking category.
if not portals[1] then
tableroot
end
-- Display the portals specified in the positional arguments.
for
local image = getImageName(portal)
-- Generate the html for the image and the portal name.
tableroot
end
return tostring(root)
Line 150 ⟶ 131:
-- Returns an array containing all image subpages (minus aliases) as loaded by mw.loadData.
local images = {}
▲ table.insert(images, mw.loadData('Module:Portal/images/' .. subpage))
end
return images
Line 162 ⟶ 142:
-- names are capitalized, so the portal links may be broken.
local lang = mw.language.getContentLanguage()
local count = 1
for
for portal in pairs(imageTable) do
portals[count] = lang:ucfirst(portal)
Line 178 ⟶ 157:
-- should be moved to a portal alias for ease of maintenance.
local exists, dupes = {}, {}
for portal, image in pairs(imageTable) do
if not exists[image] then
exists[image] = portal
else
table.insert(dupes,
end
end
Line 194 ⟶ 172:
end
end
local function processPortalArgs(args)
-- This function processes a table of arguments and returns two tables: an array of portal names for processing by ipairs, and a table of
Line 225 ⟶ 203:
-- or from another Lua module.
local origArgs
if type(frame.getParent) ==
origArgs = frame:getParent().args
for k, v in pairs(frame.args) do
Line 248 ⟶ 226:
end
p[funcName] = makeWrapper('_' .. funcName)
end
|