feat: initial Greasy Sprocket website — Astro static + Go feedback service

- Astro 5.x static site with content collections for extensions
- Pages: index, [slug] (per-extension), coffee (Ko-fi), feedback form
- Go binary gs-feedback: SQLite storage + Discord webhook notification
- Nginx config: static serving + POST proxy to Go backend
- Deploy script: build + rsync to VPS
- ThockBoard landing page with features and sound pack listing
This commit is contained in:
Jose Juan Moñino
2026-07-09 23:53:01 +02:00
commit c5958f283f
23 changed files with 4601 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
# Dependencies
node_modules/
astro/.astro/
astro/dist/
# Go build artifacts
feedback-svc/bin/
# Environment
.env
*.env
# OS
.DS_Store
Thumbs.db
# Editor
.vscode/
.idea/
+2
View File
@@ -0,0 +1,2 @@
only-built-dependencies[]=esbuild
only-built-dependencies[]=sharp
+10
View File
@@ -0,0 +1,10 @@
import { defineConfig } from 'astro/config';
export default defineConfig({
site: 'https://greasysprocket.com',
output: 'static',
server: {
host: '127.0.0.1',
port: 4321,
},
});
+14
View File
@@ -0,0 +1,14 @@
{
"name": "greasy-sprocket-website",
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"check": "astro check"
},
"dependencies": {
"astro": "^5.7.0"
}
}
+3440
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
allowBuilds:
esbuild: set this to true or false
sharp: set this to true or false
onlyBuiltDependencies:
- esbuild
- sharp
+9
View File
@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128">
<rect width="128" height="128" rx="28" fill="#0c0a09"/>
<circle cx="64" cy="64" r="36" fill="none" stroke="#f97316" stroke-width="6"/>
<circle cx="64" cy="64" r="8" fill="#f97316"/>
<line x1="64" y1="28" x2="64" y2="40" stroke="#f97316" stroke-width="4" stroke-linecap="round"/>
<line x1="64" y1="88" x2="64" y2="100" stroke="#f97316" stroke-width="4" stroke-linecap="round"/>
<line x1="28" y1="64" x2="40" y2="64" stroke="#f97316" stroke-width="4" stroke-linecap="round"/>
<line x1="88" y1="64" x2="100" y2="64" stroke="#f97316" stroke-width="4" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 680 B

