scripts/seed-forum.sh 5.4 KiB raw
1
#!/bin/sh
2
#
3
# Seed the forum (site-level discussions) with sample data for testing.
4
# Usage: ./scripts/seed-forum.sh [path/to/forge.db]
5
#
6
set -e
7
8
DB="${1:-forge.db}"
9
10
if [ ! -f "$DB" ]; then
11
    echo "Database not found: $DB"
12
    echo "Usage: $0 [path/to/forge.db]"
13
    exit 1
14
fi
15
16
echo "Seeding forum in $DB ..."
17
18
sqlite3 "$DB" <<'SQL'
19
-- Discussion 1: welcome / intro
20
INSERT INTO discussions (repo, title, body, author, created_at)
21
VALUES ('_site', 'Welcome to the Radiant forum',
22
'Hey everyone, this is the general discussion space for *all things Radiant*.
23
24
Feel free to introduce yourself, ask questions, or share what you are working on. Check out the project at <https://radiant.dev> if you have not already.
25
26
A few ground rules:
27
- Be kind and constructive.
28
- Stay on topic (use per-repo discussions for repo-specific issues).
29
- Have fun.',
30
'cloudhead.io', datetime('now', '-14 days'));
31
32
-- Replies to discussion 1
33
INSERT INTO replies (discussion_id, body, author, created_at)
34
VALUES (last_insert_rowid(), 'Thanks for setting this up! *Excited* to be here.',
35
'alice.bsky.social', datetime('now', '-13 days'));
36
37
INSERT INTO replies (discussion_id, body, author, created_at)
38
VALUES ((SELECT MAX(id) FROM discussions), 'Great to see a forum that works without JavaScript. The source is really clean too.',
39
'bob.bsky.social', datetime('now', '-12 days'));
40
41
INSERT INTO replies (discussion_id, body, author, created_at)
42
VALUES ((SELECT MAX(id) FROM discussions), 'Agreed, this is refreshing. I found the contributing guide at <https://radiant.dev/contributing> very helpful. Looking forward to contributing.',
43
'alice.bsky.social', datetime('now', '-11 days'));
44
45
-- Discussion 2: build question
46
INSERT INTO discussions (repo, title, body, author, created_at)
47
VALUES ('_site', 'Cross-compiling forge for ARM?',
48
'Has anyone tried cross-compiling the forge binary for ARM (e.g. Raspberry Pi)?
49
50
I tried `GOARCH=arm64 go build .` and it built fine, but I am wondering if there are any gotchas with the SQLite dependency on *musl* vs *glibc*.',
51
'bob.bsky.social', datetime('now', '-10 days'));
52
53
INSERT INTO replies (discussion_id, body, author, created_at)
54
VALUES (last_insert_rowid(), 'I run it on a Pi 4 with no issues. Here is what I use:
55
56
```
57
export CGO_ENABLED=1
58
export CC=aarch64-linux-gnu-gcc
59
GOARCH=arm64 go build .
60
```
61
62
See <https://go.dev/doc/install/source#environment> for the full list of env vars.',
63
'alice.bsky.social', datetime('now', '-9 days'));
64
65
INSERT INTO replies (discussion_id, body, author, created_at)
66
VALUES ((SELECT MAX(id) FROM discussions), 'Thanks, that did the trick! Setting `CGO_ENABLED=1` was the key part I was missing.',
67
'bob.bsky.social', datetime('now', '-8 days'));
68
69
-- Discussion 3: feature idea
70
INSERT INTO discussions (repo, title, body, author, created_at)
71
VALUES ('_site', 'Idea: RSS feed for repository updates',
72
'It would be nice to have an RSS/Atom feed at `/feed` or `/rss` that lists recent commits across all public repos. That way people could subscribe and stay up to date without polling the web UI.
73
74
The Atom spec is at <https://www.rfc-editor.org/rfc/rfc4287>. Anyone else interested in this?',
75
'alice.bsky.social', datetime('now', '-7 days'));
76
77
INSERT INTO replies (discussion_id, body, author, created_at)
78
VALUES (last_insert_rowid(), '*Yes!* I would use this. Per-repo feeds would be great too.',
79
'bob.bsky.social', datetime('now', '-6 days'));
80
81
INSERT INTO replies (discussion_id, body, author, created_at)
82
VALUES ((SELECT MAX(id) FROM discussions), 'I might take a crack at this. The handler would be something like:
83
84
```go
85
func (s *server) handleFeed(w http.ResponseWriter, r *http.Request) {
86
    commits := s.getRecentCommits(20)
87
    w.Header().Set("Content-Type", "application/atom+xml")
88
    renderAtomFeed(w, commits)
89
}
90
```
91
92
Seems straightforward to shell out to `git log --all` for the data.',
93
'cloudhead.io', datetime('now', '-4 days'));
94
95
-- Discussion 4: a shorter thread
96
INSERT INTO discussions (repo, title, body, author, created_at)
97
VALUES ('_site', 'Syntax highlighting for more languages?',
98
'Currently forge ships `hirad.js` and `hiril.js` for Radiance and RIL. Any plans to support other languages, or is the intent to keep it *minimal*?',
99
'bob.bsky.social', datetime('now', '-3 days'));
100
101
INSERT INTO replies (discussion_id, body, author, created_at)
102
VALUES (last_insert_rowid(), 'I think keeping it minimal is the right call. You can always drop your own highlighter scripts into `static/js/` and rebuild. The embed directive picks them up automatically.',
103
'cloudhead.io', datetime('now', '-2 days'));
104
105
-- Discussion 5: no replies yet
106
INSERT INTO discussions (repo, title, body, author, created_at)
107
VALUES ('_site', 'Deploying behind nginx reverse proxy',
108
'I am trying to set up forge behind nginx with a `/git` base URL. I pass `-base-url /git` but static assets (CSS, fonts) are not loading. Here is what I have so far:
109
110
```
111
location /git/ {
112
    proxy_pass http://127.0.0.1:8080/;
113
    proxy_set_header Host $host;
114
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
115
}
116
```
117
118
I followed the reverse proxy guide at <https://nginx.org/en/docs/http/ngx_http_proxy_module.html> but *something* is still off. Has anyone got a working config they can share?',
119
'alice.bsky.social', datetime('now', '-1 days'));
120
121
-- Avatars
122
INSERT OR IGNORE INTO avatars (handle, url) VALUES
123
  ('cloudhead.io',       '/avatars/cloudhead.svg'),
124
  ('alice.bsky.social',  '/avatars/alice.svg'),
125
  ('bob.bsky.social',    '/avatars/bob.svg');
126
127
SQL
128
129
echo "Done. Inserted 5 discussions with replies and avatars."