aboutsummaryrefslogtreecommitdiff
path: root/mod/page.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-09-05 21:23:41 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-09-08 17:44:57 +0300
commit70c1cdfd8f34472761fe5ec97f0713990c1b4f5b (patch)
treef2e631c10563bcc0cde07e4359c11b800a188d86 /mod/page.cxx
parent3be834183ae36c321e4b560dce9a63cee846e63d (diff)
Add multi-tenancy support
Diffstat (limited to 'mod/page.cxx')
-rw-r--r--mod/page.cxx31
1 files changed, 21 insertions, 10 deletions
diff --git a/mod/page.cxx b/mod/page.cxx
index 46b5e71..46f4879 100644
--- a/mod/page.cxx
+++ b/mod/page.cxx
@@ -18,6 +18,7 @@
#include <libbrep/package.hxx>
#include <libbrep/package-odb.hxx>
+#include <mod/utility.hxx>
#include <mod/build-config.hxx> // build_log_url()
using namespace std;
@@ -61,11 +62,14 @@ namespace brep
s << DIV(ID="header-menu")
<< DIV(ID="header-menu-body");
+ dir_path root (tenant_dir (root_, tenant_));
+
for (const auto& m: menu_)
{
- const string& l (m.link[0] == '/' || m.link.find (':') != string::npos
- ? m.link
- : root_.string () + m.link);
+ const string& l (
+ m.link[0] == '/' || m.link.find (':') != string::npos
+ ? m.link
+ : root.string () + m.link);
s << A(HREF=l) << m.label << ~A;
}
@@ -191,7 +195,8 @@ namespace brep
// Propagate search criteria to the package details page.
//
- << root_ / path (mime_url_encode (name_.string (), false))
+ << tenant_dir (root_, tenant_) /
+ path (mime_url_encode (name_.string (), false))
<< query_param_
<< ~HREF
@@ -221,8 +226,9 @@ namespace brep
}
else
{
- assert (root_ != nullptr);
- s << A(HREF=*root_ /
+ assert (root_ != nullptr && tenant_ != nullptr);
+
+ s << A(HREF=tenant_dir (*root_, *tenant_) /
dir_path (mime_url_encode (package_->string (), false)) /
path (version_))
<< version_;
@@ -249,7 +255,8 @@ namespace brep
<< SPAN(CLASS="value")
<< A
<< HREF
- << root_ << "?q=" << mime_url_encode (project_.string ())
+ << tenant_dir (root_, tenant_) << "?q="
+ << mime_url_encode (project_.string ())
<< ~HREF
<< project_
<< ~A
@@ -347,7 +354,10 @@ namespace brep
auto print = [&s, this] (const string& t)
{
- s << A << HREF << root_ << "?q=" << mime_url_encode (t) << ~HREF
+ s << A
+ << HREF
+ << tenant_dir (root_, tenant_) << "?q=" << mime_url_encode (t)
+ << ~HREF
<< t
<< ~A;
};
@@ -439,7 +449,7 @@ namespace brep
if (r->interface_url)
s << A(HREF=*r->interface_url + en) << n << ~A;
else if (p->internal ())
- s << A(HREF=root_ / path (en)) << n << ~A;
+ s << A(HREF=tenant_dir (root_, tenant_) / path (en)) << n << ~A;
else
// Display the dependency as plain text if no repository URL
// available.
@@ -586,7 +596,8 @@ namespace brep
<< SPAN(CLASS="value")
<< A
<< HREF
- << root_ << "?about#" << mime_url_encode (html_id (name_), false)
+ << tenant_dir (root_, tenant_) << "?about#"
+ << mime_url_encode (html_id (name_), false)
<< ~HREF
<< name_
<< ~A