Add FEED:source attribute

This commit is contained in:
Jaidyn Ann 2020-08-19 12:18:12 -05:00
parent a58c4a9f5c
commit abdf1a32d8
5 changed files with 13 additions and 1 deletions

View File

@ -79,6 +79,7 @@ AtomFeed::EntryParse ( Config* cfg, tinyxml2::XMLElement* xentry )
newEntry->SetTitle( xentry->FirstChildElement("title") );
newEntry->SetPostUrl( xentry->FirstChildElement("link")->Attribute("href") );
newEntry->SetFeedTitle( title );
bool set = false;
set = newEntry->SetDesc( xentry->FirstChildElement("summary") );

View File

@ -10,6 +10,7 @@ Entry::Entry ( BString outputPath )
{
title = BString("");
description = BString("");
feedTitle = BString("");
postUrl = BString("");
content = BString("");
outputDir = outputPath;
@ -32,6 +33,8 @@ Entry::Filetize ( Config* cfg, bool onlyIfNew = false )
title.String(), title.CountChars() );
file->WriteAttr( "FEED:description", B_STRING_TYPE, 0,
description.String(), description.CountChars() );
file->WriteAttr( "FEED:source", B_STRING_TYPE, 0,
feedTitle.String(), feedTitle.CountChars() );
file->WriteAttr( "META:url", B_STRING_TYPE, 0,
postUrl.String(), postUrl.CountChars() );
if ( date != NULL ) {
@ -52,7 +55,6 @@ bool Entry::SetTitle ( tinyxml2::XMLElement* elem ) {
if ( elem != NULL ) return SetTitle( elem->GetText() );
return false;
}
bool Entry::SetDesc ( const char* descStr ) {
if ( descStr != NULL ) description = BString( descStr );
else return false;
@ -62,6 +64,11 @@ bool Entry::SetDesc ( tinyxml2::XMLElement* elem ) {
if ( elem != NULL ) return SetDesc( elem->GetText() );
return false;
}
bool Entry::SetFeedTitle ( BString titleStr ) {
if ( titleStr != NULL ) feedTitle = titleStr;
else return false;
return true;
}
bool Entry::SetContent ( const char* contentStr ) {
if ( contentStr != NULL ) content = BString( contentStr );

View File

@ -12,6 +12,7 @@ class Entry {
public:
BString title;
BString description;
BString feedTitle;
BDateTime date;
BString postUrl;
BString content;
@ -25,6 +26,7 @@ public:
bool SetTitle ( tinyxml2::XMLElement* );
bool SetDesc ( const char* );
bool SetDesc ( tinyxml2::XMLElement* );
bool SetFeedTitle ( BString );
bool SetContent ( const char* );
bool SetContent ( tinyxml2::XMLElement* );
bool SetPostUrl ( const char* );

View File

@ -21,6 +21,7 @@ feedMimeType ( )
addAttribute( info, "FEED:name", "Name" );
addAttribute( info, "FEED:description", "Description" );
addAttribute( info, "META:url", "URL" );
addAttribute( info, "FEED:source", "Source" );
addAttribute( info, "FEED:when", "When", B_TIME_TYPE, true, false, 150 );
mime.SetAttrInfo(&info);

View File

@ -66,6 +66,7 @@ RssFeed::EntryParse ( Config* cfg, tinyxml2::XMLElement* xitem )
newEntry->SetDate ( xitem->FirstChildElement("pubDate") );
newEntry->SetPostUrl ( xitem->FirstChildElement("link") );
newEntry->SetContent ( xitem->FirstChildElement("content:encoded") );
newEntry->SetFeedTitle( title );
if ( lastDate == NULL || lastDate < newEntry->date )
lastDate = newEntry->date;