aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-advanced-search.cxx51
-rw-r--r--mod/module.cli6
-rw-r--r--mod/page.cxx29
3 files changed, 74 insertions, 12 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;
}