summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks.h1
-rw-r--r--src/feeds.c14
-rw-r--r--src/ui/util.c31
3 files changed, 32 insertions, 14 deletions
diff --git a/src/bookmarks.h b/src/bookmarks.h
index 13501ded..87d7694d 100644
--- a/src/bookmarks.h
+++ b/src/bookmarks.h
@@ -35,6 +35,7 @@ iDeclareTypeConstruction(Bookmark)
35/* TODO: Make the special internal tags a bitfield, separate from user's tags. */ 35/* TODO: Make the special internal tags a bitfield, separate from user's tags. */
36 36
37#define headings_BookmarkTag "headings" 37#define headings_BookmarkTag "headings"
38#define ignoreWeb_BookmarkTag "ignoreweb"
38#define homepage_BookmarkTag "homepage" 39#define homepage_BookmarkTag "homepage"
39#define linkSplit_BookmarkTag "linksplit" 40#define linkSplit_BookmarkTag "linksplit"
40#define remote_BookmarkTag "remote" 41#define remote_BookmarkTag "remote"
diff --git a/src/feeds.c b/src/feeds.c
index 188fffe7..baec6870 100644
--- a/src/feeds.c
+++ b/src/feeds.c
@@ -85,6 +85,7 @@ struct Impl_FeedJob {
85 iTime startTime; 85 iTime startTime;
86 iBool isFirstUpdate; /* hasn't been checked ever before */ 86 iBool isFirstUpdate; /* hasn't been checked ever before */
87 iBool checkHeadings; 87 iBool checkHeadings;
88 iBool ignoreWeb;
88 iGmRequest *request; 89 iGmRequest *request;
89 iPtrArray results; 90 iPtrArray results;
90}; 91};
@@ -97,6 +98,7 @@ static void init_FeedJob(iFeedJob *d, const iBookmark *bookmark) {
97 iZap(d->startTime); 98 iZap(d->startTime);
98 d->isFirstUpdate = iFalse; 99 d->isFirstUpdate = iFalse;
99 d->checkHeadings = hasTag_Bookmark(bookmark, headings_BookmarkTag); 100 d->checkHeadings = hasTag_Bookmark(bookmark, headings_BookmarkTag);
101 d->ignoreWeb = hasTag_Bookmark(bookmark, ignoreWeb_BookmarkTag);
100} 102}
101 103
102static void deinit_FeedJob(iFeedJob *d) { 104static void deinit_FeedJob(iFeedJob *d) {
@@ -189,6 +191,13 @@ static void trimTitle_(iString *title) {
189 remove_Block(&title->chars, 0, start - constBegin_String(title)); 191 remove_Block(&title->chars, 0, start - constBegin_String(title));
190} 192}
191 193
194static iBool isUrlIgnored_FeedJob_(const iFeedJob *d, iRangecc url) {
195 if (d->ignoreWeb) {
196 return startsWithCase_Rangecc(url, "http");
197 }
198 return iFalse;
199}
200
192static void parseResult_FeedJob_(iFeedJob *d) { 201static void parseResult_FeedJob_(iFeedJob *d) {
193 /* TODO: Should tell the user if the request failed. */ 202 /* TODO: Should tell the user if the request failed. */
194 if (isSuccess_GmStatusCode(status_GmRequest(d->request))) { 203 if (isSuccess_GmStatusCode(status_GmRequest(d->request))) {
@@ -214,7 +223,10 @@ static void parseResult_FeedJob_(iFeedJob *d) {
214 const iRangecc url = capturedRange_RegExpMatch(&m, 1); 223 const iRangecc url = capturedRange_RegExpMatch(&m, 1);
215 const iRangecc date = capturedRange_RegExpMatch(&m, 2); 224 const iRangecc date = capturedRange_RegExpMatch(&m, 2);
216 const iRangecc title = capturedRange_RegExpMatch(&m, 3); 225 const iRangecc title = capturedRange_RegExpMatch(&m, 3);
217 iFeedEntry * entry = new_FeedEntry(); 226 if (isUrlIgnored_FeedJob_(d, url)) {
227 continue;
228 }
229 iFeedEntry *entry = new_FeedEntry();
218 entry->discovered = now; 230 entry->discovered = now;
219 sub_Time(&now, &perEntryAdjust); 231 sub_Time(&now, &perEntryAdjust);
220 entry->bookmarkId = d->bookmarkId; 232 entry->bookmarkId = d->bookmarkId;
diff --git a/src/ui/util.c b/src/ui/util.c
index 0e079efb..ab799a36 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -2782,27 +2782,27 @@ static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) {
2782 } 2782 }
2783 int id = argLabel_Command(cmd, "bmid"); 2783 int id = argLabel_Command(cmd, "bmid");
2784 const iBool headings = isSelected_Widget(findChild_Widget(dlg, "feedcfg.type.headings")); 2784 const iBool headings = isSelected_Widget(findChild_Widget(dlg, "feedcfg.type.headings"));
2785 const iString *tags = collectNewFormat_String("subscribed%s", headings ? " headings" : ""); 2785 const iBool ignoreWeb = isSelected_Widget(findChild_Widget(dlg, "feedcfg.ignoreweb"));
2786 if (!id) { 2786 if (!id) {
2787 const size_t numSubs = numSubscribed_Feeds(); 2787 const size_t numSubs = numSubscribed_Feeds();
2788 const iString *url = url_DocumentWidget(document_App()); 2788 const iString *url = url_DocumentWidget(document_App());
2789 add_Bookmarks(bookmarks_App(), 2789 id = add_Bookmarks(bookmarks_App(),
2790 url, 2790 url,
2791 feedTitle, 2791 feedTitle,
2792 tags, 2792 NULL,
2793 siteIcon_GmDocument(document_DocumentWidget(document_App()))); 2793 siteIcon_GmDocument(document_DocumentWidget(document_App())));
2794 if (numSubs == 0) { 2794 if (numSubs == 0) {
2795 /* Auto-refresh after first addition. */ 2795 /* Auto-refresh after first addition. */
2796 /* TODO: Also when settings changed? */
2796 postCommand_App("feeds.refresh"); 2797 postCommand_App("feeds.refresh");
2797 } 2798 }
2798 } 2799 }
2799 else { 2800 iBookmark *bm = get_Bookmarks(bookmarks_App(), id);
2800 iBookmark *bm = get_Bookmarks(bookmarks_App(), id); 2801 iAssert(bm);
2801 if (bm) { 2802 set_String(&bm->title, feedTitle);
2802 set_String(&bm->title, feedTitle); 2803 addOrRemoveTag_Bookmark(bm, subscribed_BookmarkTag, iTrue);
2803 set_String(&bm->tags, tags); 2804 addOrRemoveTag_Bookmark(bm, headings_BookmarkTag, headings);
2804 } 2805 addOrRemoveTag_Bookmark(bm, ignoreWeb_BookmarkTag, ignoreWeb);
2805 }
2806 postCommand_App("bookmarks.changed"); 2806 postCommand_App("bookmarks.changed");
2807 setupSheetTransition_Mobile(dlg, iFalse); 2807 setupSheetTransition_Mobile(dlg, iFalse);
2808 destroy_Widget(dlg); 2808 destroy_Widget(dlg);
@@ -2831,6 +2831,7 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) {
2831 { format_CStr("title id:feedcfg.heading text:%s", headingText) }, 2831 { format_CStr("title id:feedcfg.heading text:%s", headingText) },
2832 { "input id:feedcfg.title text:${dlg.feed.title}" }, 2832 { "input id:feedcfg.title text:${dlg.feed.title}" },
2833 { "radio id:dlg.feed.entrytype", 0, 0, (const void *) typeItems }, 2833 { "radio id:dlg.feed.entrytype", 0, 0, (const void *) typeItems },
2834 { "toggle id:feedcfg.ignoreweb text:${dlg.feed.ignoreweb}" },
2834 { NULL } 2835 { NULL }
2835 }, actions, iElemCount(actions)); 2836 }, actions, iElemCount(actions));
2836 } 2837 }
@@ -2849,6 +2850,8 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) {
2849 addRadioButton_(types, "feedcfg.type.headings", "${dlg.feed.type.headings}", "feedcfg.type arg:1"); 2850 addRadioButton_(types, "feedcfg.type.headings", "${dlg.feed.type.headings}", "feedcfg.type arg:1");
2850 } 2851 }
2851 addChildFlags_Widget(values, iClob(types), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 2852 addChildFlags_Widget(values, iClob(types), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
2853 addChild_Widget(headings, iClob(makeHeading_Widget("${dlg.feed.ignoreweb}")));
2854 addChild_Widget(values, iClob(makeToggle_Widget("feedcfg.ignoreweb")));
2852 iWidget *buttons = 2855 iWidget *buttons =
2853 addChild_Widget(dlg, iClob(makeDialogButtons_Widget(actions, iElemCount(actions)))); 2856 addChild_Widget(dlg, iClob(makeDialogButtons_Widget(actions, iElemCount(actions))));
2854 setId_Widget(child_Widget(buttons, childCount_Widget(buttons) - 1), "feedcfg.save"); 2857 setId_Widget(child_Widget(buttons, childCount_Widget(buttons) - 1), "feedcfg.save");
@@ -2867,6 +2870,8 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) {
2867 : "feedcfg.type.gemini"), 2870 : "feedcfg.type.gemini"),
2868 selected_WidgetFlag, 2871 selected_WidgetFlag,
2869 iTrue); 2872 iTrue);
2873 setToggle_Widget(findChild_Widget(dlg, "feedcfg.ignoreweb"),
2874 hasTag_Bookmark(bm, ignoreWeb_BookmarkTag));
2870 setCommandHandler_Widget(dlg, handleFeedSettingCommands_); 2875 setCommandHandler_Widget(dlg, handleFeedSettingCommands_);
2871 } 2876 }
2872 setupSheetTransition_Mobile(dlg, incoming_TransitionFlag); 2877 setupSheetTransition_Mobile(dlg, incoming_TransitionFlag);