diff options
-rw-r--r-- | mod/mod-advanced-search.cxx | 51 | ||||
-rw-r--r-- | mod/module.cli | 6 | ||||
-rw-r--r-- | mod/page.cxx | 29 | ||||
-rw-r--r-- | www/advanced-search-body.css | 19 | ||||
-rw-r--r-- | www/package-details-body.css | 12 | ||||
-rw-r--r-- | www/package-version-details-body.css | 12 |
6 files changed, 94 insertions, 35 deletions
diff --git a/mod/mod-advanced-search.cxx b/mod/mod-advanced-search.cxx index 5de3b9a..23d5430 100644 --- a/mod/mod-advanced-search.cxx +++ b/mod/mod-advanced-search.cxx @@ -98,6 +98,13 @@ package_query (const brep::params::advanced_search& params) if (!params.project ().empty ()) q = q && match<T> (query::project, params.project ()); + // Package repository. + // + const string& rp (params.repository ()); + + if (rp != "*") + q = q && query::internal_repository.canonical_name == rp; + // Reviews. // const string& rs (params.reviews ()); @@ -138,6 +145,9 @@ handle (request& rq, response& rs) // Thus, let's keep it simple for now and just respond with the 501 status // code (not implemented) if such a mode is detected. // + // NOTE: don't forget to update TR_PROJECT::operator() when/if this mode is + // supported. + // if (!tenant.empty ()) throw invalid_request (501, "not implemented"); @@ -177,6 +187,22 @@ handle (request& rq, response& rs) package_db_->query_value<package_count> ( package_query<package_count> (params))); + // Load the internal repositories as the canonical name/location pairs, + // sorting them in the same way as on the About page. + // + vector<pair<string, string>> repos ({{"*", "*"}}); + { + using query = query<repository>; + + for (repository& r: + package_db_->query<repository> ( + (query::internal && query::id.tenant == tenant) + + "ORDER BY" + query::priority)) + { + repos.emplace_back (move (r.id.canonical_name), r.location.string ()); + } + } + // Print the package builds filter form on the first page only. // size_t page (params.page ()); @@ -193,7 +219,8 @@ handle (request& rq, response& rs) << TBODY << TR_INPUT ("name", "advanced-search", params.name (), "*", true) << TR_INPUT ("version", "pv", params.version (), "*") - << TR_INPUT ("project", "pr", params.project (), "*"); + << TR_INPUT ("project", "pr", params.project (), "*") + << TR_SELECT ("repository", "rp", params.repository (), repos); if (options_->reviews_url_specified ()) s << TR_SELECT ("reviews", "rv", params.reviews (), reviews); @@ -245,10 +272,17 @@ handle (request& rq, response& rs) { if (p.project == prj) { + s << ~DIV; // 'versions' class. + if (p.name == pkg) s << DIV(ID="package-break") << "..." << ~DIV; s << DIV(ID="project-break") << "..." << ~DIV; + + // Make sure we don't serialize ~DIV(CLASS="versions") twice (see + // below). + // + pkg = package_name (); } break; @@ -256,18 +290,24 @@ handle (request& rq, response& rs) if (p.project != prj) { + if (!pkg.empty ()) + s << ~DIV; // 'versions' class. + prj = move (p.project); pkg = package_name (); s << TABLE(CLASS="proplist project") << TBODY - << TR_VALUE ("project", prj.string ()) + << TR_PROJECT (prj, root, tenant) << ~TBODY << ~TABLE; } if (p.name != pkg) { + if (!pkg.empty ()) + s << ~DIV; // 'versions' class. + pkg = move (p.name); s << TABLE(CLASS="proplist package") @@ -276,7 +316,8 @@ handle (request& rq, response& rs) << TR_SUMMARY (p.summary) << TR_LICENSE (p.license_alternatives) << ~TBODY - << ~TABLE; + << ~TABLE + << DIV(CLASS="versions"); } s << TABLE(CLASS="proplist version") @@ -302,6 +343,9 @@ handle (request& rq, response& rs) << ~TABLE; } + if (!pkg.empty ()) + s << ~DIV; // 'versions' class. + t.commit (); string u (root.string () + "?advanced-search"); @@ -327,6 +371,7 @@ handle (request& rq, response& rs) add_filter ("pv", params.version ()); add_filter ("pr", params.project ()); + add_filter ("rp", params.repository (), "*"); add_filter ("rv", params.reviews (), "*"); s << DIV_PAGER (page, diff --git a/mod/module.cli b/mod/module.cli index 41684bd..f0efed8 100644 --- a/mod/module.cli +++ b/mod/module.cli @@ -924,6 +924,12 @@ namespace brep // string project | pr; + // Package repositories. If *, then no repository constraint is applied. + // Otherwise the package repository canonical name must match the value + // exactly. + // + string repository | rp = "*"; + // Package version reviews. If *, then no reviews-related constraint is // applied. Otherwise the value is supposed to be the one of the // following statuses: reviewed and unreviewed. diff --git a/mod/page.cxx b/mod/page.cxx index 17fef91..afeea0d 100644 --- a/mod/page.cxx +++ b/mod/page.cxx @@ -302,15 +302,26 @@ namespace brep s << TR(CLASS="project") << TH << "project" << ~TH << TD - << SPAN(CLASS="value") - << A - << HREF - << tenant_dir (root_, tenant_) << "?packages=" - << mime_url_encode (project_.string ()) - << ~HREF - << project_ - << ~A - << ~SPAN + << SPAN(CLASS="value"); + + // Note that we currently don't support the advanced package search in the + // multi-tenant mode. Thus, we print the project as a plain text in such a + // mode, rather than as a link. + // + if (tenant_.empty ()) + { + s << A + << HREF + << tenant_dir (root_, tenant_) << "?advanced-search&pr=" + << mime_url_encode (project_.string ()) + << ~HREF + << project_ + << ~A; + } + else + s << project_; + + s << ~SPAN << ~TD << ~TR; } diff --git a/www/advanced-search-body.css b/www/advanced-search-body.css index b2a23f6..a54100f 100644 --- a/www/advanced-search-body.css +++ b/www/advanced-search-body.css @@ -36,22 +36,29 @@ table.project, .package, table.version, #filter .package, #project-break { - padding-left: 2.25em; + margin-left: -.4rem; + padding-left: 2.25rem; } table.version, #package-break { - padding-left: 4.5em; + margin-left: 4rem; + padding-left: .4rem; +} + +table.version +{ + width: calc(100% + .8rem - 4.4rem); } -table.version:nth-child(even) {background-color: rgba(0, 0, 0, 0.07);} +table.version:nth-child(odd) {background-color: rgba(0, 0, 0, 0.07);} -table.project th, .package th, #filter th +table.project th, .package th { width: 5.5em; } -table.version th +table.version th, #filter th { width: 7.3em; } @@ -76,8 +83,6 @@ table.version tr.reviews td .pass {color: #00bb00;} #package-break, #project-break { - margin-left: -.4rem; - /* <code> style. */ font-family: monospace; font-weight: 500; diff --git a/www/package-details-body.css b/www/package-details-body.css index bdef845..23bd8f1 100644 --- a/www/package-details-body.css +++ b/www/package-details-body.css @@ -118,8 +118,7 @@ h1, h2 } #package th {width: 7.6em;} -#package tr.topics td a, -#package tr.project td a +#package tr.topics td a { display: inline-block; @@ -129,21 +128,18 @@ h1, h2 margin: 0 0.35em 0.1em 0; } -#package tr.topics td a:visited, -#package tr.project td a:visited +#package tr.topics td a:visited { color: #3870c0; } -#package tr.topics td a:hover, -#package tr.project td a:hover +#package tr.topics td a:hover { text-decoration: none; background-color: #def; } -#package tr.topics td, -#package tr.project td +#package tr.topics td { padding: 0; margin: 0 0 0 -0.5em; diff --git a/www/package-version-details-body.css b/www/package-version-details-body.css index 45f5592..bd4d753 100644 --- a/www/package-version-details-body.css +++ b/www/package-version-details-body.css @@ -171,8 +171,7 @@ h1, h2, h3 } #package th {width: 9.5em;} -#package tr.topics td a, -#package tr.project td a +#package tr.topics td a { display: inline-block; @@ -182,21 +181,18 @@ h1, h2, h3 margin: 0 0.35em 0.1em 0; } -#package tr.topics td a:visited, -#package tr.project td a:visited +#package tr.topics td a:visited { color: #3870c0; } -#package tr.topics td a:hover, -#package tr.project td a:hover +#package tr.topics td a:hover { text-decoration: none; background-color: #def; } -#package tr.topics td, -#package tr.project td +#package tr.topics td { padding: 0; margin: 0 0 0 -0.5em; |