diff options
Diffstat (limited to 'src/feeds.c')
-rw-r--r-- | src/feeds.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/feeds.c b/src/feeds.c index 87fd0d67..a1b7414e 100644 --- a/src/feeds.c +++ b/src/feeds.c | |||
@@ -253,12 +253,16 @@ static iBool isSubscribed_(void *context, const iBookmark *bm) { | |||
253 | return indexOfCStr_String(&bm->tags, "subscribed") != iInvalidPos; /* TODO: RegExp with \b */ | 253 | return indexOfCStr_String(&bm->tags, "subscribed") != iInvalidPos; /* TODO: RegExp with \b */ |
254 | } | 254 | } |
255 | 255 | ||
256 | static const iPtrArray *listSubscriptions_(void) { | ||
257 | return list_Bookmarks(bookmarks_App(), NULL, isSubscribed_, NULL); | ||
258 | } | ||
259 | |||
256 | static iBool startWorker_Feeds_(iFeeds *d) { | 260 | static iBool startWorker_Feeds_(iFeeds *d) { |
257 | if (d->worker) { | 261 | if (d->worker) { |
258 | return iFalse; /* Oops? */ | 262 | return iFalse; /* Oops? */ |
259 | } | 263 | } |
260 | /* Queue up all the subscriptions for the worker. */ | 264 | /* Queue up all the subscriptions for the worker. */ |
261 | iConstForEach(PtrArray, i, list_Bookmarks(bookmarks_App(), NULL, isSubscribed_, NULL)) { | 265 | iConstForEach(PtrArray, i, listSubscriptions_()) { |
262 | iFeedJob* job = new_FeedJob(i.ptr); | 266 | iFeedJob* job = new_FeedJob(i.ptr); |
263 | pushBack_PtrArray(&d->jobs, job); | 267 | pushBack_PtrArray(&d->jobs, job); |
264 | } | 268 | } |
@@ -303,7 +307,7 @@ static void save_Feeds_(iFeeds *d) { | |||
303 | format_String(str, "%llu\n# Feeds\n", integralSeconds_Time(&d->lastRefreshedAt)); | 307 | format_String(str, "%llu\n# Feeds\n", integralSeconds_Time(&d->lastRefreshedAt)); |
304 | write_File(f, utf8_String(str)); | 308 | write_File(f, utf8_String(str)); |
305 | /* Index of feeds for IDs. */ { | 309 | /* Index of feeds for IDs. */ { |
306 | iConstForEach(PtrArray, i, list_Bookmarks(bookmarks_App(), NULL, isSubscribed_, NULL)) { | 310 | iConstForEach(PtrArray, i, listSubscriptions_()) { |
307 | const iBookmark *bm = i.ptr; | 311 | const iBookmark *bm = i.ptr; |
308 | format_String(str, "%08x %s\n", id_Bookmark(bm), cstr_String(&bm->url)); | 312 | format_String(str, "%08x %s\n", id_Bookmark(bm), cstr_String(&bm->url)); |
309 | write_File(f, utf8_String(str)); | 313 | write_File(f, utf8_String(str)); |
@@ -460,3 +464,38 @@ const iPtrArray *listEntries_Feeds(void) { | |||
460 | sort_Array(list, cmpTimeDescending_FeedEntryPtr_); | 464 | sort_Array(list, cmpTimeDescending_FeedEntryPtr_); |
461 | return list; | 465 | return list; |
462 | } | 466 | } |
467 | |||
468 | const iString *entryListPage_Feeds(void) { | ||
469 | iFeeds *d = &feeds_; | ||
470 | iString *src = collectNew_String(); | ||
471 | format_String(src, "# Aggregated Gemini feeds\n"); | ||
472 | lock_Mutex(d->mtx); | ||
473 | const iPtrArray *subs = listSubscriptions_(); | ||
474 | appendFormat_String(src, "You are subscribed to %zu feed%s that contain%s a total of %zu entries.\n", | ||
475 | size_PtrArray(subs), | ||
476 | size_PtrArray(subs) != 1 ? "s" : "", | ||
477 | size_PtrArray(subs) == 1 ? "s" : "", | ||
478 | size_SortedArray(&d->entries)); | ||
479 | iDate on; | ||
480 | iZap(on); | ||
481 | iConstForEach(PtrArray, i, listEntries_Feeds()) { | ||
482 | const iFeedEntry *entry = i.ptr; | ||
483 | iDate entryDate; | ||
484 | init_Date(&entryDate, &entry->timestamp); | ||
485 | if (on.year != entryDate.year || on.month != entryDate.month || on.day != entryDate.day) { | ||
486 | appendFormat_String( | ||
487 | src, "## %s\n", cstrCollect_String(format_Date(&entryDate, "%Y-%m-%d"))); | ||
488 | on = entryDate; | ||
489 | } | ||
490 | const iBookmark *bm = get_Bookmarks(bookmarks_App(), entry->bookmarkId); | ||
491 | if (bm) { | ||
492 | appendFormat_String(src, | ||
493 | "=> %s %s - %s\n", | ||
494 | cstr_String(&entry->url), | ||
495 | cstr_String(&bm->title), | ||
496 | cstr_String(&entry->title)); | ||
497 | } | ||
498 | } | ||
499 | unlock_Mutex(d->mtx); | ||
500 | return src; | ||
501 | } | ||