diff options
| author | 2024-08-09 16:28:57 +0200 | |
|---|---|---|
| committer | 2024-08-09 16:28:57 +0200 | |
| commit | f5332ec0164a3a92d58081700267fe86c7aaa5a1 (patch) | |
| tree | 05c1b67c75aaa42c0f5c3c4a9a60b461049d84de /data.c | |
| 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 'data.c')
| -rw-r--r-- | data.c | 32 |
1 files changed, 26 insertions, 6 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 | } |