summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c144
1 files changed, 144 insertions, 0 deletions
diff --git a/html.c b/html.c
index 8bac8dd..71ac1bd 100644
--- a/html.c
+++ b/html.c
@@ -232,6 +232,150 @@ xs_str *html_msg_icon(xs_str *os, const xs_dict *msg)
232} 232}
233 233
234 234
235xs_html *html_note(snac *user, char *summary,
236 char *div_id, char *form_id,
237 char *ta_plh, char *ta_content,
238 char *edit_id, char *actor_id,
239 xs_val *cw_yn, char *cw_text,
240 xs_val *mnt_only, char *redir,
241 char *in_reply_to, int poll)
242{
243 xs *action = xs_fmt("%s/admin/note", user->actor);
244
245 xs_html *form;
246
247 xs_html *note = xs_html_tag("div",
248 xs_html_tag("details",
249 xs_html_tag("summary",
250 xs_html_text(summary)),
251 xs_html_tag("p", NULL),
252 xs_html_tag("div",
253 xs_html_attr("class", "snac-note"),
254 xs_html_attr("id", div_id),
255 form = xs_html_tag("form",
256 xs_html_attr("autocomplete", "off"),
257 xs_html_attr("method", "post"),
258 xs_html_attr("action", action),
259 xs_html_attr("enctype", "multipart/form-data"),
260 xs_html_attr("id", form_id),
261 xs_html_tag("textarea",
262 xs_html_attr("class", "snac-textarea"),
263 xs_html_attr("name", "content"),
264 xs_html_attr("rows", "4"),
265 xs_html_attr("wrap", "virtual"),
266 xs_html_attr("required", "required"),
267 xs_html_attr("placeholder", ta_plh),
268 xs_html_text(ta_content)),
269 xs_html_tag("p", NULL),
270 xs_html_text(L("Sensitive content: ")),
271 xs_html_sctag("input",
272 xs_html_attr("type", "checkbox"),
273 xs_html_attr("name", "sensitive"),
274 xs_html_attr(xs_type(cw_yn) == XSTYPE_TRUE ? "checked" : "", NULL)),
275 xs_html_sctag("input",
276 xs_html_attr("type", "text"),
277 xs_html_attr("name", "summary"),
278 xs_html_attr("placeholder", L("Sensitive content description")),
279 xs_html_attr("value", cw_text))))));
280
281 if (actor_id)
282 xs_html_add(form,
283 xs_html_sctag("input",
284 xs_html_attr("type", "hidden"),
285 xs_html_attr("name", "to"),
286 xs_html_attr("value", actor_id)));
287 else {
288 /* no actor_id; ask for mentioned_only */
289 xs_html_add(form,
290 xs_html_tag("p", NULL),
291 xs_html_text(L("Only for mentioned people")),
292 xs_html_sctag("input",
293 xs_html_attr("type", "checkbox"),
294 xs_html_attr("name", "mentioned_only"),
295 xs_html_attr(xs_type(mnt_only) == XSTYPE_TRUE ? "checked" : "", NULL)));
296 }
297
298 if (redir)
299 xs_html_add(form,
300 xs_html_sctag("input",
301 xs_html_attr("type", "hidden"),
302 xs_html_attr("name", "redir"),
303 xs_html_attr("value", redir)));
304
305 if (in_reply_to)
306 xs_html_add(form,
307 xs_html_sctag("input",
308 xs_html_attr("type", "hidden"),
309 xs_html_attr("name", "in_reply_to"),
310 xs_html_attr("value", in_reply_to)));
311
312 if (edit_id)
313 xs_html_add(form,
314 xs_html_sctag("input",
315 xs_html_attr("type", "hidden"),
316 xs_html_attr("name", "edit_id"),
317 xs_html_attr("value", edit_id)));
318
319 xs_html_add(form,
320 xs_html_tag("details",
321 xs_html_tag("summary",
322 xs_html_text(L("Attachment..."))),
323 xs_html_tag("p", NULL),
324 xs_html_sctag("input",
325 xs_html_attr("type", "file"),
326 xs_html_attr("name", "attach")),
327 xs_html_sctag("input",
328 xs_html_attr("type", "text"),
329 xs_html_attr("name", "alt_text"),
330 xs_html_attr("placeholder", L("Attachment description")))));
331
332 /* add poll controls */
333 if (poll) {
334 xs_html_add(form,
335 xs_html_tag("details",
336 xs_html_tag("summary",
337 xs_html_text(L("Poll..."))),
338 xs_html_tag("p", NULL),
339 xs_html_tag("textarea",
340 xs_html_attr("class", "snac-textarea"),
341 xs_html_attr("name", "poll_options"),
342 xs_html_attr("rows", "4"),
343 xs_html_attr("wrap", "virtual"),
344 xs_html_attr("placeholder", "Option 1...\nOption 2...\nOption 3...\n...")),
345 xs_html_tag("p", NULL),
346 xs_html_tag("select",
347 xs_html_attr("name", "poll_multiple"),
348 xs_html_tag("option",
349 xs_html_attr("value", "off"),
350 xs_html_text(L("One choice"))),
351 xs_html_tag("option",
352 xs_html_attr("value", "on"),
353 xs_html_text(L("Multiple choices")))),
354 xs_html_tag("select",
355 xs_html_attr("name", "poll_end_secs"),
356 xs_html_tag("option",
357 xs_html_attr("value", "300"),
358 xs_html_text(L("End in 5 minutes"))),
359 xs_html_tag("option",
360 xs_html_attr("value", "3600"),
361 xs_html_attr("selected", NULL),
362 xs_html_text(L("End in 1 hour"))),
363 xs_html_tag("option",
364 xs_html_attr("value", "86400"),
365 xs_html_text(L("End in 1 day"))))));
366 }
367
368 xs_html_add(form,
369 xs_html_tag("p", NULL),
370 xs_html_sctag("input",
371 xs_html_attr("type", "submit"),
372 xs_html_attr("class", "button"),
373 xs_html_attr("value", L("Post"))));
374
375 return note;
376}
377
378
235xs_str *html_base_header(xs_str *s) 379xs_str *html_base_header(xs_str *s)
236{ 380{
237 xs_list *p; 381 xs_list *p;