From d3f2fcd53000fc4a09cf56c90930f8c8e2ad02b4 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Thu, 2 Jun 2016 20:36:21 +0200 Subject: Adding partial htmlhelp support to template system --- src/template.cpp | 99 ++++++++++++++++++++++++++++++------- templates/html/htmlhelpindexhhc.tpl | 18 +++++++ templates/html/htmljsnavindex.tpl | 2 +- templates/html/htmljsnavtree.tpl | 2 +- templates/html/htmllayout.tpl | 1 + 5 files changed, 101 insertions(+), 21 deletions(-) create mode 100644 templates/html/htmlhelpindexhhc.tpl diff --git a/src/template.cpp b/src/template.cpp index 9e814d7..10b3e43 100644 --- a/src/template.cpp +++ b/src/template.cpp @@ -1292,6 +1292,64 @@ class FilterDivisibleBy } }; +//-------------------------------------------------------------------- + +/** @brief The implementation of the "isRelativeURL" filter */ +class FilterIsRelativeURL +{ + public: + static TemplateVariant apply(const TemplateVariant &v,const TemplateVariant &) + { + if (v.isValid() && v.type()==TemplateVariant::String) + { + QCString s = v.toString(); + if (!s.isEmpty() && s.at(0)=='!') return TRUE; + } + return FALSE; + } +}; + +//-------------------------------------------------------------------- + +/** @brief The implementation of the "isRelativeURL" filter */ +class FilterIsAbsoluteURL +{ + public: + static TemplateVariant apply(const TemplateVariant &v,const TemplateVariant &) + { + if (v.isValid() && v.type()==TemplateVariant::String) + { + QCString s = v.toString(); + if (!s.isEmpty() && s.at(0)=='^') return TRUE; + } + return FALSE; + } +}; + +//-------------------------------------------------------------------- + +/** @brief The implementation of the "decodeURL" filter + * The leading character is removed from the value in case it is a ^ or !. + * - ^ is used to encode a absolute URL + * - ! is used to encode a relative URL + */ +class FilterDecodeURL +{ + public: + static TemplateVariant apply(const TemplateVariant &v,const TemplateVariant &) + { + if (v.isValid() && v.type()==TemplateVariant::String) + { + QCString s = v.toString(); + if (!s.isEmpty() && (s.at(0)=='^' || s.at(0)=='!')) + { + return s.mid(1); + } + } + return v; + } +}; + //-------------------------------------------------------------------- @@ -1343,25 +1401,28 @@ class TemplateFilterFactory }; // register a handlers for each filter we support -static TemplateFilterFactory::AutoRegister fAdd("add"); -static TemplateFilterFactory::AutoRegister fGet("get"); -static TemplateFilterFactory::AutoRegister fRaw("raw"); -static TemplateFilterFactory::AutoRegister fList("list"); -static TemplateFilterFactory::AutoRegister fAppend("append"); -static TemplateFilterFactory::AutoRegister fLength("length"); -static TemplateFilterFactory::AutoRegister fNoWrap("nowrap"); -static TemplateFilterFactory::AutoRegister fFlatten("flatten"); -static TemplateFilterFactory::AutoRegister fDefault("default"); -static TemplateFilterFactory::AutoRegister fPrepend("prepend"); -static TemplateFilterFactory::AutoRegister fGroupBy("groupBy"); -static TemplateFilterFactory::AutoRegister fRelative("relative"); -static TemplateFilterFactory::AutoRegister fListSort("listsort"); -static TemplateFilterFactory::AutoRegister fTexLabel("texLabel"); -static TemplateFilterFactory::AutoRegister fTexIndex("texIndex"); -static TemplateFilterFactory::AutoRegister fPaginate("paginate"); -static TemplateFilterFactory::AutoRegister fStripPath("stripPath"); -static TemplateFilterFactory::AutoRegister fAlphaIndex("alphaIndex"); -static TemplateFilterFactory::AutoRegister fDivisibleBy("divisibleby"); +static TemplateFilterFactory::AutoRegister fAdd("add"); +static TemplateFilterFactory::AutoRegister fGet("get"); +static TemplateFilterFactory::AutoRegister fRaw("raw"); +static TemplateFilterFactory::AutoRegister fList("list"); +static TemplateFilterFactory::AutoRegister fAppend("append"); +static TemplateFilterFactory::AutoRegister fLength("length"); +static TemplateFilterFactory::AutoRegister fNoWrap("nowrap"); +static TemplateFilterFactory::AutoRegister fFlatten("flatten"); +static TemplateFilterFactory::AutoRegister fDefault("default"); +static TemplateFilterFactory::AutoRegister fPrepend("prepend"); +static TemplateFilterFactory::AutoRegister fGroupBy("groupBy"); +static TemplateFilterFactory::AutoRegister fRelative("relative"); +static TemplateFilterFactory::AutoRegister fListSort("listsort"); +static TemplateFilterFactory::AutoRegister fTexLabel("texLabel"); +static TemplateFilterFactory::AutoRegister fTexIndex("texIndex"); +static TemplateFilterFactory::AutoRegister fPaginate("paginate"); +static TemplateFilterFactory::AutoRegister fStripPath("stripPath"); +static TemplateFilterFactory::AutoRegister fDecodeURL("decodeURL"); +static TemplateFilterFactory::AutoRegister fAlphaIndex("alphaIndex"); +static TemplateFilterFactory::AutoRegister fDivisibleBy("divisibleby"); +static TemplateFilterFactory::AutoRegister fIsRelativeURL("isRelativeURL"); +static TemplateFilterFactory::AutoRegister fIsAbsoluteURL("isAbsoluteURL"); //-------------------------------------------------------------------- diff --git a/templates/html/htmlhelpindexhhc.tpl b/templates/html/htmlhelpindexhhc.tpl new file mode 100644 index 0000000..b5e83de --- /dev/null +++ b/templates/html/htmlhelpindexhhc.tpl @@ -0,0 +1,18 @@ + + + + + +
    +{% recursetree index.nav %} +
  • + + + + {% if not node.is_leaf_node %} +
      {{ children }}
    + {% endif %} +{% endrecursetree %} +
