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->SetTitle( xentry->FirstChildElement("title") );
newEntry->SetPostUrl( xentry->FirstChildElement("link")->Attribute("href") ); newEntry->SetPostUrl( xentry->FirstChildElement("link")->Attribute("href") );
newEntry->SetFeedTitle( title );
bool set = false; bool set = false;
set = newEntry->SetDesc( xentry->FirstChildElement("summary") ); set = newEntry->SetDesc( xentry->FirstChildElement("summary") );

View File

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

View File

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

View File

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

View File

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