From e28ab8f48c891c03cf4b3a8ed88b98d38a561960 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 Dec 2015 13:45:08 +0200 Subject: Separate brep module configuration from Apache server configuration --- brep/package-search.cxx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'brep/package-search.cxx') diff --git a/brep/package-search.cxx b/brep/package-search.cxx index f2f922c..62b162b 100644 --- a/brep/package-search.cxx +++ b/brep/package-search.cxx @@ -14,9 +14,10 @@ #include #include -#include #include #include + +#include #include #include #include @@ -33,6 +34,9 @@ init (scanner& s) options_ = make_shared ( s, unknown_mode::fail, unknown_mode::fail); + if (options_->root ().empty ()) + options_->root (dir_path ("/")); + db_ = shared_database (options_->db_host (), options_->db_port ()); } @@ -48,7 +52,7 @@ search_param (const brep::string& q) ")"; } -void brep::package_search:: +bool brep::package_search:: handle (request& rq, response& rs) { using namespace web::xhtml; @@ -58,17 +62,14 @@ handle (request& rq, response& rs) // The module options object is not changed after being created once per // server process. // - static const size_t res_page (options_->results_on_page ()); - static const dir_path& root ( - options_->root ().empty () - ? dir_path ("/") - : options_->root ()); + static const size_t res_page (options_->search_results ()); + static const dir_path& root (options_->root ()); params::package_search params; try { - param_scanner s (rq.parameters ()); + name_value_scanner s (rq.parameters ()); params = params::package_search (s, unknown_mode::fail, unknown_mode::fail); } catch (const unknown_argument& e) @@ -137,9 +138,11 @@ handle (request& rq, response& rs) t.commit (); - s << DIV_PAGER (page, pkg_count, res_page, options_->pages_in_pager (), + s << DIV_PAGER (page, pkg_count, res_page, options_->pager_pages (), root.string () + squery_param) << ~DIV << ~BODY << ~HTML; + + return true; } -- cgit v1.1