From 3f7e3c1d81fef35eada041b7d901974129238dce Mon Sep 17 00:00:00 2001 From: default Date: Mon, 14 Aug 2023 18:02:20 +0200 Subject: [PATCH] Unify the instance description text. --- html.c | 13 +------------ snac.h | 2 ++ utils.c | 30 +++++++++++++++------------- xs_mime.h | 55 +++++++++++++++++++++++++--------------------------- xs_version.h | 2 +- 5 files changed, 47 insertions(+), 55 deletions(-) diff --git a/html.c b/html.c index 126f4ab..f7fa520 100644 --- a/html.c +++ b/html.c @@ -273,18 +273,7 @@ xs_str *html_instance_header(xs_str *s) s = xs_str_cat(s, "
\n"); { - xs *s1 = xs_fmt( - "

%s is a " - "Fediverse " - "instance that uses the " - "ActivityPub " - "protocol. In other words, users at this host can communicate with people " - "that use software like Mastodon, Pleroma, Friendica, etc. " - "all around the world.

\n" - "

This server runs the " - "snac software and there is no " - "automatic sign-up process.

\n", - host); + xs *s1 = xs_replace(snac_blurb, "%host%", host); s = xs_str_cat(s, s1); } diff --git a/snac.h b/snac.h index 155205b..2efc8d1 100644 --- a/snac.h +++ b/snac.h @@ -271,6 +271,8 @@ int snac_init(const char *_basedir); int adduser(const char *uid); int resetpwd(snac *snac); +extern const char *snac_blurb; + int job_fifo_ready(void); void job_post(const xs_val *job, int urgent); void job_wait(xs_val **job); diff --git a/utils.c b/utils.c index e9d1447..bb15157 100644 --- a/utils.c +++ b/utils.c @@ -62,24 +62,27 @@ static const char *default_css = ".snac-poll-result { margin-left: auto; margin-right: auto; }\n" ; +const char *snac_blurb = + "

%host% is a Fediverse " + "instance that uses the ActivityPub " + "protocol. In other words, users at this host can communicate with people " + "that use software like Mastodon, Pleroma, Friendica, etc. " + "all around the world.

\n" + "

This server runs the " + "snac software and there is no " + "automatic sign-up process.

\n" +; + static const char *greeting_html = "\n" "\n" "\n" "Welcome to %host%\n" "\n" - "

Welcome to %host%

\n" - "

This is a Fediverse instance\n" - "that uses the ActivityPub protocol.\n" - "In other words, users at this host can communicate with people that use software like\n" - "Mastodon, Pleroma, Friendica, etc. all around the world.

\n" - "\n" - "

There is no automatic sign up process for this server. If you want to be a part of\n" - "this community, please write an email to %admin_email%\n" - "and ask politely indicating what is your preferred user id (alphanumeric characters\n" - "only).

\n" - "\n" - "

The following users are already part of this community:

\n" + "%blurb%" + "

The following users are part of this community:

\n" "\n" "%userlist%\n" "\n" @@ -180,7 +183,8 @@ int snac_init(const char *basedir) return 1; } - fwrite(greeting_html, strlen(greeting_html), 1, f); + xs *gh = xs_replace(greeting_html, "%blurb%", snac_blurb); + fwrite(gh, strlen(gh), 1, f); fclose(f); xs *sfn = xs_fmt("%s/style.css", srv_basedir); diff --git a/xs_mime.h b/xs_mime.h index 96d722b..ef7affe 100644 --- a/xs_mime.h +++ b/xs_mime.h @@ -4,14 +4,14 @@ #define _XS_MIME -char *xs_mime_by_ext(const char *file); +const char *xs_mime_by_ext(const char *file); #ifdef XS_IMPLEMENTATION /* intentionally brain-dead simple */ struct _mime_info { - char *type; - char *ext; + const char *type; + const char *ext; } mime_info[] = { { "application/json", ".json" }, { "image/gif", ".gif" }, @@ -19,23 +19,23 @@ struct _mime_info { { "image/jpeg", ".jpg" }, { "image/png", ".png" }, { "image/webp", ".webp" }, - { "video/mp4", ".mp4"}, - { "video/mp4", ".mpg4"}, - { "video/mp4", ".m4v"}, - { "video/webm", ".webm"}, - { "video/quicktime", ".mov"}, - { "video/3gpp", ".3gp"}, - { "video/ogg", ".ogv"}, - { "video/flv", ".flv"}, - { "audio/mp3", ".mp3"}, - { "audio/ogg", ".ogg"}, - { "audio/ogg", ".oga"}, - { "audio/ogg", ".opus"}, - { "audio/flac", ".flac"}, - { "audio/wav", ".wav"}, - { "audio/wma", ".wma"}, - { "audio/aac", ".aac"}, - { "audio/aac", ".m4a"}, + { "video/mp4", ".mp4" }, + { "video/mp4", ".mpg4" }, + { "video/mp4", ".m4v" }, + { "video/webm", ".webm" }, + { "video/quicktime", ".mov" }, + { "video/3gpp", ".3gp" }, + { "video/ogg", ".ogv" }, + { "video/flv", ".flv" }, + { "audio/mp3", ".mp3" }, + { "audio/ogg", ".ogg" }, + { "audio/ogg", ".oga" }, + { "audio/ogg", ".opus" }, + { "audio/flac", ".flac" }, + { "audio/wav", ".wav" }, + { "audio/wma", ".wma" }, + { "audio/aac", ".aac" }, + { "audio/aac", ".m4a" }, { "text/css", ".css" }, { "text/html", ".html" }, { "text/plain", ".txt" }, @@ -46,23 +46,20 @@ struct _mime_info { }; -char *xs_mime_by_ext(const char *file) +const char *xs_mime_by_ext(const char *file) /* returns the MIME type by file extension */ { struct _mime_info *mi = mime_info; - char *p = NULL; + xs *lfile = xs_tolower_i(xs_dup(file)); - while (p == NULL && mi->type != NULL) { - if (xs_endswith(file, mi->ext)) - p = mi->type; + while (mi->type != NULL) { + if (xs_endswith(lfile, mi->ext)) + return mi->type; mi++; } - if (p == NULL) - p = "application/octet-stream"; - - return p; + return "application/octet-stream"; } 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 */