summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
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 a6e5f98..2f7bec9 100644
--- a/html.c
+++ b/html.c
@@ -867,18 +867,10 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url)
867} 867}
868 868
869 869
870static xs_html *html_user_body(snac *user, int read_only) 870static xs_html *html_user_header(snac *user, int read_only)
871{ 871{
872 const char *proxy = NULL;
873
874 if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media")))
875 proxy = user->actor;
876
877 xs_html *body = xs_html_tag("body", NULL);
878
879 /* top nav */ 872 /* top nav */
880 xs_html *top_nav = xs_html_tag("nav", 873 xs_html *top_nav = xs_html_tag("header", NULL);
881 xs_html_attr("class", "snac-top-nav"));
882 874
883 xs *avatar = xs_dup(xs_dict_get(user->config, "avatar")); 875 xs *avatar = xs_dup(xs_dict_get(user->config, "avatar"));
884 876
@@ -890,7 +882,6 @@ static xs_html *html_user_body(snac *user, int read_only)
890 xs_html_add(top_nav, 882 xs_html_add(top_nav,
891 xs_html_sctag("img", 883 xs_html_sctag("img",
892 xs_html_attr("src", avatar), 884 xs_html_attr("src", avatar),
893 xs_html_attr("class", "snac-avatar"),
894 xs_html_attr("alt", ""))); 885 xs_html_attr("alt", "")));
895 886
896 if (read_only) { 887 if (read_only) {
@@ -971,8 +962,18 @@ static xs_html *html_user_body(snac *user, int read_only)
971 xs_html_attr("placeholder", L("Content search"))))); 962 xs_html_attr("placeholder", L("Content search")))));
972 } 963 }
973 964
974 xs_html_add(body, 965 return top_nav;
975 top_nav); 966}
967
968
969static xs_html *html_user_main(snac *user, int read_only)
970{
971 const char *proxy = NULL;
972
973 if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media")))
974 proxy = user->actor;
975
976 xs_html *main = xs_html_tag("main", NULL);
976 977
977 /* user info */ 978 /* user info */
978 xs_html *top_user = xs_html_tag("div", 979 xs_html *top_user = xs_html_tag("div",
@@ -1160,10 +1161,10 @@ static xs_html *html_user_body(snac *user, int read_only)
1160 } 1161 }
1161 } 1162 }
1162 1163
1163 xs_html_add(body, 1164 xs_html_add(main,
1164 top_user); 1165 top_user);
1165 1166
1166 return body; 1167 return main;
1167} 1168}
1168 1169
1169 1170
@@ -2816,18 +2817,18 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2816 2817
2817xs_html *html_footer(const snac *user) 2818xs_html *html_footer(const snac *user)
2818{ 2819{
2819 return xs_html_tag("div", 2820 return xs_html_tag("footer",
2820 xs_html_attr("class", "snac-footer"), 2821 xs_html_tag("p",
2821 xs_html_tag("a", 2822 xs_html_tag("a",
2822 xs_html_attr("href", srv_baseurl), 2823 xs_html_attr("href", srv_baseurl),
2823 xs_html_text(L("about this site"))), 2824 xs_html_text(L("about this site"))),
2824 xs_html_text(" - "), 2825 xs_html_text(" - "),
2825 xs_html_text(L("powered by ")), 2826 xs_html_text(L("powered by ")),
2826 xs_html_tag("a", 2827 xs_html_tag("a",
2827 xs_html_attr("href", WHAT_IS_SNAC_URL), 2828 xs_html_attr("href", WHAT_IS_SNAC_URL),
2828 xs_html_tag("abbr", 2829 xs_html_tag("abbr",
2829 xs_html_attr("title", "Social Networks Are Crap"), 2830 xs_html_attr("title", "Social Networks Are Crap"),
2830 xs_html_text("snac")))); 2831 xs_html_text("snac")))));
2831} 2832}
2832 2833
2833 2834
@@ -2858,27 +2859,33 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2858 } 2859 }
2859 2860
2860 xs_html *head; 2861 xs_html *head;
2861 xs_html *body; 2862 xs_html *header;
2863 xs_html *main;
2862 2864
2863 if (user) { 2865 if (user) {
2864 head = html_user_head(user, desc, alternate); 2866 head = html_user_head(user, desc, alternate);
2865 body = html_user_body(user, read_only); 2867 header = html_user_header(user, read_only);
2868 main = html_user_main(user, read_only);
2866 } 2869 }
2867 else { 2870 else {
2868 head = html_instance_head(); 2871 head = html_instance_head();
2869 body = html_instance_body(); 2872 header = xs_html_tag("header", NULL);
2873 main = html_instance_body();
2870 } 2874 }
2871 2875
2872 xs_html *html = xs_html_tag("html", 2876 xs_html *html = xs_html_tag("html",
2873 head, 2877 head,
2874 body); 2878 xs_html_tag("body",
2879 header,
2880 main,
2881 html_footer(user)));
2875 2882
2876 if (user && !read_only) 2883 if (user && !read_only)
2877 xs_html_add(body, 2884 xs_html_add(main,
2878 html_top_controls(user)); 2885 html_top_controls(user));
2879 2886
2880 if (error != NULL) { 2887 if (error != NULL) {
2881 xs_html_add(body, 2888 xs_html_add(main,
2882 xs_html_tag("dialog", 2889 xs_html_tag("dialog",
2883 xs_html_attr("open", NULL), 2890 xs_html_attr("open", NULL),
2884 xs_html_tag("p", 2891 xs_html_tag("p",
@@ -2894,7 +2901,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2894 if (user && !read_only) { 2901 if (user && !read_only) {
2895 xs_html *lol = xs_html_tag("ul", 2902 xs_html *lol = xs_html_tag("ul",
2896 xs_html_attr("class", "snac-list-of-lists")); 2903 xs_html_attr("class", "snac-list-of-lists"));
2897 xs_html_add(body, lol); 2904 xs_html_add(main, lol);
2898 2905
2899 xs *lists = list_maint(user, NULL, 0); /* get list of lists */ 2906 xs *lists = list_maint(user, NULL, 0); /* get list of lists */
2900 2907
@@ -2969,7 +2976,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2969 if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) { 2976 if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) {
2970 xs_html *loht = xs_html_tag("ul", 2977 xs_html *loht = xs_html_tag("ul",
2971 xs_html_attr("class", "snac-list-of-lists")); 2978 xs_html_attr("class", "snac-list-of-lists"));
2972 xs_html_add(body, loht); 2979 xs_html_add(main, loht);
2973 2980
2974 const char *ht; 2981 const char *ht;
2975 2982
@@ -2987,7 +2994,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2987 } 2994 }
2988 } 2995 }
2989 2996
2990 xs_html_add(body, 2997 xs_html_add(main,
2991 xs_html_tag("a", 2998 xs_html_tag("a",
2992 xs_html_attr("name", "snac-posts"))); 2999 xs_html_attr("name", "snac-posts")));
2993 3000
@@ -3001,7 +3008,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3001 xs_html_text(title))); 3008 xs_html_text(title)));
3002 } 3009 }
3003 3010
3004 xs_html_add(body, 3011 xs_html_add(main,
3005 posts); 3012 posts);
3006 3013
3007 int mark_shown = 0; 3014 int mark_shown = 0;
@@ -3093,14 +3100,14 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3093 xs_html_text(fn)))); 3100 xs_html_text(fn))));
3094 } 3101 }
3095 3102
3096 xs_html_add(body, 3103 xs_html_add(main,
3097 history); 3104 history);
3098 } 3105 }
3099 } 3106 }
3100 3107
3101 { 3108 {
3102 xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t); 3109 xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t);
3103 xs_html_add(body, 3110 xs_html_add(main,
3104 xs_html_raw(s1)); 3111 xs_html_raw(s1));
3105 } 3112 }
3106 3113
@@ -3129,13 +3136,10 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
3129 xs_html_attr("name", "snac-more"), 3136 xs_html_attr("name", "snac-more"),
3130 xs_html_text(L("More...")))); 3137 xs_html_text(L("More..."))));
3131 3138
3132 xs_html_add(body, 3139 xs_html_add(main,
3133 more_links); 3140 more_links);
3134 } 3141 }
3135 3142
3136 xs_html_add(body,
3137 html_footer(user));
3138
3139 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3143 return xs_html_render_s(html, "<!DOCTYPE html>\n");
3140} 3144}
3141 3145
@@ -3308,8 +3312,10 @@ xs_str *html_people(snac *user)
3308 3312
3309 xs_html *html = xs_html_tag("html", 3313 xs_html *html = xs_html_tag("html",
3310 html_user_head(user, NULL, NULL), 3314 html_user_head(user, NULL, NULL),
3311 xs_html_add(html_user_body(user, 0), 3315 xs_html_tag("body",
3312 lists, 3316 html_user_header(user, 0),
3317 xs_html_add(html_user_main(user, 0),
3318 lists),
3313 html_footer(user))); 3319 html_footer(user)));
3314 3320
3315 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3321 return xs_html_render_s(html, "<!DOCTYPE html>\n");
@@ -3326,15 +3332,18 @@ xs_str *html_notifications(snac *user, int skip, int show)
3326 xs *n_list = notify_list(user, skip, show); 3332 xs *n_list = notify_list(user, skip, show);
3327 xs *n_time = notify_check_time(user, 0); 3333 xs *n_time = notify_check_time(user, 0);
3328 3334
3329 xs_html *body = html_user_body(user, 0); 3335 xs_html *main = html_user_main(user, 0);
3330 3336
3331 xs_html *html = xs_html_tag("html", 3337 xs_html *html = xs_html_tag("html",
3332 html_user_head(user, NULL, NULL), 3338 html_user_head(user, NULL, NULL),
3333 body); 3339 xs_html_tag("body",
3340 html_user_header(user, 0),
3341 main,
3342 html_footer(user)));
3334 3343
3335 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); 3344 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor);
3336 3345
3337 xs_html_add(body, 3346 xs_html_add(main,
3338 xs_html_tag("form", 3347 xs_html_tag("form",
3339 xs_html_attr("autocomplete", "off"), 3348 xs_html_attr("autocomplete", "off"),
3340 xs_html_attr("method", "post"), 3349 xs_html_attr("method", "post"),
@@ -3350,7 +3359,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3350 3359
3351 xs_html *posts = xs_html_tag("div", 3360 xs_html *posts = xs_html_tag("div",
3352 xs_html_attr("class", "snac-posts")); 3361 xs_html_attr("class", "snac-posts"));
3353 xs_html_add(body, posts); 3362 xs_html_add(main, posts);
3354 3363
3355 xs_set rep; 3364 xs_set rep;
3356 xs_set_init(&rep); 3365 xs_set_init(&rep);
@@ -3541,7 +3550,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3541 } 3550 }
3542 3551
3543 if (noti_new == NULL && noti_seen == NULL) 3552 if (noti_new == NULL && noti_seen == NULL)
3544 xs_html_add(body, 3553 xs_html_add(main,
3545 xs_html_tag("h2", 3554 xs_html_tag("h2",
3546 xs_html_attr("class", "snac-header"), 3555 xs_html_attr("class", "snac-header"),
3547 xs_html_text(L("None")))); 3556 xs_html_text(L("None"))));
@@ -3552,7 +3561,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
3552 xs *url = xs_fmt("%s/notifications?skip=%d&show=%d", 3561 xs *url = xs_fmt("%s/notifications?skip=%d&show=%d",
3553 user->actor, skip + show, show); 3562 user->actor, skip + show, show);
3554 3563
3555 xs_html_add(body, 3564 xs_html_add(main,
3556 xs_html_tag("p", 3565 xs_html_tag("p",
3557 xs_html_tag("a", 3566 xs_html_tag("a",
3558 xs_html_attr("href", url), 3567 xs_html_attr("href", url),
@@ -3561,9 +3570,6 @@ xs_str *html_notifications(snac *user, int skip, int show)
3561 3570
3562 xs_set_free(&rep); 3571 xs_set_free(&rep);
3563 3572
3564 xs_html_add(body,
3565 html_footer(user));
3566
3567 /* set the check time to now */ 3573 /* set the check time to now */
3568 xs *dummy = notify_check_time(user, 1); 3574 xs *dummy = notify_check_time(user, 1);
3569 dummy = xs_free(dummy); 3575 dummy = xs_free(dummy);
@@ -3825,9 +3831,11 @@ int html_get_handler(const xs_dict *req, const char *q_path,
3825 3831
3826 xs_html *html = xs_html_tag("html", 3832 xs_html *html = xs_html_tag("html",
3827 html_user_head(&snac, NULL, NULL), 3833 html_user_head(&snac, NULL, NULL),
3828 xs_html_add(html_user_body(&snac, 0), 3834 xs_html_tag("body",
3829 page, 3835 html_user_header(&snac, 0),
3830 html_footer(user))); 3836 xs_html_add(html_user_main(&snac, 0),
3837 page),
3838 html_footer(user)));
3831 3839
3832 *body = xs_html_render_s(html, "<!DOCTYPE html>\n"); 3840 *body = xs_html_render_s(html, "<!DOCTYPE html>\n");
3833 *b_size = strlen(*body); 3841 *b_size = strlen(*body);