Add article abstract
This commit is contained in:
@@ -29,9 +29,9 @@
|
||||
@property (nonatomic) NSMutableArray *attributesStack;
|
||||
@property (nonatomic, readonly) NSDictionary *currentAttributes;
|
||||
@property (nonatomic) NSMutableString *xhtmlString;
|
||||
@property (nonatomic) NSString *link;
|
||||
@property (nonatomic) NSString *title;
|
||||
@property (nonatomic) NSString *subtitle;
|
||||
@property (nonatomic) NSString *feedLink;
|
||||
@property (nonatomic) NSString *feedTitle;
|
||||
@property (nonatomic) NSString *feedSubtitle;
|
||||
@property (nonatomic) NSMutableArray *articles;
|
||||
@property (nonatomic) NSDate *dateParsed;
|
||||
@property (nonatomic) RSSAXParser *parser;
|
||||
@@ -110,8 +110,8 @@
|
||||
|
||||
[self parse];
|
||||
|
||||
RSParsedFeed *parsedFeed = [[RSParsedFeed alloc] initWithURLString:self.urlString title:self.title link:self.link articles:self.articles];
|
||||
parsedFeed.subtitle = self.subtitle;
|
||||
RSParsedFeed *parsedFeed = [[RSParsedFeed alloc] initWithURLString:self.urlString title:self.feedTitle link:self.feedLink articles:self.articles];
|
||||
parsedFeed.subtitle = self.feedSubtitle;
|
||||
|
||||
return parsedFeed;
|
||||
}
|
||||
@@ -261,28 +261,28 @@ static const NSInteger kSelfLength = 5;
|
||||
|
||||
- (void)addFeedLink {
|
||||
|
||||
if (self.link && self.link.length > 0) {
|
||||
if (self.feedLink && self.feedLink.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *related = self.currentAttributes[kRelKey];
|
||||
if (related == kAlternateValue) {
|
||||
self.link = self.currentAttributes[kHrefKey];
|
||||
self.feedLink = self.currentAttributes[kHrefKey];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)addFeedTitle {
|
||||
|
||||
if (self.title.length < 1) {
|
||||
self.title = self.parser.currentStringWithTrimmedWhitespace;
|
||||
if (self.feedTitle.length < 1) {
|
||||
self.feedTitle = self.parser.currentStringWithTrimmedWhitespace;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addFeedSubtitle {
|
||||
|
||||
if (self.subtitle.length < 1) {
|
||||
self.subtitle = self.parser.currentStringWithTrimmedWhitespace;
|
||||
if (self.feedSubtitle.length < 1) {
|
||||
self.feedSubtitle = self.parser.currentStringWithTrimmedWhitespace;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,9 +319,7 @@ static const NSInteger kSelfLength = 5;
|
||||
|
||||
- (void)addSummary {
|
||||
|
||||
if (!self.currentArticle.body) {
|
||||
self.currentArticle.body = [self currentStringWithHTMLEntitiesDecoded];
|
||||
}
|
||||
self.currentArticle.abstract = [self currentStringWithHTMLEntitiesDecoded];
|
||||
}
|
||||
|
||||
|
||||
@@ -472,16 +470,12 @@ static const NSInteger kSelfLength = 5;
|
||||
BOOL isContentTag = RSSAXEqualTags(localName, kContent, kContentLength);
|
||||
BOOL isSummaryTag = RSSAXEqualTags(localName, kSummary, kSummaryLength);
|
||||
|
||||
if (self.parsingArticle && (isContentTag || isSummaryTag)) {
|
||||
|
||||
if (self.parsingArticle) {
|
||||
if (isContentTag) {
|
||||
self.currentArticle.body = [self.xhtmlString copy];
|
||||
}
|
||||
|
||||
else if (isSummaryTag) {
|
||||
if (self.currentArticle.body.length < 1) {
|
||||
self.currentArticle.body = [self.xhtmlString copy];
|
||||
}
|
||||
self.currentArticle.abstract = [self.xhtmlString copy];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
RSXML/RSParsedArticle.h
Normal file → Executable file
1
RSXML/RSParsedArticle.h
Normal file → Executable file
@@ -18,6 +18,7 @@
|
||||
|
||||
@property (nonatomic, nullable) NSString *guid;
|
||||
@property (nonatomic, nullable) NSString *title;
|
||||
@property (nonatomic, nullable) NSString *abstract;
|
||||
@property (nonatomic, nullable) NSString *body;
|
||||
@property (nonatomic, nullable) NSString *link;
|
||||
@property (nonatomic, nullable) NSString *permalink;
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
@property (nonatomic) BOOL parsingChannelImage;
|
||||
@property (nonatomic, readonly) NSDate *currentDate;
|
||||
@property (nonatomic) BOOL endRSSFound;
|
||||
@property (nonatomic) NSString *link;
|
||||
@property (nonatomic) NSString *title;
|
||||
@property (nonatomic) NSString *subtitle;
|
||||
@property (nonatomic) NSString *feedLink;
|
||||
@property (nonatomic) NSString *feedTitle;
|
||||
@property (nonatomic) NSString *feedSubtitle;
|
||||
@property (nonatomic) NSDate *dateParsed;
|
||||
|
||||
@end
|
||||
@@ -105,8 +105,8 @@
|
||||
|
||||
[self parse];
|
||||
|
||||
RSParsedFeed *parsedFeed = [[RSParsedFeed alloc] initWithURLString:self.urlString title:self.title link:self.link articles:self.articles];
|
||||
parsedFeed.subtitle = self.subtitle;
|
||||
RSParsedFeed *parsedFeed = [[RSParsedFeed alloc] initWithURLString:self.urlString title:self.feedTitle link:self.feedLink articles:self.articles];
|
||||
parsedFeed.subtitle = self.feedSubtitle;
|
||||
|
||||
return parsedFeed;
|
||||
}
|
||||
@@ -230,17 +230,17 @@ static const NSInteger kTrueLength = 5;
|
||||
}
|
||||
|
||||
if (RSSAXEqualTags(localName, kLink, kLinkLength)) {
|
||||
if (!self.link) {
|
||||
self.link = self.parser.currentStringWithTrimmedWhitespace;
|
||||
if (!self.feedLink) {
|
||||
self.feedLink = self.parser.currentStringWithTrimmedWhitespace;
|
||||
}
|
||||
}
|
||||
|
||||
else if (RSSAXEqualTags(localName, kTitle, kTitleLength)) {
|
||||
self.title = self.parser.currentStringWithTrimmedWhitespace;
|
||||
self.feedTitle = self.parser.currentStringWithTrimmedWhitespace;
|
||||
}
|
||||
|
||||
else if (RSSAXEqualTags(localName, kDescription, kDescriptionLength)) {
|
||||
self.subtitle = self.parser.currentStringWithTrimmedWhitespace;
|
||||
self.feedSubtitle = self.parser.currentStringWithTrimmedWhitespace;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,12 +277,12 @@ static const NSInteger kTrueLength = 5;
|
||||
return s;
|
||||
}
|
||||
|
||||
if (!self.link) {
|
||||
if (!self.feedLink) {
|
||||
//TODO: get feed URL and use that to resolve URL.*/
|
||||
return s;
|
||||
}
|
||||
|
||||
NSURL *baseURL = [NSURL URLWithString:self.link];
|
||||
NSURL *baseURL = [NSURL URLWithString:self.feedLink];
|
||||
if (!baseURL) {
|
||||
return s;
|
||||
}
|
||||
@@ -332,10 +332,7 @@ static const NSInteger kTrueLength = 5;
|
||||
self.currentArticle.link = [self urlString:self.parser.currentStringWithTrimmedWhitespace];
|
||||
}
|
||||
else if (RSSAXEqualTags(localName, kDescription, kDescriptionLength)) {
|
||||
|
||||
if (!self.currentArticle.body) {
|
||||
self.currentArticle.body = [self currentStringWithHTMLEntitiesDecoded];
|
||||
}
|
||||
self.currentArticle.abstract = [self currentStringWithHTMLEntitiesDecoded];
|
||||
}
|
||||
else if (RSSAXEqualTags(localName, kTitle, kTitleLength)) {
|
||||
self.currentArticle.title = [self currentStringWithHTMLEntitiesDecoded];
|
||||
|
||||
Reference in New Issue
Block a user