Export as RSS feed.
More...
#include <remwharead/export/rss.hpp>
Export as RSS feed.
- Since
- 0.8.0
◆ ExportBase()
remwharead::Export::ExportBase::ExportBase |
|
explicit |
Export list of Database::entry.
- Parameters
-
const list< Database::entry > sort_entries(list< Database::entry > entries) const
Sort entries from newest to oldest.
Definition: export.cpp:30
◆ print()
void remwharead::Export::RSS::print |
( |
| ) |
const |
|
overridevirtual |
Print output to std::ostream.
Implements remwharead::Export::ExportBase.
42 XMLWriter writer(_out, XMLWriter::CANONICAL);
43 AttributesImpl attrs_rss, attrs_guid;
44 constexpr
char timefmt_rfc822[] =
"%w, %d %b %Y %H:%M:%S %Z";
46 attrs_rss.addAttribute(
"",
"",
"version",
"",
"2.0");
47 attrs_rss.addAttribute(
"",
"",
"xmlns:atom",
"",
48 "http://www.w3.org/2005/Atom");
49 attrs_guid.addAttribute(
"",
"",
"isPermaLink",
"",
"false");
51 writer.startDocument();
52 writer.startElement(
"",
"",
"rss", attrs_rss);
53 writer.startElement(
"",
"",
"channel");
55 writer.startElement(
"",
"",
"title");
56 writer.characters(
"Visited things");
57 writer.endElement(
"",
"",
"title");
59 writer.startElement(
"",
"",
"link");
61 writer.endElement(
"",
"",
"link");
63 writer.startElement(
"",
"",
"description");
64 writer.characters(
"Export from remwharead.");
65 writer.endElement(
"",
"",
"description");
67 writer.startElement(
"",
"",
"generator");
68 writer.characters(
string(
"remwharead ") + global::version);
69 writer.endElement(
"",
"",
"generator");
71 const string now = DateTimeFormatter::format(DateTime(),
73 writer.startElement(
"",
"",
"lastBuildDate");
74 writer.characters(now);
75 writer.endElement(
"",
"",
"lastBuildDate");
79 writer.startElement(
"",
"",
"item");
81 writer.startElement(
"",
"",
"title");
82 writer.characters(entry.title);
83 writer.endElement(
"",
"",
"title");
85 writer.startElement(
"",
"",
"link");
86 writer.characters(entry.uri);
87 writer.endElement(
"",
"",
"link");
89 writer.startElement(
"",
"",
"guid", attrs_guid);
90 writer.characters(entry.uri +
" at " +
91 timepoint_to_string(entry.datetime));
92 writer.endElement(
"",
"",
"guid");
94 const time_t time = system_clock::to_time_t(entry.datetime);
95 const string time_visited = DateTimeFormatter::format(
96 Timestamp::fromEpochTime(time), timefmt_rfc822);
97 writer.startElement(
"",
"",
"pubDate");
98 writer.characters(time_visited);
99 writer.endElement(
"",
"",
"pubDate");
101 string description = entry.description;
102 if (!description.empty())
104 description +=
"\n\n";
106 if (!entry.tags.empty())
108 description +=
"Tags: ";
109 for (
const string &tag : entry.tags)
112 if (tag != *(entry.tags.rbegin()))
118 if (!entry.archive_uri.empty())
120 description +=
"\n\nArchived version: " + entry.archive_uri;
122 writer.startElement(
"",
"",
"description");
123 writer.characters(description);
124 writer.endElement(
"",
"",
"description");
126 writer.endElement(
"",
"",
"item");
129 writer.endElement(
"",
"",
"channel");
130 writer.endElement(
"",
"",
"rss");
131 writer.endDocument();
134 catch (std::exception &e)
136 cerr <<
"Error in " << __func__ <<
": " << e.what() << endl;
struct remwharead::Database::entry entry
Describes a database entry.
The documentation for this class was generated from the following files:
- include/export/rss.hpp
- src/lib/export/rss.cpp