diff options
| author | 2024-08-09 16:28:57 +0200 | |
|---|---|---|
| committer | 2024-08-09 16:28:57 +0200 | |
| commit | f5332ec0164a3a92d58081700267fe86c7aaa5a1 (patch) | |
| tree | 05c1b67c75aaa42c0f5c3c4a9a60b461049d84de | |
| parent | New function mastoapi_timeline(). (diff) | |
| download | penes-snac2-f5332ec0164a3a92d58081700267fe86c7aaa5a1.tar.gz penes-snac2-f5332ec0164a3a92d58081700267fe86c7aaa5a1.tar.xz penes-snac2-f5332ec0164a3a92d58081700267fe86c7aaa5a1.zip | |
Added some functions that return index filenames.
Diffstat (limited to '')
| -rw-r--r-- | data.c | 32 | ||||
| -rw-r--r-- | snac.h | 5 |
2 files changed, 30 insertions, 7 deletions
| @@ -1300,10 +1300,17 @@ xs_list *timeline_top_level(snac *snac, const xs_list *list) | |||
| 1300 | } | 1300 | } |
| 1301 | 1301 | ||
| 1302 | 1302 | ||
| 1303 | xs_list *timeline_simple_list(snac *snac, const char *idx_name, int skip, int show) | 1303 | xs_str *user_index_fn(snac *user, const char *idx_name) |
| 1304 | /* returns the filename of a user index */ | ||
| 1305 | { | ||
| 1306 | return xs_fmt("%s/%s.idx", user->basedir, idx_name); | ||
| 1307 | } | ||
| 1308 | |||
| 1309 | |||
| 1310 | xs_list *timeline_simple_list(snac *user, const char *idx_name, int skip, int show) | ||
| 1304 | /* returns a timeline (with all entries) */ | 1311 | /* returns a timeline (with all entries) */ |
| 1305 | { | 1312 | { |
| 1306 | xs *idx = xs_fmt("%s/%s.idx", snac->basedir, idx_name); | 1313 | xs *idx = user_index_fn(user, idx_name); |
| 1307 | 1314 | ||
| 1308 | return index_list_desc(idx, skip, show); | 1315 | return index_list_desc(idx, skip, show); |
| 1309 | } | 1316 | } |
| @@ -1327,10 +1334,16 @@ xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show) | |||
| 1327 | } | 1334 | } |
| 1328 | 1335 | ||
| 1329 | 1336 | ||
| 1337 | xs_str *instance_index_fn(void) | ||
| 1338 | { | ||
| 1339 | return xs_fmt("%s/public.idx", srv_basedir); | ||
| 1340 | } | ||
| 1341 | |||
| 1342 | |||
| 1330 | xs_list *timeline_instance_list(int skip, int show) | 1343 | xs_list *timeline_instance_list(int skip, int show) |
| 1331 | /* returns the timeline for the full instance */ | 1344 | /* returns the timeline for the full instance */ |
| 1332 | { | 1345 | { |
| 1333 | xs *idx = xs_fmt("%s/public.idx", srv_basedir); | 1346 | xs *idx = instance_index_fn(); |
| 1334 | 1347 | ||
| 1335 | return index_list_desc(idx, skip, show); | 1348 | return index_list_desc(idx, skip, show); |
| 1336 | } | 1349 | } |
| @@ -1803,15 +1816,22 @@ void tag_index(const char *id, const xs_dict *obj) | |||
| 1803 | } | 1816 | } |
| 1804 | 1817 | ||
| 1805 | 1818 | ||
| 1806 | xs_list *tag_search(const char *tag, int skip, int show) | 1819 | xs_str *tag_fn(const char *tag) |
| 1807 | /* returns the list of posts tagged with tag */ | ||
| 1808 | { | 1820 | { |
| 1809 | if (*tag == '#') | 1821 | if (*tag == '#') |
| 1810 | tag++; | 1822 | tag++; |
| 1811 | 1823 | ||
| 1812 | xs *lw_tag = xs_tolower_i(xs_dup(tag)); | 1824 | xs *lw_tag = xs_tolower_i(xs_dup(tag)); |
| 1813 | xs *md5 = xs_md5_hex(lw_tag, strlen(lw_tag)); | 1825 | xs *md5 = xs_md5_hex(lw_tag, strlen(lw_tag)); |
| 1814 | xs *idx = xs_fmt("%s/tag/%c%c/%s.idx", srv_basedir, md5[0], md5[1], md5); | 1826 | |
| 1827 | return xs_fmt("%s/tag/%c%c/%s.idx", srv_basedir, md5[0], md5[1], md5); | ||
| 1828 | } | ||
| 1829 | |||
| 1830 | |||
| 1831 | xs_list *tag_search(const char *tag, int skip, int show) | ||
| 1832 | /* returns the list of posts tagged with tag */ | ||
| 1833 | { | ||
| 1834 | xs *idx = tag_fn(tag); | ||
| 1815 | 1835 | ||
| 1816 | return index_list_desc(idx, skip, show); | 1836 | return index_list_desc(idx, skip, show); |
| 1817 | } | 1837 | } |
| @@ -145,13 +145,15 @@ int timeline_touch(snac *snac); | |||
| 145 | int timeline_here(snac *snac, const char *md5); | 145 | int timeline_here(snac *snac, const char *md5); |
| 146 | int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg); | 146 | int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg); |
| 147 | int timeline_del(snac *snac, const char *id); | 147 | int timeline_del(snac *snac, const char *id); |
| 148 | xs_list *timeline_simple_list(snac *snac, const char *idx_name, int skip, int show); | 148 | xs_str *user_index_fn(snac *user, const char *idx_name); |
| 149 | xs_list *timeline_simple_list(snac *user, const char *idx_name, int skip, int show); | ||
| 149 | xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show); | 150 | xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show); |
| 150 | int timeline_add(snac *snac, const char *id, const xs_dict *o_msg); | 151 | int timeline_add(snac *snac, const char *id, const xs_dict *o_msg); |
| 151 | int timeline_admire(snac *snac, const char *id, const char *admirer, int like); | 152 | int timeline_admire(snac *snac, const char *id, const char *admirer, int like); |
| 152 | 153 | ||
| 153 | xs_list *timeline_top_level(snac *snac, const xs_list *list); | 154 | xs_list *timeline_top_level(snac *snac, const xs_list *list); |
| 154 | xs_list *local_list(snac *snac, int max); | 155 | xs_list *local_list(snac *snac, int max); |
| 156 | xs_str *instance_index_fn(void); | ||
| 155 | xs_list *timeline_instance_list(int skip, int show); | 157 | xs_list *timeline_instance_list(int skip, int show); |
| 156 | 158 | ||
| 157 | int following_add(snac *snac, const char *actor, const xs_dict *msg); | 159 | int following_add(snac *snac, const char *actor, const xs_dict *msg); |
| @@ -179,6 +181,7 @@ void hide(snac *snac, const char *id); | |||
| 179 | int is_hidden(snac *snac, const char *id); | 181 | int is_hidden(snac *snac, const char *id); |
| 180 | 182 | ||
| 181 | void tag_index(const char *id, const xs_dict *obj); | 183 | void tag_index(const char *id, const xs_dict *obj); |
| 184 | xs_str *tag_fn(const char *tag); | ||
| 182 | xs_list *tag_search(const char *tag, int skip, int show); | 185 | xs_list *tag_search(const char *tag, int skip, int show); |
| 183 | 186 | ||
| 184 | xs_val *list_maint(snac *user, const char *list, int op); | 187 | xs_val *list_maint(snac *user, const char *list, int op); |