aboutsummaryrefslogtreecommitdiff
path: root/mod/page.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-08-30 23:14:51 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-08-31 18:19:37 +0300
commitd22f466823192963c22eb8f51ae930cb5af8fa9a (patch)
treef60f5dc30a76a2fff67ab20b399dafe05e80a024 /mod/page.cxx
parent05eeac08b63449925cc2e12d2fdaf937d5fa1bbc (diff)
Add support for git repositories to brep-load
Diffstat (limited to 'mod/page.cxx')
-rw-r--r--mod/page.cxx46
1 files changed, 27 insertions, 19 deletions
diff --git a/mod/page.cxx b/mod/page.cxx
index 3a6e989..46b5e71 100644
--- a/mod/page.cxx
+++ b/mod/page.cxx
@@ -401,7 +401,7 @@ namespace brep
//
set<package_name> names;
for (const auto& da: d)
- names.emplace (da.name ());
+ names.emplace (da.name);
bool mult (names.size () > 1);
@@ -411,7 +411,7 @@ namespace brep
bool first (true);
for (const auto& da: d)
{
- package_name n (da.name ());
+ const package_name& n (da.name);
if (names.find (n) != names.end ())
{
names.erase (n);
@@ -421,24 +421,32 @@ namespace brep
else
s << " | ";
- shared_ptr<package> p (da.package.load ());
- assert (p->internal () || !p->other_repositories.empty ());
-
- shared_ptr<repository> r (
- p->internal ()
- ? p->internal_repository.load ()
- : p->other_repositories[0].load ());
-
- auto en (mime_url_encode (n.string (), false));
-
- if (r->url)
- s << A(HREF=*r->url + en) << n << ~A;
- else if (p->internal ())
- s << A(HREF=root_ / path (en)) << n << ~A;
+ // Try to display the dependency as a link if it is resolved.
+ // Otherwise display it as plain text.
+ //
+ if (da.package != nullptr)
+ {
+ shared_ptr<package> p (da.package.load ());
+ assert (p->internal () || !p->other_repositories.empty ());
+
+ shared_ptr<repository> r (
+ p->internal ()
+ ? p->internal_repository.load ()
+ : p->other_repositories[0].load ());
+
+ auto en (mime_url_encode (n.string (), false));
+
+ 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;
+ else
+ // Display the dependency as plain text if no repository URL
+ // available.
+ //
+ s << n;
+ }
else
- // Display the dependency as a plain text if no repository URL
- // available.
- //
s << n;
}
}