summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html.c122
1 files changed, 65 insertions, 57 deletions
diff --git a/html.c b/html.c
index aec7d0a..911e670 100644
--- a/html.c
+++ b/html.c
@@ -881,18 +881,10 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url)
881} 881}
882 882
883 883
884static xs_html *html_user_body(snac *user, int read_only) 884static xs_html *html_user_header(snac *user, int read_only)
885{ 885{
886 const char *proxy = NULL;
887
888 if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media")))
889 proxy = user->actor;
890
891 xs_html *body = xs_html_tag("body", NULL);
892
893 /* top nav */ 886 /* top nav */
894 xs_html *top_nav = xs_html_tag("nav", 887 xs_html *top_nav = xs_html_tag("header", NULL);
895 xs_html_attr("class", "snac-top-nav"));
896 888
897 xs *avatar = xs_dup(xs_dict_get(user->config, "avatar")); 889 xs *avatar = xs_dup(xs_dict_get(user->config, "avatar"));
898 890
@@ -904,7 +896,6 @@ static xs_html *html_user_body(snac *user, int read_only)
904 xs_html_add(top_nav, 896 xs_html_add(top_nav,
905 xs_html_sctag("img", 897 xs_html_sctag("img",
906 xs_html_attr("src", avatar), 898 xs_html_attr("src", avatar),
907 xs_html_attr("class", "snac-avatar"),
908 xs_html_attr("alt", ""))); 899 xs_html_attr("alt", "")));
909 900
910 if (read_only) { 901 if (read_only) {
@@ -973,8 +964,18 @@ static xs_html *html_user_body(snac *user, int read_only)
973 xs_html_attr("placeholder", L("Content search"))))); 964 xs_html_attr("placeholder", L("Content search")))));
974 } 965 }
975 966
976 xs_html_add(body, 967 return top_nav;
977 top_nav); 968}
969
970
971static xs_html *html_user_main(snac *user, int read_only)
972{
973 const char *proxy = NULL;
974
975 if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media")))
976 proxy = user->actor;
977
978 xs_html *main = xs_html_tag("main", NULL);
978 979
979 /* user info */ 980 /* user info */
980 xs_html *top_user = xs_html_tag("div", 981 xs_html *top_user = xs_html_tag("div",
@@ -1166,10 +1167,10 @@ static xs_html *html_user_body(snac *user, int read_only)
1166 } 1167 }
1167 } 1168 }
1168 1169
1169 xs_html_add(body, 1170 xs_html_add(main,
1170 top_user); 1171 top_user);
1171 1172
1172 return body; 1173 return main;
1173} 1174}
1174 1175
1175 1176
@@ -2801,18 +2802,18 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2801 2802
2802xs_html *html_footer(const snac *user) 2803xs_html *html_footer(const snac *user)
2803{ 2804{
2804 return xs_html_tag("div", 2805 return xs_html_tag("footer",
2805 xs_html_attr("class", "snac-footer"), 2806 xs_html_tag("p",
2806 xs_html_tag("a", 2807 xs_html_tag("a",
2807 xs_html_attr("href", srv_baseurl), 2808 xs_html_attr("href", srv_baseurl),
2808 xs_html_text(L("about this site"))), 2809 xs_html_text(L("about this site"))),
2809 xs_html_text(" - "), 2810 xs_html_text(" - "),
2810 xs_html_text(L("powered by ")), 2811 xs_html_text(L("powered by ")),
2811 xs_html_tag("a", 2812 xs_html_tag("a",
2812 xs_html_attr("href", WHAT_IS_SNAC_URL), 2813 xs_html_attr("href", WHAT_IS_SNAC_URL),
2813 xs_html_tag("abbr", 2814 xs_html_tag("abbr",
2814 xs_html_attr("title", "Social Networks Are Crap"), 2815 xs_html_attr("title", "Social Networks Are Crap"),
2815 xs_html_text("snac")))); 2816 xs_html_text("snac")))));
2816} 2817}
2817 2818
2818 2819
@@ -2843,27 +2844,33 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2843 } 2844 }
2844 2845
2845 xs_html *head; 2846 xs_html *head;
2846 xs_html *body; 2847 xs_html *header;
2848 xs_html *main;
2847 2849
2848 if (user) { 2850 if (user) {
2849 head = html_user_head(user, desc, alternate); 2851 head = html_user_head(user, desc, alternate);
2850 body = html_user_body(user, read_only); 2852 header = html_user_header(user, read_only);
2853 main = html_user_main(user, read_only);
2851 } 2854 }
2852 else { 2855 else {
2853 head = html_instance_head(); 2856 head = html_instance_head();
2854 body = html_instance_body(); 2857 header = xs_html_tag("header", NULL);
2858 main = html_instance_body();
2855 } 2859 }
2856 2860
2857 xs_html *html = xs_html_tag("html", 2861 xs_html *html = xs_html_tag("html",
2858 head, 2862 head,
2859 body); 2863 xs_html_tag("body",
2864 header,
2865 main,
2866 html_footer(user)));
2860 2867
2861 if (user && !read_only) 2868 if (user && !read_only)
2862 xs_html_add(body, 2869 xs_html_add(main,
2863 html_top_controls(user)); 2870 html_top_controls(user));
2864 2871
2865 if (error != NULL) { 2872 if (error != NULL) {
2866 xs_html_add(body, 2873 xs_html_add(main,
2867 xs_html_tag("dialog", 2874 xs_html_tag("dialog",
2868 xs_html_attr("open", NULL), 2875 xs_html_attr("open", NULL),
2869 xs_html_tag("p", 2876 xs_html_tag("p",
@@ -2879,7 +2886,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2879 if (user && !read_only) { 2886 if (user && !read_only) {
2880 xs_html *lol = xs_html_tag("ul", 2887 xs_html *lol = xs_html_tag("ul",
2881 xs_html_attr("class", "snac-list-of-lists")); 2888 xs_html_attr("class", "snac-list-of-lists"));
2882 xs_html_add(body, lol); 2889 xs_html_add(main, lol);
2883 2890
2884 xs *lists = list_maint(user, NULL, 0); /* get list of lists */ 2891 xs *lists = list_maint(user, NULL, 0); /* get list of lists */
2885 2892
@@ -2954,7 +2961,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2954 if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) { 2961 if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) {
2955 xs_html *loht = xs_html_tag("ul", 2962 xs_html *loht = xs_html_tag("ul",
2956 xs_html_attr("class", "snac-list-of-lists")); 2963 xs_html_attr("class", "snac-list-of-lists"));
2957 xs_html_add(body, loht); 2964 xs_html_add(main, loht);
2958 2965
2959 const char *ht; 2966 const char *ht;
2960 2967
@@ -2972,7 +2979,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2972 } 2979 }
2973 } 2980 }
2974 2981
2975 xs_html_add(body, 2982 xs_html_add(main,
2976 xs_html_tag("a", 2983 xs_html_tag("a",
2977 xs_html_attr("name", "snac-posts"))); 2984 xs_html_attr("name", "snac-posts")));
2978 2985
@@ -2986,7 +2993,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2986 xs_html_text(title))); 2993 xs_html_text(title)));
2987 } 2994 }
2988 2995
2989 xs_html_add(body, 2996 xs_html_add(main,
2990 posts); 2997 posts);
2991 2998
2992 int mark_shown = 0; 2999 int mark_shown = 0;
@@ -3078,14 +3085,14 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3078 xs_html_text(fn)))); 3085 xs_html_text(fn))));
3079 } 3086 }
3080 3087
3081 xs_html_add(body, 3088 xs_html_add(main,
3082 history); 3089 history);
3083 } 3090 }
3084 } 3091 }
3085 3092
3086 { 3093 {
3087 xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t); 3094 xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t);
3088 xs_html_add(body, 3095 xs_html_add(main,
3089 xs_html_raw(s1)); 3096 xs_html_raw(s1));
3090 } 3097 }
3091 3098
@@ -3114,13 +3121,10 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3114 xs_html_attr("name", "snac-more"), 3121 xs_html_attr("name", "snac-more"),
3115 xs_html_text(L("More...")))); 3122 xs_html_text(L("More..."))));
3116 3123
3117 xs_html_add(body, 3124 xs_html_add(main,
3118 more_links); 3125 more_links);
3119 } 3126 }
3120 3127
3121 xs_html_add(body,
3122 html_footer(user));
3123
3124 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3128 return xs_html_render_s(html, "<!DOCTYPE html>\n");
3125} 3129}
3126 3130
@@ -3287,8 +3291,10 @@ xs_str *html_people(snac *user)
3287 3291
3288 xs_html *html = xs_html_tag("html", 3292 xs_html *html = xs_html_tag("html",
3289 html_user_head(user, NULL, NULL), 3293 html_user_head(user, NULL, NULL),
3290 xs_html_add(html_user_body(user, 0), 3294 xs_html_tag("body",
3291 lists, 3295 html_user_header(user, 0),
3296 xs_html_add(html_user_main(user, 0),
3297 lists),
3292 html_footer(user))); 3298 html_footer(user)));
3293 3299
3294 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3300 return xs_html_render_s(html, "<!DOCTYPE html>\n");
@@ -3305,15 +3311,18 @@ xs_str *html_notifications(snac *user, int skip, int show)
3305 xs *n_list = notify_list(user, skip, show); 3311 xs *n_list = notify_list(user, skip, show);
3306 xs *n_time = notify_check_time(user, 0); 3312 xs *n_time = notify_check_time(user, 0);
3307 3313
3308 xs_html *body = html_user_body(user, 0); 3314 xs_html *main = html_user_main(user, 0);
3309 3315
3310 xs_html *html = xs_html_tag("html", 3316 xs_html *html = xs_html_tag("html",
3311 html_user_head(user, NULL, NULL), 3317 html_user_head(user, NULL, NULL),
3312 body); 3318 xs_html_tag("body",
3319 html_user_header(user, 0),
3320 main,
3321 html_footer(user)));
3313 3322
3314 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); 3323 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor);
3315 3324
3316 xs_html_add(body, 3325 xs_html_add(main,
3317 xs_html_tag("form", 3326 xs_html_tag("form",
3318 xs_html_attr("autocomplete", "off"), 3327 xs_html_attr("autocomplete", "off"),
3319 xs_html_attr("method", "post"), 3328 xs_html_attr("method", "post"),
@@ -3329,7 +3338,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3329 3338
3330 xs_html *posts = xs_html_tag("div", 3339 xs_html *posts = xs_html_tag("div",
3331 xs_html_attr("class", "snac-posts")); 3340 xs_html_attr("class", "snac-posts"));
3332 xs_html_add(body, posts); 3341 xs_html_add(main, posts);
3333 3342
3334 xs_set rep; 3343 xs_set rep;
3335 xs_set_init(&rep); 3344 xs_set_init(&rep);
@@ -3520,7 +3529,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3520 } 3529 }
3521 3530
3522 if (noti_new == NULL && noti_seen == NULL) 3531 if (noti_new == NULL && noti_seen == NULL)
3523 xs_html_add(body, 3532 xs_html_add(main,
3524 xs_html_tag("h2", 3533 xs_html_tag("h2",
3525 xs_html_attr("class", "snac-header"), 3534 xs_html_attr("class", "snac-header"),
3526 xs_html_text(L("None")))); 3535 xs_html_text(L("None"))));
@@ -3531,7 +3540,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3531 xs *url = xs_fmt("%s/notifications?skip=%d&show=%d", 3540 xs *url = xs_fmt("%s/notifications?skip=%d&show=%d",
3532 user->actor, skip + show, show); 3541 user->actor, skip + show, show);
3533 3542
3534 xs_html_add(body, 3543 xs_html_add(main,
3535 xs_html_tag("p", 3544 xs_html_tag("p",
3536 xs_html_tag("a", 3545 xs_html_tag("a",
3537 xs_html_attr("href", url), 3546 xs_html_attr("href", url),
@@ -3540,9 +3549,6 @@ xs_str *html_notifications(snac *user, int skip, int show)
3540 3549
3541 xs_set_free(&rep); 3550 xs_set_free(&rep);
3542 3551
3543 xs_html_add(body,
3544 html_footer(user));
3545
3546 /* set the check time to now */ 3552 /* set the check time to now */
3547 xs *dummy = notify_check_time(user, 1); 3553 xs *dummy = notify_check_time(user, 1);
3548 dummy = xs_free(dummy); 3554 dummy = xs_free(dummy);
@@ -3806,9 +3812,11 @@ int html_get_handler(const xs_dict *req, const char *q_path,
3806 3812
3807 xs_html *html = xs_html_tag("html", 3813 xs_html *html = xs_html_tag("html",
3808 html_user_head(&snac, NULL, NULL), 3814 html_user_head(&snac, NULL, NULL),
3809 xs_html_add(html_user_body(&snac, 0), 3815 xs_html_tag("body",
3810 page, 3816 html_user_header(&snac, 0),
3811 html_footer(user))); 3817 xs_html_add(html_user_main(&snac, 0),
3818 page),
3819 html_footer(user)));
3812 3820
3813 *body = xs_html_render_s(html, "<!DOCTYPE html>\n"); 3821 *body = xs_html_render_s(html, "<!DOCTYPE html>\n");
3814 *b_size = strlen(*body); 3822 *b_size = strlen(*body);