diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-07-11 15:51:59 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-07-11 16:51:21 +0300 |
commit | 6a41864fdb57c75be3db87b357063b0c828dbc18 (patch) | |
tree | b2f9a56555cd7b642529842013528c95072cd606 /mod | |
parent | 21033565488f6c63b4c40962cccfdc8b6ca32b2a (diff) |
Add support for package project manifest value
Diffstat (limited to 'mod')
-rw-r--r-- | mod/mod-package-details.cxx | 3 | ||||
-rw-r--r-- | mod/mod-package-search.cxx | 2 | ||||
-rw-r--r-- | mod/mod-package-version-details.cxx | 3 | ||||
-rw-r--r-- | mod/page.cxx | 43 | ||||
-rw-r--r-- | mod/page.hxx | 31 |
5 files changed, 72 insertions, 10 deletions
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_; }; |