Content deleted Content added
testing previous/next section (part 3) |
Added support for previous/next in database |
||
(7 intermediate revisions by the same user not shown) | |||
Line 20:
end
local function ifnotempty(s, a, b)
else▼
end▼
end
Line 34 ⟶ 30:
end
local function parsedate(y, m, d)
local success, result = pcall(lang.formatDate, lang, 'F j, Y', date_str)
end
local function parsecoord(frame, s)
return frame:expandTemplate{
title = 'coord',
▲ if( lat and NS and lon and EW ) then
}
▲ return frame:expandTemplate{ title = 'coord', args = {lat, NS, lon, EW, 'type:landmark'} }
end▼
end
Line 90 ⟶ 86:
local function createLink(label, suffix)
local prefix = "Solar eclipse of "
if ifexist(link) then▼
-- check if label starts with the prefix
return string.format('[[%s|%s]]', link, label)▼
if mw.ustring.find(label, "^" .. prefix) then
-- extract the date part from the label
return label▼
local dateLabel = mw.ustring.sub(label, #prefix + 1)
local page = label -- this is the full page title to link to
else
-- if page doesn't exist, display the date
return dateLabel
end
-- if the label is a a link, keep it
if mw.ustring.match(label, "^%[%[.*%]%]$") then
else
-- for labels without the prefix, display as plain text
return label
end
end
Line 141 ⟶ 154:
setarg('end_total', dargs['TiTE'])
setarg('end_partial', dargs['TiPE'])
setarg('previous', '')
setarg('next', '')
end
end
Line 146 ⟶ 161:
local function infobox(frame)
local
"Solar eclipse of " .. (args['date'] or ''),
"For instructions on use, see [[Template:Infobox Solar eclipse]]")
Line 167 ⟶ 182:
belowstr = string.format('<div style="width:100%%"><div class="noprint" style="text-align:right">%s →</div></div>', nextLink)
end
local eclipse_types = {
total = { label = "Total eclipse", color = "#690005" },
partial = { label = "Partial eclipse", color = "#c56b55" },
annular = { label = "Annular eclipse", color = "#5555c5" },
hybrid = { label = "Hybrid eclipse", color = "#55c555" }
}
local nature = args['nature'] and args['nature']:lower() or ''
local eclipse_config = eclipse_types[nature] or { label = "Eclipse", color = "#727272" }
local type_header = string.format(
'<span style="background-color: %s; color: white; display: block;">%s</span>',
eclipse_config.color,
eclipse_config.label
)
Line 172 ⟶ 202:
["bodyclass"] = "vevent",
["bodystyle"] = "width:25em; text-align:left; font-size:88%;",
["
["
["below"] = belowstr,
["belowstyle"] = "text-align:center; padding-top:0.5em",
Line 184 ⟶ 213:
["data1"] = mapstr,
------------- Type of eclipse and saros -------------
["label4"] = "[[Gamma (eclipse)|Gamma]]",
["data4"] = args['gamma'] or '',
Line 240 ⟶ 266:
end
return infobox(frame)
end
|