Content deleted Content added
style before attacking the infobox use |
tstyles |
||
(One intermediate revision by the same user not shown) | |||
Line 18:
local function getDateStuff(argsDate)
--[[
Note: This function takes advantage of the formatDate's second argument to
Line 25 ⟶ 24:
--]]
local lang = mw.language.getContentLanguage()
dateStuff.argsDate = argsDate▼
local year = lang:formatDate('Y', argsDate)▼
local firstOfMonth = lang:formatDate('01-m-Y', argsDate)
▲ local daysInMonth = lang:formatDate('j', firstOfMonth .. ' +1 month -1 day')
firstWeekday = tonumber(lang:formatDate('w', firstOfMonth)) + 1
}
▲ local firstWeekday = lang:formatDate('w', firstOfMonth) -- Sunday = 0, Saturday = 6
▲ firstWeekday = firstWeekday + 1 -- Make compatible with Lua tables. Sunday = 1, Saturday = 7.
▲ return dateStuff
end
Line 75 ⟶ 56:
if dateStuff.argsDate or isLinkworthy(day, currentDay) then
table.insert(calStrings, string.format(
"
currentYear,
currentMonth,
Line 92 ⟶ 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 131 ⟶ 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 157 ⟶ 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 167 ⟶ 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 187 ⟶ 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 194 ⟶ 146:
end
local dateStuff = getDateStuff(argsDate)
return frame:extensionTag{
local dayStrings = makeDayStrings(dateStuff)▼
name = 'templatestyles',
args = { src = 'Module:Current events calendar/styles.css' }
end
|