From 0ebdc6a8f9bd26d73687adc654120751f928188c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Aug 2015 11:20:45 +0200 Subject: XHTML generation revision --- brep/package-search.cxx | 69 ++++++++++++-------------- web/xhtml | 129 ++++++++++++++++++++++++++++++++++-------------- 2 files changed, 123 insertions(+), 75 deletions(-) diff --git a/brep/package-search.cxx b/brep/package-search.cxx index 3317d43..455778b 100644 --- a/brep/package-search.cxx +++ b/brep/package-search.cxx @@ -58,7 +58,7 @@ namespace brep throw invalid_request (400, e.what ()); } - // @@ Would be nice to have a manipulator identing string properly + // @@ Would be nice to have a manipulator indenting string properly // according to the most nested element identation. // const char* ident ("\n "); @@ -68,11 +68,11 @@ namespace brep s << HTML << HEAD << TITLE << title << ~TITLE - << STYLE(TYPE="text/css") << ident + << CSS_STYLE << ident << ".package {margin: 0 0 0.5em;}" << ident << ".name a {text-decoration: none;}" << ident << ".summary {font-size: small;}" - << ~STYLE + << ~CSS_STYLE << ~HEAD << BODY; @@ -93,59 +93,52 @@ namespace brep for (const auto& p: r) { - s << DIV(CLASS="package") - << DIV(CLASS="name") - << A - << HREF - << "/go/" << mime_url_encode (p.name); + s << DIV(CLASS="package") + << DIV(CLASS="name") + << A + << HREF << "/go/" << mime_url_encode (p.name); // Propagate search criteria to the package version search url. // if (!q.empty ()) - s << "?" << q; - - s << ~HREF - << p.name - << ~A - << ~DIV - << DIV(CLASS="summary") - << p.summary - << ~DIV - << ~DIV; + s << "?" << q; + + s << ~HREF + << p.name + << ~A + << ~DIV + << DIV(CLASS="summary") + << p.summary + << ~DIV + << ~DIV; } t.commit (); if (pr.page () || r.size () == options_->results_on_page ()) { - s << DIV; + s << DIV; if (pr.page ()) - { - s << A - << HREF << "/?p=" << pr.page () - 1 - << (q.empty () ? "" : "&" + q) - << ~HREF - << "Previous" - << ~A - << " "; - } + s << A + << HREF << "/?p=" << pr.page () - 1 << (q.empty () ? "" : "&" + q) + << ~HREF + << "Previous" + << ~A + << " "; // @@ Not ideal as can produce link to an empty page, but easy to fix // and most likelly will be replaced with something more meaningful // based on knowing the total number of matched packages. // if (r.size () == options_->results_on_page ()) - { - s << A - << HREF << "/?p=" << pr.page () + 1 - << (q.empty () ? "" : "&" + q) - << ~HREF - << "Next" - << ~A; - } - - s << ~DIV; + s << A + << HREF << "/?p=" << pr.page () + 1 << (q.empty () ? "" : "&" + q) + << ~HREF + << "Next" + << ~A; + + s << ~DIV; } s << ~BODY diff --git a/web/xhtml b/web/xhtml index 4fc6119..2d4007c 100644 --- a/web/xhtml +++ b/web/xhtml @@ -5,15 +5,13 @@ #ifndef WEB_XHTML #define WEB_XHTML -#include // function - #include namespace web { // "Canonical" XHTML5 vocabulary. // - // One-letter tag names and local variable clash problem: + // * One-letter tag names and local variable clash problem // // a at|an|an anc anch // b bt|bo|bl bld bold @@ -27,6 +25,7 @@ namespace web // - _a, a_, xa // - A, I // - x::i + // - user-defined literals: "a"_e, "/a"_e, "id"_a // // Things can actually get much worse, consider: // @@ -36,12 +35,35 @@ namespace web // So perhaps this is the situation where the explicit namespace // qualification (e.g., x::p) is the only robust option? // + // + // * Element/attribute name clash problem (e.g., STYLE) + // + // - some attribute/element name decorator (STYLEA, STYLE_A, STYLE_) + // - rename attribute/element (e.g., STYLEDEF or CSSSTYLE[adds TYPE]); + // in case of STYLE we should probably rename the element since + // attribute will be much more frequently used. + // - "scope" attributes inside elements (P::STYLE); somewhat + // burdensome: P(P::STYLE); could then use low-case names + // for attributes + // - "scope" elements inside other elements (HEAD::STYLE); also + // burdensome. + // + // + // * Text wrapping/indentation + // + // For some (inline) elements we want additional indentation: + // + // 1. Indent content on newline (e.g., for