mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 06:25:04 +00:00
If style.css does not exist, it's created with the default one.
This commit is contained in:
parent
d8e77aca76
commit
6778350211
3 changed files with 27 additions and 6 deletions
8
data.c
8
data.c
|
@ -156,6 +156,14 @@ int srv_open(const char *basedir, int auto_upgrade)
|
|||
/* read (and drop) emojis.json, possibly creating it */
|
||||
xs_free(emojis());
|
||||
|
||||
/* if style.css does not exist, create it */
|
||||
xs *css_fn = xs_fmt("%s/style.css", srv_basedir);
|
||||
|
||||
if (mtime(css_fn) == 0) {
|
||||
srv_log(xs_fmt("Writing style.css"));
|
||||
write_default_css();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
1
snac.h
1
snac.h
|
@ -347,6 +347,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
|
|||
char **body, int *b_size, char **ctype);
|
||||
xs_str *timeline_to_rss(snac *user, const xs_list *timeline, char *title, char *link, char *desc);
|
||||
|
||||
int write_default_css(void);
|
||||
int snac_init(const char *_basedir);
|
||||
int adduser(const char *uid);
|
||||
int resetpwd(snac *snac);
|
||||
|
|
24
utils.c
24
utils.c
|
@ -107,6 +107,22 @@ static const char *greeting_html =
|
|||
"<p>This site is powered by <abbr title=\"Social Networks Are Crap\">snac</abbr>.</p>\n"
|
||||
"</body></html>\n";
|
||||
|
||||
|
||||
int write_default_css(void)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
xs *sfn = xs_fmt("%s/style.css", srv_basedir);
|
||||
if ((f = fopen(sfn, "w")) == NULL)
|
||||
return 1;
|
||||
|
||||
fwrite(default_css, strlen(default_css), 1, f);
|
||||
fclose(f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int snac_init(const char *basedir)
|
||||
{
|
||||
FILE *f;
|
||||
|
@ -217,15 +233,11 @@ int snac_init(const char *basedir)
|
|||
fwrite(gh, strlen(gh), 1, f);
|
||||
fclose(f);
|
||||
|
||||
xs *sfn = xs_fmt("%s/style.css", srv_basedir);
|
||||
if ((f = fopen(sfn, "w")) == NULL) {
|
||||
printf("ERROR: cannot create '%s'\n", sfn);
|
||||
if (write_default_css()) {
|
||||
printf("ERROR: cannot create style.css\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fwrite(default_css, strlen(default_css), 1, f);
|
||||
fclose(f);
|
||||
|
||||
xs *cfn = xs_fmt("%s/server.json", srv_basedir);
|
||||
if ((f = fopen(cfn, "w")) == NULL) {
|
||||
printf("ERROR: cannot create '%s'\n", cfn);
|
||||
|
|
Loading…
Reference in a new issue