+15
View File
@@ -0,0 +1,15 @@
import { defineCollection, z } from 'astro:content';
const extensions = defineCollection({
type: 'content',
schema: z.object({
name: z.string(),
tagline: z.string(),
features: z.array(z.string()).optional(),
screenshot: z.string().optional(),
chromeStoreUrl: z.string().url().optional().or(z.literal('')),
downloadUrl: z.string().optional(),
}),
});
export const collections = { extensions };
@@ -0,0 +1,39 @@
---
name: ThockBoard
tagline: Mechanical keyboard sounds for every keystroke. 16 sound packs, zero setup.
features:
- "16 sound packs (Cherry MX, buckling spring, zen, water drops, and more)"
- "Adjustable volume per pack"
- "Dark/light theme with palette switcher"
- "Works on any website — no configuration needed"
- "100% free, no premium tiers"
screenshot: "/images/thockboard-preview.png"
chromeStoreUrl: ""
downloadUrl: "https://git.d0a1.es/d0a1/thockboard/releases"
---
ThockBoard adds satisfying mechanical keyboard sounds to every keystroke, on any website.
Choose from 16 carefully crafted sound packs — from the classic Cherry MX Blue click
to soothing zen water drops and bamboo chimes. Each pack is synthesized with DSP
for realistic, non-repetitive audio.
## Sound packs
| Category | Packs |
|----------|-------|
| Mechanical | Cherry MX Blue, Cherry MX Red, Buckling Spring, Topre |
| Thocky | Thocky Default, Deep Thock, Hall Effect |
| Zen | Water Drop, Bamboo, Singing Bowl, Crystal |
| Fun | Bubble, Soft Tap, Pop, Mechanical Click, Rain |
## Privacy
ThockBoard doesn't collect any data. No analytics, no tracking, no telemetry.
Sound files are bundled with the extension — nothing is downloaded from external servers.
## Free forever
ThockBoard is 100% free. All 16 sound packs are available to everyone. There are no
premium tiers, no locked features, no usage limits. If you enjoy it, you can
[buy me a coffee](/coffee) — but there's zero pressure.
+45
View File
@@ -0,0 +1,45 @@
---
interface Props {
title: string;
description?: string;
}
const { title, description = 'Free Chrome extensions — no limits, no catch.' } = Astro.props;
---
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content={description} />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<title>{title}</title>
</head>
<body>
<header class="site-header">
<div class="container">
<a href="/" class="logo">⚙️ <span>Greasy Sprocket</span></a>
<nav>
<a href="/">Extensions</a>
<a href="/coffee">☕ Support</a>
<a href="/feedback">Feedback</a>
</nav>
</div>
</header>
<main>
<slot />
</main>
<footer class="site-footer">
<div class="container">
<p>
Greasy Sprocket — Free Chrome extensions, always.<br />
<a href="/coffee">Support my work ☕</a> ·
<a href="/feedback">Leave feedback</a>
</p>
</div>
</footer>
</body>
</html>
+59
View File
@@ -0,0 +1,59 @@
---
import Base from '../layouts/Base.astro';
import { getCollection } from 'astro:content';
export async function getStaticPaths() {
const extensions = await getCollection('extensions');
return extensions.map((ext) => ({
params: { slug: ext.slug },
props: { ext },
}));
}
const { ext } = Astro.props;
const { Content } = await ext.render();
---
<Base title={`${ext.data.name} — Greasy Sprocket`} description={ext.data.tagline}>
<section class="ext-hero">
<div class="container">
<div class="info">
<span class="badge">100% Free</span>
<h1>{ext.data.name}</h1>
<p>{ext.data.tagline}</p>
<div style="display:flex;gap:12px">
{ext.data.chromeStoreUrl && (
<a href={ext.data.chromeStoreUrl} class="btn btn-primary" target="_blank" rel="noopener">
Add to Chrome
</a>
)}
{ext.data.downloadUrl && (
<a href={ext.data.downloadUrl} class="btn btn-outline">
Download ZIP
</a>
)}
</div>
</div>
{ext.data.screenshot && (
<div class="screenshot">
<img src={ext.data.screenshot} alt={`${ext.data.name} screenshot`} />
</div>
)}
</div>
</section>
<section class="section">
<div class="container">
<div class="feature-list">
{ext.data.features?.map((feature: string) => (
<div class="feature-item">
<h4>✅ {feature}</h4>
</div>
))}
</div>
<div style="margin-top:32px">
<Content />
</div>
</div>
</section>
</Base>
+30
View File
@@ -0,0 +1,30 @@
---
import Base from '../layouts/Base.astro';
---
<Base title="Support Greasy Sprocket ☕">
<section class="hero">
<div class="container">
<span class="badge">No pressure · Everything is free</span>
<h1>Buy me a coffee ☕</h1>
<p>
If you enjoy my extensions and want to support my work, consider buying me a coffee.
Every contribution helps me keep building free tools for everyone.
</p>
</div>
</section>
<section class="section">
<div class="container" style="text-align:center">
<div class="coffee-options">
<a href="https://ko-fi.com/monyi" class="coffee-btn" target="_blank" rel="noopener">
☕<br/>Ko-fi<span>Buy me a coffee</span>
</a>
</div>
<p style="color:var(--text-muted);max-width:480px;margin:24px auto 0">
All extensions are and will always be 100% free. This is completely voluntary —
no features are locked behind donations, and there are no premium tiers.
</p>
</div>
</section>
</Base>
+76
View File
@@ -0,0 +1,76 @@
---
import Base from '../layouts/Base.astro';
const extSlug = Astro.url.searchParams.get('ext') || '';
---
<Base title="Feedback — Greasy Sprocket">
<section class="hero">
<div class="container">
<h1>Tell us why you left</h1>
<p>Your feedback helps us improve. No email required, no account needed.</p>
</div>
</section>
<section class="section">
<div class="container">
<div id="feedback-form" class="feedback-form">
<form id="uninstall-feedback">
<input type="hidden" name="ext" value={extSlug} />
<div class="form-group">
<label for="reason">Why did you uninstall? <span style="color:var(--text-muted)">(optional)</span></label>
<select name="reason" id="reason">
<option value="">Select a reason...</option>
<option value="not-needed">Didn't need it</option>
<option value="too-many">Too many extensions</option>
<option value="bugs">Bugs or issues</option>
<option value="alternative">Prefer an alternative</option>
<option value="other">Other</option>
</select>
</div>
<div class="form-group">
<label for="text">Anything else? <span style="color:var(--text-muted)">(optional)</span></label>
<textarea name="text" id="text" placeholder="Tell us more..." maxlength="500"></textarea>
</div>
<div class="form-actions">
<a href="/" class="btn btn-outline">No thanks</a>
<button type="submit" class="btn btn-primary">Send feedback</button>
</div>
</form>
</div>
<div id="feedback-success" class="form-success" hidden>
<h2>✅ Thanks for your feedback!</h2>
<p>We appreciate you taking the time. All our extensions are free — feel free to come back anytime.</p>
<a href="/" class="btn btn-outline" style="margin-top:24px">Back to home</a>
</div>
</div>
</section>
<script is:inline>
document.getElementById('uninstall-feedback').addEventListener('submit', async (e) => {
e.preventDefault();
const form = e.target;
const data = new FormData(form);
const payload = {
ext: data.get('ext') || '',
reason: data.get('reason') || '',
text: data.get('text') || '',
};
try {
await fetch('/feedback', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
} catch (err) {
// Silent fail — feedback is best-effort
}
document.getElementById('feedback-form').hidden = true;
document.getElementById('feedback-success').hidden = false;
});
</script>
</Base>
+54
View File
@@ -0,0 +1,54 @@
---
import Base from '../layouts/Base.astro';
import { getCollection } from 'astro:content';
const extensions = await getCollection('extensions');
---
<Base title="Greasy Sprocket — Free Chrome Extensions">
<section class="hero">
<div class="container">
<span class="badge">100% Free · No limits · No catch</span>
<h1>Chrome extensions that just work</h1>
<p>
We build small, useful browser extensions. They're free, they'll always be free,
and they'll never nag you for money. If you love them, you can buy us a coffee.
</p>
<div style="display:flex;gap:12px;justify-content:center">
<a href="#extensions" class="btn btn-primary">Browse extensions</a>
<a href="/coffee" class="btn btn-outline">☕ Support us</a>
</div>
</div>
</section>
<section class="section" id="extensions">
<div class="container">
<h2>Extensions</h2>
<div class="ext-grid">
{extensions.map((ext) => (
<article class="ext-card">
<h3>{ext.data.name}</h3>
<p>{ext.data.tagline}</p>
<div class="links">
<a href={`/${ext.slug}`}>Learn more →</a>
{ext.data.chromeStoreUrl && (
<a href={ext.data.chromeStoreUrl} target="_blank" rel="noopener">Chrome Store</a>
)}
</div>
</article>
))}
</div>
</div>
</section>
<section class="section">
<div class="container" style="text-align:center">
<h2>Why free?</h2>
<p style="color:var(--text-muted);max-width:520px;margin:0 auto">
We believe useful tools shouldn't be locked behind paywalls. Every extension is
fully featured, no premium tiers, no trial periods. If you want to support development,
you can <a href="/coffee">buy us a coffee</a> — but there's zero pressure.
</p>
</div>
</section>
</Base>
+360
View File
@@ -0,0 +1,360 @@
:root {
--bg: #0c0a09;
--bg-elevated: #1c1917;
--bg-card: #1e1b18;
--border: #2e2a27;
--text: #fafaf9;
--text-muted: #a8a29e;
--accent: #f97316;
--accent-hover: #fb923c;
--radius: 8px;
--max-width: 960px;
}
[data-theme="light"] {
--bg: #fafaf9;
--bg-elevated: #ffffff;
--bg-card: #ffffff;
--border: #e7e5e4;
--text: #1c1917;
--text-muted: #78716c;
--accent: #c2410c;
--accent-hover: #9a3412;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
font-family: system-ui, -apple-system, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.6;
min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.container {
max-width: var(--max-width);
margin: 0 auto;
padding: 0 24px;
}
/* Header */
.site-header {
border-bottom: 1px solid var(--border);
padding: 16px 0;
position: sticky;
top: 0;
background: var(--bg);
z-index: 100;
}
.site-header .container {
display: flex;
align-items: center;
justify-content: space-between;
}
.logo {
font-weight: 700;
font-size: 18px;
color: var(--text);
display: flex;
align-items: center;
gap: 8px;
}
.logo span { color: var(--accent); }
nav { display: flex; gap: 24px; }
nav a { color: var(--text-muted); font-size: 14px; font-weight: 500; }
nav a:hover { color: var(--text); }
/* Hero */
.hero {
padding: 80px 0 60px;
text-align: center;
}
.hero h1 {
font-size: 48px;
font-weight: 800;
letter-spacing: -0.03em;
margin-bottom: 16px;
}
.hero p {
font-size: 20px;
color: var(--text-muted);
max-width: 600px;
margin: 0 auto 32px;
}
.hero .badge {
display: inline-block;
padding: 6px 16px;
background: color-mix(in srgb, var(--accent) 15%, transparent);
color: var(--accent);
border-radius: 9999px;
font-size: 13px;
font-weight: 600;
margin-bottom: 24px;
}
/* Extension grid */
.ext-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 20px;
padding: 40px 0;
}
.ext-card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 24px;
transition: border-color 200ms ease;
}
.ext-card:hover {
border-color: var(--accent);
}
.ext-card h3 {
font-size: 18px;
margin-bottom: 8px;
}
.ext-card p {
color: var(--text-muted);
font-size: 14px;
margin-bottom: 16px;
}
.ext-card .links {
display: flex;
gap: 12px;
}
.ext-card .links a {
font-size: 14px;
font-weight: 500;
}
/* Buttons */
.btn {
display: inline-block;
padding: 12px 24px;
border-radius: var(--radius);
font-weight: 600;
font-size: 15px;
transition: all 200ms ease;
cursor: pointer;
border: none;
}
.btn-primary {
background: var(--accent);
color: #fff;
}
.btn-primary:hover {
background: var(--accent-hover);
color: #fff;
}
.btn-outline {
background: transparent;
border: 1px solid var(--border);
color: var(--text);
}
.btn-outline:hover {
border-color: var(--accent);
color: var(--text);
}
/* Sections */
.section {
padding: 60px 0;
border-top: 1px solid var(--border);
}
.section h2 {
font-size: 32px;
font-weight: 700;
margin-bottom: 24px;
letter-spacing: -0.02em;
}
/* Footer */
.site-footer {
border-top: 1px solid var(--border);
padding: 40px 0;
text-align: center;
color: var(--text-muted);
font-size: 14px;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--text); }
/* Feedback form */
.feedback-form {
max-width: 480px;
margin: 40px auto;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
font-size: 14px;
font-weight: 600;
margin-bottom: 6px;
color: var(--text);
}
.form-group select,
.form-group textarea {
width: 100%;
padding: 10px 12px;
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: var(--radius);
color: var(--text);
font-size: 14px;
font-family: inherit;
}
.form-group textarea {
min-height: 100px;
resize: vertical;
}
.form-group select:focus,
.form-group textarea:focus {
outline: none;
border-color: var(--accent);
}
.form-actions {
display: flex;
gap: 12px;
justify-content: flex-end;
}
.form-success {
text-align: center;
padding: 40px;
color: var(--text-muted);
}
.form-success h2 { color: var(--accent); }
/* Coffee page */
.coffee-options {
display: flex;
gap: 16px;
justify-content: center;
flex-wrap: wrap;
margin: 40px 0;
}
.coffee-btn {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
padding: 24px 32px;
background: var(--bg-card);
border: 2px solid var(--border);
border-radius: var(--radius);
color: var(--text);
font-weight: 700;
font-size: 24px;
min-width: 120px;
transition: all 200ms ease;
}
.coffee-btn:hover {
border-color: var(--accent);
color: var(--text);
}
.coffee-btn span {
font-size: 13px;
font-weight: 400;
color: var(--text-muted);
}
/* Landing page (per-extension) */
.ext-hero {
padding: 60px 0 40px;
}
.ext-hero .container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 40px;
align-items: center;
}
.ext-hero .info h1 {
font-size: 36px;
font-weight: 800;
margin-bottom: 12px;
}
.ext-hero .info p {
color: var(--text-muted);
font-size: 17px;
margin-bottom: 24px;
}
.ext-hero .screenshot {
border-radius: var(--radius);
border: 1px solid var(--border);
overflow: hidden;
}
.ext-hero .screenshot img {
width: 100%;
display: block;
}
.feature-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
gap: 16px;
padding: 20px 0;
}
.feature-item {
padding: 16px;
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius);
}
.feature-item h4 {
font-size: 15px;
margin-bottom: 4px;
}
.feature-item p {
font-size: 13px;
color: var(--text-muted);
}
@media (max-width: 720px) {
.hero h1 { font-size: 32px; }
.hero p { font-size: 16px; }
.ext-hero .container { grid-template-columns: 1fr; }
.ext-hero .screenshot { order: -1; }
}
+5
View File
@@ -0,0 +1,5 @@
{
"extends": "astro/tsconfigs/strict",
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"]
}
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail
# Deploy Greasy Sprocket website to VPS
# Usage: VPS_IP=1.2.3.4 bash deploy/deploy.sh
VPS_IP="${VPS_IP:?Set VPS_IP env var}"
SSH_KEY="${SSH_KEY:-$HOME/.hermes/id_rsa_gs}"
SSH_USER="${SSH_USER:-root}"
echo "=== Building Astro ==="
cd astro
pnpm install --frozen-lockfile 2>/dev/null || pnpm install
pnpm run build
cd ..
echo "=== Building Go feedback service ==="
cd feedback-svc
make build
cd ..
echo "=== Uploading to VPS ==="
# Upload static files
rsync -avz --delete astro/dist/ "${SSH_USER}@${VPS_IP}:/var/www/greasysprocket.com/"
# Upload Go binary
scp -i "$SSH_KEY" feedback-svc/bin/gs-feedback "${SSH_USER}@${VPS_IP}:/usr/local/bin/gs-feedback"
# Upload systemd service (if changed)
scp -i "$SSH_KEY" deploy/gs-feedback.service "${SSH_USER}@${VPS_IP}:/etc/systemd/system/gs-feedback.service"
echo "=== Restarting services ==="
ssh -i "$SSH_KEY" "${SSH_USER}@${VPS_IP}" '
chmod +x /usr/local/bin/gs-feedback &&
mkdir -p /var/lib/gs-feedback &&
chown www-data:www-data /var/lib/gs-feedback &&
systemctl daemon-reload &&
systemctl restart gs-feedback &&
systemctl reload nginx &&
echo "✅ Deploy complete"
'
+24
View File
@@ -0,0 +1,24 @@
[Unit]
Description=Greasy Sprocket Feedback Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/gs-feedback
Environment=GS_PORT=8080
Environment=GS_DB_PATH=/var/lib/gs-feedback/feedback.db
Environment=GS_DISCORD_WEBHOOK=__DISCORD_WEBHOOK_URL__
Restart=on-failure
RestartSec=5
User=www-data
Group=www-data
# Security
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/gs-feedback
PrivateTmp=true
[Install]
WantedBy=multi-user.target
+54
View File
@@ -0,0 +1,54 @@
server {
listen 80;
server_name greasysprocket.com www.greasysprocket.com;
root /var/www/greasysprocket.com;
index index.html;
# Static files
location / {
try_files $uri $uri/index.html $uri.html =404;
}
# Feedback POST → Go binary (separate location for POST only)
location = /feedback {
# POST goes to Go backend
limit_except GET POST { deny all; }
# If POST, proxy to Go service
if ($request_method = POST) {
rewrite ^ /feedback_api last;
}
# GET serves the feedback page
try_files $uri $uri/index.html /feedback/index.html;
}
# Internal location for POST proxy
location = /feedback_api {
internal;
proxy_pass http://127.0.0.1:8080/feedback;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Content-Type $http_content_type;
}
# Stats endpoint
location /feedback/stats {
proxy_pass http://127.0.0.1:8080/feedback/stats;
proxy_set_header Host $host;
}
# Gzip
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml;
gzip_min_length 1000;
# Cache static assets
location ~* \.(jpg|jpeg|png|gif|svg|ico|woff2?)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
location ~* \.(css|js)$ {
expires 7d;
add_header Cache-Control "public";
}
}
+8
View File
@@ -0,0 +1,8 @@
.PHONY: build clean
build:
mkdir -p bin
CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/gs-feedback ./...
clean:
rm -rf bin
+21
View File
@@ -0,0 +1,21 @@
module greasy-sprocket/feedback-svc
go 1.24
require modernc.org/sqlite v1.34.1
require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
golang.org/x/sys v0.22.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.55.3 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
)
+49
View File
@@ -0,0 +1,49 @@
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo=
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
modernc.org/cc/v4 v4.21.4 h1:3Be/Rdo1fpr8GrQ7IVw9OHtplU4gWbb+wNgeoBMmGLQ=
modernc.org/cc/v4 v4.21.4/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
modernc.org/ccgo/v4 v4.19.2 h1:lwQZgvboKD0jBwdaeVCTouxhxAyN6iawF3STraAal8Y=
modernc.org/ccgo/v4 v4.19.2/go.mod h1:ysS3mxiMV38XGRTTcgo0DQTeTmAO4oCmJl1nX9VFI3s=
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw=
modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU=
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI=
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
modernc.org/libc v1.55.3 h1:AzcW1mhlPNrRtjS5sS+eW2ISCgSOLLNyFzRh/V3Qj/U=
modernc.org/libc v1.55.3/go.mod h1:qFXepLhz+JjFThQ4kzwzOjA/y/artDeg+pcYnY+Q83w=
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc=
modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss=
modernc.org/sqlite v1.34.1 h1:u3Yi6M0N8t9yKRDwhXcyp1eS5/ErhPTBggxWFuR6Hfk=
modernc.org/sqlite v1.34.1/go.mod h1:pXV2xHxhzXZsgT/RtTFAPY6JJDEvOTcTdwADQCCWD4k=
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
+221
View File
@@ -0,0 +1,221 @@
package main
import (
"database/sql"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"strings"
"time"
_ "modernc.org/sqlite"
)
type FeedbackRequest struct {
Ext string `json:"ext"`
Reason string `json:"reason"`
Text string `json:"text"`
}
type FeedbackResponse struct {
OK bool `json:"ok"`
}
func main() {
dbPath := os.Getenv("GS_DB_PATH")
if dbPath == "" {
dbPath = "/var/lib/gs-feedback/feedback.db"
}
discordWebhook := os.Getenv("GS_DISCORD_WEBHOOK")
port := os.Getenv("GS_PORT")
if port == "" {
port = "8080"
}
// Ensure directory exists
if err := os.MkdirAll(strings.TrimSuffix(dbPath, "/feedback.db"), 0755); err != nil {
log.Printf("warn: could not create db directory: %v", err)
}
db, err := sql.Open("sqlite", dbPath)
if err != nil {
log.Fatalf("failed to open database: %v", err)
}
defer db.Close()
// Create table if not exists
schema := `
CREATE TABLE IF NOT EXISTS feedback (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ext TEXT NOT NULL,
reason TEXT DEFAULT '',
text TEXT DEFAULT '',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);`
if _, err := db.Exec(schema); err != nil {
log.Fatalf("failed to create table: %v", err)
}
mux := http.NewServeMux()
// POST /feedback — receive feedback
mux.HandleFunc("/feedback", func(w http.ResponseWriter, r *http.Request) {
if r.Method == "OPTIONS" {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
w.WriteHeader(http.StatusOK)
return
}
if r.Method != "POST" {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
// CORS
w.Header().Set("Access-Control-Allow-Origin", "*")
var req FeedbackRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, "Invalid JSON", http.StatusBadRequest)
return
}
// Validate
req.Ext = strings.TrimSpace(req.Ext)
req.Reason = strings.TrimSpace(req.Reason)
req.Text = strings.TrimSpace(req.Text)
if len(req.Text) > 500 {
http.Error(w, "Text too long", http.StatusBadRequest)
return
}
// Insert into SQLite
_, err := db.Exec(
"INSERT INTO feedback (ext, reason, text) VALUES (?, ?, ?)",
req.Ext, req.Reason, req.Text,
)
if err != nil {
log.Printf("error inserting feedback: %v", err)
http.Error(w, "Internal error", http.StatusInternalServerError)
return
}
log.Printf("feedback received: ext=%s reason=%s", req.Ext, req.Reason)
// Discord webhook (best-effort, non-blocking)
if discordWebhook != "" {
go sendDiscordNotification(discordWebhook, req)
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(FeedbackResponse{OK: true})
})
// GET /feedback/stats — simple stats endpoint (optional, for future dashboard)
mux.HandleFunc("/feedback/stats", func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
rows, err := db.Query(`
SELECT ext, reason, COUNT(*) as count
FROM feedback
GROUP BY ext, reason
ORDER BY count DESC
`)
if err != nil {
http.Error(w, "Internal error", http.StatusInternalServerError)
return
}
defer rows.Close()
type Stat struct {
Ext string `json:"ext"`
Reason string `json:"reason"`
Count int `json:"count"`
}
var stats []Stat
for rows.Next() {
var s Stat
if err := rows.Scan(&s.Ext, &s.Reason, &s.Count); err != nil {
continue
}
stats = append(stats, s)
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(stats)
})
// Health check
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, "ok")
})
log.Printf("gs-feedback starting on :%s (db=%s)", port, dbPath)
srv := &http.Server{
Addr: ":" + port,
Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
}
if err := srv.ListenAndServe(); err != nil {
log.Fatalf("server error: %v", err)
}
}
func sendDiscordNotification(webhookURL string, req FeedbackRequest) {
reasonLabels := map[string]string{
"not-needed": "Didn't need it",
"too-many": "Too many extensions",
"bugs": "Bugs or issues",
"alternative": "Prefer an alternative",
"other": "Other",
}
reasonLabel := reasonLabels[req.Reason]
if reasonLabel == "" {
reasonLabel = req.Reason
}
extLabel := req.Ext
if extLabel == "" {
extLabel = "unknown"
}
textPreview := req.Text
if len(textPreview) > 200 {
textPreview = textPreview[:200] + "..."
}
description := fmt.Sprintf("**Extension:** %s\n**Reason:** %s", extLabel, reasonLabel)
if textPreview != "" {
description += fmt.Sprintf("\n**Comment:** %s", textPreview)
}
payload := map[string]interface{}{
"embeds": []map[string]interface{}{
{
"title": "📋 Uninstall Feedback",
"description": description,
"color": 0xf97316,
"timestamp": time.Now().UTC().Format(time.RFC3339),
},
},
}
body, _ := json.Marshal(payload)
resp, err := http.Post(webhookURL, "application/json", strings.NewReader(string(body)))
if err != nil {
log.Printf("discord webhook error: %v", err)
return
}
resp.Body.Close()
}