From 1ce84922e3008cad6cf1b9056b705f2642bd3772 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 28 Oct 2015 17:56:30 +0200 Subject: WEB pages re-styling --- web/apache/request.cxx | 32 ++++++++++++++------------------ web/apache/service.cxx | 2 +- web/module | 8 ++++++-- web/xhtml | 25 +++++++++++++++++-------- 4 files changed, 38 insertions(+), 29 deletions(-) (limited to 'web') diff --git a/web/apache/request.cxx b/web/apache/request.cxx index 497d2d6..9887104 100644 --- a/web/apache/request.cxx +++ b/web/apache/request.cxx @@ -99,33 +99,31 @@ namespace web { if (::strcasecmp (h->key, "Cookie") == 0) { - for (const char* n (h->val); n != 0; ) + for (const char* n (h->val); n != nullptr; ) { const char* v (strchr (n, '=')); const char* e (strchr (n, ';')); - if (e && e < v) - v = 0; + if (e != nullptr && e < v) + v = nullptr; - string name (v + string name (v != nullptr ? mime_url_decode (n, v, true) : (e ? mime_url_decode (n, e, true) : mime_url_decode (n, n + strlen (n), true))); - string value; + optional value; if (v++) - { value = e ? mime_url_decode (v, e, true) : mime_url_decode (v, v + strlen (v), true); - } - if (!name.empty () || !value.empty ()) + if (!name.empty () || value) cookies_->emplace_back (move (name), move (value)); - n = e ? e + 1 : 0; + n = e ? e + 1 : nullptr; } } } @@ -252,33 +250,31 @@ namespace web void request:: parse_parameters (const char* args) { - for (auto n (args); n != 0; ) + for (auto n (args); n != nullptr; ) { const char* v (strchr (n, '=')); const char* e (strchr (n, '&')); - if (e && e < v) - v = 0; + if (e != nullptr && e < v) + v = nullptr; - string name (v + string name (v != nullptr ? mime_url_decode (n, v) : (e ? mime_url_decode (n, e) : mime_url_decode (n, n + strlen (n)))); - string value; + optional value; if (v++) - { value = e ? mime_url_decode (v, e) : mime_url_decode (v, v + strlen (v)); - } - if (!name.empty () || !value.empty ()) + if (!name.empty () || value) parameters_->emplace_back (move (name), move (value)); - n = e ? e + 1 : 0; + n = e ? e + 1 : nullptr; } } } diff --git a/web/apache/service.cxx b/web/apache/service.cxx index 69bb874..782e09b 100644 --- a/web/apache/service.cxx +++ b/web/apache/service.cxx @@ -70,7 +70,7 @@ namespace web return 0; } - srv.options_.emplace_back (name, value); + srv.options_.emplace_back (name, string (value)); return 0; } diff --git a/web/module b/web/module index 7398d45..25c4bf2 100644 --- a/web/module +++ b/web/module @@ -14,6 +14,7 @@ #include // runtime_error #include +#include namespace web { @@ -57,15 +58,18 @@ namespace web sequence_error (std::string d): std::runtime_error (std::move (d)) {} }; + template + using optional = butl::optional; + struct name_value { // These should eventually become string_view's. // std::string name; - std::string value; + optional value; name_value () {} - name_value (std::string n, std::string v) + name_value (std::string n, optional v) : name (std::move (n)), value (std::move (v)) {} }; diff --git a/web/xhtml b/web/xhtml index b4c1a0d..7446a27 100644 --- a/web/xhtml +++ b/web/xhtml @@ -309,10 +309,16 @@ namespace web static const element H5 ("h5"); static const element H6 ("h6"); static const element LI ("li"); + static const element LINK ("link"); static const element META ("meta"); static const element P ("p"); static const element PRE ("pre"); + static const element TABLE ("table"); + static const element TBODY ("tbody"); + static const element TD ("td"); + static const element TH ("th"); static const element TITLE ("title"); + static const element TR ("tr"); static const element UL ("ul"); static const inline_element A ("a"); @@ -326,14 +332,17 @@ namespace web // Attributes. // - static const attribute CLASS ("class"); - static const attribute CONTENT ("content"); - static const attribute HREF ("href"); - static const attribute ID ("id"); - static const attribute NAME ("name"); - static const attribute STYLE ("style"); - static const attribute TYPE ("type"); - static const attribute VALUE ("value"); + + static const attribute AUTOFOCUS ("autofocus"); + static const attribute CLASS ("class"); + static const attribute CONTENT ("content"); + static const attribute HREF ("href"); + static const attribute ID ("id"); + static const attribute NAME ("name"); + static const attribute REL ("rel"); + static const attribute STYLE ("style"); + static const attribute TYPE ("type"); + static const attribute VALUE ("value"); } } -- cgit v1.1