Content deleted Content added
reduce getDateStuff to a single non-temporary struct |
tstyles |
||
Line 56:
if dateStuff.argsDate or isLinkworthy(day, currentDay) then
table.insert(calStrings, string.format(
"
currentYear,
currentMonth,
Line 73:
local monthAndYear = dateStuff.monthAndYear
local root = mw.html.create('table')
-- The next two lines help to make the table-layout-based Archive pages look▼
-- good. When the Archives have been converted to a grid-based layout, this▼
-- logic can be removed, and the corressponding CSS margin attribute can be▼
root
:addClass('
▲
:addClass(dateStuff.argsDate and 'current-events-calendar-archive')
-- Headings
:tag('
:
:
▲ :wikitext(makeWikilink(
▲ 'Portal:Current events/' .. dateStuff.previousMonthAndYear,
'◀'▼
▲ ))
:done()▼
:done()
:tag('
:wikitext(makeWikilink(
'Portal:Current events/' .. monthAndYear,
Line 112 ⟶ 94:
))
:done()
:tag('
▲ :addClass('noprint')
▲ :wikitext(makeWikilink(
▲ 'Portal:Current events/' .. dateStuff.nextMonthAndYear,
-- Day of week headings
local dayHeadingRow = root:tag('tr')
local weekdays = {'S', 'M', 'T', 'W', 'T', 'F', 'S'}
for
dayHeadingRow:tag('th'):wikitext(weekday)
end
Line 138 ⟶ 116:
cellCount = cellCount + 1
-- Use a blank cell if there is no corresponding dateString
local dayString = dayStrings[cellCount] or
weeklyRow:tag('td'):wikitext(dayString)
end
end
Line 148 ⟶ 124:
if not dateStuff.argsDate then -- No footer necessary on Archive pages.
root:tag('tr')
:addClass('current-events-calendar-footer')
:addClass('noprint')
:tag('td')
:attr('colspan', '7')
:wikitext(makeWikilink(
'Portal:Current events/' .. monthAndYear,
Line 168 ⟶ 139:
function p.main(frame)
local argsDate = nil
if
-- If a date is passed in, assume that the display page is an Archive page.
-- If no date passed in, assume that the display page is the current Current Events page
Line 175 ⟶ 146:
end
local dateStuff = getDateStuff(argsDate)
return frame:extensionTag{
local dayStrings = makeDayStrings(dateStuff)▼
name = 'templatestyles',
args = { src = 'Module:Current events calendar/styles.css' }
end
|