aboutsummaryrefslogtreecommitdiff
path: root/mod
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
parent05eeac08b63449925cc2e12d2fdaf937d5fa1bbc (diff)
Add support for git repositories to brep-load
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-package-version-details.cxx87
-rw-r--r--mod/page.cxx46
2 files changed, 81 insertions, 52 deletions
diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx
index 0e3b3f7..d2d96d2 100644
--- a/mod/mod-package-version-details.cxx
+++ b/mod/mod-package-version-details.cxx
@@ -184,8 +184,6 @@ handle (request& rq, response& rs)
: P_DESCRIPTION (*d, options_->package_description (),
url (!full, id)));
- assert (pkg->location && pkg->sha256sum);
-
const repository_location& rl (pkg->internal_repository.load ()->location);
s << TABLE(CLASS="proplist", ID="version")
@@ -198,10 +196,22 @@ handle (request& rq, response& rs)
<< TR_PRIORITY (pkg->priority)
<< TR_LICENSES (pkg->license_alternatives)
<< TR_REPOSITORY (rl.canonical_name (), root)
- << TR_LOCATION (rl)
- << TR_DOWNLOAD (rl.string () + "/" + pkg->location->string ())
- << TR_SHA256SUM (*pkg->sha256sum)
- << ~TBODY
+ << TR_LOCATION (rl);
+
+ if (rl.type () == repository_type::pkg)
+ {
+ assert (pkg->location);
+
+ s << TR_DOWNLOAD (rl.string () + "/" + pkg->location->string ());
+ }
+
+ if (pkg->fragment)
+ s << TR_VALUE ("fragment", *pkg->fragment);
+
+ if (pkg->sha256sum)
+ s << TR_SHA256SUM (*pkg->sha256sum);
+
+ s << ~TBODY
<< ~TABLE
<< TABLE(CLASS="proplist", ID="package")
@@ -267,38 +277,49 @@ handle (request& rq, response& rs)
if (&d != &da[0])
s << " | ";
- shared_ptr<package> p (d.package.load ());
- assert (p->internal () || !p->other_repositories.empty ());
-
- shared_ptr<repository> r (
- p->internal ()
- ? p->internal_repository.load ()
- : p->other_repositories[0].load ());
-
const auto& dcon (d.constraint);
- const package_name& dname (p->id.name);
- string ename (mime_url_encode (dname.string (), false));
-
- if (r->url)
- {
- string u (*r->url + ename);
- s << A(HREF=u) << dname << ~A;
+ const package_name& dname (d.name);
- if (dcon)
- s << ' ' << A(HREF=u + "/" + p->version.string ()) << *dcon << ~A;
- }
- else if (p->internal ())
+ // Try to display the dependency as a link if it is resolved.
+ // Otherwise display it as a plain text.
+ //
+ if (d.package != nullptr)
{
- dir_path u (root / dir_path (ename));
- s << A(HREF=u) << dname << ~A;
-
- if (dcon)
- s << ' ' << A(HREF=u / path (p->version.string ())) << *dcon << ~A;
+ shared_ptr<package> p (d.package.load ());
+ assert (p->internal () || !p->other_repositories.empty ());
+
+ shared_ptr<repository> r (
+ p->internal ()
+ ? p->internal_repository.load ()
+ : p->other_repositories[0].load ());
+
+ string ename (mime_url_encode (dname.string (), false));
+
+ if (r->interface_url)
+ {
+ string u (*r->interface_url + ename);
+ s << A(HREF=u) << dname << ~A;
+
+ if (dcon)
+ s << ' '
+ << A(HREF=u + "/" + p->version.string ()) << *dcon << ~A;
+ }
+ else if (p->internal ())
+ {
+ dir_path u (root / dir_path (ename));
+ s << A(HREF=u) << dname << ~A;
+
+ if (dcon)
+ s << ' '
+ << A(HREF=u / path (p->version.string ())) << *dcon << ~A;
+ }
+ else
+ // Display the dependency as a plain text if no repository URL
+ // available.
+ //
+ s << d;
}
else
- // Display the dependency as a plain text if no repository URL
- // available.
- //
s << d;
}
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;
}
}