diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2018-03-23 01:08:25 +0100 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2018-03-23 11:10:25 +0100 |
| commit | 1ac74521291069d8b8666c6e6702b2f383fe7335 (patch) | |
| tree | 05b0f463f4e019223e57b029d9d96cc261d00e60 /Source/Core/UICommon/AutoUpdate.cpp | |
| parent | 1f3310874b0a38cac3547b85392f50a8244f8649 (diff) | |
AutoUpdater: Generate basic HTML changelog.
Diffstat (limited to 'Source/Core/UICommon/AutoUpdate.cpp')
| -rw-r--r-- | Source/Core/UICommon/AutoUpdate.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/Source/Core/UICommon/AutoUpdate.cpp b/Source/Core/UICommon/AutoUpdate.cpp index 2554969257..003135683a 100644 --- a/Source/Core/UICommon/AutoUpdate.cpp +++ b/Source/Core/UICommon/AutoUpdate.cpp @@ -5,6 +5,7 @@ #include "UICommon/AutoUpdate.h" #include <picojson/picojson.h> +#include <string> #include "Common/CommonPaths.h" #include "Common/FileUtil.h" @@ -46,6 +47,48 @@ void CleanupFromPreviousUpdate() File::Delete(reloc_updater_path); } #endif + +// This ignores i18n because most of the text in there (change descriptions) is only going to be +// written in english anyway. +std::string GenerateChangelog(const picojson::array& versions) +{ + std::string changelog; + for (const auto& ver : versions) + { + if (!ver.is<picojson::object>()) + continue; + picojson::object ver_obj = ver.get<picojson::object>(); + + if (ver_obj["changelog_html"].is<picojson::null>()) + { + if (!changelog.empty()) + changelog += "<div style=\"margin-top: 0.4em;\"></div>"; // Vertical spacing. + + // Try to link to the PR if we have this info. Otherwise just show shortrev. + if (ver_obj["pr_url"].is<std::string>()) + { + changelog += "<a href=\"" + ver_obj["pr_url"].get<std::string>() + "\">" + + ver_obj["shortrev"].get<std::string>() + "</a>"; + } + else + { + changelog += ver_obj["shortrev"].get<std::string>(); + } + + changelog += " by <a href = \"" + ver_obj["author_url"].get<std::string>() + "\">" + + ver_obj["author"].get<std::string>() + "</a> — " + + ver_obj["short_descr"].get<std::string>(); + } + else + { + if (!changelog.empty()) + changelog += "<hr>"; + changelog += "<b>Dolphin " + ver_obj["shortrev"].get<std::string>() + "</b>"; + changelog += "<p>" + ver_obj["changelog_html"].get<std::string>() + "</p>"; + } + } + return changelog; +} } // namespace bool AutoUpdateChecker::SystemSupportsAutoUpdates() @@ -106,7 +149,7 @@ void AutoUpdateChecker::CheckForUpdate() nvi.new_hash = obj["new"].get<picojson::object>()["hash"].get<std::string>(); // TODO: generate the HTML changelog from the JSON information. - nvi.changelog_html = "<h2>TBD</h2>"; + nvi.changelog_html = GenerateChangelog(obj["changelog"].get<picojson::array>()); OnUpdateAvailable(nvi); } |
