summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-10-06 09:56:40 +0200
committerGravatar default2024-10-06 09:56:44 +0200
commit7774a68f3f8211e9aaa98c837c868f6435eb4acf (patch)
tree52053f9459c4a1df13a2ef69388e3028766c4988
parentMore hashtag regex improvements. (diff)
downloadpenes-snac2-7774a68f3f8211e9aaa98c837c868f6435eb4acf.tar.gz
penes-snac2-7774a68f3f8211e9aaa98c837c868f6435eb4acf.tar.xz
penes-snac2-7774a68f3f8211e9aaa98c837c868f6435eb4acf.zip
New HTML variable error (still unused).
Diffstat (limited to '')
-rw-r--r--html.c46
-rw-r--r--httpd.c4
-rw-r--r--snac.h2
3 files changed, 35 insertions, 17 deletions
diff --git a/html.c b/html.c
index 6310ed4..914f3d2 100644
--- a/html.c
+++ b/html.c
@@ -577,7 +577,7 @@ static xs_html *html_instance_body(void)
577} 577}
578 578
579 579
580xs_html *html_user_head(snac *user, char *desc, char *url) 580xs_html *html_user_head(snac *user, const char *desc, const char *url)
581{ 581{
582 xs_html *head = html_base_head(); 582 xs_html *head = html_base_head();
583 583
@@ -2138,7 +2138,8 @@ xs_html *html_footer(void)
2138 2138
2139xs_str *html_timeline(snac *user, const xs_list *list, int read_only, 2139xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2140 int skip, int show, int show_more, 2140 int skip, int show, int show_more,
2141 char *title, char *page, int utl) 2141 const char *title, const char *page,
2142 int utl, const char *error)
2142/* returns the HTML for the timeline */ 2143/* returns the HTML for the timeline */
2143{ 2144{
2144 xs_list *p = (xs_list *)list; 2145 xs_list *p = (xs_list *)list;
@@ -2180,6 +2181,19 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
2180 xs_html_add(body, 2181 xs_html_add(body,
2181 html_top_controls(user)); 2182 html_top_controls(user));
2182 2183
2184 if (error != NULL) {
2185 xs_html_add(body,
2186 xs_html_tag("dialog",
2187 xs_html_attr("open", NULL),
2188 xs_html_tag("p",
2189 xs_html_text(error)),
2190 xs_html_tag("form",
2191 xs_html_attr("method", "dialog"),
2192 xs_html_sctag("input",
2193 xs_html_attr("type", "submit"),
2194 xs_html_attr("value", L("Dismiss"))))));
2195 }
2196
2183 /* show links to the available lists */ 2197 /* show links to the available lists */
2184 if (user && !read_only) { 2198 if (user && !read_only) {
2185 xs_html *lol = xs_html_tag("ul", 2199 xs_html *lol = xs_html_tag("ul",
@@ -2767,6 +2781,9 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2767 } 2781 }
2768 } 2782 }
2769 2783
2784 /* get a possible error message */
2785 const char *error = xs_dict_get(q_vars, "error");
2786
2770 /* a show of 0 has no sense */ 2787 /* a show of 0 has no sense */
2771 if (show == 0) 2788 if (show == 0)
2772 show = def_show; 2789 show = def_show;
@@ -2776,7 +2793,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2776 2793
2777 if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) { 2794 if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) {
2778 /** empty public timeline for private users **/ 2795 /** empty public timeline for private users **/
2779 *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, "", 1); 2796 *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, "", 1, error);
2780 *b_size = strlen(*body); 2797 *b_size = strlen(*body);
2781 status = HTTP_STATUS_OK; 2798 status = HTTP_STATUS_OK;
2782 } 2799 }
@@ -2794,7 +2811,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2794 xs *pins = pinned_list(&snac); 2811 xs *pins = pinned_list(&snac);
2795 pins = xs_list_cat(pins, list); 2812 pins = xs_list_cat(pins, list);
2796 2813
2797 *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, "", 1); 2814 *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, "", 1, error);
2798 2815
2799 *b_size = strlen(*body); 2816 *b_size = strlen(*body);
2800 status = HTTP_STATUS_OK; 2817 status = HTTP_STATUS_OK;
@@ -2827,7 +2844,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2827 xs *title = xs_fmt(xs_list_len(tl) ? 2844 xs *title = xs_fmt(xs_list_len(tl) ?
2828 L("Search results for tag %s") : L("Nothing found for tag %s"), q); 2845 L("Search results for tag %s") : L("Nothing found for tag %s"), q);
2829 2846
2830 *body = html_timeline(&snac, tl, 0, skip, show, more, title, page, 0); 2847 *body = html_timeline(&snac, tl, 0, skip, show, more, title, page, 0, error);
2831 *b_size = strlen(*body); 2848 *b_size = strlen(*body);
2832 status = HTTP_STATUS_OK; 2849 status = HTTP_STATUS_OK;
2833 } 2850 }
@@ -2851,7 +2868,8 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2851 else 2868 else
2852 title = xs_fmt(L("Nothing found for '%s'"), q); 2869 title = xs_fmt(L("Nothing found for '%s'"), q);
2853 2870
2854 *body = html_timeline(&snac, tl, 0, skip, tl_len, to || tl_len == show, title, page, 0); 2871 *body = html_timeline(&snac, tl, 0, skip, tl_len, to || tl_len == show,
2872 title, page, 0, error);
2855 *b_size = strlen(*body); 2873 *b_size = strlen(*body);
2856 status = HTTP_STATUS_OK; 2874 status = HTTP_STATUS_OK;
2857 } 2875 }
@@ -2876,7 +2894,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2876 xs *next = timeline_list(&snac, "private", skip + show, 1); 2894 xs *next = timeline_list(&snac, "private", skip + show, 1);
2877 2895
2878 *body = html_timeline(&snac, list, 0, skip, show, 2896 *body = html_timeline(&snac, list, 0, skip, show,
2879 xs_list_len(next), NULL, "/admin", 1); 2897 xs_list_len(next), NULL, "/admin", 1, error);
2880 2898
2881 *b_size = strlen(*body); 2899 *b_size = strlen(*body);
2882 status = HTTP_STATUS_OK; 2900 status = HTTP_STATUS_OK;
@@ -2900,7 +2918,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2900 if (md5 && *md5 && timeline_here(&snac, md5)) { 2918 if (md5 && *md5 && timeline_here(&snac, md5)) {
2901 xs *list = xs_list_append(xs_list_new(), md5); 2919 xs *list = xs_list_append(xs_list_new(), md5);
2902 2920
2903 *body = html_timeline(&snac, list, 0, 0, 0, 0, NULL, "/admin", 1); 2921 *body = html_timeline(&snac, list, 0, 0, 0, 0, NULL, "/admin", 1, error);
2904 *b_size = strlen(*body); 2922 *b_size = strlen(*body);
2905 status = HTTP_STATUS_OK; 2923 status = HTTP_STATUS_OK;
2906 } 2924 }
@@ -2941,7 +2959,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2941 xs *next = timeline_instance_list(skip + show, 1); 2959 xs *next = timeline_instance_list(skip + show, 1);
2942 2960
2943 *body = html_timeline(&snac, list, 0, skip, show, 2961 *body = html_timeline(&snac, list, 0, skip, show,
2944 xs_list_len(next), L("Showing instance timeline"), "/instance", 0); 2962 xs_list_len(next), L("Showing instance timeline"), "/instance", 0, error);
2945 *b_size = strlen(*body); 2963 *b_size = strlen(*body);
2946 status = HTTP_STATUS_OK; 2964 status = HTTP_STATUS_OK;
2947 } 2965 }
@@ -2956,7 +2974,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2956 xs *list = pinned_list(&snac); 2974 xs *list = pinned_list(&snac);
2957 2975
2958 *body = html_timeline(&snac, list, 0, skip, show, 2976 *body = html_timeline(&snac, list, 0, skip, show,
2959 0, L("Pinned posts"), "", 0); 2977 0, L("Pinned posts"), "", 0, error);
2960 *b_size = strlen(*body); 2978 *b_size = strlen(*body);
2961 status = HTTP_STATUS_OK; 2979 status = HTTP_STATUS_OK;
2962 } 2980 }
@@ -2971,7 +2989,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2971 xs *list = bookmark_list(&snac); 2989 xs *list = bookmark_list(&snac);
2972 2990
2973 *body = html_timeline(&snac, list, 0, skip, show, 2991 *body = html_timeline(&snac, list, 0, skip, show,
2974 0, L("Bookmarked posts"), "", 0); 2992 0, L("Bookmarked posts"), "", 0, error);
2975 *b_size = strlen(*body); 2993 *b_size = strlen(*body);
2976 status = HTTP_STATUS_OK; 2994 status = HTTP_STATUS_OK;
2977 } 2995 }
@@ -2986,7 +3004,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2986 xs *list = draft_list(&snac); 3004 xs *list = draft_list(&snac);
2987 3005
2988 *body = html_timeline(&snac, list, 0, skip, show, 3006 *body = html_timeline(&snac, list, 0, skip, show,
2989 0, L("Post drafts"), "", 0); 3007 0, L("Post drafts"), "", 0, error);
2990 *b_size = strlen(*body); 3008 *b_size = strlen(*body);
2991 status = HTTP_STATUS_OK; 3009 status = HTTP_STATUS_OK;
2992 } 3010 }
@@ -3012,7 +3030,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
3012 xs *title = xs_fmt(L("Showing timeline for list '%s'"), name); 3030 xs *title = xs_fmt(L("Showing timeline for list '%s'"), name);
3013 3031
3014 *body = html_timeline(&snac, ttl, 0, skip, show, 3032 *body = html_timeline(&snac, ttl, 0, skip, show,
3015 xs_list_len(next), title, base, 1); 3033 xs_list_len(next), title, base, 1, error);
3016 *b_size = strlen(*body); 3034 *b_size = strlen(*body);
3017 status = HTTP_STATUS_OK; 3035 status = HTTP_STATUS_OK;
3018 } 3036 }
@@ -3032,7 +3050,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
3032 3050
3033 list = xs_list_append(list, md5); 3051 list = xs_list_append(list, md5);
3034 3052
3035 *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL, "", 1); 3053 *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL, "", 1, error);
3036 *b_size = strlen(*body); 3054 *b_size = strlen(*body);
3037 status = HTTP_STATUS_OK; 3055 status = HTTP_STATUS_OK;
3038 } 3056 }
diff --git a/httpd.c b/httpd.c
index fd3d9e4..2fe9d6b 100644
--- a/httpd.c
+++ b/httpd.c
@@ -204,7 +204,7 @@ int server_get_handler(xs_dict *req, const char *q_path,
204 else { 204 else {
205 xs *page = xs_fmt("?t=%s", t); 205 xs *page = xs_fmt("?t=%s", t);
206 xs *title = xs_fmt(L("Search results for tag #%s"), t); 206 xs *title = xs_fmt(L("Search results for tag #%s"), t);
207 *body = html_timeline(NULL, tl, 0, skip, show, more, title, page, 0); 207 *body = html_timeline(NULL, tl, 0, skip, show, more, title, page, 0, NULL);
208 } 208 }
209 } 209 }
210 else 210 else
@@ -212,7 +212,7 @@ int server_get_handler(xs_dict *req, const char *q_path,
212 /** instance timeline **/ 212 /** instance timeline **/
213 xs *tl = timeline_instance_list(0, 30); 213 xs *tl = timeline_instance_list(0, 30);
214 *body = html_timeline(NULL, tl, 0, 0, 0, 0, 214 *body = html_timeline(NULL, tl, 0, 0, 0, 0,
215 L("Recent posts by users in this instance"), NULL, 0); 215 L("Recent posts by users in this instance"), NULL, 0, NULL);
216 } 216 }
217 else 217 else
218 *body = greeting_html(); 218 *body = greeting_html();
diff --git a/snac.h b/snac.h
index 693844e..90413ea 100644
--- a/snac.h
+++ b/snac.h
@@ -346,7 +346,7 @@ xs_str *encode_html(const char *str);
346 346
347xs_str *html_timeline(snac *user, const xs_list *list, int read_only, 347xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
348 int skip, int show, int show_more, 348 int skip, int show, int show_more,
349 char *title, char *page, int utl); 349 const char *title, const char *page, int utl, const char *error);
350 350
351int html_get_handler(const xs_dict *req, const char *q_path, 351int html_get_handler(const xs_dict *req, const char *q_path,
352 char **body, int *b_size, char **ctype, xs_str **etag); 352 char **body, int *b_size, char **ctype, xs_str **etag);