diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-10 08:07:56 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-10 08:07:56 +0300 |
commit | 2acabec65b8af9a87a822c2171fdcce2fb4dfec7 (patch) | |
tree | 3aeb3f7d9ffbc34d158e28b0bbe353b79be8f823 | |
parent | aeaf46c5ac708bc225ea4095b7ce8fc607c74867 (diff) |
Feeds: Added option to ignore web links
-rw-r--r-- | po/en.po | 3 | ||||
-rw-r--r-- | res/lang/de.bin | bin | 26204 -> 26246 bytes | |||
-rw-r--r-- | res/lang/en.bin | bin | 23714 -> 23756 bytes | |||
-rw-r--r-- | res/lang/eo.bin | bin | 22568 -> 22610 bytes | |||
-rw-r--r-- | res/lang/es.bin | bin | 26228 -> 26270 bytes | |||
-rw-r--r-- | res/lang/es_MX.bin | bin | 24628 -> 24670 bytes | |||
-rw-r--r-- | res/lang/fi.bin | bin | 26500 -> 26542 bytes | |||
-rw-r--r-- | res/lang/fr.bin | bin | 26978 -> 27020 bytes | |||
-rw-r--r-- | res/lang/gl.bin | bin | 25521 -> 25563 bytes | |||
-rw-r--r-- | res/lang/ia.bin | bin | 25601 -> 25643 bytes | |||
-rw-r--r-- | res/lang/ie.bin | bin | 25363 -> 25405 bytes | |||
-rw-r--r-- | res/lang/isv.bin | bin | 22504 -> 22546 bytes | |||
-rw-r--r-- | res/lang/pl.bin | bin | 26805 -> 26847 bytes | |||
-rw-r--r-- | res/lang/ru.bin | bin | 38260 -> 38302 bytes | |||
-rw-r--r-- | res/lang/sk.bin | bin | 22833 -> 22875 bytes | |||
-rw-r--r-- | res/lang/sr.bin | bin | 37917 -> 37959 bytes | |||
-rw-r--r-- | res/lang/tok.bin | bin | 23799 -> 23841 bytes | |||
-rw-r--r-- | res/lang/zh_Hans.bin | bin | 22553 -> 22595 bytes | |||
-rw-r--r-- | res/lang/zh_Hant.bin | bin | 22622 -> 22664 bytes | |||
-rw-r--r-- | src/bookmarks.h | 1 | ||||
-rw-r--r-- | src/feeds.c | 14 | ||||
-rw-r--r-- | src/ui/util.c | 31 |
22 files changed, 35 insertions, 14 deletions
@@ -1195,6 +1195,9 @@ msgstr "YYYY-MM-DD Links" | |||
1195 | msgid "dlg.feed.type.headings" | 1195 | msgid "dlg.feed.type.headings" |
1196 | msgstr "New Headings" | 1196 | msgstr "New Headings" |
1197 | 1197 | ||
1198 | msgid "dlg.feed.ignoreweb" | ||
1199 | msgstr "Ignore HTTP(S) links:" | ||
1200 | |||
1198 | msgid "dlg.feed.save" | 1201 | msgid "dlg.feed.save" |
1199 | msgstr "Save Settings" | 1202 | msgstr "Save Settings" |
1200 | 1203 | ||
diff --git a/res/lang/de.bin b/res/lang/de.bin index 146d5381..6c107a9b 100644 --- a/res/lang/de.bin +++ b/res/lang/de.bin | |||
Binary files differ | |||
diff --git a/res/lang/en.bin b/res/lang/en.bin index 4bf379c3..f4643494 100644 --- a/res/lang/en.bin +++ b/res/lang/en.bin | |||
Binary files differ | |||
diff --git a/res/lang/eo.bin b/res/lang/eo.bin index deb8318a..0e979500 100644 --- a/res/lang/eo.bin +++ b/res/lang/eo.bin | |||
Binary files differ | |||
diff --git a/res/lang/es.bin b/res/lang/es.bin index 009a5602..5ff7a436 100644 --- a/res/lang/es.bin +++ b/res/lang/es.bin | |||
Binary files differ | |||
diff --git a/res/lang/es_MX.bin b/res/lang/es_MX.bin index 2dd5c250..80418686 100644 --- a/res/lang/es_MX.bin +++ b/res/lang/es_MX.bin | |||
Binary files differ | |||
diff --git a/res/lang/fi.bin b/res/lang/fi.bin index 9fc77c32..aed63d43 100644 --- a/res/lang/fi.bin +++ b/res/lang/fi.bin | |||
Binary files differ | |||
diff --git a/res/lang/fr.bin b/res/lang/fr.bin index e1ade2d7..50294528 100644 --- a/res/lang/fr.bin +++ b/res/lang/fr.bin | |||
Binary files differ | |||
diff --git a/res/lang/gl.bin b/res/lang/gl.bin index 817af16d..50132047 100644 --- a/res/lang/gl.bin +++ b/res/lang/gl.bin | |||
Binary files differ | |||
diff --git a/res/lang/ia.bin b/res/lang/ia.bin index 0dde0e4f..d9056731 100644 --- a/res/lang/ia.bin +++ b/res/lang/ia.bin | |||
Binary files differ | |||
diff --git a/res/lang/ie.bin b/res/lang/ie.bin index 648dca41..b7ac42ad 100644 --- a/res/lang/ie.bin +++ b/res/lang/ie.bin | |||
Binary files differ | |||
diff --git a/res/lang/isv.bin b/res/lang/isv.bin index 9d721ea5..8353d9c3 100644 --- a/res/lang/isv.bin +++ b/res/lang/isv.bin | |||
Binary files differ | |||
diff --git a/res/lang/pl.bin b/res/lang/pl.bin index f0f47033..dc3a47c2 100644 --- a/res/lang/pl.bin +++ b/res/lang/pl.bin | |||
Binary files differ | |||
diff --git a/res/lang/ru.bin b/res/lang/ru.bin index 1f59057b..e960e70e 100644 --- a/res/lang/ru.bin +++ b/res/lang/ru.bin | |||
Binary files differ | |||
diff --git a/res/lang/sk.bin b/res/lang/sk.bin index a31a6fd5..0d9388aa 100644 --- a/res/lang/sk.bin +++ b/res/lang/sk.bin | |||
Binary files differ | |||
diff --git a/res/lang/sr.bin b/res/lang/sr.bin index c5aa0b2b..8f213790 100644 --- a/res/lang/sr.bin +++ b/res/lang/sr.bin | |||
Binary files differ | |||
diff --git a/res/lang/tok.bin b/res/lang/tok.bin index 19a11654..7e96591b 100644 --- a/res/lang/tok.bin +++ b/res/lang/tok.bin | |||
Binary files differ | |||
diff --git a/res/lang/zh_Hans.bin b/res/lang/zh_Hans.bin index 86d96d3e..85b9df62 100644 --- a/res/lang/zh_Hans.bin +++ b/res/lang/zh_Hans.bin | |||
Binary files differ | |||
diff --git a/res/lang/zh_Hant.bin b/res/lang/zh_Hant.bin index fc0cb990..a92546c7 100644 --- a/res/lang/zh_Hant.bin +++ b/res/lang/zh_Hant.bin | |||
Binary files differ | |||
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 | ||
102 | static void deinit_FeedJob(iFeedJob *d) { | 104 | static 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 | ||
194 | static iBool isUrlIgnored_FeedJob_(const iFeedJob *d, iRangecc url) { | ||
195 | if (d->ignoreWeb) { | ||
196 | return startsWithCase_Rangecc(url, "http"); | ||
197 | } | ||
198 | return iFalse; | ||
199 | } | ||
200 | |||
192 | static void parseResult_FeedJob_(iFeedJob *d) { | 201 | static 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); |