diff options
| -rw-r--r-- | html.c | 115 |
1 files changed, 103 insertions, 12 deletions
| @@ -259,23 +259,111 @@ d_char *html_user_header(snac *snac, d_char *s, int local) | |||
| 259 | 259 | ||
| 260 | /* user info */ | 260 | /* user info */ |
| 261 | { | 261 | { |
| 262 | s = xs_str_cat(s, "<div class=\"h-card snac-top-user\">\n"); | 262 | xs *bio = NULL; |
| 263 | char *_tmpl = | ||
| 264 | "<div class=\"h-card snac-top-user\">\n" | ||
| 265 | "<p class=\"p-name snac-top-user-name\">%s</p>\n" | ||
| 266 | "<p class=\"snac-top-user-id\">@%s@%s</p>\n" | ||
| 267 | "<div class=\"p-note snac-top-user-bio\">%s</div>\n" | ||
| 268 | "</div>\n"; | ||
| 269 | |||
| 270 | not_really_markdown(xs_dict_get(snac->config, "bio"), &bio); | ||
| 271 | |||
| 272 | xs *s1 = xs_fmt(_tmpl, | ||
| 273 | xs_dict_get(snac->config, "name"), | ||
| 274 | xs_dict_get(snac->config, "uid"), xs_dict_get(srv_config, "host"), | ||
| 275 | bio | ||
| 276 | ); | ||
| 263 | 277 | ||
| 264 | xs *s1 = xs_fmt("<p class=\"p-name snac-top-user-name\">%s</p>\n", | ||
| 265 | xs_dict_get(snac->config, "name")); | ||
| 266 | s = xs_str_cat(s, s1); | 278 | s = xs_str_cat(s, s1); |
| 279 | } | ||
| 267 | 280 | ||
| 268 | xs *s2 = xs_fmt("<p class=\"snac-top-user-id\">@%s@%s</p>\n", | 281 | return s; |
| 269 | xs_dict_get(snac->config, "uid"), xs_dict_get(srv_config, "host")); | 282 | } |
| 270 | s = xs_str_cat(s, s2); | ||
| 271 | 283 | ||
| 272 | xs *bio = NULL; | ||
| 273 | not_really_markdown(xs_dict_get(snac->config, "bio"), &bio); | ||
| 274 | xs *s3 = xs_fmt("<div class=\"p-note snac-top-user-bio\">%s</div>\n", bio); | ||
| 275 | s = xs_str_cat(s, s3); | ||
| 276 | 284 | ||
| 277 | s = xs_str_cat(s, "</div>\n"); | 285 | d_char *html_top_controls(snac *snac, d_char *s) |
| 278 | } | 286 | /* generates the top controls */ |
| 287 | { | ||
| 288 | char *_tmpl = | ||
| 289 | "<div class=\"snac-top-controls\">\n" | ||
| 290 | |||
| 291 | "<div class=\"snac-note\">\n" | ||
| 292 | "<form method=\"post\" action=\"%s/admin/note\">\n" | ||
| 293 | "<textarea class=\"snac-textarea\" name=\"content\" " | ||
| 294 | "rows=\"8\" wrap=\"virtual\" required=\"required\"></textarea>\n" | ||
| 295 | "<input type=\"hidden\" name=\"in_reply_to\" value=\"\">\n" | ||
| 296 | "<input type=\"submit\" class=\"button\" value=\"%s\">\n" | ||
| 297 | "</form><p>\n" | ||
| 298 | "</div>\n" | ||
| 299 | |||
| 300 | "<div class=\"snac-top-controls-more\">\n" | ||
| 301 | "<details><summary>%s</summary>\n" | ||
| 302 | |||
| 303 | "<form method=\"post\" action=\"%s/admin/action\">\n" | ||
| 304 | "<input type=\"text\" name=\"actor\" required=\"required\">\n" | ||
| 305 | "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n" | ||
| 306 | "</form></p>\n" | ||
| 307 | |||
| 308 | "<form method=\"post\" action=\"%s\">\n" | ||
| 309 | "<input type=\"text\" name=\"id\" required=\"required\">\n" | ||
| 310 | "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n" | ||
| 311 | "</form></p>\n" | ||
| 312 | |||
| 313 | "<details><summary>%s</summary>\n" | ||
| 314 | |||
| 315 | "<div class=\"snac-user-setup\">\n" | ||
| 316 | "<form method=\"post\" action=\"%s/admin/user-setup\">\n" | ||
| 317 | "<p>%s:<br>\n" | ||
| 318 | "<input type=\"text\" name=\"name\" value=\"%s\"></p>\n" | ||
| 319 | |||
| 320 | "<p>%s:<br>\n" | ||
| 321 | "<input type=\"text\" name=\"avatar\" value=\"%s\"></p>\n" | ||
| 322 | |||
| 323 | "<p>%s:<br>\n" | ||
| 324 | "<textarea name=\"bio\" cols=60 rows=4>%s</textarea></p>\n" | ||
| 325 | |||
| 326 | "<p>%s:<br>\n" | ||
| 327 | "<input type=\"password\" name=\"passwd1\" value=\"\"></p>\n" | ||
| 328 | |||
| 329 | "<p>%s:<br>\n" | ||
| 330 | "<input type=\"password\" name=\"passwd2\" value=\"\"></p>\n" | ||
| 331 | |||
| 332 | "<input type=\"submit\" class=\"button\" value=\"%s\">\n" | ||
| 333 | "</form>\n" | ||
| 334 | |||
| 335 | "</div>\n" | ||
| 336 | "</details>\n" | ||
| 337 | "</details>\n" | ||
| 338 | "</div>\n" | ||
| 339 | "</div>\n"; | ||
| 340 | |||
| 341 | xs *s1 = xs_fmt(_tmpl, | ||
| 342 | snac->actor, | ||
| 343 | L("Post"), | ||
| 344 | |||
| 345 | L("More options..."), | ||
| 346 | |||
| 347 | snac->actor, | ||
| 348 | L("Follow"), L("(by URL or user@host)"), | ||
| 349 | |||
| 350 | snac->actor, | ||
| 351 | L("Boost"), L("(by URL)"), | ||
| 352 | |||
| 353 | L("User setup..."), | ||
| 354 | snac->actor, | ||
| 355 | L("User name"), | ||
| 356 | xs_dict_get(snac->config, "name"), | ||
| 357 | L("Avatar URL"), | ||
| 358 | xs_dict_get(snac->config, "avatar"), | ||
| 359 | L("Bio"), | ||
| 360 | xs_dict_get(snac->config, "bio"), | ||
| 361 | L("Password (only to change it)"), | ||
| 362 | L("Repeat Password"), | ||
| 363 | L("Update user info") | ||
| 364 | ); | ||
| 365 | |||
| 366 | s = xs_str_cat(s, s1); | ||
| 279 | 367 | ||
| 280 | return s; | 368 | return s; |
| 281 | } | 369 | } |
| @@ -288,6 +376,9 @@ d_char *html_timeline(snac *snac, char *list, int local) | |||
| 288 | 376 | ||
| 289 | s = html_user_header(snac, s, local); | 377 | s = html_user_header(snac, s, local); |
| 290 | 378 | ||
| 379 | if (!local) | ||
| 380 | s = html_top_controls(snac, s); | ||
| 381 | |||
| 291 | s = xs_str_cat(s, "<h1>HI</h1>\n"); | 382 | s = xs_str_cat(s, "<h1>HI</h1>\n"); |
| 292 | 383 | ||
| 293 | s = xs_str_cat(s, xs_fmt("len() == %d\n", xs_list_len(list))); | 384 | s = xs_str_cat(s, xs_fmt("len() == %d\n", xs_list_len(list))); |