add theming
This commit is contained in:
parent
885e7d6e02
commit
8639799f6d
10 changed files with 1069 additions and 287 deletions
|
|
@ -1,252 +1,9 @@
|
|||
package report
|
||||
|
||||
// cyberpunkCSS is the shared stylesheet used by both the daily report and
|
||||
// the index page. It does not include map-specific rules or page-specific
|
||||
// overrides (those live in reportExtraCSS / each template's own <style>).
|
||||
const cyberpunkCSS = `
|
||||
:root {
|
||||
--bg: #050510;
|
||||
--bg2: #0a0a20;
|
||||
--green: #00ff9f;
|
||||
--cyan: #00e5ff;
|
||||
--magenta: #ff00c8;
|
||||
--text: #c0c0e0;
|
||||
--border: #1a1a3a;
|
||||
}
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 14px;
|
||||
min-height: 100vh;
|
||||
position: relative;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
body::after {
|
||||
content: '';
|
||||
position: fixed;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background: repeating-linear-gradient(
|
||||
0deg,
|
||||
transparent,
|
||||
transparent 2px,
|
||||
rgba(0,0,0,0.08) 2px,
|
||||
rgba(0,0,0,0.08) 4px
|
||||
);
|
||||
pointer-events: none;
|
||||
z-index: 9999;
|
||||
}
|
||||
header {
|
||||
background: var(--bg2);
|
||||
border-bottom: 2px solid var(--magenta);
|
||||
padding: 24px 32px;
|
||||
text-align: center;
|
||||
}
|
||||
header h1 {
|
||||
font-size: 2.4rem;
|
||||
color: var(--cyan);
|
||||
text-shadow: 0 0 20px var(--cyan), 0 0 40px rgba(0,229,255,0.5);
|
||||
letter-spacing: 6px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
header .subtitle {
|
||||
color: var(--green);
|
||||
text-shadow: 0 0 10px var(--green);
|
||||
margin-top: 6px;
|
||||
font-size: 0.85rem;
|
||||
letter-spacing: 3px;
|
||||
}
|
||||
.nav-back {
|
||||
padding: 10px 32px;
|
||||
background: var(--bg2);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.nav-back a {
|
||||
color: var(--magenta);
|
||||
text-decoration: none;
|
||||
font-size: 0.85rem;
|
||||
letter-spacing: 2px;
|
||||
text-shadow: 0 0 8px var(--magenta);
|
||||
}
|
||||
.nav-back a:hover { text-shadow: 0 0 16px var(--magenta); }
|
||||
.container { max-width: 1400px; margin: 0 auto; padding: 24px 16px; }
|
||||
h2 {
|
||||
color: var(--cyan);
|
||||
text-shadow: 0 0 12px var(--cyan);
|
||||
font-size: 1.2rem;
|
||||
letter-spacing: 3px;
|
||||
text-transform: uppercase;
|
||||
margin-bottom: 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
.section { margin-bottom: 40px; }
|
||||
.cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 16px;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
.card {
|
||||
background: var(--bg2);
|
||||
border: 1px solid var(--magenta);
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 0 16px rgba(255,0,200,0.15), inset 0 0 20px rgba(0,0,0,0.3);
|
||||
text-align: center;
|
||||
}
|
||||
.card .label {
|
||||
color: var(--green);
|
||||
text-shadow: 0 0 8px var(--green);
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.card .value {
|
||||
color: var(--cyan);
|
||||
text-shadow: 0 0 16px var(--cyan);
|
||||
font-size: 1.8rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
.charts-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
.chart-card {
|
||||
background: var(--bg2);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 0 12px rgba(0,229,255,0.08);
|
||||
}
|
||||
.chart-card h3 {
|
||||
color: var(--green);
|
||||
text-shadow: 0 0 8px var(--green);
|
||||
font-size: 0.8rem;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
canvas { max-width: 100%; }
|
||||
.table-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.search-bar { display: flex; align-items: center; gap: 10px; }
|
||||
.search-bar input {
|
||||
background: var(--bg2);
|
||||
border: 1px solid var(--green);
|
||||
color: var(--green);
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 13px;
|
||||
padding: 6px 12px;
|
||||
width: 280px;
|
||||
outline: none;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 0 8px rgba(0,255,159,0.15);
|
||||
}
|
||||
.search-bar input::placeholder { color: rgba(0,255,159,0.4); }
|
||||
.search-bar label {
|
||||
color: var(--green);
|
||||
font-size: 0.8rem;
|
||||
letter-spacing: 1px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.page-info { color: rgba(0,255,159,0.6); font-size: 0.8rem; letter-spacing: 1px; min-width: 140px; }
|
||||
.page-size-select { display: flex; align-items: center; gap: 6px; }
|
||||
.page-size-select label { color: var(--green); font-size: 0.8rem; letter-spacing: 1px; text-transform: uppercase; }
|
||||
.page-size-select select {
|
||||
background: var(--bg2);
|
||||
border: 1px solid var(--green);
|
||||
color: var(--green);
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 13px;
|
||||
padding: 4px 8px;
|
||||
outline: none;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.page-btns { display: flex; gap: 8px; margin-left: auto; }
|
||||
.page-btns button {
|
||||
background: transparent;
|
||||
border: 1px solid var(--cyan);
|
||||
color: var(--cyan);
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 12px;
|
||||
padding: 5px 14px;
|
||||
cursor: pointer;
|
||||
border-radius: 2px;
|
||||
letter-spacing: 1px;
|
||||
transition: background 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
.page-btns button:hover:not(:disabled) { background: rgba(0,229,255,0.1); box-shadow: 0 0 8px rgba(0,229,255,0.3); }
|
||||
.page-btns button:disabled { opacity: 0.3; cursor: default; }
|
||||
.table-wrap { overflow-x: auto; }
|
||||
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
thead th {
|
||||
background: rgba(0,229,255,0.05);
|
||||
color: var(--cyan);
|
||||
text-shadow: 0 0 6px var(--cyan);
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid var(--cyan);
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
|
||||
tbody tr:hover { background: rgba(0,255,159,0.04); }
|
||||
tbody td { padding: 8px 14px; color: var(--text); vertical-align: top; word-break: break-all; }
|
||||
tbody td:first-child { color: var(--green); font-weight: bold; white-space: nowrap; }
|
||||
.status { display: inline-block; padding: 1px 6px; border-radius: 3px; font-weight: bold; font-size: 12px; }
|
||||
.s2xx { color: #00ff9f; border: 1px solid #00ff9f; text-shadow: 0 0 6px #00ff9f; }
|
||||
.s3xx { color: #00e5ff; border: 1px solid #00e5ff; }
|
||||
.s4xx { color: #ffcc00; border: 1px solid #ffcc00; }
|
||||
.s5xx { color: #ff4444; border: 1px solid #ff4444; text-shadow: 0 0 8px #ff4444; }
|
||||
.level { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
|
||||
.l-error, .l-crit, .l-alert, .l-emerg { color: #ff4444; border: 1px solid #ff4444; }
|
||||
.l-warn { color: #ffcc00; border: 1px solid #ffcc00; }
|
||||
.l-info, .l-notice { color: #00e5ff; border: 1px solid #00e5ff; }
|
||||
.l-debug { color: #888; border: 1px solid #444; }
|
||||
.rank { color: var(--magenta); text-shadow: 0 0 6px var(--magenta); }
|
||||
footer {
|
||||
text-align: center;
|
||||
padding: 24px;
|
||||
color: rgba(192,192,224,0.4);
|
||||
font-size: 0.75rem;
|
||||
border-top: 1px solid var(--border);
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
`
|
||||
|
||||
// reportExtraCSS holds CSS only used in daily/single reports (map, map labels).
|
||||
const reportExtraCSS = `
|
||||
#map { height: 480px; border: 1px solid var(--magenta); border-radius: 4px; background: #0a0a20; }
|
||||
.map-label {
|
||||
background: rgba(5,5,16,0.85) !important;
|
||||
border: 1px solid var(--magenta) !important;
|
||||
border-radius: 3px !important;
|
||||
color: #fff !important;
|
||||
font-family: 'Courier New', monospace !important;
|
||||
font-size: 11px !important;
|
||||
padding: 2px 5px !important;
|
||||
white-space: nowrap !important;
|
||||
box-shadow: 0 0 6px rgba(255,0,200,0.4) !important;
|
||||
pointer-events: none !important;
|
||||
}
|
||||
.map-label::before { display: none !important; }
|
||||
`
|
||||
|
||||
// reportTemplate is the cyberpunk-themed HTML template for a single report
|
||||
// (either the only report, or one day's report in --split-by-day mode).
|
||||
// reportTemplate is the HTML template for a single report (either the only
|
||||
// report, or one day's report in --split-by-day mode). Its stylesheet and
|
||||
// chart/map colors are supplied at render time via the active theme
|
||||
// (see themes.go and GenerateHTML).
|
||||
const reportTemplate = `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
|
@ -258,7 +15,7 @@ const reportTemplate = `<!DOCTYPE html>
|
|||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
{{end}}
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
||||
<style>` + cyberpunkCSS + reportExtraCSS + `</style>
|
||||
<style>{{.ThemeCSS}}{{.ThemeExtraCSS}}</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
@ -436,13 +193,15 @@ const reportTemplate = `<!DOCTYPE html>
|
|||
|
||||
<script>
|
||||
// ── Chart.js defaults ──────────────────────────────────────────────────────
|
||||
Chart.defaults.color = '#c0c0e0';
|
||||
Chart.defaults.borderColor = '#1a1a3a';
|
||||
Chart.defaults.font.family = "'Courier New', monospace";
|
||||
Chart.defaults.color = '{{.ChartText}}';
|
||||
Chart.defaults.borderColor = '{{.ChartGrid}}';
|
||||
Chart.defaults.font.family = "{{.ChartFont}}";
|
||||
|
||||
const neonGreen = '#00ff9f';
|
||||
const neonCyan = '#00e5ff';
|
||||
const neonMag = '#ff00c8';
|
||||
const chartC1 = '{{.Chart1}}';
|
||||
const chartC2 = '{{.Chart2}}';
|
||||
const chartC3 = '{{.Chart3}}';
|
||||
const chartWarn = '{{.ChartWarn}}';
|
||||
const chartErr = '{{.ChartErr}}';
|
||||
|
||||
// ── Status Codes Chart ─────────────────────────────────────────────────────
|
||||
(function(){
|
||||
|
|
@ -452,10 +211,10 @@ const neonMag = '#ff00c8';
|
|||
const values = labels.map(k => rawStatuses[k]);
|
||||
const colors = labels.map(k => {
|
||||
const n = parseInt(k);
|
||||
if (n < 300) return neonGreen;
|
||||
if (n < 400) return neonCyan;
|
||||
if (n < 500) return '#ffcc00';
|
||||
return '#ff4444';
|
||||
if (n < 300) return chartC1;
|
||||
if (n < 400) return chartC2;
|
||||
if (n < 500) return chartWarn;
|
||||
return chartErr;
|
||||
});
|
||||
new Chart(document.getElementById('chartStatus'), {
|
||||
type: 'bar',
|
||||
|
|
@ -472,7 +231,7 @@ const neonMag = '#ff00c8';
|
|||
const values = paths.map(p => p.count);
|
||||
new Chart(document.getElementById('chartPaths'), {
|
||||
type: 'bar',
|
||||
data: { labels, datasets: [{ data: values, backgroundColor: neonMag, borderWidth: 0 }] },
|
||||
data: { labels, datasets: [{ data: values, backgroundColor: chartC3, borderWidth: 0 }] },
|
||||
options: {
|
||||
indexAxis: 'y',
|
||||
plugins: { legend: { display: false } },
|
||||
|
|
@ -491,8 +250,8 @@ const neonMag = '#ff00c8';
|
|||
type: 'line',
|
||||
data: { labels, datasets: [{
|
||||
data: values,
|
||||
borderColor: neonCyan,
|
||||
backgroundColor: 'rgba(0,229,255,0.08)',
|
||||
borderColor: chartC2,
|
||||
backgroundColor: '{{.Chart2Fill}}',
|
||||
tension: 0.3,
|
||||
fill: true,
|
||||
pointRadius: 3
|
||||
|
|
@ -620,8 +379,8 @@ function errorSetPageSize(n) { errorPager.setPageSize(n); }
|
|||
}
|
||||
|
||||
const map = L.map('map').setView([20, 0], 2);
|
||||
L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', {
|
||||
attribution: '© <a href="https://carto.com/">CARTO</a>',
|
||||
L.tileLayer('{{.MapTileURL}}', {
|
||||
attribution: '{{.MapAttribution}}',
|
||||
maxZoom: 18
|
||||
}).addTo(map);
|
||||
|
||||
|
|
@ -632,8 +391,8 @@ function errorSetPageSize(n) { errorPager.setPageSize(n); }
|
|||
|
||||
const marker = L.circleMarker([pt.lat, pt.lon], {
|
||||
radius: Math.min(4 + Math.log(pt.count + 1) * 3, 20),
|
||||
fillColor: '#ff00c8',
|
||||
color: '#ff00c8',
|
||||
fillColor: '{{.MarkerColor}}',
|
||||
color: '{{.MarkerColor}}',
|
||||
weight: 1,
|
||||
opacity: 0.9,
|
||||
fillOpacity: 0.5
|
||||
|
|
@ -661,22 +420,18 @@ function errorSetPageSize(n) { errorPager.setPageSize(n); }
|
|||
</html>
|
||||
`
|
||||
|
||||
// indexTemplate is the cyberpunk-themed HTML template for the index page
|
||||
// generated by --split-by-day. It lists all daily reports with aggregate stats.
|
||||
// indexTemplate is the HTML template for the index page generated by
|
||||
// --split-by-day. It lists all daily reports with aggregate stats. Its
|
||||
// stylesheet is supplied at render time via the active theme (see
|
||||
// themes.go and GenerateIndexHTML); .day-link and .err-* rules live in
|
||||
// each theme's shared CSS block.
|
||||
const indexTemplate = `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>nxstats — Daily Index</title>
|
||||
<style>` + cyberpunkCSS + `
|
||||
/* Index-specific */
|
||||
.day-link { color: var(--cyan); text-decoration: none; }
|
||||
.day-link:hover { text-shadow: 0 0 10px var(--cyan); }
|
||||
.err-low { color: var(--green); text-shadow: 0 0 6px var(--green); }
|
||||
.err-med { color: #ffcc00; }
|
||||
.err-high { color: #ff4444; text-shadow: 0 0 8px #ff4444; }
|
||||
</style>
|
||||
<style>{{.ThemeCSS}}</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue