diff --git a/Dockerfile b/Dockerfile index cbe90d6..8761662 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \ gnupg \ ca-certificates \ fonts-liberation \ + fonts-noto-color-emoji \ libasound2 \ libatk-bridge2.0-0 \ libatk1.0-0 \ diff --git a/api.js b/api.js index 0d0c2c1..a1d2549 100644 --- a/api.js +++ b/api.js @@ -18,6 +18,11 @@ app.use(express.urlencoded({ limit: '1gb', extended: true })); // Request logging middleware app.use((req, res, next) => { + // skip logging health checks + if (req.url === '/health') { + return next(); + } + const timestamp = new Date().toISOString(); console.log(`\n[${timestamp}] ${req.method} ${req.url}`); @@ -134,6 +139,23 @@ function cleanupOldCache() { } } +function formatCount(num) { + if (num === null || num === undefined) return '0'; + + num = parseInt(num); + + if (num >= 1000000000) { + return (num / 1000000000).toFixed(1).replace(/\.0$/, '') + 'B'; + } + if (num >= 1000000) { + return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'M'; + } + if (num >= 1000) { + return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'K'; + } + return num.toString(); +} + function formatTimestamp(epoch) { const date = new Date(epoch * 1000); @@ -160,6 +182,28 @@ async function generateQuoteBuffer(config) { ? `
` : ''; + // Only show engagement bar if all fields provided + const engagementHtml = config.engagement ? ` +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ ` : ''; + const html = ` @@ -231,6 +275,28 @@ async function generateQuoteBuffer(config) { font-size: 15px; color: rgb(113, 118, 123); } + .engagement-bar { + display: flex; + gap: 24px; + padding: 12px 0; + margin-top: 12px; + border-top: 1px solid rgb(47, 51, 54); + } + .engagement-item { + display: flex; + gap: 4px; + } + .engagement-count { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; + font-size: 14px; + font-weight: 700; + color: rgb(231, 233, 234); + } + .engagement-label { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; + font-size: 14px; + color: rgb(113, 118, 123); + } @@ -246,6 +312,7 @@ async function generateQuoteBuffer(config) {
${config.text}
${imageHtml}
${config.timestamp}
+ ${engagementHtml}