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

Content deleted Content added
.
max-width
 
(8 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 .. '">'
 
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 40 ⟶ 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 53 ⟶ 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 93 ⟶ 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 101 ⟶ 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
Line 210 ⟶ 208:
debugLog(nil, "Yes, this is a category")
 
parsePagename(thispagename)
--[[]
if not parsePagename(thispagename) then
-- some error parsing the title, so don't proceed to output
return publishDebugLog()
end
]]--
debugLog(1, "all parse done")