From 1ac74521291069d8b8666c6e6702b2f383fe7335 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Fri, 23 Mar 2018 01:08:25 +0100 Subject: [PATCH] AutoUpdater: Generate basic HTML changelog. --- Source/Core/UICommon/AutoUpdate.cpp | 45 ++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) 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 +#include #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()) + continue; + picojson::object ver_obj = ver.get(); + + if (ver_obj["changelog_html"].is()) + { + if (!changelog.empty()) + changelog += "
"; // Vertical spacing. + + // Try to link to the PR if we have this info. Otherwise just show shortrev. + if (ver_obj["pr_url"].is()) + { + changelog += "() + "\">" + + ver_obj["shortrev"].get() + ""; + } + else + { + changelog += ver_obj["shortrev"].get(); + } + + changelog += " by () + "\">" + + ver_obj["author"].get() + " — " + + ver_obj["short_descr"].get(); + } + else + { + if (!changelog.empty()) + changelog += "
"; + changelog += "Dolphin " + ver_obj["shortrev"].get() + ""; + changelog += "

" + ver_obj["changelog_html"].get() + "

"; + } + } + return changelog; +} } // namespace bool AutoUpdateChecker::SystemSupportsAutoUpdates() @@ -106,7 +149,7 @@ void AutoUpdateChecker::CheckForUpdate() nvi.new_hash = obj["new"].get()["hash"].get(); // TODO: generate the HTML changelog from the JSON information. - nvi.changelog_html = "

TBD

"; + nvi.changelog_html = GenerateChangelog(obj["changelog"].get()); OnUpdateAvailable(nvi); }