summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/html.c b/html.c
index 78c6aed..5614956 100644
--- a/html.c
+++ b/html.c
@@ -967,6 +967,7 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
967 xs *uid = NULL; 967 xs *uid = NULL;
968 char *p_path; 968 char *p_path;
969 int cache = 1; 969 int cache = 1;
970 int save = 1;
970 char *v; 971 char *v;
971 972
972 xs *l = xs_split_n(q_path, "/", 2); 973 xs *l = xs_split_n(q_path, "/", 2);
@@ -1004,6 +1005,14 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
1004 if ((v = xs_dict_get(srv_config, "disable_cache")) && xs_type(v) == XSTYPE_TRUE) 1005 if ((v = xs_dict_get(srv_config, "disable_cache")) && xs_type(v) == XSTYPE_TRUE)
1005 cache = 0; 1006 cache = 0;
1006 1007
1008 int skip = 0;
1009 int show = 50;
1010 char *q_vars = xs_dict_get(req, "q_vars");
1011 if ((v = xs_dict_get(q_vars, "skip")) != NULL)
1012 skip = atoi(v), cache = 0, save = 0;
1013 if ((v = xs_dict_get(q_vars, "show")) != NULL)
1014 show = atoi(v), cache = 0, save = 0;
1015
1007 if (p_path == NULL) { 1016 if (p_path == NULL) {
1008 /* public timeline */ 1017 /* public timeline */
1009 xs *h = xs_str_localtime(0, "%Y-%m.html"); 1018 xs *h = xs_str_localtime(0, "%Y-%m.html");
@@ -1016,13 +1025,20 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
1016 status = 200; 1025 status = 200;
1017 } 1026 }
1018 else { 1027 else {
1019 xs *list = timeline_list(&snac, "public", XS_ALL); 1028 xs *list = timeline_list(&snac, "public", skip, show);
1020 1029
1021 *body = html_timeline(&snac, list, 1); 1030 *body = html_timeline(&snac, list, 1);
1031 if (xs_list_len(list) == show)
1032 *body = xs_str_cat(
1033 *body, xs_fmt(
1034 "<p>"
1035 "<a href=\"%s?skip=%d&show=%d\" name=\"snac-more\">More…</a>"
1036 "</p>\n", snac.actor, skip + show, show));
1022 *b_size = strlen(*body); 1037 *b_size = strlen(*body);
1023 status = 200; 1038 status = 200;
1024 1039
1025 history_add(&snac, h, *body, *b_size); 1040 if (save)
1041 history_add(&snac, h, *body, *b_size);
1026 } 1042 }
1027 } 1043 }
1028 else 1044 else
@@ -1042,13 +1058,20 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
1042 else { 1058 else {
1043 snac_debug(&snac, 1, xs_fmt("building timeline")); 1059 snac_debug(&snac, 1, xs_fmt("building timeline"));
1044 1060
1045 xs *list = timeline_list(&snac, "private", XS_ALL); 1061 xs *list = timeline_list(&snac, "private", skip, show);
1046 1062
1047 *body = html_timeline(&snac, list, 0); 1063 *body = html_timeline(&snac, list, 0);
1064 if (xs_list_len(list) == show)
1065 *body = xs_str_cat(
1066 *body, xs_fmt(
1067 "<p>"
1068 "<a href=\"%s/admin?skip=%d&show=%d\" name=\"snac-more\">More…</a>"
1069 "</p>\n", snac.actor, skip + show, show));
1048 *b_size = strlen(*body); 1070 *b_size = strlen(*body);
1049 status = 200; 1071 status = 200;
1050 1072
1051 history_add(&snac, "timeline.html_", *body, *b_size); 1073 if (save)
1074 history_add(&snac, "timeline.html_", *body, *b_size);
1052 } 1075 }
1053 } 1076 }
1054 } 1077 }
@@ -1109,7 +1132,7 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
1109 if (strcmp(p_path, ".rss") == 0) { 1132 if (strcmp(p_path, ".rss") == 0) {
1110 /* public timeline in RSS format */ 1133 /* public timeline in RSS format */
1111 d_char *rss; 1134 d_char *rss;
1112 xs *elems = timeline_simple_list(&snac, "public", 20); 1135 xs *elems = timeline_simple_list(&snac, "public", 0, 20);
1113 xs *bio = not_really_markdown(xs_dict_get(snac.config, "bio")); 1136 xs *bio = not_really_markdown(xs_dict_get(snac.config, "bio"));
1114 char *p, *v; 1137 char *p, *v;
1115 1138
@@ -1202,7 +1225,7 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
1202 uid = xs_list_get(l, 1); 1225 uid = xs_list_get(l, 1);
1203 if (!uid || !user_open(&snac, uid)) { 1226 if (!uid || !user_open(&snac, uid)) {
1204 /* invalid user */ 1227 /* invalid user */
1205 srv_log(xs_fmt("html_get_handler bad user %s", uid)); 1228 srv_log(xs_fmt("html_post_handler bad user %s", uid));
1206 return 404; 1229 return 404;
1207 } 1230 }
1208 1231