aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbrep/package.cxx4
-rw-r--r--libbrep/package.hxx9
-rw-r--r--libbrep/package.xml1
-rw-r--r--load/load.cxx5
-rw-r--r--mod/mod-package-details.cxx3
-rw-r--r--mod/mod-package-search.cxx2
-rw-r--r--mod/mod-package-version-details.cxx3
-rw-r--r--mod/page.cxx43
-rw-r--r--mod/page.hxx31
-rw-r--r--tests/load/1/math/libexp-+2-1.2+1.tar.gzbin351 -> 367 bytes
-rw-r--r--tests/load/1/math/packages.manifest5
-rw-r--r--tests/load/driver.cxx6
12 files changed, 96 insertions, 16 deletions
diff --git a/libbrep/package.cxx b/libbrep/package.cxx
index 3e457b2..8c0abfe 100644
--- a/libbrep/package.cxx
+++ b/libbrep/package.cxx
@@ -49,6 +49,7 @@ namespace brep
package::
package (package_name nm,
version_type vr,
+ package_name pn,
priority_type pr,
string sm,
license_alternatives_type la,
@@ -70,6 +71,7 @@ namespace brep
shared_ptr<repository_type> rp)
: id (move (nm), vr),
version (move (vr)),
+ project (move (pn)),
priority (move (pr)),
summary (move (sm)),
license_alternatives (move (la)),
@@ -124,7 +126,7 @@ namespace brep
// the available internal repositories.
//
string k (id.name.string () + " " + version.string () + " " +
- version.string (true));
+ version.string (true) + " " + project.string ());
// Add tags to keywords.
//
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 0f3f181..e7a8338 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -298,8 +298,9 @@ namespace brep
// Create internal package object. Note that for stubs the build
// constraints are meaningless, and so not saved.
//
- package (package_name name,
+ package (package_name,
version_type,
+ package_name project,
priority_type,
string summary,
license_alternatives_type,
@@ -336,6 +337,12 @@ namespace brep
//
package_id id;
upstream_version version;
+
+ // Matches the package name if the project name is not specified in
+ // the manifest.
+ //
+ package_name project;
+
priority_type priority;
string summary;
license_alternatives_type license_alternatives;
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 08ecc61..47ff071 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -77,6 +77,7 @@
<column name="version_revision" type="INTEGER" null="false"/>
<column name="version_upstream" type="TEXT" null="false"/>
<column name="version_release" type="TEXT" null="true"/>
+ <column name="project" type="CITEXT" null="false"/>
<column name="priority" type="INTEGER" null="false"/>
<column name="priority_comment" type="TEXT" null="false"/>
<column name="summary" type="TEXT" null="false"/>
diff --git a/load/load.cxx b/load/load.cxx
index ca7c6c7..1875f2a 100644
--- a/load/load.cxx
+++ b/load/load.cxx
@@ -402,9 +402,14 @@ load_packages (const shared_ptr<repository>& rp, database& db)
move (pd.constraint)});
}
+ // Cache before the package name is moved.
+ //
+ package_name project (pm.effective_project ());
+
p = make_shared<package> (
move (pm.name),
move (pm.version),
+ move (project),
pm.priority ? move (*pm.priority) : priority (),
move (pm.summary),
move (pm.license_alternatives),
diff --git a/mod/mod-package-details.cxx b/mod/mod-package-details.cxx
index ffd0ae7..3db9e1f 100644
--- a/mod/mod-package-details.cxx
+++ b/mod/mod-package-details.cxx
@@ -186,7 +186,8 @@ handle (request& rq, response& rs)
s << TABLE(CLASS="proplist", ID="package")
<< TBODY
- << TR_LICENSE (licenses);
+ << TR_LICENSE (licenses)
+ << TR_PROJECT (pkg->project, root);
if (pkg->url)
s << TR_URL (*pkg->url);
diff --git a/mod/mod-package-search.cxx b/mod/mod-package-search.cxx
index d53397e..a86e5a7 100644
--- a/mod/mod-package-search.cxx
+++ b/mod/mod-package-search.cxx
@@ -163,7 +163,7 @@ handle (request& rq, response& rs)
<< TR_NAME (p->id.name, squery_param, root)
<< TR_SUMMARY (p->summary)
<< TR_LICENSE (p->license_alternatives)
- << TR_TAGS (p->tags, root)
+ << TR_TAGS (p->project, p->tags, root)
<< TR_DEPENDS (p->dependencies, root)
<< TR_REQUIRES (p->requirements)
<< ~TBODY
diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx
index 833b802..0e3b3f7 100644
--- a/mod/mod-package-version-details.cxx
+++ b/mod/mod-package-version-details.cxx
@@ -205,7 +205,8 @@ handle (request& rq, response& rs)
<< ~TABLE
<< TABLE(CLASS="proplist", ID="package")
- << TBODY;
+ << TBODY
+ << TR_PROJECT (pkg->project, root);
const auto& u (pkg->url);
diff --git a/mod/page.cxx b/mod/page.cxx
index 614bf79..3a6e989 100644
--- a/mod/page.cxx
+++ b/mod/page.cxx
@@ -8,7 +8,7 @@
#include <ios> // hex, uppercase, right
#include <sstream>
#include <iomanip> // setw(), setfill()
-#include <algorithm> // min()
+#include <algorithm> // min(), find()
#include <libstudxml/serializer.hxx>
@@ -238,6 +238,26 @@ namespace brep
<< ~TR;
}
+ // TR_PROJECT
+ //
+ void TR_PROJECT::
+ operator() (serializer& s) const
+ {
+ s << TR(CLASS="project")
+ << TH << "project" << ~TH
+ << TD
+ << SPAN(CLASS="value")
+ << A
+ << HREF
+ << root_ << "?q=" << mime_url_encode (project_.string ())
+ << ~HREF
+ << project_
+ << ~A
+ << ~SPAN
+ << ~TD
+ << ~TR;
+ }
+
// TR_SUMMARY
//
void TR_SUMMARY::
@@ -318,21 +338,32 @@ namespace brep
void TR_TAGS::
operator() (serializer& s) const
{
- if (!tags_.empty ())
+ if (!tags_.empty () || project_)
{
s << TR(CLASS="tags")
<< TH << "tags" << ~TH
<< TD
<< SPAN(CLASS="value");
- for (const auto& t: tags_)
+ auto print = [&s, this] (const string& t)
{
- if (&t != &tags_[0])
- s << " ";
-
s << A << HREF << root_ << "?q=" << mime_url_encode (t) << ~HREF
<< t
<< ~A;
+ };
+
+ bool pt (project_ != nullptr &&
+ find (tags_.begin (), tags_.end (), *project_) == tags_.end ());
+
+ if (pt)
+ print (project_->string ());
+
+ for (const string& t: tags_)
+ {
+ if (&t != &tags_[0] || pt)
+ s << " ";
+
+ print (t);
}
s << ~SPAN
diff --git a/mod/page.hxx b/mod/page.hxx
index 2b8c31f..759984e 100644
--- a/mod/page.hxx
+++ b/mod/page.hxx
@@ -210,6 +210,25 @@ namespace brep
const dir_path* root_;
};
+ // Generates package project name element.
+ //
+ // Displays a link to the package search page with the project name
+ // specified as a keyword.
+ //
+ class TR_PROJECT
+ {
+ public:
+ TR_PROJECT (const package_name& p, const dir_path& r)
+ : project_ (p), root_ (r) {}
+
+ void
+ operator() (xml::serializer&) const;
+
+ private:
+ const package_name& project_;
+ const dir_path& root_;
+ };
+
// Generates package summary element.
//
class TR_SUMMARY
@@ -258,12 +277,22 @@ namespace brep
class TR_TAGS
{
public:
- TR_TAGS (const strings& ts, const dir_path& r): tags_ (ts), root_ (r) {}
+ // Display the tag link list.
+ //
+ TR_TAGS (const strings& ts, const dir_path& r)
+ : project_ (nullptr), tags_ (ts), root_ (r) {}
+
+ // As above but prepend the list with a tag link produced from the project
+ // name, if it differs from other tags.
+ //
+ TR_TAGS (const package_name& pr, const strings& ts, const dir_path& r)
+ : project_ (&pr), tags_ (ts), root_ (r) {}
void
operator() (xml::serializer&) const;
private:
+ const package_name* project_;
const strings& tags_;
const dir_path& root_;
};
diff --git a/tests/load/1/math/libexp-+2-1.2+1.tar.gz b/tests/load/1/math/libexp-+2-1.2+1.tar.gz
index 084de3f..56f877e 100644
--- a/tests/load/1/math/libexp-+2-1.2+1.tar.gz
+++ b/tests/load/1/math/libexp-+2-1.2+1.tar.gz
Binary files differ
diff --git a/tests/load/1/math/packages.manifest b/tests/load/1/math/packages.manifest
index 9b39555..3ac5efd 100644
--- a/tests/load/1/math/packages.manifest
+++ b/tests/load/1/math/packages.manifest
@@ -3,9 +3,10 @@ sha256sum: b85ba3a0ba45b98e1fbb2507f199bc4b218a4a413ec6ba4094e214a7507490a2
:
name: libexp
version: +2-1.2+1
+project: mathLab
summary: The exponent
license: MIT
-tags: c++, exponent
+tags: mathlab, c++, exponent
description: The exponent math function.
url: http://www.exp.com
email: users@exp.com
@@ -15,7 +16,7 @@ depends: libpq >= 9.0.0
build-exclude: *; Only supported on Linux.
build-include: linux*
location: libexp-+2-1.2+1.tar.gz
-sha256sum: 040b3817418121e8e922ac3a6d3752378f78239faad7d257de87019557fdd245
+sha256sum: bc68940a1b3b7e345cbceac35d308b4e04b304f49ff2087340949f2879709967
:
name: libfoo
version: +0-X.Y
diff --git a/tests/load/driver.cxx b/tests/load/driver.cxx
index f6a4268..8e7c86e 100644
--- a/tests/load/driver.cxx
+++ b/tests/load/driver.cxx
@@ -196,6 +196,7 @@ main (int argc, char* argv[])
db.load<package> (
package_id (package_name ("libfoo"), version ("+0-X.Y"))));
+ assert (fpvxy->project == package_name ("libfoo"));
assert (fpvxy->summary == "The Foo Library");
assert (fpvxy->tags.empty ());
assert (!fpvxy->description);
@@ -662,8 +663,9 @@ main (int argc, char* argv[])
db.load<package> (
package_id (package_name ("libexp"), version ("+2-1.2+1"))));
+ assert (epv->project == "mathLab");
assert (epv->summary == "The exponent");
- assert (epv->tags == strings ({"c++", "exponent"}));
+ assert (epv->tags == strings ({"mathlab", "c++", "exponent"}));
assert (epv->description && *epv->description ==
"The exponent math function.");
assert (epv->url && *epv->url == "http://www.exp.com");
@@ -704,7 +706,7 @@ main (int argc, char* argv[])
assert (check_location (epv));
assert (epv->sha256sum && *epv->sha256sum ==
- "040b3817418121e8e922ac3a6d3752378f78239faad7d257de87019557fdd245");
+ "bc68940a1b3b7e345cbceac35d308b4e04b304f49ff2087340949f2879709967");
// Verify libpq package version.
//