aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-package-details.cxx12
-rw-r--r--mod/mod-package-version-details.cxx16
-rw-r--r--mod/module.cli21
-rw-r--r--mod/page.cxx74
-rw-r--r--mod/page.hxx43
5 files changed, 164 insertions, 2 deletions
diff --git a/mod/mod-package-details.cxx b/mod/mod-package-details.cxx
index 1fb51da..15a4115 100644
--- a/mod/mod-package-details.cxx
+++ b/mod/mod-package-details.cxx
@@ -270,8 +270,16 @@ handle (request& rq, response& rs)
//
s << TR_REPOSITORY (rl, root, tenant)
<< TR_DEPENDS (p->dependencies, root, tenant)
- << TR_REQUIRES (p->requirements)
- << ~TBODY
+ << TR_REQUIRES (p->requirements);
+
+ if (options_->reviews_url_specified ())
+ {
+ package_db_->load (*p, p->reviews_section);
+
+ s << TR_REVIEWS_SUMMARY (p->reviews, options_->reviews_url ());
+ }
+
+ s << ~TBODY
<< ~TABLE;
}
s << ~DIV;
diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx
index 91923e5..e28310c 100644
--- a/mod/mod-package-version-details.cxx
+++ b/mod/mod-package-version-details.cxx
@@ -528,6 +528,22 @@ handle (request& rq, response& rs)
print_tests (test_dependency_type::examples);
print_tests (test_dependency_type::benchmarks);
+ if (options_->reviews_url_specified ())
+ {
+ package_db_->load (*pkg, pkg->reviews_section);
+
+ const optional<reviews_summary>& rvs (pkg->reviews);
+ const string& u (options_->reviews_url ());
+
+ s << H3 << "Reviews" << ~H3
+ << TABLE(CLASS="proplist", ID="reviews")
+ << TBODY
+ << TR_REVIEWS_COUNTER (review_result::fail, rvs, u)
+ << TR_REVIEWS_COUNTER (review_result::pass, rvs, u)
+ << ~TBODY
+ << ~TABLE;
+ }
+
bool builds (build_db_ != nullptr && pkg->buildable);
if (builds)
diff --git a/mod/module.cli b/mod/module.cli
index 5133935..7b0c0d2 100644
--- a/mod/module.cli
+++ b/mod/module.cli
@@ -454,6 +454,25 @@ namespace brep
}
};
+ class package_version_metadata
+ {
+ string reviews-url
+ {
+ "<url>",
+ "The base URL for the reviews manifest files. If this option is
+ specified, then the review information is displayed on the package
+ version details page.
+
+ The complete URL is formed by adding the following path to the base:
+
+ \
+ <project>/<package>/<version>/reviews.manifest
+ \
+
+ Note that no separator is added between the base and this path."
+ }
+ };
+
class page
{
web::xhtml::fragment logo
@@ -530,6 +549,7 @@ namespace brep
search,
page,
repository_url,
+ package_version_metadata,
handler
{
};
@@ -538,6 +558,7 @@ namespace brep
build, build_db,
page,
repository_url,
+ package_version_metadata,
handler
{
dir_path bindist-root
diff --git a/mod/page.cxx b/mod/page.cxx
index 177fb64..17fef91 100644
--- a/mod/page.cxx
+++ b/mod/page.cxx
@@ -618,6 +618,80 @@ namespace brep
<< ~TR;
}
+ // TR_REVIEWS_SUMMARY
+ //
+ void TR_REVIEWS_SUMMARY::
+ operator() (serializer& s) const
+ {
+ s << TR(CLASS="reviews")
+ << TH << "reviews" << ~TH
+ << TD
+ << SPAN(CLASS="value");
+
+ if (reviews_)
+ {
+ s << A
+ << HREF
+ << reviews_url_ << reviews_->manifest_file
+ << ~HREF;
+
+ if (reviews_->fail != 0)
+ s << SPAN(CLASS="fail") << '-' << reviews_->fail << ~SPAN;
+
+ if (reviews_->fail != 0 && reviews_->pass != 0)
+ s << '/';
+
+ if (reviews_->pass != 0)
+ s << SPAN(CLASS="pass") << '+' << reviews_->pass << ~SPAN;
+
+ s << ~A;
+ }
+ else
+ s << SPAN(CLASS="none") << 0 << ~SPAN;
+
+ s << ~SPAN
+ << ~TD
+ << ~TR;
+ }
+
+ // TR_REVIEWS_COUNTER
+ //
+ void TR_REVIEWS_COUNTER::
+ operator() (serializer& s) const
+ {
+ const char* l (result == review_result::fail ? "fail" : "pass");
+
+ s << TR(CLASS=l)
+ << TH << l << ~TH
+ << TD
+ << SPAN(CLASS="value");
+
+ if (reviews_)
+ {
+ size_t n (result == review_result::fail
+ ? reviews_->fail
+ : reviews_->pass);
+
+ if (n != 0)
+ {
+ s << A
+ << HREF
+ << reviews_url_ << reviews_->manifest_file
+ << ~HREF
+ << SPAN(CLASS=l) << n << ~SPAN
+ << ~A;
+ }
+ else
+ s << n;
+ }
+ else
+ s << SPAN(CLASS="none") << 0 << ~SPAN;
+
+ s << ~SPAN
+ << ~TD
+ << ~TR;
+ }
+
// TR_URL
//
void TR_URL::
diff --git a/mod/page.hxx b/mod/page.hxx
index 7329e2d..3455fe8 100644
--- a/mod/page.hxx
+++ b/mod/page.hxx
@@ -15,6 +15,7 @@
#include <libbrep/build.hxx>
#include <libbrep/package.hxx>
+#include <libbrep/review-manifest.hxx> // review_result
#include <mod/diagnostics.hxx>
#include <mod/options-types.hxx> // page_menu
@@ -371,6 +372,48 @@ namespace brep
const requirements& requirements_;
};
+ // Generate package versions reviews summary element.
+ //
+ class TR_REVIEWS_SUMMARY
+ {
+ public:
+ TR_REVIEWS_SUMMARY (const optional<reviews_summary>& rs, const string& u)
+ : reviews_ (rs), reviews_url_ (u) {}
+
+ void
+ operator() (xml::serializer&) const;
+
+ private:
+ const optional<reviews_summary>& reviews_;
+ const string& reviews_url_;
+ };
+
+ // Generate package versions reviews summary counter element. The passed
+ // review result denotes which kind of counter needs to be displayed and can
+ // only be fail or pass.
+ //
+ class TR_REVIEWS_COUNTER
+ {
+ public:
+ TR_REVIEWS_COUNTER (review_result r,
+ const optional<reviews_summary>& rs,
+ const string& u)
+ : result (r),
+ reviews_ (rs),
+ reviews_url_ (u)
+ {
+ assert (r == review_result::fail || r == review_result::pass);
+ }
+
+ void
+ operator() (xml::serializer&) const;
+
+ private:
+ review_result result;
+ const optional<reviews_summary>& reviews_;
+ const string& reviews_url_;
+ };
+
// Generate url element. Strip the `<scheme>://` prefix from the link text.
//
class TR_URL