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