diff options
| author | 2025-04-18 06:45:58 +0000 | |
|---|---|---|
| committer | 2025-07-05 21:18:48 +0000 | |
| commit | c11bfae555e7fa0851bf2afada5e0d680c142f23 (patch) | |
| tree | abe59c46e00a1de863eb2d363beb99e60c782dce | |
| parent | Commit my version of the stylesheet (diff) | |
| download | penes-snac2-c11bfae555e7fa0851bf2afada5e0d680c142f23.tar.gz penes-snac2-c11bfae555e7fa0851bf2afada5e0d680c142f23.tar.xz penes-snac2-c11bfae555e7fa0851bf2afada5e0d680c142f23.zip | |
Modified generated HTML to match my stylesheet ehheh
| -rw-r--r-- | html.c | 122 |
1 files changed, 65 insertions, 57 deletions
| @@ -880,18 +880,10 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url) | |||
| 880 | } | 880 | } |
| 881 | 881 | ||
| 882 | 882 | ||
| 883 | static xs_html *html_user_body(snac *user, int read_only) | 883 | static xs_html *html_user_header(snac *user, int read_only) |
| 884 | { | 884 | { |
| 885 | const char *proxy = NULL; | ||
| 886 | |||
| 887 | if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media"))) | ||
| 888 | proxy = user->actor; | ||
| 889 | |||
| 890 | xs_html *body = xs_html_tag("body", NULL); | ||
| 891 | |||
| 892 | /* top nav */ | 885 | /* top nav */ |
| 893 | xs_html *top_nav = xs_html_tag("nav", | 886 | xs_html *top_nav = xs_html_tag("header", NULL); |
| 894 | xs_html_attr("class", "snac-top-nav")); | ||
| 895 | 887 | ||
| 896 | xs *avatar = xs_dup(xs_dict_get(user->config, "avatar")); | 888 | xs *avatar = xs_dup(xs_dict_get(user->config, "avatar")); |
| 897 | 889 | ||
| @@ -903,7 +895,6 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 903 | xs_html_add(top_nav, | 895 | xs_html_add(top_nav, |
| 904 | xs_html_sctag("img", | 896 | xs_html_sctag("img", |
| 905 | xs_html_attr("src", avatar), | 897 | xs_html_attr("src", avatar), |
| 906 | xs_html_attr("class", "snac-avatar"), | ||
| 907 | xs_html_attr("alt", ""))); | 898 | xs_html_attr("alt", ""))); |
| 908 | 899 | ||
| 909 | if (read_only) { | 900 | if (read_only) { |
| @@ -984,8 +975,18 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 984 | xs_html_attr("placeholder", L("Content search"))))); | 975 | xs_html_attr("placeholder", L("Content search"))))); |
| 985 | } | 976 | } |
| 986 | 977 | ||
| 987 | xs_html_add(body, | 978 | return top_nav; |
| 988 | top_nav); | 979 | } |
| 980 | |||
| 981 | |||
| 982 | static xs_html *html_user_main(snac *user, int read_only) | ||
| 983 | { | ||
| 984 | const char *proxy = NULL; | ||
| 985 | |||
| 986 | if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media"))) | ||
| 987 | proxy = user->actor; | ||
| 988 | |||
| 989 | xs_html *main = xs_html_tag("main", NULL); | ||
| 989 | 990 | ||
| 990 | /* user info */ | 991 | /* user info */ |
| 991 | xs_html *top_user = xs_html_tag("div", | 992 | xs_html *top_user = xs_html_tag("div", |
| @@ -1180,10 +1181,10 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 1180 | } | 1181 | } |
| 1181 | } | 1182 | } |
| 1182 | 1183 | ||
| 1183 | xs_html_add(body, | 1184 | xs_html_add(main, |
| 1184 | top_user); | 1185 | top_user); |
| 1185 | 1186 | ||
| 1186 | return body; | 1187 | return main; |
| 1187 | } | 1188 | } |
| 1188 | 1189 | ||
| 1189 | 1190 | ||
| @@ -2844,18 +2845,18 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2844 | 2845 | ||
| 2845 | xs_html *html_footer(const snac *user) | 2846 | xs_html *html_footer(const snac *user) |
| 2846 | { | 2847 | { |
| 2847 | return xs_html_tag("div", | 2848 | return xs_html_tag("footer", |
| 2848 | xs_html_attr("class", "snac-footer"), | 2849 | xs_html_tag("p", |
| 2849 | xs_html_tag("a", | 2850 | xs_html_tag("a", |
| 2850 | xs_html_attr("href", srv_baseurl), | 2851 | xs_html_attr("href", srv_baseurl), |
| 2851 | xs_html_text(L("about this site"))), | 2852 | xs_html_text(L("about this site"))), |
| 2852 | xs_html_text(" - "), | 2853 | xs_html_text(" - "), |
| 2853 | xs_html_text(L("powered by ")), | 2854 | xs_html_text(L("powered by ")), |
| 2854 | xs_html_tag("a", | 2855 | xs_html_tag("a", |
| 2855 | xs_html_attr("href", WHAT_IS_SNAC_URL), | 2856 | xs_html_attr("href", WHAT_IS_SNAC_URL), |
| 2856 | xs_html_tag("abbr", | 2857 | xs_html_tag("abbr", |
| 2857 | xs_html_attr("title", "Social Networks Are Crap"), | 2858 | xs_html_attr("title", "Social Networks Are Crap"), |
| 2858 | xs_html_text("snac")))); | 2859 | xs_html_text("snac"))))); |
| 2859 | } | 2860 | } |
| 2860 | 2861 | ||
| 2861 | 2862 | ||
| @@ -2886,27 +2887,33 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2886 | } | 2887 | } |
| 2887 | 2888 | ||
| 2888 | xs_html *head; | 2889 | xs_html *head; |
| 2889 | xs_html *body; | 2890 | xs_html *header; |
| 2891 | xs_html *main; | ||
| 2890 | 2892 | ||
| 2891 | if (user) { | 2893 | if (user) { |
| 2892 | head = html_user_head(user, desc, alternate); | 2894 | head = html_user_head(user, desc, alternate); |
| 2893 | body = html_user_body(user, read_only); | 2895 | header = html_user_header(user, read_only); |
| 2896 | main = html_user_main(user, read_only); | ||
| 2894 | } | 2897 | } |
| 2895 | else { | 2898 | else { |
| 2896 | head = html_instance_head(); | 2899 | head = html_instance_head(); |
| 2897 | body = html_instance_body(); | 2900 | header = xs_html_tag("header", NULL); |
| 2901 | main = html_instance_body(); | ||
| 2898 | } | 2902 | } |
| 2899 | 2903 | ||
| 2900 | xs_html *html = xs_html_tag("html", | 2904 | xs_html *html = xs_html_tag("html", |
| 2901 | head, | 2905 | head, |
| 2902 | body); | 2906 | xs_html_tag("body", |
| 2907 | header, | ||
| 2908 | main, | ||
| 2909 | html_footer(user))); | ||
| 2903 | 2910 | ||
| 2904 | if (user && !read_only) | 2911 | if (user && !read_only) |
| 2905 | xs_html_add(body, | 2912 | xs_html_add(main, |
| 2906 | html_top_controls(user)); | 2913 | html_top_controls(user)); |
| 2907 | 2914 | ||
| 2908 | if (error != NULL) { | 2915 | if (error != NULL) { |
| 2909 | xs_html_add(body, | 2916 | xs_html_add(main, |
| 2910 | xs_html_tag("dialog", | 2917 | xs_html_tag("dialog", |
| 2911 | xs_html_attr("open", NULL), | 2918 | xs_html_attr("open", NULL), |
| 2912 | xs_html_tag("p", | 2919 | xs_html_tag("p", |
| @@ -2922,7 +2929,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2922 | if (user && !read_only) { | 2929 | if (user && !read_only) { |
| 2923 | xs_html *lol = xs_html_tag("ul", | 2930 | xs_html *lol = xs_html_tag("ul", |
| 2924 | xs_html_attr("class", "snac-list-of-lists")); | 2931 | xs_html_attr("class", "snac-list-of-lists")); |
| 2925 | xs_html_add(body, lol); | 2932 | xs_html_add(main, lol); |
| 2926 | 2933 | ||
| 2927 | xs *lists = list_maint(user, NULL, 0); /* get list of lists */ | 2934 | xs *lists = list_maint(user, NULL, 0); /* get list of lists */ |
| 2928 | 2935 | ||
| @@ -2997,7 +3004,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2997 | if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) { | 3004 | if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) { |
| 2998 | xs_html *loht = xs_html_tag("ul", | 3005 | xs_html *loht = xs_html_tag("ul", |
| 2999 | xs_html_attr("class", "snac-list-of-lists")); | 3006 | xs_html_attr("class", "snac-list-of-lists")); |
| 3000 | xs_html_add(body, loht); | 3007 | xs_html_add(main, loht); |
| 3001 | 3008 | ||
| 3002 | const char *ht; | 3009 | const char *ht; |
| 3003 | 3010 | ||
| @@ -3015,7 +3022,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 3015 | } | 3022 | } |
| 3016 | } | 3023 | } |
| 3017 | 3024 | ||
| 3018 | xs_html_add(body, | 3025 | xs_html_add(main, |
| 3019 | xs_html_tag("a", | 3026 | xs_html_tag("a", |
| 3020 | xs_html_attr("name", "snac-posts"))); | 3027 | xs_html_attr("name", "snac-posts"))); |
| 3021 | 3028 | ||
| @@ -3029,7 +3036,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 3029 | xs_html_text(title))); | 3036 | xs_html_text(title))); |
| 3030 | } | 3037 | } |
| 3031 | 3038 | ||
| 3032 | xs_html_add(body, | 3039 | xs_html_add(main, |
| 3033 | posts); | 3040 | posts); |
| 3034 | 3041 | ||
| 3035 | int mark_shown = 0; | 3042 | int mark_shown = 0; |
| @@ -3121,14 +3128,14 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 3121 | xs_html_text(fn)))); | 3128 | xs_html_text(fn)))); |
| 3122 | } | 3129 | } |
| 3123 | 3130 | ||
| 3124 | xs_html_add(body, | 3131 | xs_html_add(main, |
| 3125 | history); | 3132 | history); |
| 3126 | } | 3133 | } |
| 3127 | } | 3134 | } |
| 3128 | 3135 | ||
| 3129 | { | 3136 | { |
| 3130 | xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t); | 3137 | xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t); |
| 3131 | xs_html_add(body, | 3138 | xs_html_add(main, |
| 3132 | xs_html_raw(s1)); | 3139 | xs_html_raw(s1)); |
| 3133 | } | 3140 | } |
| 3134 | 3141 | ||
| @@ -3157,13 +3164,10 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 3157 | xs_html_attr("name", "snac-more"), | 3164 | xs_html_attr("name", "snac-more"), |
| 3158 | xs_html_text(L("More...")))); | 3165 | xs_html_text(L("More...")))); |
| 3159 | 3166 | ||
| 3160 | xs_html_add(body, | 3167 | xs_html_add(main, |
| 3161 | more_links); | 3168 | more_links); |
| 3162 | } | 3169 | } |
| 3163 | 3170 | ||
| 3164 | xs_html_add(body, | ||
| 3165 | html_footer(user)); | ||
| 3166 | |||
| 3167 | return xs_html_render_s(html, "<!DOCTYPE html>\n"); | 3171 | return xs_html_render_s(html, "<!DOCTYPE html>\n"); |
| 3168 | } | 3172 | } |
| 3169 | 3173 | ||
| @@ -3336,8 +3340,10 @@ xs_str *html_people(snac *user) | |||
| 3336 | 3340 | ||
| 3337 | xs_html *html = xs_html_tag("html", | 3341 | xs_html *html = xs_html_tag("html", |
| 3338 | html_user_head(user, NULL, NULL), | 3342 | html_user_head(user, NULL, NULL), |
| 3339 | xs_html_add(html_user_body(user, 0), | 3343 | xs_html_tag("body", |
| 3340 | lists, | 3344 | html_user_header(user, 0), |
| 3345 | xs_html_add(html_user_main(user, 0), | ||
| 3346 | lists), | ||
| 3341 | html_footer(user))); | 3347 | html_footer(user))); |
| 3342 | 3348 | ||
| 3343 | return xs_html_render_s(html, "<!DOCTYPE html>\n"); | 3349 | return xs_html_render_s(html, "<!DOCTYPE html>\n"); |
| @@ -3354,15 +3360,18 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3354 | xs *n_list = notify_list(user, skip, show); | 3360 | xs *n_list = notify_list(user, skip, show); |
| 3355 | xs *n_time = notify_check_time(user, 0); | 3361 | xs *n_time = notify_check_time(user, 0); |
| 3356 | 3362 | ||
| 3357 | xs_html *body = html_user_body(user, 0); | 3363 | xs_html *main = html_user_main(user, 0); |
| 3358 | 3364 | ||
| 3359 | xs_html *html = xs_html_tag("html", | 3365 | xs_html *html = xs_html_tag("html", |
| 3360 | html_user_head(user, NULL, NULL), | 3366 | html_user_head(user, NULL, NULL), |
| 3361 | body); | 3367 | xs_html_tag("body", |
| 3368 | html_user_header(user, 0), | ||
| 3369 | main, | ||
| 3370 | html_footer(user))); | ||
| 3362 | 3371 | ||
| 3363 | xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); | 3372 | xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); |
| 3364 | 3373 | ||
| 3365 | xs_html_add(body, | 3374 | xs_html_add(main, |
| 3366 | xs_html_tag("form", | 3375 | xs_html_tag("form", |
| 3367 | xs_html_attr("autocomplete", "off"), | 3376 | xs_html_attr("autocomplete", "off"), |
| 3368 | xs_html_attr("method", "post"), | 3377 | xs_html_attr("method", "post"), |
| @@ -3378,7 +3387,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3378 | 3387 | ||
| 3379 | xs_html *posts = xs_html_tag("div", | 3388 | xs_html *posts = xs_html_tag("div", |
| 3380 | xs_html_attr("class", "snac-posts")); | 3389 | xs_html_attr("class", "snac-posts")); |
| 3381 | xs_html_add(body, posts); | 3390 | xs_html_add(main, posts); |
| 3382 | 3391 | ||
| 3383 | xs_set rep; | 3392 | xs_set rep; |
| 3384 | xs_set_init(&rep); | 3393 | xs_set_init(&rep); |
| @@ -3579,7 +3588,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3579 | } | 3588 | } |
| 3580 | 3589 | ||
| 3581 | if (noti_new == NULL && noti_seen == NULL) | 3590 | if (noti_new == NULL && noti_seen == NULL) |
| 3582 | xs_html_add(body, | 3591 | xs_html_add(main, |
| 3583 | xs_html_tag("h2", | 3592 | xs_html_tag("h2", |
| 3584 | xs_html_attr("class", "snac-header"), | 3593 | xs_html_attr("class", "snac-header"), |
| 3585 | xs_html_text(L("None")))); | 3594 | xs_html_text(L("None")))); |
| @@ -3590,7 +3599,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3590 | xs *url = xs_fmt("%s/notifications?skip=%d&show=%d", | 3599 | xs *url = xs_fmt("%s/notifications?skip=%d&show=%d", |
| 3591 | user->actor, skip + show, show); | 3600 | user->actor, skip + show, show); |
| 3592 | 3601 | ||
| 3593 | xs_html_add(body, | 3602 | xs_html_add(main, |
| 3594 | xs_html_tag("p", | 3603 | xs_html_tag("p", |
| 3595 | xs_html_tag("a", | 3604 | xs_html_tag("a", |
| 3596 | xs_html_attr("href", url), | 3605 | xs_html_attr("href", url), |
| @@ -3599,9 +3608,6 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3599 | 3608 | ||
| 3600 | xs_set_free(&rep); | 3609 | xs_set_free(&rep); |
| 3601 | 3610 | ||
| 3602 | xs_html_add(body, | ||
| 3603 | html_footer(user)); | ||
| 3604 | |||
| 3605 | /* set the check time to now */ | 3611 | /* set the check time to now */ |
| 3606 | xs *dummy = notify_check_time(user, 1); | 3612 | xs *dummy = notify_check_time(user, 1); |
| 3607 | dummy = xs_free(dummy); | 3613 | dummy = xs_free(dummy); |
| @@ -3871,9 +3877,11 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3871 | 3877 | ||
| 3872 | xs_html *html = xs_html_tag("html", | 3878 | xs_html *html = xs_html_tag("html", |
| 3873 | html_user_head(&snac, NULL, NULL), | 3879 | html_user_head(&snac, NULL, NULL), |
| 3874 | xs_html_add(html_user_body(&snac, 0), | 3880 | xs_html_tag("body", |
| 3875 | page, | 3881 | html_user_header(&snac, 0), |
| 3876 | html_footer(user))); | 3882 | xs_html_add(html_user_main(&snac, 0), |
| 3883 | page), | ||
| 3884 | html_footer(user))); | ||
| 3877 | 3885 | ||
| 3878 | *body = xs_html_render_s(html, "<!DOCTYPE html>\n"); | 3886 | *body = xs_html_render_s(html, "<!DOCTYPE html>\n"); |
| 3879 | *b_size = strlen(*body); | 3887 | *b_size = strlen(*body); |