Module:Sandbox/BrownHairedGirl/GenericDecadeCatNav v01: Difference between revisions

Content deleted Content added
Created page with '--v01 -- config local textSize = '90%' local tableClass="infobox" local tableFallbackWidth="75%" local tableWidth="calc(100% - 300px)" local tableStyle="m...'
 
max-width
 
(12 intermediate revisions by the same user not shown)
Line 5:
local textSize = '90%'
local tableClass="infobox"
local tableFallbackWidthtableFallbackMaxWidth="75%auto"
local tableWidthtableMaxWidth="calc(100% - 300px)"
local tableStyle="margin-left:auto; margin-right:auto; clear:left; float:left;"
local evenRowStyleRowStyle = "background-color:#f3f3f3;"
local oddRowStyle = ""
local labelStyle = "text-align:right; font-weight: bold;"
local listStyle = "text-align:left; font-weight: normal;"
Line 31 ⟶ 30:
function makeTableRow()
debugLog(2, "makeTableRow")
thisRow = '<tr style="' .. RowStyle .. '">'
if (rowLabel == nil) then
 
thisRow = thisRow .. '<td style="' .. listStyle .. ';"><div class="hlist">\n'
for i = -5, 5 do
thisRow = thisRow .. "* silly"
thisRow = thisRow .. "* " .. makeCatLink(thisPageDecade + (i * 10)) .. "\n"
end
thisRow = thisRow .. '</div></td>\n</tr>\n'
return thisRow
Line 41 ⟶ 42:
 
function makeTable()
if true then
return ""
end
debugLog(1, "makeTable")
tableRowNum = 0
local myTable = '<table class="' .. tableClass .. '"'
myTable = myTable .. ' style="' .. tableStyle .. '; font-size:' .. textSize .. '; max-width:' .. tableFallbackWidthtableFallbackMaxWidth .. '; max-width:' .. tableWidthtableMaxWidth ..'">\n'
myTable = myTable .. makeTableRow("")
myTable = myTable .. "</table>\n"
Line 54 ⟶ 52:
 
 
-- Make a piped link to a decade category, if it exists
 
-- Make a piped link to a category, if it exists
-- If it doesn't exist, just display the greyed the link title without linking
function makeCatLink(catname, dispx)
local decadeFulltext = tostring(math.abs(x)) .. 's'
local displaytext
if (dispx ~=< "") and (disp ~= nil)0 then
decadeFulltext = decadeFulltext .. " BC"
-- use 'disp' parameter, but strip any trailing disambiguator
displaytext = mw.ustring.gsub(disp, "%s+%(.+$", "")
else
displaytext = catname
end
local catname = title_prefix .. decadeFulltext .. title_suffix
 
local fmtlink
local catPage = mw.title.new( catname, "Category" )
if (catPage.exists) then
fmtlink = "[[:Category:" .. catname .. "|" .. displaytextdecadeFulltext .. "]]"
else
fmtlink = '<span style="color:' .. greyLinkColor .. '">' .. displaytextdecadeFulltext .. "</span>"
end
 
Line 94 ⟶ 90:
function parsePagename(pn)
debugLog(1, "parsePagename: [" .. pn .. "]")
match_prefix, match_decade, match_suffix = mw.ustring.match(pn, "^(.*-)(%d+0s BC)(.*)$")
if match_decade == nil then
match_prefix, match_decade, match_suffix = mw.ustring.match(pn, "^(.*-)(%d+0s)(.*)$")
end
if match_decade == nil then
Line 102 ⟶ 98:
return false
end
debugLog(2, 'Split [' .. pn .. ']: /' .. match_prefix .. '/' .. match_decade ..'/' .. match_suffix ..'/')
if (match_prefix ~= nil) and (match_prefix ~= "") then
if (mw.ustring.sub(match_prefix, -1 ) ~= ' ') then
debugLog(2, 'Invalid. [' .. pn .. '] has no space before decade"')
return false
end
end
 
end
if (match_suffix ~= nil) and (match_suffix ~= "") then
if (mw.ustring.sub(match_suffix, 1, 1) ~= ' ') then
debugLog(2, 'Invalid. [' .. pn .. '] has no space after decade"')
return false
end
Line 128 ⟶ 124:
match_decade = mw.ustring.gsub(match_decade, "0s$", "0")
thisPageDecade = tonumber(match_decade)
if trueisBC then
thisPageDecade = -thisPageDecade
end
title_prefix = match_prefix