From 7e4c92e29954c14f9c1dd51aff95fff25d3ced32 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 22 May 2019 14:15:44 +0300 Subject: Add support for package manifest upstream-version value --- mod/mod-package-details.cxx | 2 +- mod/mod-package-version-details.cxx | 2 +- mod/page.cxx | 17 ++++++++++------- mod/page.hxx | 16 ++++++++++++---- 4 files changed, 24 insertions(+), 13 deletions(-) (limited to 'mod') diff --git a/mod/mod-package-details.cxx b/mod/mod-package-details.cxx index 5074eca..7b75e62 100644 --- a/mod/mod-package-details.cxx +++ b/mod/mod-package-details.cxx @@ -254,7 +254,7 @@ handle (request& rq, response& rs) s << TABLE(CLASS="proplist version") << TBODY - << TR_VERSION (name, p->version, root, tenant) + << TR_VERSION (name, p->version, root, tenant, p->upstream_version) // @@ Shouldn't we skip low priority row ? Don't think so, why? // diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx index 40cbad6..437bff4 100644 --- a/mod/mod-package-version-details.cxx +++ b/mod/mod-package-version-details.cxx @@ -210,7 +210,7 @@ handle (request& rq, response& rs) // Repeat version here since it can be cut out in the header. // - << TR_VERSION (pkg->version) + << TR_VERSION (pkg->version, pkg->upstream_version) << TR_PRIORITY (pkg->priority) << TR_LICENSES (pkg->license_alternatives) diff --git a/mod/page.cxx b/mod/page.cxx index 228a137..0c4c257 100644 --- a/mod/page.cxx +++ b/mod/page.cxx @@ -153,8 +153,8 @@ namespace brep if (!value_.empty ()) s << VALUE(value_); - if (!placeholder_.empty ()) - s << PLACEHOLDER(placeholder_); + if (placeholder_ != nullptr) + s << PLACEHOLDER(*placeholder_); if (autofocus_) s << AUTOFOCUS(""); @@ -249,7 +249,9 @@ namespace brep { s << version_; - if (stub_) + if (upstream_version_ != nullptr) + s << " (" << *upstream_version_ << ')'; + else if (stub_) s << " (stub)"; } else @@ -259,12 +261,13 @@ namespace brep s << A(HREF=tenant_dir (*root_, *tenant_) / dir_path (mime_url_encode (package_->string (), false)) / path (version_)) - << version_; + << version_ + << ~A; - if (stub_) + if (upstream_version_ != nullptr) + s << " (" << *upstream_version_ << ')'; + else if (stub_) s << " (stub)"; - - s << ~A; } s << ~SPAN diff --git a/mod/page.hxx b/mod/page.hxx index 7260031..28257c1 100644 --- a/mod/page.hxx +++ b/mod/page.hxx @@ -129,7 +129,11 @@ namespace brep const string& v, const string& p = string (), bool a = false) - : label_ (l), name_ (n), value_ (v), placeholder_ (p), autofocus_ (a) + : label_ (l), + name_ (n), + value_ (v), + placeholder_ (!p.empty () ? &p : nullptr), + autofocus_ (a) { } @@ -140,7 +144,7 @@ namespace brep const string& label_; const string& name_; const string& value_; - const string& placeholder_; + const string* placeholder_; bool autofocus_; }; @@ -222,9 +226,11 @@ namespace brep TR_VERSION (const package_name& p, const version& v, const dir_path& r, - const string& t) + const string& t, + const optional& u = nullopt) : package_ (&p), version_ (v.string ()), + upstream_version_ (u ? &*u : nullptr), stub_ (v.compare (wildcard_version, true) == 0), root_ (&r), tenant_ (&t) @@ -233,9 +239,10 @@ namespace brep // Display the version as a regular text. // - TR_VERSION (const version& v) + TR_VERSION (const version& v, const optional& u = nullopt) : package_ (nullptr), version_ (v.string ()), + upstream_version_ (u ? &*u : nullptr), stub_ (v.compare (wildcard_version, true) == 0), root_ (nullptr), tenant_ (nullptr) @@ -248,6 +255,7 @@ namespace brep private: const package_name* package_; string version_; + const string* upstream_version_; bool stub_; const dir_path* root_; const string* tenant_; -- cgit v1.1