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-05-23 21:13:22 +0000
commitb934b8b2418234f797215c33b0ffb4b90043bdb7 (patch)
tree456a02c0a80b812ff3559aa0ac7d631536bfda4e /html.c
parentCommit my version of the stylesheet (diff)
downloadpenes-snac2-b934b8b2418234f797215c33b0ffb4b90043bdb7.tar.gz
penes-snac2-b934b8b2418234f797215c33b0ffb4b90043bdb7.tar.xz
penes-snac2-b934b8b2418234f797215c33b0ffb4b90043bdb7.zip
Modified generated HTML to match my stylesheet ehheh
Diffstat (limited to 'html.c')
-rw-r--r--html.c124
1 files changed, 66 insertions, 58 deletions
diff --git a/html.c b/html.c
index d807f4b..bcd71aa 100644
--- a/html.c
+++ b/html.c
@@ -854,18 +854,10 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url)
854} 854}
855 855
856 856
857static xs_html *html_user_body(snac *user, int read_only) 857static xs_html *html_user_header(snac *user, int read_only)
858{ 858{
859 const char *proxy = NULL;
860
861 if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media")))
862 proxy = user->actor;
863
864 xs_html *body = xs_html_tag("body", NULL);
865
866 /* top nav */ 859 /* top nav */
867 xs_html *top_nav = xs_html_tag("nav", 860 xs_html *top_nav = xs_html_tag("header", NULL);
868 xs_html_attr("class", "snac-top-nav"));
869 861
870 xs *avatar = xs_dup(xs_dict_get(user->config, "avatar")); 862 xs *avatar = xs_dup(xs_dict_get(user->config, "avatar"));
871 863
@@ -877,7 +869,6 @@ static xs_html *html_user_body(snac *user, int read_only)
877 xs_html_add(top_nav, 869 xs_html_add(top_nav,
878 xs_html_sctag("img", 870 xs_html_sctag("img",
879 xs_html_attr("src", avatar), 871 xs_html_attr("src", avatar),
880 xs_html_attr("class", "snac-avatar"),
881 xs_html_attr("alt", ""))); 872 xs_html_attr("alt", "")));
882 873
883 if (read_only) { 874 if (read_only) {
@@ -946,8 +937,18 @@ static xs_html *html_user_body(snac *user, int read_only)
946 xs_html_attr("placeholder", L("Content search"))))); 937 xs_html_attr("placeholder", L("Content search")))));
947 } 938 }
948 939
949 xs_html_add(body, 940 return top_nav;
950 top_nav); 941}
942
943
944static xs_html *html_user_main(snac *user, int read_only)
945{
946 const char *proxy = NULL;
947
948 if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media")))
949 proxy = user->actor;
950
951 xs_html *main = xs_html_tag("main", NULL);
951 952
952 /* user info */ 953 /* user info */
953 xs_html *top_user = xs_html_tag("div", 954 xs_html *top_user = xs_html_tag("div",
@@ -1142,10 +1143,10 @@ static xs_html *html_user_body(snac *user, int read_only)
1142 } 1143 }
1143 } 1144 }
1144 1145
1145 xs_html_add(body, 1146 xs_html_add(main,
1146 top_user); 1147 top_user);
1147 1148
1148 return body; 1149 return main;
1149} 1150}
1150 1151
1151 1152
@@ -2781,18 +2782,18 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2781 2782
2782xs_html *html_footer(const snac *user) 2783xs_html *html_footer(const snac *user)
2783{ 2784{
2784 return xs_html_tag("div", 2785 return xs_html_tag("footer",
2785 xs_html_attr("class", "snac-footer"), 2786 xs_html_tag("p",
2786 xs_html_tag("a", 2787 xs_html_tag("a",
2787 xs_html_attr("href", srv_baseurl), 2788 xs_html_attr("href", srv_baseurl),
2788 xs_html_text(L("about this site"))), 2789 xs_html_text(L("about this site"))),
2789 xs_html_text(" - "), 2790 xs_html_text(" - "),
2790 xs_html_text(L("powered by ")), 2791 xs_html_text(L("powered by ")),
2791 xs_html_tag("a", 2792 xs_html_tag("a",
2792 xs_html_attr("href", WHAT_IS_SNAC_URL), 2793 xs_html_attr("href", WHAT_IS_SNAC_URL),
2793 xs_html_tag("abbr", 2794 xs_html_tag("abbr",
2794 xs_html_attr("title", "Social Networks Are Crap"), 2795 xs_html_attr("title", "Social Networks Are Crap"),
2795 xs_html_text("snac")))); 2796 xs_html_text("snac")))));
2796} 2797}
2797 2798
2798 2799
@@ -2823,27 +2824,33 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2823 } 2824 }
2824 2825
2825 xs_html *head; 2826 xs_html *head;
2826 xs_html *body; 2827 xs_html *header;
2828 xs_html *main;
2827 2829
2828 if (user) { 2830 if (user) {
2829 head = html_user_head(user, desc, alternate); 2831 head = html_user_head(user, desc, alternate);
2830 body = html_user_body(user, read_only); 2832 header = html_user_header(user, read_only);
2833 main = html_user_main(user, read_only);
2831 } 2834 }
2832 else { 2835 else {
2833 head = html_instance_head(); 2836 head = html_instance_head();
2834 body = html_instance_body(); 2837 header = xs_html_tag("header", NULL);
2838 main = html_instance_body();
2835 } 2839 }
2836 2840
2837 xs_html *html = xs_html_tag("html", 2841 xs_html *html = xs_html_tag("html",
2838 head, 2842 head,
2839 body); 2843 xs_html_tag("body",
2844 header,
2845 main,
2846 html_footer(user)));
2840 2847
2841 if (user && !read_only) 2848 if (user && !read_only)
2842 xs_html_add(body, 2849 xs_html_add(main,
2843 html_top_controls(user)); 2850 html_top_controls(user));
2844 2851
2845 if (error != NULL) { 2852 if (error != NULL) {
2846 xs_html_add(body, 2853 xs_html_add(main,
2847 xs_html_tag("dialog", 2854 xs_html_tag("dialog",
2848 xs_html_attr("open", NULL), 2855 xs_html_attr("open", NULL),
2849 xs_html_tag("p", 2856 xs_html_tag("p",
@@ -2859,7 +2866,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2859 if (user && !read_only) { 2866 if (user && !read_only) {
2860 xs_html *lol = xs_html_tag("ul", 2867 xs_html *lol = xs_html_tag("ul",
2861 xs_html_attr("class", "snac-list-of-lists")); 2868 xs_html_attr("class", "snac-list-of-lists"));
2862 xs_html_add(body, lol); 2869 xs_html_add(main, lol);
2863 2870
2864 xs *lists = list_maint(user, NULL, 0); /* get list of lists */ 2871 xs *lists = list_maint(user, NULL, 0); /* get list of lists */
2865 2872
@@ -2934,7 +2941,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2934 if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) { 2941 if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) {
2935 xs_html *loht = xs_html_tag("ul", 2942 xs_html *loht = xs_html_tag("ul",
2936 xs_html_attr("class", "snac-list-of-lists")); 2943 xs_html_attr("class", "snac-list-of-lists"));
2937 xs_html_add(body, loht); 2944 xs_html_add(main, loht);
2938 2945
2939 const char *ht; 2946 const char *ht;
2940 2947
@@ -2952,7 +2959,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2952 } 2959 }
2953 } 2960 }
2954 2961
2955 xs_html_add(body, 2962 xs_html_add(main,
2956 xs_html_tag("a", 2963 xs_html_tag("a",
2957 xs_html_attr("name", "snac-posts"))); 2964 xs_html_attr("name", "snac-posts")));
2958 2965
@@ -2966,7 +2973,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2966 xs_html_text(title))); 2973 xs_html_text(title)));
2967 } 2974 }
2968 2975
2969 xs_html_add(body, 2976 xs_html_add(main,
2970 posts); 2977 posts);
2971 2978
2972 int mark_shown = 0; 2979 int mark_shown = 0;
@@ -3058,14 +3065,14 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3058 xs_html_text(fn)))); 3065 xs_html_text(fn))));
3059 } 3066 }
3060 3067
3061 xs_html_add(body, 3068 xs_html_add(main,
3062 history); 3069 history);
3063 } 3070 }
3064 } 3071 }
3065 3072
3066 { 3073 {
3067 xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t); 3074 xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t);
3068 xs_html_add(body, 3075 xs_html_add(main,
3069 xs_html_raw(s1)); 3076 xs_html_raw(s1));
3070 } 3077 }
3071 3078
@@ -3094,13 +3101,10 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3094 xs_html_attr("name", "snac-more"), 3101 xs_html_attr("name", "snac-more"),
3095 xs_html_text(L("More...")))); 3102 xs_html_text(L("More..."))));
3096 3103
3097 xs_html_add(body, 3104 xs_html_add(main,
3098 more_links); 3105 more_links);
3099 } 3106 }
3100 3107
3101 xs_html_add(body,
3102 html_footer(user));
3103
3104 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3108 return xs_html_render_s(html, "<!DOCTYPE html>\n");
3105} 3109}
3106 3110
@@ -3266,8 +3270,10 @@ xs_str *html_people(snac *user)
3266 3270
3267 xs_html *html = xs_html_tag("html", 3271 xs_html *html = xs_html_tag("html",
3268 html_user_head(user, NULL, NULL), 3272 html_user_head(user, NULL, NULL),
3269 xs_html_add(html_user_body(user, 0), 3273 xs_html_tag("body",
3270 lists, 3274 html_user_header(user, 0),
3275 xs_html_add(html_user_main(user, 0),
3276 lists),
3271 html_footer(user))); 3277 html_footer(user)));
3272 3278
3273 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3279 return xs_html_render_s(html, "<!DOCTYPE html>\n");
@@ -3284,15 +3290,18 @@ xs_str *html_notifications(snac *user, int skip, int show)
3284 xs *n_list = notify_list(user, skip, show); 3290 xs *n_list = notify_list(user, skip, show);
3285 xs *n_time = notify_check_time(user, 0); 3291 xs *n_time = notify_check_time(user, 0);
3286 3292
3287 xs_html *body = html_user_body(user, 0); 3293 xs_html *main = html_user_main(user, 0);
3288 3294
3289 xs_html *html = xs_html_tag("html", 3295 xs_html *html = xs_html_tag("html",
3290 html_user_head(user, NULL, NULL), 3296 html_user_head(user, NULL, NULL),
3291 body); 3297 xs_html_tag("body",
3298 html_user_header(user, 0),
3299 main,
3300 html_footer(user)));
3292 3301
3293 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); 3302 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor);
3294 3303
3295 xs_html_add(body, 3304 xs_html_add(main,
3296 xs_html_tag("form", 3305 xs_html_tag("form",
3297 xs_html_attr("autocomplete", "off"), 3306 xs_html_attr("autocomplete", "off"),
3298 xs_html_attr("method", "post"), 3307 xs_html_attr("method", "post"),
@@ -3308,7 +3317,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3308 3317
3309 xs_html *posts = xs_html_tag("div", 3318 xs_html *posts = xs_html_tag("div",
3310 xs_html_attr("class", "snac-posts")); 3319 xs_html_attr("class", "snac-posts"));
3311 xs_html_add(body, posts); 3320 xs_html_add(main, posts);
3312 3321
3313 xs_set rep; 3322 xs_set rep;
3314 xs_set_init(&rep); 3323 xs_set_init(&rep);
@@ -3497,7 +3506,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3497 } 3506 }
3498 3507
3499 if (noti_new == NULL && noti_seen == NULL) 3508 if (noti_new == NULL && noti_seen == NULL)
3500 xs_html_add(body, 3509 xs_html_add(main,
3501 xs_html_tag("h2", 3510 xs_html_tag("h2",
3502 xs_html_attr("class", "snac-header"), 3511 xs_html_attr("class", "snac-header"),
3503 xs_html_text(L("None")))); 3512 xs_html_text(L("None"))));
@@ -3508,7 +3517,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3508 xs *url = xs_fmt("%s/notifications?skip=%d&show=%d", 3517 xs *url = xs_fmt("%s/notifications?skip=%d&show=%d",
3509 user->actor, skip + show, show); 3518 user->actor, skip + show, show);
3510 3519
3511 xs_html_add(body, 3520 xs_html_add(main,
3512 xs_html_tag("p", 3521 xs_html_tag("p",
3513 xs_html_tag("a", 3522 xs_html_tag("a",
3514 xs_html_attr("href", url), 3523 xs_html_attr("href", url),
@@ -3517,9 +3526,6 @@ xs_str *html_notifications(snac *user, int skip, int show)
3517 3526
3518 xs_set_free(&rep); 3527 xs_set_free(&rep);
3519 3528
3520 xs_html_add(body,
3521 html_footer(user));
3522
3523 /* set the check time to now */ 3529 /* set the check time to now */
3524 xs *dummy = notify_check_time(user, 1); 3530 xs *dummy = notify_check_time(user, 1);
3525 dummy = xs_free(dummy); 3531 dummy = xs_free(dummy);
@@ -3682,7 +3688,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
3682 3688
3683 if (xs_is_true(xs_dict_get(srv_config, "strict_public_timelines"))) 3689 if (xs_is_true(xs_dict_get(srv_config, "strict_public_timelines")))
3684 list = timeline_simple_list(&snac, "public", skip, show, &more); 3690 list = timeline_simple_list(&snac, "public", skip, show, &more);
3685 else 3691 else
3686 list = timeline_list(&snac, "public", skip, show, &more); 3692 list = timeline_list(&snac, "public", skip, show, &more);
3687 3693
3688 xs *pins = pinned_list(&snac); 3694 xs *pins = pinned_list(&snac);
@@ -3783,9 +3789,11 @@ int html_get_handler(const xs_dict *req, const char *q_path,
3783 3789
3784 xs_html *html = xs_html_tag("html", 3790 xs_html *html = xs_html_tag("html",
3785 html_user_head(&snac, NULL, NULL), 3791 html_user_head(&snac, NULL, NULL),
3786 xs_html_add(html_user_body(&snac, 0), 3792 xs_html_tag("body",
3787 page, 3793 html_user_header(&snac, 0),
3788 html_footer(user))); 3794 xs_html_add(html_user_main(&snac, 0),
3795 page),
3796 html_footer(user)));
3789 3797
3790 *body = xs_html_render_s(html, "<!DOCTYPE html>\n"); 3798 *body = xs_html_render_s(html, "<!DOCTYPE html>\n");
3791 *b_size = strlen(*body); 3799 *b_size = strlen(*body);