From 90dc7547484b7993cf725626f014130cca6212d4 Mon Sep 17 00:00:00 2001 From: relikd Date: Tue, 12 Feb 2019 21:48:18 +0100 Subject: [PATCH] Fix issue #1, use guid if no link is set --- baRSS/Core Data/FeedArticle+Ext.m | 16 +++++++--------- baRSS/Preferences/General Tab/SettingsGeneral.m | 6 +++++- .../Preferences/General Tab/SettingsGeneral.xib | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/baRSS/Core Data/FeedArticle+Ext.m b/baRSS/Core Data/FeedArticle+Ext.m index 4dbcff4..f2ea4ff 100644 --- a/baRSS/Core Data/FeedArticle+Ext.m +++ b/baRSS/Core Data/FeedArticle+Ext.m @@ -35,13 +35,16 @@ fa.unread = YES; fa.guid = entry.guid; fa.title = entry.title; - fa.abstract = entry.abstract; + if (entry.abstract.length > 0) { // remove html tags and save plain text to db + NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"<[^>]*>" options:kNilOptions error:nil]; + fa.abstract = [regex stringByReplacingMatchesInString:entry.abstract options:kNilOptions range:NSMakeRange(0, entry.abstract.length) withTemplate:@""]; + } fa.body = entry.body; fa.author = entry.author; fa.link = entry.link; fa.published = entry.datePublished; - if (!fa.published) - fa.published = entry.dateModified; + if (!fa.link) fa.link = entry.guid; // may be wrong, but better than returning nothing. + if (!fa.published) fa.published = entry.dateModified; return fa; } @@ -64,12 +67,7 @@ item.title = [self shortArticleName]; item.enabled = (self.link.length > 0); item.state = (self.unread && [UserPrefs defaultYES:@"feedTickMark"] ? NSControlStateValueOn : NSControlStateValueOff); - //mi.toolTip = item.abstract; - // TODO: Do regex during save, not during display. Its here for testing purposes ... - if (self.abstract.length > 0) { - NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"<[^>]*>" options:kNilOptions error:nil]; - item.toolTip = [regex stringByReplacingMatchesInString:self.abstract options:kNilOptions range:NSMakeRange(0, self.abstract.length) withTemplate:@""]; - } + item.toolTip = self.abstract; item.representedObject = self.objectID; item.target = [self class]; item.action = @selector(didClickOnMenuItem:); diff --git a/baRSS/Preferences/General Tab/SettingsGeneral.m b/baRSS/Preferences/General Tab/SettingsGeneral.m index 72b966e..49d8156 100644 --- a/baRSS/Preferences/General Tab/SettingsGeneral.m +++ b/baRSS/Preferences/General Tab/SettingsGeneral.m @@ -64,7 +64,11 @@ NSUInteger deleted = [StoreCoordinator deleteUnreferenced]; [StoreCoordinator restoreFeedIndexPaths]; [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationTotalUnreadCountReset object:nil]; - NSLog(@"Removed %lu unreferenced core data entries.", deleted); + // show only if >0, but hey, this button will vanish anyway ... + NSAlert *alert = [[NSAlert alloc] init]; + alert.messageText = [NSString stringWithFormat:@"Removed %lu unreferenced core data entries.", deleted]; + alert.alertStyle = NSAlertStyleInformational; + [alert runModal]; } - (IBAction)changeMenuBarIconSetting:(NSButton*)sender { diff --git a/baRSS/Preferences/General Tab/SettingsGeneral.xib b/baRSS/Preferences/General Tab/SettingsGeneral.xib index b667ff9..db2dd2e 100644 --- a/baRSS/Preferences/General Tab/SettingsGeneral.xib +++ b/baRSS/Preferences/General Tab/SettingsGeneral.xib @@ -380,7 +380,7 @@