aboutsummaryrefslogtreecommitdiff
path: root/brep
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-15 13:38:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-15 13:38:57 +0200
commitef9615aebb8a7b504c3b5cd2610e3c8f5bb4de58 (patch)
treeaca0be97a87005f177d0e015f132b117726cfe12 /brep
parentd43e00ba64a5332100a8a2330d251051302b0193 (diff)
Various cleanups and improvements, INSTALL-DEV instructions
Diffstat (limited to 'brep')
-rw-r--r--brep/module2
-rw-r--r--brep/module.cxx2
-rw-r--r--brep/options.cli88
-rw-r--r--brep/package-details.cxx6
-rw-r--r--brep/package-search.cxx4
-rw-r--r--brep/package-version-details.cxx8
-rw-r--r--brep/repository-details.cxx2
-rw-r--r--brep/shared-database4
-rw-r--r--brep/shared-database.cxx14
9 files changed, 103 insertions, 27 deletions
diff --git a/brep/module b/brep/module
index 4ac6023..80a0a56 100644
--- a/brep/module
+++ b/brep/module
@@ -81,7 +81,7 @@ namespace brep
//
// While uint8 is more than enough, use uint16 for the ease of printing.
//
- uint16_t verb_ {0};
+ uint16_t verb_ = 0;
template <class F> void level1 (const F& f) const {if (verb_ >= 1) f ();}
template <class F> void level2 (const F& f) const {if (verb_ >= 2) f ();}
diff --git a/brep/module.cxx b/brep/module.cxx
index 253d807..d3ffcb4 100644
--- a/brep/module.cxx
+++ b/brep/module.cxx
@@ -207,7 +207,7 @@ namespace brep
name_value_scanner s (mo);
options::module o (s, unknown_mode::fail, unknown_mode::fail);
- verb_ = o.log_verbosity ();
+ verb_ = o.verbosity ();
loaded_ = true;
}
catch (const server_error& e)
diff --git a/brep/options.cli b/brep/options.cli
index d5041c8..aaf0092 100644
--- a/brep/options.cli
+++ b/brep/options.cli
@@ -16,43 +16,107 @@ namespace brep
//
class module
{
- uint16_t log-verbosity;
- dir_path root = "/";
+ dir_path root = "/"
+ {
+ "<path>"
+ "Repository root. That is, this is the part of the URL from the host
+ name and until the start of the repository. For example, root value
+ '\cb{/pkg/}' means the repository URL is http://example.org/pkg/.
+ Specify '\cb{/}' to use the web server root (http://example.org/)."
+ }
+
+ uint16_t verbosity = 0
+ {
+ "<level>",
+ "Trace verbosity level. Level 0 disables tracing, which is also the
+ default."
+ }
};
class db
{
- string db-host = "localhost";
- uint16_t db-port = 5432;
+ string db-user
+ {
+ "<user>",
+ "Database user name. If not specified, then operating system (login)
+ name is used."
+ }
+
+ string db-password
+ {
+ "<pass>",
+ "Database password. If not specified, then login without password is
+ expected to work."
+ }
+
+ string db-name = "brep"
+ {
+ "<name>",
+ "Database name. If not specified, then '\cb{brep}' is used by default."
+ }
+
+ string db-host
+ {
+ "<host>",
+ "Database host name, address, or socket. If not specified, then connect
+ to \cb{localhost} using the operating system-default mechanism
+ (Unix-domain socket, etc)."
+ }
+
+ uint16_t db-port = 0
+ {
+ "<port>",
+ "Database port number. If not specified, the default port is used."
+ }
};
class search
{
- uint16_t search-results = 10;
- uint16_t pager-pages = 5;
+ uint16_t search-results = 10
+ {
+ "<num>",
+ "Number of results per page. The default is 10."
+ }
+
+ uint16_t search-pages = 5
+ {
+ "<num>",
+ "Number of pages in navigation (pager). The default is 5."
+ }
};
class package
{
- uint16_t description-len = 500; // ~ 80 chars x 6 lines.
- uint16_t changes-len = 5000; // ~ 80 chars x 60 lines.
+ uint16_t package-description = 500
+ {
+ "<len>",
+ "Number of package description characters to display in brief pages.
+ The default is 500 (~ 80 characters * 6 lines)."
+ }
+
+ uint16_t package-changes = 5000;
+ {
+ "<len>",
+ "Number of package changes characters to display in brief pages. The
+ default is 5000 (~ 80 chars x 60 lines)."
+ }
};
// Module options.
//
- class package_search: module, db, search
+ class package_search: search, db, module
{
};
- class package_details: module, db, search, package
+ class package_details: package, search, db, module
{
};
- class package_version_details: module, db, package
+ class package_version_details: package, db, module
{
};
- class repository_details: module, db
+ class repository_details: db, module
{
};
diff --git a/brep/package-details.cxx b/brep/package-details.cxx
index 30e185e..a10f668 100644
--- a/brep/package-details.cxx
+++ b/brep/package-details.cxx
@@ -37,7 +37,7 @@ init (scanner& s)
if (options_->root ().empty ())
options_->root (dir_path ("/"));
- db_ = shared_database (options_->db_host (), options_->db_port ());
+ db_ = shared_database (*options_);
}
template <typename T>
@@ -160,7 +160,7 @@ handle (request& rq, response& rs)
if (const auto& d = pkg->description)
s << (full
? P_DESCRIPTION (*d, id)
- : P_DESCRIPTION (*d, options_->description_len (),
+ : P_DESCRIPTION (*d, options_->package_description (),
url (!full, squery, page, id)));
s << TABLE(CLASS="proplist", ID="package")
@@ -232,7 +232,7 @@ handle (request& rq, response& rs)
t.commit ();
- s << DIV_PAGER (page, pkg_count, res_page, options_->pager_pages (),
+ s << DIV_PAGER (page, pkg_count, res_page, options_->search_pages (),
url (full, squery))
<< ~DIV
<< ~BODY
diff --git a/brep/package-search.cxx b/brep/package-search.cxx
index 62b162b..448a915 100644
--- a/brep/package-search.cxx
+++ b/brep/package-search.cxx
@@ -37,7 +37,7 @@ init (scanner& s)
if (options_->root ().empty ())
options_->root (dir_path ("/"));
- db_ = shared_database (options_->db_host (), options_->db_port ());
+ db_ = shared_database (*options_);
}
template <typename T>
@@ -138,7 +138,7 @@ handle (request& rq, response& rs)
t.commit ();
- s << DIV_PAGER (page, pkg_count, res_page, options_->pager_pages (),
+ s << DIV_PAGER (page, pkg_count, res_page, options_->search_pages (),
root.string () + squery_param)
<< ~DIV
<< ~BODY
diff --git a/brep/package-version-details.cxx b/brep/package-version-details.cxx
index 8f6cd7d..9bc06f6 100644
--- a/brep/package-version-details.cxx
+++ b/brep/package-version-details.cxx
@@ -40,7 +40,7 @@ init (scanner& s)
if (options_->root ().empty ())
options_->root (dir_path ("/"));
- db_ = shared_database (options_->db_host (), options_->db_port ());
+ db_ = shared_database (*options_);
}
bool brep::package_version_details::
@@ -152,7 +152,7 @@ handle (request& rq, response& rs)
if (const auto& d = pkg->description)
s << (full
? P_DESCRIPTION (*d, id)
- : P_DESCRIPTION (*d, options_->description_len (),
+ : P_DESCRIPTION (*d, options_->package_description (),
url (!full, id)));
assert (pkg->location);
@@ -302,7 +302,9 @@ handle (request& rq, response& rs)
s << H3 << "Changes" << ~H3
<< (full
? PRE_CHANGES (ch)
- : PRE_CHANGES (ch, options_->changes_len (), url (!full, "changes")));
+ : PRE_CHANGES (ch,
+ options_->package_changes (),
+ url (!full, "changes")));
s << ~DIV
<< ~BODY
diff --git a/brep/repository-details.cxx b/brep/repository-details.cxx
index ee34dc2..0d71ac8 100644
--- a/brep/repository-details.cxx
+++ b/brep/repository-details.cxx
@@ -36,7 +36,7 @@ init (scanner& s)
if (options_->root ().empty ())
options_->root (dir_path ("/"));
- db_ = shared_database (options_->db_host (), options_->db_port ());
+ db_ = shared_database (*options_);
}
bool brep::repository_details::
diff --git a/brep/shared-database b/brep/shared-database
index 4d8186d..b445cc1 100644
--- a/brep/shared-database
+++ b/brep/shared-database
@@ -9,6 +9,8 @@
#include <brep/types>
+#include <brep/options>
+
namespace brep
{
// Returns pointer to the shared database instance, creating one on the
@@ -17,7 +19,7 @@ namespace brep
// otherwise. Is not thread-safe.
//
shared_ptr<odb::core::database>
- shared_database (const string& host, unsigned int port);
+ shared_database (const options::db&);
}
#endif // BREP_SHARED_DATABASE
diff --git a/brep/shared-database.cxx b/brep/shared-database.cxx
index db6b811..1389dab 100644
--- a/brep/shared-database.cxx
+++ b/brep/shared-database.cxx
@@ -14,7 +14,7 @@
namespace brep
{
shared_ptr<odb::database>
- shared_database (const string& h, unsigned int p)
+ shared_database (const options::db& o)
{
using odb::pgsql::database;
static weak_ptr<database> db;
@@ -25,14 +25,22 @@ namespace brep
//
if (shared_ptr<database> d = db.lock ())
{
- if (h != d->host () || p != d->port ())
+ if (o.db_user () != d->user () ||
+ o.db_password () != d->password () ||
+ o.db_name () != d->db () ||
+ o.db_host () != d->host () ||
+ o.db_port () != d->port ())
throw std::runtime_error ("shared database host/port mismatch");
return d;
}
else
{
- d = make_shared<database> ("", "", "brep", h, p);
+ d = make_shared<database> (o.db_user (),
+ o.db_password (),
+ o.db_name (),
+ o.db_host (),
+ o.db_port ());
db = d;
return d;
}