+ + diff --git a/templates/html/htmljsnavindex.tpl b/templates/html/htmljsnavindex.tpl index 07a9efc..b24b166 100644 --- a/templates/html/htmljsnavindex.tpl +++ b/templates/html/htmljsnavindex.tpl @@ -2,6 +2,6 @@ var NAVTREEINDEX{{ idx }} = { {% for entry in entries %} - "{{ entry.file }}{{ config.HTML_FILE_EXTENSION }}{% if entry.anchor %}#{{ entry.anchor }}{% endif %}":[{% for e in entry.path %}{% if not forloop.first %}{{ e.index }}{% if not forloop.last%},{% endif %}{% endif %}{% endfor %}]{% if not forloop.last %},{%endif %} + "{{ entry.file|decodeURL }}{{ config.HTML_FILE_EXTENSION }}{% if entry.anchor %}#{{ entry.anchor }}{% endif %}":[{% for e in entry.path %}{% if not forloop.first %}{{ e.index }}{% if not forloop.last%},{% endif %}{% endif %}{% endfor %}]{% if not forloop.last %},{%endif %} {% endfor %} }; diff --git a/templates/html/htmljsnavtree.tpl b/templates/html/htmljsnavtree.tpl index 9970161..947b980 100644 --- a/templates/html/htmljsnavtree.tpl +++ b/templates/html/htmljsnavtree.tpl @@ -1,7 +1,7 @@ var NAVTREE = [ {% recursetree index.nav %} - [ "{{ node.name }}", {% if node.file %}"{% if node.isReference %}{{ node.externalReference }}{% endif %}{{ node.file }}{{ config.HTML_FILE_EXTENSION }}{% if node.anchor %}#{{ node.anchor }}{% endif %}"{% else %}null{% endif %},{% if not node.is_leaf_node %} [ + [ "{{ node.name }}", {% if node.file %}"{% if node.isReference %}{{ node.externalReference }}{% endif %}{{ node.file|decodeURL }}{{ config.HTML_FILE_EXTENSION }}{% if node.anchor %}#{{ node.anchor }}{% endif %}"{% else %}null{% endif %},{% if not node.is_leaf_node %} [ {{ children }} ]{% else %} null{% endif %} ]{% if not node.last %},{% endif %} {% endrecursetree %} diff --git a/templates/html/htmllayout.tpl b/templates/html/htmllayout.tpl index 9834f67..a40bdbc 100644 --- a/templates/html/htmllayout.tpl +++ b/templates/html/htmllayout.tpl @@ -270,6 +270,7 @@ {% if config.GENERATE_HTMLHELP %} {% encoding config.CHM_INDEX_ENCODING|default:'CP1250' %} {% create 'index.hhp' from 'htmlhelpindexhhp.tpl' %} + {% create 'index.hhc' from 'htmlhelpindexhhc.tpl' %} {% endencoding %} {% endif %} -- cgit v0.12