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-08-01 22:19:11 +0000
commit090f9cdfb9a4b65c0de07da2ab2d14260b24cf81 (patch)
treef9a17d9580cc17a9d4e1c7c8471220e0bd869429 /html.c
parentCommit my version of the stylesheet (diff)
downloadpenes-snac2-090f9cdfb9a4b65c0de07da2ab2d14260b24cf81.tar.gz
penes-snac2-090f9cdfb9a4b65c0de07da2ab2d14260b24cf81.tar.xz
penes-snac2-090f9cdfb9a4b65c0de07da2ab2d14260b24cf81.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 aeb6cb1..60cdb1c 100644
--- a/html.c
+++ b/html.c
@@ -880,18 +880,10 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url)
880} 880}
881 881
882 882
883static xs_html *html_user_body(snac *user, int read_only) 883static 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
982static 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
2845xs_html *html_footer(const snac *user) 2846xs_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
@@ -3021,7 +3028,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3021 } 3028 }
3022 } 3029 }
3023 3030
3024 xs_html_add(body, 3031 xs_html_add(main,
3025 xs_html_tag("a", 3032 xs_html_tag("a",
3026 xs_html_attr("name", "snac-posts"))); 3033 xs_html_attr("name", "snac-posts")));
3027 3034
@@ -3035,7 +3042,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3035 xs_html_text(title))); 3042 xs_html_text(title)));
3036 } 3043 }
3037 3044
3038 xs_html_add(body, 3045 xs_html_add(main,
3039 posts); 3046 posts);
3040 3047
3041 int mark_shown = 0; 3048 int mark_shown = 0;
@@ -3127,14 +3134,14 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3127 xs_html_text(fn)))); 3134 xs_html_text(fn))));
3128 } 3135 }
3129 3136
3130 xs_html_add(body, 3137 xs_html_add(main,
3131 history); 3138 history);
3132 } 3139 }
3133 } 3140 }
3134 3141
3135 { 3142 {
3136 xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t); 3143 xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t);
3137 xs_html_add(body, 3144 xs_html_add(main,
3138 xs_html_raw(s1)); 3145 xs_html_raw(s1));
3139 } 3146 }
3140 3147
@@ -3163,13 +3170,10 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3163 xs_html_attr("name", "snac-more"), 3170 xs_html_attr("name", "snac-more"),
3164 xs_html_text(L("More...")))); 3171 xs_html_text(L("More..."))));
3165 3172
3166 xs_html_add(body, 3173 xs_html_add(main,
3167 more_links); 3174 more_links);
3168 } 3175 }
3169 3176
3170 xs_html_add(body,
3171 html_footer(user));
3172
3173 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3177 return xs_html_render_s(html, "<!DOCTYPE html>\n");
3174} 3178}
3175 3179
@@ -3342,8 +3346,10 @@ xs_str *html_people(snac *user)
3342 3346
3343 xs_html *html = xs_html_tag("html", 3347 xs_html *html = xs_html_tag("html",
3344 html_user_head(user, NULL, NULL), 3348 html_user_head(user, NULL, NULL),
3345 xs_html_add(html_user_body(user, 0), 3349 xs_html_tag("body",
3346 lists, 3350 html_user_header(user, 0),
3351 xs_html_add(html_user_main(user, 0),
3352 lists),
3347 html_footer(user))); 3353 html_footer(user)));
3348 3354
3349 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3355 return xs_html_render_s(html, "<!DOCTYPE html>\n");
@@ -3360,15 +3366,18 @@ xs_str *html_notifications(snac *user, int skip, int show)
3360 xs *n_list = notify_list(user, skip, show); 3366 xs *n_list = notify_list(user, skip, show);
3361 xs *n_time = notify_check_time(user, 0); 3367 xs *n_time = notify_check_time(user, 0);
3362 3368
3363 xs_html *body = html_user_body(user, 0); 3369 xs_html *main = html_user_main(user, 0);
3364 3370
3365 xs_html *html = xs_html_tag("html", 3371 xs_html *html = xs_html_tag("html",
3366 html_user_head(user, NULL, NULL), 3372 html_user_head(user, NULL, NULL),
3367 body); 3373 xs_html_tag("body",
3374 html_user_header(user, 0),
3375 main,
3376 html_footer(user)));
3368 3377
3369 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); 3378 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor);
3370 3379
3371 xs_html_add(body, 3380 xs_html_add(main,
3372 xs_html_tag("form", 3381 xs_html_tag("form",
3373 xs_html_attr("autocomplete", "off"), 3382 xs_html_attr("autocomplete", "off"),
3374 xs_html_attr("method", "post"), 3383 xs_html_attr("method", "post"),
@@ -3384,7 +3393,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3384 3393
3385 xs_html *posts = xs_html_tag("div", 3394 xs_html *posts = xs_html_tag("div",
3386 xs_html_attr("class", "snac-posts")); 3395 xs_html_attr("class", "snac-posts"));
3387 xs_html_add(body, posts); 3396 xs_html_add(main, posts);
3388 3397
3389 xs_set rep; 3398 xs_set rep;
3390 xs_set_init(&rep); 3399 xs_set_init(&rep);
@@ -3585,7 +3594,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3585 } 3594 }
3586 3595
3587 if (noti_new == NULL && noti_seen == NULL) 3596 if (noti_new == NULL && noti_seen == NULL)
3588 xs_html_add(body, 3597 xs_html_add(main,
3589 xs_html_tag("h2", 3598 xs_html_tag("h2",
3590 xs_html_attr("class", "snac-header"), 3599 xs_html_attr("class", "snac-header"),
3591 xs_html_text(L("None")))); 3600 xs_html_text(L("None"))));
@@ -3596,7 +3605,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3596 xs *url = xs_fmt("%s/notifications?skip=%d&show=%d", 3605 xs *url = xs_fmt("%s/notifications?skip=%d&show=%d",
3597 user->actor, skip + show, show); 3606 user->actor, skip + show, show);
3598 3607
3599 xs_html_add(body, 3608 xs_html_add(main,
3600 xs_html_tag("p", 3609 xs_html_tag("p",
3601 xs_html_tag("a", 3610 xs_html_tag("a",
3602 xs_html_attr("href", url), 3611 xs_html_attr("href", url),
@@ -3605,9 +3614,6 @@ xs_str *html_notifications(snac *user, int skip, int show)
3605 3614
3606 xs_set_free(&rep); 3615 xs_set_free(&rep);
3607 3616
3608 xs_html_add(body,
3609 html_footer(user));
3610
3611 /* set the check time to now */ 3617 /* set the check time to now */
3612 xs *dummy = notify_check_time(user, 1); 3618 xs *dummy = notify_check_time(user, 1);
3613 dummy = xs_free(dummy); 3619 dummy = xs_free(dummy);
@@ -3877,9 +3883,11 @@ int html_get_handler(const xs_dict *req, const char *q_path,
3877 3883
3878 xs_html *html = xs_html_tag("html", 3884 xs_html *html = xs_html_tag("html",
3879 html_user_head(&snac, NULL, NULL), 3885 html_user_head(&snac, NULL, NULL),
3880 xs_html_add(html_user_body(&snac, 0), 3886 xs_html_tag("body",
3881 page, 3887 html_user_header(&snac, 0),
3882 html_footer(user))); 3888 xs_html_add(html_user_main(&snac, 0),
3889 page),
3890 html_footer(user)));
3883 3891
3884 *body = xs_html_render_s(html, "<!DOCTYPE html>\n"); 3892 *body = xs_html_render_s(html, "<!DOCTYPE html>\n");
3885 *b_size = strlen(*body); 3893 *b_size = strlen(*body);