Add install count to homepage

This commit is contained in:
2025-10-31 23:18:18 -05:00
parent 1a73732f7c
commit f5c9d8c0c4
5 changed files with 56 additions and 2 deletions

View File

@@ -4,11 +4,18 @@ import express from 'express';
import bodyParser from 'body-parser'; import bodyParser from 'body-parser';
import type { Express } from 'express'; import type { Express } from 'express';
import { createEvent } from 'ics'; import { createEvent } from 'ics';
import path from 'path';
import { promises as fsp } from 'fs';
interface WebConfig { interface WebConfig {
port?: number; port?: number;
} }
interface Install {
os: 'manjaro' | 'mint' | 'chrome' | 'other',
form: 'laptop' | 'desktop' | 'aio'
}
const DATE = process.env['DATE'] || 'November 1st'; const DATE = process.env['DATE'] || 'November 1st';
const TIME = process.env['TIME'] || '2:30PM-5:30PM'; const TIME = process.env['TIME'] || '2:30PM-5:30PM';
@@ -23,6 +30,7 @@ class Web {
private _webserver: http.Server | null = null; private _webserver: http.Server | null = null;
private app: Express | null = null; private app: Express | null = null;
private port: number; private port: number;
private installs: Install[] = [];
// private options: WebConfig; // private options: WebConfig;
constructor(options: WebConfig = {}) { constructor(options: WebConfig = {}) {
@@ -33,6 +41,14 @@ class Web {
initialize = async () => { initialize = async () => {
// const options = this.options; // const options = this.options;
const app: Express = this.app = express(); const app: Express = this.app = express();
try {
this.installs = JSON.parse(await fsp.readFile(process.env['config'] || process.env['CONFIG'] || path.join(process.cwd(), 'config', 'installs.json'), 'utf-8'));
}
catch(ex) {
console.error(ex);
this.installs = [];
}
app.set('trust proxy', 1); app.set('trust proxy', 1);
app.set('view engine', 'ejs'); app.set('view engine', 'ejs');
@@ -70,6 +86,7 @@ class Web {
description: `Windows 10 support is ending, but you may not need a brand-new PC! Sector67 in Madison, Wisconsin is hosting a Linux install party to help the community keep their current computers usable and up-to-date. Join us on ${DATE}` description: `Windows 10 support is ending, but you may not need a brand-new PC! Sector67 in Madison, Wisconsin is hosting a Linux install party to help the community keep their current computers usable and up-to-date. Join us on ${DATE}`
}, },
date: DATE, date: DATE,
installs: this.installs,
time: TIME time: TIME
}); });
}); });

View File

@@ -73,6 +73,34 @@ img {
max-width: 100%; max-width: 100%;
} }
#installs {
h1 {
animation-iteration-count: infinite;
animation-name: zoomie;
animation-duration: 1.5s;
animation-timing-function: ease-out;
}
span {
padding: .05em .25em;
border-radius: .15em;
}
}
@keyframes zoomie {
0% {
transform: perspective(800px) translate3d(0, 0, 0px);
}
50% {
transform: perspective(800px) translate3d(0, 0, 40px);
}
100% {
transform: perspective(800px) translate3d(0, 0, 0px);
}
}
@media screen and (max-width:540px) { @media screen and (max-width:540px) {
.content { .content {
width: 95%; width: 95%;

View File

@@ -45,3 +45,7 @@ a.btn {
} }
} }
} }
#installs span {
background: #1A237E;
}

View File

@@ -14,7 +14,7 @@
<link rel="canonical" href="<%= page.canonical%>"/> <link rel="canonical" href="<%= page.canonical%>"/>
<% } %> <% } %>
<link rel="shortcut icon" href="/assets/svg/favicon.svg"> <link rel="shortcut icon" href="/assets/svg/favicon.svg">
<link rel="stylesheet" href="/assets/css/styles.css?v5"> <link rel="stylesheet" href="/assets/css/styles.css?v6">
<script nonce="<%= cspNonce %>"> <script nonce="<%= cspNonce %>">
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
document.body.classList.remove('preload'); document.body.classList.remove('preload');

View File

@@ -8,6 +8,11 @@
<body class="preload"> <body class="preload">
<%- include("navigation", locals) %> <%- include("navigation", locals) %>
<div class="content"> <div class="content">
<% if (installs && installs.length) { %>
<div id="installs">
<h1>We have saved <span><%= installs.length %></span> computer<% if (installs.length > 1) { %>s<% } %>!</h1>
</div>
<% } %>
<p><a href="https://www.sector67.org/">Sector67</a> presents...</p> <p><a href="https://www.sector67.org/">Sector67</a> presents...</p>
<h1>Linux Install Party Madison</h1> <h1>Linux Install Party Madison</h1>
<h2>Are you ready to reduce e-waste and save some money?</h2> <h2>Are you ready to reduce e-waste and save some money?</h2>