diff --git a/src/main.cpp b/src/main.cpp index dd2b4b9..49c75b1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,6 +38,7 @@ using std::endl; using std::string; using std::ostringstream; using std::stringstream; +using std::uint8_t; using std::uint16_t; using std::chrono::system_clock; @@ -105,6 +106,25 @@ const string strtime(const string &time) return strtime(std::chrono::system_clock::from_time_t(std::mktime(&tm))); } +void write_line(const uint8_t spaces, const string &tag, const string &value) +{ + string endtag; + // If there is a space in the tag, use only the part up until the space for + // the ending tag. + const size_t pos = tag.find(' '); + if (pos == std::string::npos) + { + endtag = tag; + } + else + { + endtag = tag.substr(0, pos); + } + + cout << std::string(spaces, ' '); + cout << '<' << tag << '>' << value << "\n"; +} + int main(int argc, char *argv[]) { const char *envquery = std::getenv("QUERY_STRING"); @@ -177,20 +197,17 @@ int main(int argc, char *argv[]) { const bool prerelease = release["prerelease"].asBool(); const string type = (prerelease ? "Pre-Release" : "Stable"); - cout << - " \n" - " " - << project << ": " << release["name"].asString() << "\n" - " " << baseurl << "/" << repo << "/releases\n" - " " - << domain << " release " << release["id"].asString() << "\n" - " " - << strtime(release["published_at"].asString()) << "\n" - " " << type << "

" - << "
\n" << release["body"].asString() << "\n"
-             << "      
Download tarball" << "]]>
\n"; - + cout << " \n"; + write_line(6, "title", project + ": " + release["name"].asString()); + write_line(6, "link", baseurl + "/" + repo + "/releases"); + write_line(6, "guid isPermaLink=\"false\"", + domain + " release " + release["id"].asString()); + write_line(6, "pubDate", strtime(release["published_at"].asString())); + write_line(6, "description", + "" + type + "

\n"
+                   + release["body"].asString() + "\n"
+                   "      
Download tarball" + "]]>"); cout << "
\n"; }