diff options
| -rw-r--r-- | html.c | 122 |
1 files changed, 65 insertions, 57 deletions
| @@ -915,18 +915,10 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url) | |||
| 915 | } | 915 | } |
| 916 | 916 | ||
| 917 | 917 | ||
| 918 | static xs_html *html_user_body(snac *user, int read_only) | 918 | static xs_html *html_user_header(snac *user, int read_only) |
| 919 | { | 919 | { |
| 920 | const char *proxy = NULL; | ||
| 921 | |||
| 922 | if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media"))) | ||
| 923 | proxy = user->actor; | ||
| 924 | |||
| 925 | xs_html *body = xs_html_tag("body", NULL); | ||
| 926 | |||
| 927 | /* top nav */ | 920 | /* top nav */ |
| 928 | xs_html *top_nav = xs_html_tag("nav", | 921 | xs_html *top_nav = xs_html_tag("header", NULL); |
| 929 | xs_html_attr("class", "snac-top-nav")); | ||
| 930 | 922 | ||
| 931 | xs *avatar = xs_dup(xs_dict_get(user->config, "avatar")); | 923 | xs *avatar = xs_dup(xs_dict_get(user->config, "avatar")); |
| 932 | 924 | ||
| @@ -938,7 +930,6 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 938 | xs_html_add(top_nav, | 930 | xs_html_add(top_nav, |
| 939 | xs_html_sctag("img", | 931 | xs_html_sctag("img", |
| 940 | xs_html_attr("src", avatar), | 932 | xs_html_attr("src", avatar), |
| 941 | xs_html_attr("class", "snac-avatar"), | ||
| 942 | xs_html_attr("alt", ""))); | 933 | xs_html_attr("alt", ""))); |
| 943 | 934 | ||
| 944 | if (read_only) { | 935 | if (read_only) { |
| @@ -1019,8 +1010,18 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 1019 | xs_html_attr("placeholder", L("Content search"))))); | 1010 | xs_html_attr("placeholder", L("Content search"))))); |
| 1020 | } | 1011 | } |
| 1021 | 1012 | ||
| 1022 | xs_html_add(body, | 1013 | return top_nav; |
| 1023 | top_nav); | 1014 | } |
| 1015 | |||
| 1016 | |||
| 1017 | static xs_html *html_user_main(snac *user, int read_only) | ||
| 1018 | { | ||
| 1019 | const char *proxy = NULL; | ||
| 1020 | |||
| 1021 | if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media"))) | ||
| 1022 | proxy = user->actor; | ||
| 1023 | |||
| 1024 | xs_html *main = xs_html_tag("main", NULL); | ||
| 1024 | 1025 | ||
| 1025 | /* user info */ | 1026 | /* user info */ |
| 1026 | xs_html *top_user = xs_html_tag("div", | 1027 | xs_html *top_user = xs_html_tag("div", |
| @@ -1215,10 +1216,10 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 1215 | } | 1216 | } |
| 1216 | } | 1217 | } |
| 1217 | 1218 | ||
| 1218 | xs_html_add(body, | 1219 | xs_html_add(main, |
| 1219 | top_user); | 1220 | top_user); |
| 1220 | 1221 | ||
| 1221 | return body; | 1222 | return main; |
| 1222 | } | 1223 | } |
| 1223 | 1224 | ||
| 1224 | 1225 | ||
| @@ -2898,18 +2899,18 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2898 | 2899 | ||
| 2899 | xs_html *html_footer(const snac *user) | 2900 | xs_html *html_footer(const snac *user) |
| 2900 | { | 2901 | { |
| 2901 | return xs_html_tag("div", | 2902 | return xs_html_tag("footer", |
| 2902 | xs_html_attr("class", "snac-footer"), | 2903 | xs_html_tag("p", |
| 2903 | xs_html_tag("a", | 2904 | xs_html_tag("a", |
| 2904 | xs_html_attr("href", srv_baseurl), | 2905 | xs_html_attr("href", srv_baseurl), |
| 2905 | xs_html_text(L("about this site"))), | 2906 | xs_html_text(L("about this site"))), |
| 2906 | xs_html_text(" - "), | 2907 | xs_html_text(" - "), |
| 2907 | xs_html_text(L("powered by ")), | 2908 | xs_html_text(L("powered by ")), |
| 2908 | xs_html_tag("a", | 2909 | xs_html_tag("a", |
| 2909 | xs_html_attr("href", WHAT_IS_SNAC_URL), | 2910 | xs_html_attr("href", WHAT_IS_SNAC_URL), |
| 2910 | xs_html_tag("abbr", | 2911 | xs_html_tag("abbr", |
| 2911 | xs_html_attr("title", "Social Networks Are Crap"), | 2912 | xs_html_attr("title", "Social Networks Are Crap"), |
| 2912 | xs_html_text(USER_AGENT)))); | 2913 | xs_html_text(USER_AGENT))))); |
| 2913 | } | 2914 | } |
| 2914 | 2915 | ||
| 2915 | 2916 | ||
| @@ -2940,27 +2941,33 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2940 | } | 2941 | } |
| 2941 | 2942 | ||
| 2942 | xs_html *head; | 2943 | xs_html *head; |
| 2943 | xs_html *body; | 2944 | xs_html *header; |
| 2945 | xs_html *main; | ||
| 2944 | 2946 | ||
| 2945 | if (user) { | 2947 | if (user) { |
| 2946 | head = html_user_head(user, desc, alternate); | 2948 | head = html_user_head(user, desc, alternate); |
| 2947 | body = html_user_body(user, read_only); | 2949 | header = html_user_header(user, read_only); |
| 2950 | main = html_user_main(user, read_only); | ||
| 2948 | } | 2951 | } |
| 2949 | else { | 2952 | else { |
| 2950 | head = html_instance_head(); | 2953 | head = html_instance_head(); |
| 2951 | body = html_instance_body(); | 2954 | header = xs_html_tag("header", NULL); |
| 2955 | main = html_instance_body(); | ||
| 2952 | } | 2956 | } |
| 2953 | 2957 | ||
| 2954 | xs_html *html = xs_html_tag("html", | 2958 | xs_html *html = xs_html_tag("html", |
| 2955 | head, | 2959 | head, |
| 2956 | body); | 2960 | xs_html_tag("body", |
| 2961 | header, | ||
| 2962 | main, | ||
| 2963 | html_footer(user))); | ||
| 2957 | 2964 | ||
| 2958 | if (user && !read_only) | 2965 | if (user && !read_only) |
| 2959 | xs_html_add(body, | 2966 | xs_html_add(main, |
| 2960 | html_top_controls(user)); | 2967 | html_top_controls(user)); |
| 2961 | 2968 | ||
| 2962 | if (error != NULL) { | 2969 | if (error != NULL) { |
| 2963 | xs_html_add(body, | 2970 | xs_html_add(main, |
| 2964 | xs_html_tag("dialog", | 2971 | xs_html_tag("dialog", |
| 2965 | xs_html_attr("open", NULL), | 2972 | xs_html_attr("open", NULL), |
| 2966 | xs_html_tag("p", | 2973 | xs_html_tag("p", |
| @@ -2976,7 +2983,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2976 | if (user && !read_only) { | 2983 | if (user && !read_only) { |
| 2977 | xs_html *lol = xs_html_tag("ul", | 2984 | xs_html *lol = xs_html_tag("ul", |
| 2978 | xs_html_attr("class", "snac-list-of-lists")); | 2985 | xs_html_attr("class", "snac-list-of-lists")); |
| 2979 | xs_html_add(body, lol); | 2986 | xs_html_add(main, lol); |
| 2980 | 2987 | ||
| 2981 | xs *lists = list_maint(user, NULL, 0); /* get list of lists */ | 2988 | xs *lists = list_maint(user, NULL, 0); /* get list of lists */ |
| 2982 | 2989 | ||
| @@ -3051,7 +3058,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 3051 | if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) { | 3058 | if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) { |
| 3052 | xs_html *loht = xs_html_tag("ul", | 3059 | xs_html *loht = xs_html_tag("ul", |
| 3053 | xs_html_attr("class", "snac-list-of-lists")); | 3060 | xs_html_attr("class", "snac-list-of-lists")); |
| 3054 | xs_html_add(body, loht); | 3061 | xs_html_add(main, loht); |
| 3055 | 3062 | ||
| 3056 | const char *ht; | 3063 | const char *ht; |
| 3057 | 3064 | ||
| @@ -3075,7 +3082,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 3075 | } | 3082 | } |
| 3076 | } | 3083 | } |
| 3077 | 3084 | ||
| 3078 | xs_html_add(body, | 3085 | xs_html_add(main, |
| 3079 | xs_html_tag("a", | 3086 | xs_html_tag("a", |
| 3080 | xs_html_attr("name", "snac-posts"))); | 3087 | xs_html_attr("name", "snac-posts"))); |
| 3081 | 3088 | ||
| @@ -3089,7 +3096,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 3089 | xs_html_text(title))); | 3096 | xs_html_text(title))); |
| 3090 | } | 3097 | } |
| 3091 | 3098 | ||
| 3092 | xs_html_add(body, | 3099 | xs_html_add(main, |
| 3093 | posts); | 3100 | posts); |
| 3094 | 3101 | ||
| 3095 | int mark_shown = 0; | 3102 | int mark_shown = 0; |
| @@ -3181,14 +3188,14 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 3181 | xs_html_text(fn)))); | 3188 | xs_html_text(fn)))); |
| 3182 | } | 3189 | } |
| 3183 | 3190 | ||
| 3184 | xs_html_add(body, | 3191 | xs_html_add(main, |
| 3185 | history); | 3192 | history); |
| 3186 | } | 3193 | } |
| 3187 | } | 3194 | } |
| 3188 | 3195 | ||
| 3189 | { | 3196 | { |
| 3190 | xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t); | 3197 | xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t); |
| 3191 | xs_html_add(body, | 3198 | xs_html_add(main, |
| 3192 | xs_html_raw(s1)); | 3199 | xs_html_raw(s1)); |
| 3193 | } | 3200 | } |
| 3194 | 3201 | ||
| @@ -3217,13 +3224,10 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 3217 | xs_html_attr("name", "snac-more"), | 3224 | xs_html_attr("name", "snac-more"), |
| 3218 | xs_html_text(L("More...")))); | 3225 | xs_html_text(L("More...")))); |
| 3219 | 3226 | ||
| 3220 | xs_html_add(body, | 3227 | xs_html_add(main, |
| 3221 | more_links); | 3228 | more_links); |
| 3222 | } | 3229 | } |
| 3223 | 3230 | ||
| 3224 | xs_html_add(body, | ||
| 3225 | html_footer(user)); | ||
| 3226 | |||
| 3227 | return xs_html_render_s(html, "<!DOCTYPE html>\n"); | 3231 | return xs_html_render_s(html, "<!DOCTYPE html>\n"); |
| 3228 | } | 3232 | } |
| 3229 | 3233 | ||
| @@ -3396,8 +3400,10 @@ xs_str *html_people(snac *user) | |||
| 3396 | 3400 | ||
| 3397 | xs_html *html = xs_html_tag("html", | 3401 | xs_html *html = xs_html_tag("html", |
| 3398 | html_user_head(user, NULL, NULL), | 3402 | html_user_head(user, NULL, NULL), |
| 3399 | xs_html_add(html_user_body(user, 0), | 3403 | xs_html_tag("body", |
| 3400 | lists, | 3404 | html_user_header(user, 0), |
| 3405 | xs_html_add(html_user_main(user, 0), | ||
| 3406 | lists), | ||
| 3401 | html_footer(user))); | 3407 | html_footer(user))); |
| 3402 | 3408 | ||
| 3403 | return xs_html_render_s(html, "<!DOCTYPE html>\n"); | 3409 | return xs_html_render_s(html, "<!DOCTYPE html>\n"); |
| @@ -3414,15 +3420,18 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3414 | xs *n_list = notify_list(user, skip, show); | 3420 | xs *n_list = notify_list(user, skip, show); |
| 3415 | xs *n_time = notify_check_time(user, 0); | 3421 | xs *n_time = notify_check_time(user, 0); |
| 3416 | 3422 | ||
| 3417 | xs_html *body = html_user_body(user, 0); | 3423 | xs_html *main = html_user_main(user, 0); |
| 3418 | 3424 | ||
| 3419 | xs_html *html = xs_html_tag("html", | 3425 | xs_html *html = xs_html_tag("html", |
| 3420 | html_user_head(user, NULL, NULL), | 3426 | html_user_head(user, NULL, NULL), |
| 3421 | body); | 3427 | xs_html_tag("body", |
| 3428 | html_user_header(user, 0), | ||
| 3429 | main, | ||
| 3430 | html_footer(user))); | ||
| 3422 | 3431 | ||
| 3423 | xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); | 3432 | xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); |
| 3424 | 3433 | ||
| 3425 | xs_html_add(body, | 3434 | xs_html_add(main, |
| 3426 | xs_html_tag("form", | 3435 | xs_html_tag("form", |
| 3427 | xs_html_attr("autocomplete", "off"), | 3436 | xs_html_attr("autocomplete", "off"), |
| 3428 | xs_html_attr("method", "post"), | 3437 | xs_html_attr("method", "post"), |
| @@ -3438,7 +3447,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3438 | 3447 | ||
| 3439 | xs_html *posts = xs_html_tag("div", | 3448 | xs_html *posts = xs_html_tag("div", |
| 3440 | xs_html_attr("class", "snac-posts")); | 3449 | xs_html_attr("class", "snac-posts")); |
| 3441 | xs_html_add(body, posts); | 3450 | xs_html_add(main, posts); |
| 3442 | 3451 | ||
| 3443 | xs_set rep; | 3452 | xs_set rep; |
| 3444 | xs_set_init(&rep); | 3453 | xs_set_init(&rep); |
| @@ -3639,7 +3648,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3639 | } | 3648 | } |
| 3640 | 3649 | ||
| 3641 | if (noti_new == NULL && noti_seen == NULL) | 3650 | if (noti_new == NULL && noti_seen == NULL) |
| 3642 | xs_html_add(body, | 3651 | xs_html_add(main, |
| 3643 | xs_html_tag("h2", | 3652 | xs_html_tag("h2", |
| 3644 | xs_html_attr("class", "snac-header"), | 3653 | xs_html_attr("class", "snac-header"), |
| 3645 | xs_html_text(L("None")))); | 3654 | xs_html_text(L("None")))); |
| @@ -3650,7 +3659,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3650 | xs *url = xs_fmt("%s/notifications?skip=%d&show=%d", | 3659 | xs *url = xs_fmt("%s/notifications?skip=%d&show=%d", |
| 3651 | user->actor, skip + show, show); | 3660 | user->actor, skip + show, show); |
| 3652 | 3661 | ||
| 3653 | xs_html_add(body, | 3662 | xs_html_add(main, |
| 3654 | xs_html_tag("p", | 3663 | xs_html_tag("p", |
| 3655 | xs_html_tag("a", | 3664 | xs_html_tag("a", |
| 3656 | xs_html_attr("href", url), | 3665 | xs_html_attr("href", url), |
| @@ -3659,9 +3668,6 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3659 | 3668 | ||
| 3660 | xs_set_free(&rep); | 3669 | xs_set_free(&rep); |
| 3661 | 3670 | ||
| 3662 | xs_html_add(body, | ||
| 3663 | html_footer(user)); | ||
| 3664 | |||
| 3665 | /* set the check time to now */ | 3671 | /* set the check time to now */ |
| 3666 | xs *dummy = notify_check_time(user, 1); | 3672 | xs *dummy = notify_check_time(user, 1); |
| 3667 | dummy = xs_free(dummy); | 3673 | dummy = xs_free(dummy); |
| @@ -3931,9 +3937,11 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3931 | 3937 | ||
| 3932 | xs_html *html = xs_html_tag("html", | 3938 | xs_html *html = xs_html_tag("html", |
| 3933 | html_user_head(&snac, NULL, NULL), | 3939 | html_user_head(&snac, NULL, NULL), |
| 3934 | xs_html_add(html_user_body(&snac, 0), | 3940 | xs_html_tag("body", |
| 3935 | page, | 3941 | html_user_header(&snac, 0), |
| 3936 | html_footer(user))); | 3942 | xs_html_add(html_user_main(&snac, 0), |
| 3943 | page), | ||
| 3944 | html_footer(user))); | ||
| 3937 | 3945 | ||
| 3938 | *body = xs_html_render_s(html, "<!DOCTYPE html>\n"); | 3946 | *body = xs_html_render_s(html, "<!DOCTYPE html>\n"); |
| 3939 | *b_size = strlen(*body); | 3947 | *b_size = strlen(*body); |