Modul:Random portal component: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
Hidayatsrf (bicara | kontrib) Tidak ada ringkasan suntingan |
Hidayatsrf (bicara | kontrib) Tidak ada ringkasan suntingan |
||
(4 revisi perantara oleh pengguna yang sama tidak ditampilkan) | |||
Baris 1:
-- This module implements [[Template
local p = {}
Baris 10:
local function subPageTrackingCategories(pages, max, header)
local retval = "";
local availableSubPageCount = 0;▼
local i;▼
local thispagetitle = mw.title.getCurrentTitle().text
-- don't track DYK etc, only selected/featured articles, biogs etc
if ((string.find(header, "/[
return retval
end
Baris 23 ⟶ 21:
end
-- no tracking if this is a subpage
if ((mw.ustring.match(thispagetitle, "/") ~= nil) and (thispagetitle ~= "AC/DC")) then
return retval
end
local
-- Check for missing subpages at end of alleged number range
▲ myMaxCheck = tonumber(max)
while availableSubPageCount > 0 and not mw.title.new(pages.subpage .. '/' .. tostring(availableSubPageCount)).exists do
end
retval = retval .. "[[Kategori:Komponen portal acak dengan subhalaman yang tersedia lebih sedikit dari maks yang ditentukan]]"
local aSubPage = mw.title.new(pages.subpage .. '/' .. i)▼
else
-- Check for spurious subpages beyond end of alleged number range
▲ availableSubPageCount = availableSubPageCount + 1;
▲
availableSubPageCount = availableSubPageCount + 1
end
retval = retval .. "[[Kategori:Komponen portal acak dengan lebih banyak subhalaman yang tersedia daripada jumlah maksimal]]"
▲ if (availableSubPageCount < tonumber(max)) then
end
end
-- before categorising, check what type of subpage we are categorising, and if detected, categorise images separately
local subpageType = "
local subpageName = pages.subpage
subpageName = mw.ustring.gsub(subpageName, "^[^/]*/", "")
subpageName = mw.ustring.lower(subpageName)
if ((mw.ustring.find(subpageName, "
(mw.ustring.find(subpageName, "
(mw.ustring.find(subpageName, "panorama", 1, true) ~= nil)) then
subpageType = "
end
if (availableSubPageCount < 2) then
retval = retval .. "[[
elseif (availableSubPageCount <= 5) then
retval = retval .. "[[
elseif (availableSubPageCount <= 10) then
retval = retval .. "[[
elseif (availableSubPageCount <= 15) then
retval = retval .. "[[
elseif (availableSubPageCount <= 20) then
retval = retval .. "[[
elseif (availableSubPageCount <= 25) then
retval = retval .. "[[
elseif (availableSubPageCount <= 30) then
retval = retval .. "[[
elseif (availableSubPageCount <= 40) then
retval = retval .. "[[
elseif (availableSubPageCount <= 50) then
retval = retval .. "[[
else
retval = retval .. "[[
end
return retval;
Baris 100 ⟶ 99:
pages.root = args.rootpage or currentTitle.prefixedText
pages.subpage = pages.root .. '/' .. expandArg(args, 'subpage')
pages.random = pages.subpage .. '/' .. getRandomNumber(args.max)▼
repeat
tries = tries - 1
until tries < 1 or mw.title.new(pages.random).exists
pages.footer = 'Template:Box-footer'
return pages
Baris 115 ⟶ 118:
)
if mw.title.getCurrentTitle().namespace == 100 then -- is in the portal namespace
msg = msg .. '[[
end
return msg
Baris 172 ⟶ 175:
ret[#ret + 1] = getRandomSubpageContent(frame, pages)
ret[#ret + 1] = getFooter(frame, pages, string.format(
'[[/
expandArg(args, 'subpage'),
pages.subpage,
args.footer or '
))
|