diff options
| author | 2023-05-17 10:40:44 +0200 | |
|---|---|---|
| committer | 2023-05-17 10:40:44 +0200 | |
| commit | 83aad1b7a44a125efe369f39c55ee1c373327322 (patch) | |
| tree | 4ef1c7a5d9a3e63845ba698ac7168a18258c4fd4 | |
| parent | Got rid of xs_encdec.h. (diff) | |
| download | penes-snac2-83aad1b7a44a125efe369f39c55ee1c373327322.tar.gz penes-snac2-83aad1b7a44a125efe369f39c55ee1c373327322.tar.xz penes-snac2-83aad1b7a44a125efe369f39c55ee1c373327322.zip | |
Added some comments.
| -rw-r--r-- | html.c | 51 |
1 files changed, 20 insertions, 31 deletions
| @@ -1347,8 +1347,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1347 | if ((v = xs_dict_get(q_vars, "show")) != NULL) | 1347 | if ((v = xs_dict_get(q_vars, "show")) != NULL) |
| 1348 | show = atoi(v), cache = 0, save = 0; | 1348 | show = atoi(v), cache = 0, save = 0; |
| 1349 | 1349 | ||
| 1350 | if (p_path == NULL) { | 1350 | if (p_path == NULL) { /** public timeline **/ |
| 1351 | /* public timeline */ | ||
| 1352 | xs *h = xs_str_localtime(0, "%Y-%m.html"); | 1351 | xs *h = xs_str_localtime(0, "%Y-%m.html"); |
| 1353 | 1352 | ||
| 1354 | if (cache && history_mtime(&snac, h) > timeline_mtime(&snac)) { | 1353 | if (cache && history_mtime(&snac, h) > timeline_mtime(&snac)) { |
| @@ -1372,9 +1371,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1372 | } | 1371 | } |
| 1373 | } | 1372 | } |
| 1374 | else | 1373 | else |
| 1375 | if (strcmp(p_path, "admin") == 0) { | 1374 | if (strcmp(p_path, "admin") == 0) { /** private timeline **/ |
| 1376 | /* private timeline */ | ||
| 1377 | |||
| 1378 | if (!login(&snac, req)) | 1375 | if (!login(&snac, req)) |
| 1379 | status = 401; | 1376 | status = 401; |
| 1380 | else { | 1377 | else { |
| @@ -1402,9 +1399,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1402 | } | 1399 | } |
| 1403 | } | 1400 | } |
| 1404 | else | 1401 | else |
| 1405 | if (strcmp(p_path, "people") == 0) { | 1402 | if (strcmp(p_path, "people") == 0) { /** the list of people **/ |
| 1406 | /* the list of people */ | ||
| 1407 | |||
| 1408 | if (!login(&snac, req)) | 1403 | if (!login(&snac, req)) |
| 1409 | status = 401; | 1404 | status = 401; |
| 1410 | else { | 1405 | else { |
| @@ -1414,9 +1409,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1414 | } | 1409 | } |
| 1415 | } | 1410 | } |
| 1416 | else | 1411 | else |
| 1417 | if (strcmp(p_path, "notifications") == 0) { | 1412 | if (strcmp(p_path, "notifications") == 0) { /** the list of notifications **/ |
| 1418 | /* the list of notifications */ | ||
| 1419 | |||
| 1420 | if (!login(&snac, req)) | 1413 | if (!login(&snac, req)) |
| 1421 | status = 401; | 1414 | status = 401; |
| 1422 | else { | 1415 | else { |
| @@ -1426,8 +1419,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1426 | } | 1419 | } |
| 1427 | } | 1420 | } |
| 1428 | else | 1421 | else |
| 1429 | if (xs_startswith(p_path, "p/")) { | 1422 | if (xs_startswith(p_path, "p/")) { /** a timeline with just one entry **/ |
| 1430 | /* a timeline with just one entry */ | ||
| 1431 | xs *id = xs_fmt("%s/%s", snac.actor, p_path); | 1423 | xs *id = xs_fmt("%s/%s", snac.actor, p_path); |
| 1432 | xs *msg = NULL; | 1424 | xs *msg = NULL; |
| 1433 | 1425 | ||
| @@ -1443,8 +1435,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1443 | } | 1435 | } |
| 1444 | } | 1436 | } |
| 1445 | else | 1437 | else |
| 1446 | if (xs_startswith(p_path, "s/")) { | 1438 | if (xs_startswith(p_path, "s/")) { /** a static file **/ |
| 1447 | /* a static file */ | ||
| 1448 | xs *l = xs_split(p_path, "/"); | 1439 | xs *l = xs_split(p_path, "/"); |
| 1449 | char *id = xs_list_get(l, 1); | 1440 | char *id = xs_list_get(l, 1); |
| 1450 | int sz; | 1441 | int sz; |
| @@ -1456,8 +1447,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1456 | } | 1447 | } |
| 1457 | } | 1448 | } |
| 1458 | else | 1449 | else |
| 1459 | if (xs_startswith(p_path, "h/")) { | 1450 | if (xs_startswith(p_path, "h/")) { /** an entry from the history **/ |
| 1460 | /* an entry from the history */ | ||
| 1461 | xs *l = xs_split(p_path, "/"); | 1451 | xs *l = xs_split(p_path, "/"); |
| 1462 | char *id = xs_list_get(l, 1); | 1452 | char *id = xs_list_get(l, 1); |
| 1463 | 1453 | ||
| @@ -1467,8 +1457,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1467 | } | 1457 | } |
| 1468 | } | 1458 | } |
| 1469 | else | 1459 | else |
| 1470 | if (strcmp(p_path, ".rss") == 0) { | 1460 | if (strcmp(p_path, ".rss") == 0) { /** public timeline in RSS format **/ |
| 1471 | /* public timeline in RSS format */ | ||
| 1472 | d_char *rss; | 1461 | d_char *rss; |
| 1473 | xs *elems = timeline_simple_list(&snac, "public", 0, 20); | 1462 | xs *elems = timeline_simple_list(&snac, "public", 0, 20); |
| 1474 | xs *bio = not_really_markdown(xs_dict_get(snac.config, "bio")); | 1463 | xs *bio = not_really_markdown(xs_dict_get(snac.config, "bio")); |
| @@ -1588,7 +1577,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1588 | } | 1577 | } |
| 1589 | #endif | 1578 | #endif |
| 1590 | 1579 | ||
| 1591 | if (p_path && strcmp(p_path, "admin/note") == 0) { | 1580 | if (p_path && strcmp(p_path, "admin/note") == 0) { /** **/ |
| 1592 | /* post note */ | 1581 | /* post note */ |
| 1593 | xs_str *content = xs_dict_get(p_vars, "content"); | 1582 | xs_str *content = xs_dict_get(p_vars, "content"); |
| 1594 | xs_str *in_reply_to = xs_dict_get(p_vars, "in_reply_to"); | 1583 | xs_str *in_reply_to = xs_dict_get(p_vars, "in_reply_to"); |
| @@ -1696,7 +1685,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1696 | status = 303; | 1685 | status = 303; |
| 1697 | } | 1686 | } |
| 1698 | else | 1687 | else |
| 1699 | if (p_path && strcmp(p_path, "admin/action") == 0) { | 1688 | if (p_path && strcmp(p_path, "admin/action") == 0) { /** **/ |
| 1700 | /* action on an entry */ | 1689 | /* action on an entry */ |
| 1701 | char *id = xs_dict_get(p_vars, "id"); | 1690 | char *id = xs_dict_get(p_vars, "id"); |
| 1702 | char *actor = xs_dict_get(p_vars, "actor"); | 1691 | char *actor = xs_dict_get(p_vars, "actor"); |
| @@ -1709,7 +1698,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1709 | 1698 | ||
| 1710 | status = 303; | 1699 | status = 303; |
| 1711 | 1700 | ||
| 1712 | if (strcmp(action, L("Like")) == 0) { | 1701 | if (strcmp(action, L("Like")) == 0) { /** **/ |
| 1713 | xs *msg = msg_admiration(&snac, id, "Like"); | 1702 | xs *msg = msg_admiration(&snac, id, "Like"); |
| 1714 | 1703 | ||
| 1715 | if (msg != NULL) { | 1704 | if (msg != NULL) { |
| @@ -1718,7 +1707,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1718 | } | 1707 | } |
| 1719 | } | 1708 | } |
| 1720 | else | 1709 | else |
| 1721 | if (strcmp(action, L("Boost")) == 0) { | 1710 | if (strcmp(action, L("Boost")) == 0) { /** **/ |
| 1722 | xs *msg = msg_admiration(&snac, id, "Announce"); | 1711 | xs *msg = msg_admiration(&snac, id, "Announce"); |
| 1723 | 1712 | ||
| 1724 | if (msg != NULL) { | 1713 | if (msg != NULL) { |
| @@ -1727,19 +1716,19 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1727 | } | 1716 | } |
| 1728 | } | 1717 | } |
| 1729 | else | 1718 | else |
| 1730 | if (strcmp(action, L("MUTE")) == 0) { | 1719 | if (strcmp(action, L("MUTE")) == 0) { /** **/ |
| 1731 | mute(&snac, actor); | 1720 | mute(&snac, actor); |
| 1732 | } | 1721 | } |
| 1733 | else | 1722 | else |
| 1734 | if (strcmp(action, L("Unmute")) == 0) { | 1723 | if (strcmp(action, L("Unmute")) == 0) { /** **/ |
| 1735 | unmute(&snac, actor); | 1724 | unmute(&snac, actor); |
| 1736 | } | 1725 | } |
| 1737 | else | 1726 | else |
| 1738 | if (strcmp(action, L("Hide")) == 0) { | 1727 | if (strcmp(action, L("Hide")) == 0) { /** **/ |
| 1739 | hide(&snac, id); | 1728 | hide(&snac, id); |
| 1740 | } | 1729 | } |
| 1741 | else | 1730 | else |
| 1742 | if (strcmp(action, L("Follow")) == 0) { | 1731 | if (strcmp(action, L("Follow")) == 0) { /** **/ |
| 1743 | xs *msg = msg_follow(&snac, actor); | 1732 | xs *msg = msg_follow(&snac, actor); |
| 1744 | 1733 | ||
| 1745 | if (msg != NULL) { | 1734 | if (msg != NULL) { |
| @@ -1752,7 +1741,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1752 | } | 1741 | } |
| 1753 | } | 1742 | } |
| 1754 | else | 1743 | else |
| 1755 | if (strcmp(action, L("Unfollow")) == 0) { | 1744 | if (strcmp(action, L("Unfollow")) == 0) { /** **/ |
| 1756 | /* get the following object */ | 1745 | /* get the following object */ |
| 1757 | xs *object = NULL; | 1746 | xs *object = NULL; |
| 1758 | 1747 | ||
| @@ -1769,7 +1758,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1769 | snac_log(&snac, xs_fmt("actor is not being followed %s", actor)); | 1758 | snac_log(&snac, xs_fmt("actor is not being followed %s", actor)); |
| 1770 | } | 1759 | } |
| 1771 | else | 1760 | else |
| 1772 | if (strcmp(action, L("Delete")) == 0) { | 1761 | if (strcmp(action, L("Delete")) == 0) { /** **/ |
| 1773 | char *actor_form = xs_dict_get(p_vars, "actor-form"); | 1762 | char *actor_form = xs_dict_get(p_vars, "actor-form"); |
| 1774 | if (actor_form != NULL) { | 1763 | if (actor_form != NULL) { |
| 1775 | /* delete follower */ | 1764 | /* delete follower */ |
| @@ -1802,7 +1791,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1802 | history_del(&snac, "timeline.html_"); | 1791 | history_del(&snac, "timeline.html_"); |
| 1803 | } | 1792 | } |
| 1804 | else | 1793 | else |
| 1805 | if (p_path && strcmp(p_path, "admin/user-setup") == 0) { | 1794 | if (p_path && strcmp(p_path, "admin/user-setup") == 0) { /** **/ |
| 1806 | /* change of user data */ | 1795 | /* change of user data */ |
| 1807 | char *v; | 1796 | char *v; |
| 1808 | char *p1, *p2; | 1797 | char *p1, *p2; |
| @@ -1881,7 +1870,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1881 | status = 303; | 1870 | status = 303; |
| 1882 | } | 1871 | } |
| 1883 | else | 1872 | else |
| 1884 | if (p_path && strcmp(p_path, "admin/clear-notifications") == 0) { | 1873 | if (p_path && strcmp(p_path, "admin/clear-notifications") == 0) { /** **/ |
| 1885 | notify_clear(&snac); | 1874 | notify_clear(&snac); |
| 1886 | timeline_touch(&snac); | 1875 | timeline_touch(&snac); |
| 1887 | 1876 | ||