From b192a3fcc7875210b3e1f6bd2292022a78c9f0e1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 15 Sep 2015 17:48:57 +0200 Subject: Partial package version detals page implementation --- brep/package-version-details.cxx | 103 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 brep/package-version-details.cxx (limited to 'brep/package-version-details.cxx') diff --git a/brep/package-version-details.cxx b/brep/package-version-details.cxx new file mode 100644 index 0000000..094c3a3 --- /dev/null +++ b/brep/package-version-details.cxx @@ -0,0 +1,103 @@ +// file : brep/package-version-details.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include +#include // make_shared() +#include +#include // invalid_argument + + +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +using namespace std; +using namespace cli; +using namespace odb::core; + +namespace brep +{ + void package_version_details:: + init (scanner& s) + { + MODULE_DIAG; + + options_ = make_shared ( + s, unknown_mode::fail, unknown_mode::fail); + + db_ = shared_database (options_->db_host (), options_->db_port ()); + } + + void package_version_details:: + handle (request& rq, response& rs) + { + using namespace xml; + using namespace web; + using namespace web::xhtml; + + MODULE_DIAG; + + path::reverse_iterator i (rq.path ().rbegin ()); + version ver; + + try + { + ver = version (*i++); + } + catch (const invalid_argument& ) + { + throw invalid_request (400, "invalid package version format"); + } + + assert (i != rq.path ().rend ()); + const string& package (*i); + + params::package_version_details pr; + + try + { + param_scanner s (rq.parameters ()); + pr = params::package_version_details ( + s, unknown_mode::fail, unknown_mode::fail); + } + catch (const unknown_argument& e) + { + throw invalid_request (400, e.what ()); + } + + const char* ident ("\n "); + const string name (package + "-" + ver.string ()); + const string title ("Package Version " + name); + serializer s (rs.content (), title); + + s << HTML + << HEAD + << TITLE << title << ~TITLE + << CSS_STYLE << ident + << "a {text-decoration: none;}" << ident + << "a:hover {text-decoration: underline;}" << ident + << ".name {font-size: xx-large; font-weight: bold;}" + << ~CSS_STYLE + << ~HEAD + << BODY; + + s << DIV(CLASS="name") + << name + << ~DIV; + + s << ~BODY + << ~HTML; + } +} -- cgit v1.1