commit 7774a68
default
·
2024-10-06 07:56:40 +0000 UTC
parent b7e78e6
New HTML variable error (still unused).
M
html.c
+32,
-14
1@@ -577,7 +577,7 @@ static xs_html *html_instance_body(void)
2 }
3
4
5-xs_html *html_user_head(snac *user, char *desc, char *url)
6+xs_html *html_user_head(snac *user, const char *desc, const char *url)
7 {
8 xs_html *head = html_base_head();
9
10@@ -2138,7 +2138,8 @@ xs_html *html_footer(void)
11
12 xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
13 int skip, int show, int show_more,
14- char *title, char *page, int utl)
15+ const char *title, const char *page,
16+ int utl, const char *error)
17 /* returns the HTML for the timeline */
18 {
19 xs_list *p = (xs_list *)list;
20@@ -2180,6 +2181,19 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
21 xs_html_add(body,
22 html_top_controls(user));
23
24+ if (error != NULL) {
25+ xs_html_add(body,
26+ xs_html_tag("dialog",
27+ xs_html_attr("open", NULL),
28+ xs_html_tag("p",
29+ xs_html_text(error)),
30+ xs_html_tag("form",
31+ xs_html_attr("method", "dialog"),
32+ xs_html_sctag("input",
33+ xs_html_attr("type", "submit"),
34+ xs_html_attr("value", L("Dismiss"))))));
35+ }
36+
37 /* show links to the available lists */
38 if (user && !read_only) {
39 xs_html *lol = xs_html_tag("ul",
40@@ -2767,6 +2781,9 @@ int html_get_handler(const xs_dict *req, const char *q_path,
41 }
42 }
43
44+ /* get a possible error message */
45+ const char *error = xs_dict_get(q_vars, "error");
46+
47 /* a show of 0 has no sense */
48 if (show == 0)
49 show = def_show;
50@@ -2776,7 +2793,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
51
52 if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) {
53 /** empty public timeline for private users **/
54- *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, "", 1);
55+ *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, "", 1, error);
56 *b_size = strlen(*body);
57 status = HTTP_STATUS_OK;
58 }
59@@ -2794,7 +2811,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
60 xs *pins = pinned_list(&snac);
61 pins = xs_list_cat(pins, list);
62
63- *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, "", 1);
64+ *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, "", 1, error);
65
66 *b_size = strlen(*body);
67 status = HTTP_STATUS_OK;
68@@ -2827,7 +2844,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
69 xs *title = xs_fmt(xs_list_len(tl) ?
70 L("Search results for tag %s") : L("Nothing found for tag %s"), q);
71
72- *body = html_timeline(&snac, tl, 0, skip, show, more, title, page, 0);
73+ *body = html_timeline(&snac, tl, 0, skip, show, more, title, page, 0, error);
74 *b_size = strlen(*body);
75 status = HTTP_STATUS_OK;
76 }
77@@ -2851,7 +2868,8 @@ int html_get_handler(const xs_dict *req, const char *q_path,
78 else
79 title = xs_fmt(L("Nothing found for '%s'"), q);
80
81- *body = html_timeline(&snac, tl, 0, skip, tl_len, to || tl_len == show, title, page, 0);
82+ *body = html_timeline(&snac, tl, 0, skip, tl_len, to || tl_len == show,
83+ title, page, 0, error);
84 *b_size = strlen(*body);
85 status = HTTP_STATUS_OK;
86 }
87@@ -2876,7 +2894,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
88 xs *next = timeline_list(&snac, "private", skip + show, 1);
89
90 *body = html_timeline(&snac, list, 0, skip, show,
91- xs_list_len(next), NULL, "/admin", 1);
92+ xs_list_len(next), NULL, "/admin", 1, error);
93
94 *b_size = strlen(*body);
95 status = HTTP_STATUS_OK;
96@@ -2900,7 +2918,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
97 if (md5 && *md5 && timeline_here(&snac, md5)) {
98 xs *list = xs_list_append(xs_list_new(), md5);
99
100- *body = html_timeline(&snac, list, 0, 0, 0, 0, NULL, "/admin", 1);
101+ *body = html_timeline(&snac, list, 0, 0, 0, 0, NULL, "/admin", 1, error);
102 *b_size = strlen(*body);
103 status = HTTP_STATUS_OK;
104 }
105@@ -2941,7 +2959,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
106 xs *next = timeline_instance_list(skip + show, 1);
107
108 *body = html_timeline(&snac, list, 0, skip, show,
109- xs_list_len(next), L("Showing instance timeline"), "/instance", 0);
110+ xs_list_len(next), L("Showing instance timeline"), "/instance", 0, error);
111 *b_size = strlen(*body);
112 status = HTTP_STATUS_OK;
113 }
114@@ -2956,7 +2974,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
115 xs *list = pinned_list(&snac);
116
117 *body = html_timeline(&snac, list, 0, skip, show,
118- 0, L("Pinned posts"), "", 0);
119+ 0, L("Pinned posts"), "", 0, error);
120 *b_size = strlen(*body);
121 status = HTTP_STATUS_OK;
122 }
123@@ -2971,7 +2989,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
124 xs *list = bookmark_list(&snac);
125
126 *body = html_timeline(&snac, list, 0, skip, show,
127- 0, L("Bookmarked posts"), "", 0);
128+ 0, L("Bookmarked posts"), "", 0, error);
129 *b_size = strlen(*body);
130 status = HTTP_STATUS_OK;
131 }
132@@ -2986,7 +3004,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
133 xs *list = draft_list(&snac);
134
135 *body = html_timeline(&snac, list, 0, skip, show,
136- 0, L("Post drafts"), "", 0);
137+ 0, L("Post drafts"), "", 0, error);
138 *b_size = strlen(*body);
139 status = HTTP_STATUS_OK;
140 }
141@@ -3012,7 +3030,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
142 xs *title = xs_fmt(L("Showing timeline for list '%s'"), name);
143
144 *body = html_timeline(&snac, ttl, 0, skip, show,
145- xs_list_len(next), title, base, 1);
146+ xs_list_len(next), title, base, 1, error);
147 *b_size = strlen(*body);
148 status = HTTP_STATUS_OK;
149 }
150@@ -3032,7 +3050,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
151
152 list = xs_list_append(list, md5);
153
154- *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL, "", 1);
155+ *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL, "", 1, error);
156 *b_size = strlen(*body);
157 status = HTTP_STATUS_OK;
158 }
M
httpd.c
+2,
-2
1@@ -204,7 +204,7 @@ int server_get_handler(xs_dict *req, const char *q_path,
2 else {
3 xs *page = xs_fmt("?t=%s", t);
4 xs *title = xs_fmt(L("Search results for tag #%s"), t);
5- *body = html_timeline(NULL, tl, 0, skip, show, more, title, page, 0);
6+ *body = html_timeline(NULL, tl, 0, skip, show, more, title, page, 0, NULL);
7 }
8 }
9 else
10@@ -212,7 +212,7 @@ int server_get_handler(xs_dict *req, const char *q_path,
11 /** instance timeline **/
12 xs *tl = timeline_instance_list(0, 30);
13 *body = html_timeline(NULL, tl, 0, 0, 0, 0,
14- L("Recent posts by users in this instance"), NULL, 0);
15+ L("Recent posts by users in this instance"), NULL, 0, NULL);
16 }
17 else
18 *body = greeting_html();
M
snac.h
+1,
-1
1@@ -346,7 +346,7 @@ xs_str *encode_html(const char *str);
2
3 xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
4 int skip, int show, int show_more,
5- char *title, char *page, int utl);
6+ const char *title, const char *page, int utl, const char *error);
7
8 int html_get_handler(const xs_dict *req, const char *q_path,
9 char **body, int *b_size, char **ctype, xs_str **etag);