diff options
| author | 2024-09-04 09:48:35 +0200 | |
|---|---|---|
| committer | 2024-09-04 09:48:35 +0200 | |
| commit | 6778350211aeae076be80393cbef637e0218ad49 (patch) | |
| tree | af2edb5302be580629b62a1a454463e142b90842 /utils.c | |
| parent | Added some CSS styling to the list-of-lists. (diff) | |
| download | penes-snac2-6778350211aeae076be80393cbef637e0218ad49.tar.gz penes-snac2-6778350211aeae076be80393cbef637e0218ad49.tar.xz penes-snac2-6778350211aeae076be80393cbef637e0218ad49.zip | |
If style.css does not exist, it's created with the default one.
Diffstat (limited to '')
| -rw-r--r-- | utils.c | 24 |
1 files changed, 18 insertions, 6 deletions
| @@ -107,6 +107,22 @@ static const char *greeting_html = | |||
| 107 | "<p>This site is powered by <abbr title=\"Social Networks Are Crap\">snac</abbr>.</p>\n" | 107 | "<p>This site is powered by <abbr title=\"Social Networks Are Crap\">snac</abbr>.</p>\n" |
| 108 | "</body></html>\n"; | 108 | "</body></html>\n"; |
| 109 | 109 | ||
| 110 | |||
| 111 | int write_default_css(void) | ||
| 112 | { | ||
| 113 | FILE *f; | ||
| 114 | |||
| 115 | xs *sfn = xs_fmt("%s/style.css", srv_basedir); | ||
| 116 | if ((f = fopen(sfn, "w")) == NULL) | ||
| 117 | return 1; | ||
| 118 | |||
| 119 | fwrite(default_css, strlen(default_css), 1, f); | ||
| 120 | fclose(f); | ||
| 121 | |||
| 122 | return 0; | ||
| 123 | } | ||
| 124 | |||
| 125 | |||
| 110 | int snac_init(const char *basedir) | 126 | int snac_init(const char *basedir) |
| 111 | { | 127 | { |
| 112 | FILE *f; | 128 | FILE *f; |
| @@ -217,15 +233,11 @@ int snac_init(const char *basedir) | |||
| 217 | fwrite(gh, strlen(gh), 1, f); | 233 | fwrite(gh, strlen(gh), 1, f); |
| 218 | fclose(f); | 234 | fclose(f); |
| 219 | 235 | ||
| 220 | xs *sfn = xs_fmt("%s/style.css", srv_basedir); | 236 | if (write_default_css()) { |
| 221 | if ((f = fopen(sfn, "w")) == NULL) { | 237 | printf("ERROR: cannot create style.css\n"); |
| 222 | printf("ERROR: cannot create '%s'\n", sfn); | ||
| 223 | return 1; | 238 | return 1; |
| 224 | } | 239 | } |
| 225 | 240 | ||
| 226 | fwrite(default_css, strlen(default_css), 1, f); | ||
| 227 | fclose(f); | ||
| 228 | |||
| 229 | xs *cfn = xs_fmt("%s/server.json", srv_basedir); | 241 | xs *cfn = xs_fmt("%s/server.json", srv_basedir); |
| 230 | if ((f = fopen(cfn, "w")) == NULL) { | 242 | if ((f = fopen(cfn, "w")) == NULL) { |
| 231 | printf("ERROR: cannot create '%s'\n", cfn); | 243 | printf("ERROR: cannot create '%s'\n", cfn); |