commit 3f7e3c1
default
·
2023-08-14 16:02:20 +0000 UTC
parent 16c1406
Unify the instance description text.
5 files changed,
+47,
-55
M
html.c
+1,
-12
1@@ -273,18 +273,7 @@ xs_str *html_instance_header(xs_str *s)
2 s = xs_str_cat(s, "<div class=\"snac-instance-blurb\">\n");
3
4 {
5- xs *s1 = xs_fmt(
6- "<p><b>%s</b> is a "
7- "<a href=\"https:/" "/en.wikipedia.org/wiki/Fediverse\">Fediverse</a> "
8- "instance that uses the "
9- "<a href=\"https:/" "/en.wikipedia.org/wiki/ActivityPub\">ActivityPub</a> "
10- "protocol. In other words, users at this host can communicate with people "
11- "that use software like Mastodon, Pleroma, Friendica, etc. "
12- "all around the world.</p>\n"
13- "<p>This server runs the "
14- "<a href=\"" WHAT_IS_SNAC_URL "\">snac</a> software and there is no "
15- "automatic sign-up process.</p>\n",
16- host);
17+ xs *s1 = xs_replace(snac_blurb, "%host%", host);
18 s = xs_str_cat(s, s1);
19 }
20
M
snac.h
+2,
-0
1@@ -271,6 +271,8 @@ int snac_init(const char *_basedir);
2 int adduser(const char *uid);
3 int resetpwd(snac *snac);
4
5+extern const char *snac_blurb;
6+
7 int job_fifo_ready(void);
8 void job_post(const xs_val *job, int urgent);
9 void job_wait(xs_val **job);
M
utils.c
+17,
-13
1@@ -62,24 +62,27 @@ static const char *default_css =
2 ".snac-poll-result { margin-left: auto; margin-right: auto; }\n"
3 ;
4
5+const char *snac_blurb =
6+ "<p><b>%host%</b> is a <a href=\"https:/"
7+ "/en.wikipedia.org/wiki/Fediverse\">Fediverse</a> "
8+ "instance that uses the <a href=\"https:/"
9+ "/en.wikipedia.org/wiki/ActivityPub\">ActivityPub</a> "
10+ "protocol. In other words, users at this host can communicate with people "
11+ "that use software like Mastodon, Pleroma, Friendica, etc. "
12+ "all around the world.</p>\n"
13+ "<p>This server runs the "
14+ "<a href=\"" WHAT_IS_SNAC_URL "\">snac</a> software and there is no "
15+ "automatic sign-up process.</p>\n"
16+;
17+
18 static const char *greeting_html =
19 "<!DOCTYPE html>\n"
20 "<html><head>\n"
21 "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n"
22 "<title>Welcome to %host%</title>\n"
23 "<body style=\"margin: auto; max-width: 50em\">\n"
24- "<h1>Welcome to %host%</h1>\n"
25- "<p>This is a <a href=\"https://en.wikipedia.org/wiki/Fediverse\">Fediverse</a> instance\n"
26- "that uses the <a href=\"https://en.wikipedia.org/wiki/ActivityPub\">ActivityPub</a> protocol.\n"
27- "In other words, users at this host can communicate with people that use software like\n"
28- "Mastodon, Pleroma, Friendica, etc. all around the world.</p>\n"
29- "\n"
30- "<p>There is no automatic sign up process for this server. If you want to be a part of\n"
31- "this community, please write an email to %admin_email%\n"
32- "and ask politely indicating what is your preferred user id (alphanumeric characters\n"
33- "only).</p>\n"
34- "\n"
35- "<p>The following users are already part of this community:</p>\n"
36+ "%blurb%"
37+ "<p>The following users are part of this community:</p>\n"
38 "\n"
39 "%userlist%\n"
40 "\n"
41@@ -180,7 +183,8 @@ int snac_init(const char *basedir)
42 return 1;
43 }
44
45- fwrite(greeting_html, strlen(greeting_html), 1, f);
46+ xs *gh = xs_replace(greeting_html, "%blurb%", snac_blurb);
47+ fwrite(gh, strlen(gh), 1, f);
48 fclose(f);
49
50 xs *sfn = xs_fmt("%s/style.css", srv_basedir);
+26,
-29
1@@ -4,14 +4,14 @@
2
3 #define _XS_MIME
4
5-char *xs_mime_by_ext(const char *file);
6+const char *xs_mime_by_ext(const char *file);
7
8 #ifdef XS_IMPLEMENTATION
9
10 /* intentionally brain-dead simple */
11 struct _mime_info {
12- char *type;
13- char *ext;
14+ const char *type;
15+ const char *ext;
16 } mime_info[] = {
17 { "application/json", ".json" },
18 { "image/gif", ".gif" },
19@@ -19,23 +19,23 @@ struct _mime_info {
20 { "image/jpeg", ".jpg" },
21 { "image/png", ".png" },
22 { "image/webp", ".webp" },
23- { "video/mp4", ".mp4"},
24- { "video/mp4", ".mpg4"},
25- { "video/mp4", ".m4v"},
26- { "video/webm", ".webm"},
27- { "video/quicktime", ".mov"},
28- { "video/3gpp", ".3gp"},
29- { "video/ogg", ".ogv"},
30- { "video/flv", ".flv"},
31- { "audio/mp3", ".mp3"},
32- { "audio/ogg", ".ogg"},
33- { "audio/ogg", ".oga"},
34- { "audio/ogg", ".opus"},
35- { "audio/flac", ".flac"},
36- { "audio/wav", ".wav"},
37- { "audio/wma", ".wma"},
38- { "audio/aac", ".aac"},
39- { "audio/aac", ".m4a"},
40+ { "video/mp4", ".mp4" },
41+ { "video/mp4", ".mpg4" },
42+ { "video/mp4", ".m4v" },
43+ { "video/webm", ".webm" },
44+ { "video/quicktime", ".mov" },
45+ { "video/3gpp", ".3gp" },
46+ { "video/ogg", ".ogv" },
47+ { "video/flv", ".flv" },
48+ { "audio/mp3", ".mp3" },
49+ { "audio/ogg", ".ogg" },
50+ { "audio/ogg", ".oga" },
51+ { "audio/ogg", ".opus" },
52+ { "audio/flac", ".flac" },
53+ { "audio/wav", ".wav" },
54+ { "audio/wma", ".wma" },
55+ { "audio/aac", ".aac" },
56+ { "audio/aac", ".m4a" },
57 { "text/css", ".css" },
58 { "text/html", ".html" },
59 { "text/plain", ".txt" },
60@@ -46,23 +46,20 @@ struct _mime_info {
61 };
62
63
64-char *xs_mime_by_ext(const char *file)
65+const char *xs_mime_by_ext(const char *file)
66 /* returns the MIME type by file extension */
67 {
68 struct _mime_info *mi = mime_info;
69- char *p = NULL;
70+ xs *lfile = xs_tolower_i(xs_dup(file));
71
72- while (p == NULL && mi->type != NULL) {
73- if (xs_endswith(file, mi->ext))
74- p = mi->type;
75+ while (mi->type != NULL) {
76+ if (xs_endswith(lfile, mi->ext))
77+ return mi->type;
78
79 mi++;
80 }
81
82- if (p == NULL)
83- p = "application/octet-stream";
84-
85- return p;
86+ return "application/octet-stream";
87 }
88
89
+1,
-1
1@@ -1 +1 @@
2-/* 5b007ed034f8598be964d72f5becf24b379a7dd8 */
3+/* 17cae699036ab791f9bd4e9c1b875b1f808121f0 */