summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2025-04-18 06:45:58 +0000
committerGravatar Uko Kokņevičs2025-11-02 06:35:41 +0000
commit9d35ce5bcc11a51a4dcd1fd7874288692a7c815c (patch)
tree563bcea6663ff5c0dba275b92e77fa82080b4e4d /html.c
parentCommit my version of the stylesheet (diff)
downloadpenes-snac2-9d35ce5bcc11a51a4dcd1fd7874288692a7c815c.tar.gz
penes-snac2-9d35ce5bcc11a51a4dcd1fd7874288692a7c815c.tar.xz
penes-snac2-9d35ce5bcc11a51a4dcd1fd7874288692a7c815c.zip
Modified generated HTML to match my stylesheet ehheh
Diffstat (limited to 'html.c')
-rw-r--r--html.c122
1 files changed, 65 insertions, 57 deletions
diff --git a/html.c b/html.c
index 2146c93..4b2cc72 100644
--- a/html.c
+++ b/html.c
@@ -984,18 +984,10 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url)
984} 984}
985 985
986 986
987static xs_html *html_user_body(snac *user, int read_only) 987static xs_html *html_user_header(snac *user, int read_only)
988{ 988{
989 const char *proxy = NULL;
990
991 if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media")))
992 proxy = user->actor;
993
994 xs_html *body = xs_html_tag("body", NULL);
995
996 /* top nav */ 989 /* top nav */
997 xs_html *top_nav = xs_html_tag("nav", 990 xs_html *top_nav = xs_html_tag("header", NULL);
998 xs_html_attr("class", "snac-top-nav"));
999 991
1000 xs *avatar = xs_dup(xs_dict_get(user->config, "avatar")); 992 xs *avatar = xs_dup(xs_dict_get(user->config, "avatar"));
1001 993
@@ -1007,7 +999,6 @@ static xs_html *html_user_body(snac *user, int read_only)
1007 xs_html_add(top_nav, 999 xs_html_add(top_nav,
1008 xs_html_sctag("img", 1000 xs_html_sctag("img",
1009 xs_html_attr("src", avatar), 1001 xs_html_attr("src", avatar),
1010 xs_html_attr("class", "snac-avatar"),
1011 xs_html_attr("alt", ""))); 1002 xs_html_attr("alt", "")));
1012 1003
1013 if (read_only) { 1004 if (read_only) {
@@ -1088,8 +1079,18 @@ static xs_html *html_user_body(snac *user, int read_only)
1088 xs_html_attr("placeholder", L("Content search"))))); 1079 xs_html_attr("placeholder", L("Content search")))));
1089 } 1080 }
1090 1081
1091 xs_html_add(body, 1082 return top_nav;
1092 top_nav); 1083}
1084
1085
1086static xs_html *html_user_main(snac *user, int read_only)
1087{
1088 const char *proxy = NULL;
1089
1090 if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media")))
1091 proxy = user->actor;
1092
1093 xs_html *main = xs_html_tag("main", NULL);
1093 1094
1094 /* user info */ 1095 /* user info */
1095 xs_html *top_user = xs_html_tag("div", 1096 xs_html *top_user = xs_html_tag("div",
@@ -1284,10 +1285,10 @@ static xs_html *html_user_body(snac *user, int read_only)
1284 } 1285 }
1285 } 1286 }
1286 1287
1287 xs_html_add(body, 1288 xs_html_add(main,
1288 top_user); 1289 top_user);
1289 1290
1290 return body; 1291 return main;
1291} 1292}
1292 1293
1293 1294
@@ -2968,18 +2969,18 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2968 2969
2969xs_html *html_footer(const snac *user) 2970xs_html *html_footer(const snac *user)
2970{ 2971{
2971 return xs_html_tag("div", 2972 return xs_html_tag("footer",
2972 xs_html_attr("class", "snac-footer"), 2973 xs_html_tag("p",
2973 xs_html_tag("a", 2974 xs_html_tag("a",
2974 xs_html_attr("href", srv_baseurl), 2975 xs_html_attr("href", srv_baseurl),
2975 xs_html_text(L("about this site"))), 2976 xs_html_text(L("about this site"))),
2976 xs_html_text(" - "), 2977 xs_html_text(" - "),
2977 xs_html_text(L("powered by ")), 2978 xs_html_text(L("powered by ")),
2978 xs_html_tag("a", 2979 xs_html_tag("a",
2979 xs_html_attr("href", WHAT_IS_SNAC_URL), 2980 xs_html_attr("href", WHAT_IS_SNAC_URL),
2980 xs_html_tag("abbr", 2981 xs_html_tag("abbr",
2981 xs_html_attr("title", "Social Networks Are Crap"), 2982 xs_html_attr("title", "Social Networks Are Crap"),
2982 xs_html_text(USER_AGENT)))); 2983 xs_html_text(USER_AGENT)))));
2983} 2984}
2984 2985
2985 2986
@@ -3010,27 +3011,33 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3010 } 3011 }
3011 3012
3012 xs_html *head; 3013 xs_html *head;
3013 xs_html *body; 3014 xs_html *header;
3015 xs_html *main;
3014 3016
3015 if (user) { 3017 if (user) {
3016 head = html_user_head(user, desc, alternate); 3018 head = html_user_head(user, desc, alternate);
3017 body = html_user_body(user, read_only); 3019 header = html_user_header(user, read_only);
3020 main = html_user_main(user, read_only);
3018 } 3021 }
3019 else { 3022 else {
3020 head = html_instance_head(); 3023 head = html_instance_head();
3021 body = html_instance_body(); 3024 header = xs_html_tag("header", NULL);
3025 main = html_instance_body();
3022 } 3026 }
3023 3027
3024 xs_html *html = xs_html_tag("html", 3028 xs_html *html = xs_html_tag("html",
3025 head, 3029 head,
3026 body); 3030 xs_html_tag("body",
3031 header,
3032 main,
3033 html_footer(user)));
3027 3034
3028 if (user && !read_only) 3035 if (user && !read_only)
3029 xs_html_add(body, 3036 xs_html_add(main,
3030 html_top_controls(user)); 3037 html_top_controls(user));
3031 3038
3032 if (error != NULL) { 3039 if (error != NULL) {
3033 xs_html_add(body, 3040 xs_html_add(main,
3034 xs_html_tag("dialog", 3041 xs_html_tag("dialog",
3035 xs_html_attr("open", NULL), 3042 xs_html_attr("open", NULL),
3036 xs_html_tag("p", 3043 xs_html_tag("p",
@@ -3046,7 +3053,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3046 if (user && !read_only) { 3053 if (user && !read_only) {
3047 xs_html *lol = xs_html_tag("ul", 3054 xs_html *lol = xs_html_tag("ul",
3048 xs_html_attr("class", "snac-list-of-lists")); 3055 xs_html_attr("class", "snac-list-of-lists"));
3049 xs_html_add(body, lol); 3056 xs_html_add(main, lol);
3050 3057
3051 xs *lists = list_maint(user, NULL, 0); /* get list of lists */ 3058 xs *lists = list_maint(user, NULL, 0); /* get list of lists */
3052 3059
@@ -3121,7 +3128,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3121 if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) { 3128 if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) {
3122 xs_html *loht = xs_html_tag("ul", 3129 xs_html *loht = xs_html_tag("ul",
3123 xs_html_attr("class", "snac-list-of-lists")); 3130 xs_html_attr("class", "snac-list-of-lists"));
3124 xs_html_add(body, loht); 3131 xs_html_add(main, loht);
3125 3132
3126 const char *ht; 3133 const char *ht;
3127 3134
@@ -3145,7 +3152,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3145 } 3152 }
3146 } 3153 }
3147 3154
3148 xs_html_add(body, 3155 xs_html_add(main,
3149 xs_html_tag("a", 3156 xs_html_tag("a",
3150 xs_html_attr("name", "snac-posts"))); 3157 xs_html_attr("name", "snac-posts")));
3151 3158
@@ -3159,7 +3166,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3159 xs_html_text(title))); 3166 xs_html_text(title)));
3160 } 3167 }
3161 3168
3162 xs_html_add(body, posts); 3169 xs_html_add(main, posts);
3163 3170
3164 int mark_shown = 0; 3171 int mark_shown = 0;
3165 3172
@@ -3259,14 +3266,14 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3259 xs_html_text(fn)))); 3266 xs_html_text(fn))));
3260 } 3267 }
3261 3268
3262 xs_html_add(body, 3269 xs_html_add(main,
3263 history); 3270 history);
3264 } 3271 }
3265 } 3272 }
3266 3273
3267 { 3274 {
3268 xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t); 3275 xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t);
3269 xs_html_add(body, 3276 xs_html_add(main,
3270 xs_html_raw(s1)); 3277 xs_html_raw(s1));
3271 } 3278 }
3272 3279
@@ -3295,13 +3302,10 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3295 xs_html_attr("name", "snac-more"), 3302 xs_html_attr("name", "snac-more"),
3296 xs_html_text(L("More...")))); 3303 xs_html_text(L("More..."))));
3297 3304
3298 xs_html_add(body, 3305 xs_html_add(main,
3299 more_links); 3306 more_links);
3300 } 3307 }
3301 3308
3302 xs_html_add(body,
3303 html_footer(user));
3304
3305 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3309 return xs_html_render_s(html, "<!DOCTYPE html>\n");
3306} 3310}
3307 3311
@@ -3474,8 +3478,10 @@ xs_str *html_people(snac *user)
3474 3478
3475 xs_html *html = xs_html_tag("html", 3479 xs_html *html = xs_html_tag("html",
3476 html_user_head(user, NULL, NULL), 3480 html_user_head(user, NULL, NULL),
3477 xs_html_add(html_user_body(user, 0), 3481 xs_html_tag("body",
3478 lists, 3482 html_user_header(user, 0),
3483 xs_html_add(html_user_main(user, 0),
3484 lists),
3479 html_footer(user))); 3485 html_footer(user)));
3480 3486
3481 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3487 return xs_html_render_s(html, "<!DOCTYPE html>\n");
@@ -3492,15 +3498,18 @@ xs_str *html_notifications(snac *user, int skip, int show)
3492 xs *n_list = notify_list(user, skip, show); 3498 xs *n_list = notify_list(user, skip, show);
3493 xs *n_time = notify_check_time(user, 0); 3499 xs *n_time = notify_check_time(user, 0);
3494 3500
3495 xs_html *body = html_user_body(user, 0); 3501 xs_html *main = html_user_main(user, 0);
3496 3502
3497 xs_html *html = xs_html_tag("html", 3503 xs_html *html = xs_html_tag("html",
3498 html_user_head(user, NULL, NULL), 3504 html_user_head(user, NULL, NULL),
3499 body); 3505 xs_html_tag("body",
3506 html_user_header(user, 0),
3507 main,
3508 html_footer(user)));
3500 3509
3501 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); 3510 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor);
3502 3511
3503 xs_html_add(body, 3512 xs_html_add(main,
3504 xs_html_tag("form", 3513 xs_html_tag("form",
3505 xs_html_attr("autocomplete", "off"), 3514 xs_html_attr("autocomplete", "off"),
3506 xs_html_attr("method", "post"), 3515 xs_html_attr("method", "post"),
@@ -3516,7 +3525,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3516 3525
3517 xs_html *posts = xs_html_tag("div", 3526 xs_html *posts = xs_html_tag("div",
3518 xs_html_attr("class", "snac-posts")); 3527 xs_html_attr("class", "snac-posts"));
3519 xs_html_add(body, posts); 3528 xs_html_add(main, posts);
3520 3529
3521 xs_set rep; 3530 xs_set rep;
3522 xs_set_init(&rep); 3531 xs_set_init(&rep);
@@ -3717,7 +3726,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3717 } 3726 }
3718 3727
3719 if (noti_new == NULL && noti_seen == NULL) 3728 if (noti_new == NULL && noti_seen == NULL)
3720 xs_html_add(body, 3729 xs_html_add(main,
3721 xs_html_tag("h2", 3730 xs_html_tag("h2",
3722 xs_html_attr("class", "snac-header"), 3731 xs_html_attr("class", "snac-header"),
3723 xs_html_text(L("None")))); 3732 xs_html_text(L("None"))));
@@ -3728,7 +3737,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3728 xs *url = xs_fmt("%s/notifications?skip=%d&show=%d", 3737 xs *url = xs_fmt("%s/notifications?skip=%d&show=%d",
3729 user->actor, skip + show, show); 3738 user->actor, skip + show, show);
3730 3739
3731 xs_html_add(body, 3740 xs_html_add(main,
3732 xs_html_tag("p", 3741 xs_html_tag("p",
3733 xs_html_tag("a", 3742 xs_html_tag("a",
3734 xs_html_attr("href", url), 3743 xs_html_attr("href", url),
@@ -3737,9 +3746,6 @@ xs_str *html_notifications(snac *user, int skip, int show)
3737 3746
3738 xs_set_free(&rep); 3747 xs_set_free(&rep);
3739 3748
3740 xs_html_add(body,
3741 html_footer(user));
3742
3743 /* set the check time to now */ 3749 /* set the check time to now */
3744 xs *dummy = notify_check_time(user, 1); 3750 xs *dummy = notify_check_time(user, 1);
3745 dummy = xs_free(dummy); 3751 dummy = xs_free(dummy);
@@ -4010,9 +4016,11 @@ int html_get_handler(const xs_dict *req, const char *q_path,
4010 4016
4011 xs_html *html = xs_html_tag("html", 4017 xs_html *html = xs_html_tag("html",
4012 html_user_head(&snac, NULL, NULL), 4018 html_user_head(&snac, NULL, NULL),
4013 xs_html_add(html_user_body(&snac, 0), 4019 xs_html_tag("body",
4014 page, 4020 html_user_header(&snac, 0),
4015 html_footer(user))); 4021 xs_html_add(html_user_main(&snac, 0),
4022 page),
4023 html_footer(user)));
4016 4024
4017 *body = xs_html_render_s(html, "<!DOCTYPE html>\n"); 4025 *body = xs_html_render_s(html, "<!DOCTYPE html>\n");
4018 *b_size = strlen(*body); 4026 *b_size = strlen(*body);