diff options
-rw-r--r-- | src/feeds.c | 43 | ||||
-rw-r--r-- | src/feeds.h | 2 | ||||
-rw-r--r-- | src/gmrequest.c | 6 |
3 files changed, 48 insertions, 3 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 | } | ||
diff --git a/src/feeds.h b/src/feeds.h index c5c3d447..7ad6c2aa 100644 --- a/src/feeds.h +++ b/src/feeds.h | |||
@@ -38,3 +38,5 @@ void init_Feeds (const char *saveDir); | |||
38 | void deinit_Feeds (void); | 38 | void deinit_Feeds (void); |
39 | 39 | ||
40 | const iPtrArray * listEntries_Feeds (void); | 40 | const iPtrArray * listEntries_Feeds (void); |
41 | |||
42 | const iString * entryListPage_Feeds (void); | ||
diff --git a/src/gmrequest.c b/src/gmrequest.c index 7443c68c..2ac580b6 100644 --- a/src/gmrequest.c +++ b/src/gmrequest.c | |||
@@ -25,8 +25,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
25 | #include "gmcerts.h" | 25 | #include "gmcerts.h" |
26 | #include "gopher.h" | 26 | #include "gopher.h" |
27 | #include "app.h" /* dataDir_App() */ | 27 | #include "app.h" /* dataDir_App() */ |
28 | #include "embedded.h" | 28 | #include "feeds.h" |
29 | #include "ui/text.h" | 29 | #include "ui/text.h" |
30 | #include "embedded.h" | ||
30 | #include "defs.h" | 31 | #include "defs.h" |
31 | 32 | ||
32 | #include <the_Foundation/file.h> | 33 | #include <the_Foundation/file.h> |
@@ -259,6 +260,9 @@ static const iBlock *aboutPageSource_(iRangecc path) { | |||
259 | if (equalCase_Rangecc(path, "debug")) { | 260 | if (equalCase_Rangecc(path, "debug")) { |
260 | return utf8_String(debugInfo_App()); | 261 | return utf8_String(debugInfo_App()); |
261 | } | 262 | } |
263 | if (equalCase_Rangecc(path, "feeds")) { | ||
264 | return utf8_String(entryListPage_Feeds()); | ||
265 | } | ||
262 | return src; | 266 | return src; |
263 | } | 267 | } |
264 | 268 | ||