From d4379004846eafa58b976fbdc7ecb9d6e4db8217 Mon Sep 17 00:00:00 2001
From: Martijn Vermaat <martijn@vermaat.name>
Date: Mon, 9 Dec 2013 15:57:31 +0100
Subject: [PATCH] Use Jinja2 for static pages

---
 mutalyzer/templates/about.html         | 175 +++++++++++++------------
 mutalyzer/templates/index.html         | 150 +++++++++++----------
 mutalyzer/templates/nameGenerator.html |  18 +--
 mutalyzer/templates/webservices.html   | 122 +++++++++--------
 mutalyzer/website.py                   |   6 +-
 5 files changed, 246 insertions(+), 225 deletions(-)

diff --git a/mutalyzer/templates/about.html b/mutalyzer/templates/about.html
index 8f880555..dcf17b90 100644
--- a/mutalyzer/templates/about.html
+++ b/mutalyzer/templates/about.html
@@ -1,82 +1,93 @@
-<html>
-  <head>
-    <title></title>
-  </head>
-  <body>
-    <div metal:define-macro="content">
-      <center>
-        <h3>About</h3>
-      </center>
-      Mutalyzer <span tal:content = "structure string:${version}"></span>
-      is designed and developed by Jeroen F.J. Laros, with the
-      following exceptions:
-      <ul>
-        <li>The LRG parser, as well as the Batch interfaces are written
-            by Gerben R. Stouten.</li>
-        <li>The position converter interfaces (web service and WWW) are
-            written by Gerard C.P. Schaafsma.</li>
-        <li>Current development and maintenance is done by Martijn
-            Vermaat.</li>
-        <li>Automatic extraction of variant descriptions is implemented by
-        Jonathan Vis.</li>
-      </ul>
-      Furthermore we would like to thank the following people for their
-      valuable work on previous versions that acted as a guideline for the
-      development of the current version:
-      <ul>
-        <li>Ernest van Ophuizen.</li>
-        <li>Martin Wildeman.</li>
-        <li>Corinne Bareil.</li>
-        <li>Gerben R. Stouten.</li>
-      </ul>
-      Specifications are given by Peter E.M. Taschner and Johan T. den
-      Dunnen.<br>
-      <br>
-      Since references to WWW-sites are not yet acknowledged as citations,
-      please mention
-      <a href="http://www.ncbi.nlm.nih.gov/pubmed/18000842">
-        &quot;Wildeman M et al. (2008). Improving sequence variant
-        descriptions in mutation databases and literature using the
-        Mutalyzer sequence variation nomenclature checker. Hum Mutat 29,
-        6-13&quot;</a> (<a href="http://dx.doi.org/10.1002/humu.20654">direct
-        link</a>) when referring to these pages.<br>
-      <br>
-      Project development is sponsored by
-      <a href="http://www.gen2phen.org" target="_blank">
-        <img src="static/images/gen_2_phen_logo_print.png"
-             width="110"
-             height="50"
-             align="middle"
-             border="0"
-             alt="Eurogentest"></a>
-      and
-      <a href="http://www.nbic.nl" target="_blank">
-        <img src="static/images/nbic_logo.png"
-             width="229"
-             height="50"
-             align="middle"
-             border="0"
-             alt="NBIC"></a>
-      and has been supported by
-      <a href="http://www.eurogentest.org" target="_blank">
-        <img src="static/images/Eurogentest.png"
-             width="110"
-             height="50"
-             align="middle"
-             border="0"
-             alt="Eurogentest"></a>
-      and
-      <a href="http://www.commit-nl.nl/" target="_blank">
-        <img src="static/images/commit_logo.png"
-             width="122"
-             height="50"
-             align="middle"
-             border="0"
-             alt="Dutch national program COMMIT"></a>
-      <br><br>
-      Some icons are copyright &copy;
-      <a href="http://p.yusukekamiyamane.com/">Yusuke Kamiyamane</a>.
-      <br>
-    </div>
-  </body>
-</html>
+{% extends "base.html" %}
+
+{% set active_page = "about" %}
+{% set page_title = "About Mutalyzer" %}
+
+{% block content %}
+
+<p>
+Mutalyzer {{ version|e }} is designed and developed by Jeroen F.J. Laros, with
+the following exceptions:
+</p>
+
+<ul>
+  <li>The LRG parser, as well as the Batch interfaces are written
+      by Gerben R. Stouten.</li>
+  <li>The position converter interfaces (web service and WWW) are
+      written by Gerard C.P. Schaafsma.</li>
+  <li>Current development and maintenance is done by Martijn
+      Vermaat.</li>
+  <li>Automatic extraction of variant descriptions is implemented by
+  Jonathan Vis.</li>
+</ul>
+
+<p>
+Furthermore we would like to thank the following people for their
+valuable work on previous versions that acted as a guideline for the
+development of the current version:
+</p>
+
+<ul>
+  <li>Ernest van Ophuizen.</li>
+  <li>Martin Wildeman.</li>
+  <li>Corinne Bareil.</li>
+  <li>Gerben R. Stouten.</li>
+</ul>
+
+<p>
+Specifications are given by Peter E.M. Taschner and Johan T. den
+Dunnen.
+</p>
+
+<p>
+Since references to WWW-sites are not yet acknowledged as citations,
+please mention
+<a href="http://www.ncbi.nlm.nih.gov/pubmed/18000842">
+  &quot;Wildeman M et al. (2008). Improving sequence variant
+  descriptions in mutation databases and literature using the
+  Mutalyzer sequence variation nomenclature checker. Hum Mutat 29,
+  6-13&quot;</a> (<a href="http://dx.doi.org/10.1002/humu.20654">direct
+  link</a>) when referring to these pages.
+</p>
+
+<p>
+Project development is sponsored by
+<a href="http://www.gen2phen.org" target="_blank">
+  <img src="static/images/gen_2_phen_logo_print.png"
+       width="110"
+       height="50"
+       align="middle"
+       border="0"
+       alt="Eurogentest"></a>
+and
+<a href="http://www.nbic.nl" target="_blank">
+  <img src="static/images/nbic_logo.png"
+       width="229"
+       height="50"
+       align="middle"
+       border="0"
+       alt="NBIC"></a>
+and has been supported by
+<a href="http://www.eurogentest.org" target="_blank">
+  <img src="static/images/Eurogentest.png"
+       width="110"
+       height="50"
+       align="middle"
+       border="0"
+       alt="Eurogentest"></a>
+and
+<a href="http://www.commit-nl.nl/" target="_blank">
+  <img src="static/images/commit_logo.png"
+       width="122"
+       height="50"
+       align="middle"
+       border="0"
+       alt="Dutch national program COMMIT"></a>
+</p>
+
+<p>
+Some icons are copyright &copy;
+<a href="http://p.yusukekamiyamane.com/">Yusuke Kamiyamane</a>.
+</p>
+
+{% endblock content %}
diff --git a/mutalyzer/templates/index.html b/mutalyzer/templates/index.html
index e248df27..15246e76 100644
--- a/mutalyzer/templates/index.html
+++ b/mutalyzer/templates/index.html
@@ -1,78 +1,76 @@
-<html>
-  <head>
-    <title></title>
-  </head>
-  <body>
-    <div metal:define-macro="content">
-      <center><h3>Welcome to the Mutalyzer web site</h3></center>
-      <br>
+{% extends "base.html" %}
 
-      The aim of this program suite is to support checks of sequence variant
-      nomenclature according to the
-      <a href="http://www.hgvs.org/mutnomen/">guidelines</a> of the
-      <a href="http://www.hgvs.org">Human Genome Variation Society</a>.<br>
-      <br>
-      <br>
+{% set active_page = "homepage" %}
+{% set page_title = "Welcome to the Mutalyzer website" %}
 
-      Different interfaces are provided to collect the information necessary
-      for the checks:
-      <ul>
-        <li>
-          The <a href = "check">Name Checker</a> takes the complete sequence
-          variant description as input and checks whether it is correct.
-        </li>
-        <li>
-          The <a href = "syntaxCheck">Syntax Checker</a> takes the complete
-          sequence variant description as input and checks whether the syntax
-          is correct.
-        </li>
-        <li>
-          The <a href = "positionConverter">Position Converter</a> can convert
-          chromosomal positions to transcript orientated positions and vice
-          versa.
-        </li>
-        <li>
-          The <a href = "snp">SNP converter</a> allows you to convert a
-          dbSNP rsId to HGVS notation.
-        </li>
-        <li>
-          The <a href = "nameGenerator">Name Generator</a> is a user friendly
-          interface that helps to make a valid HGVS variant description.
-        </li>
-        <li>
-          The <a href = "descriptionExtract">Description Extractor</a> allows
-          you to generate the HGVS variant description from a reference
-          sequence and an observed sequence.
-        </li>
-        <li>
-          The <a href = "upload">Reference File Loader</a> allows you to load and
-          use your own reference sequence.
-        </li>
-        <li>
-          The <a href="batch">Batch Checkers</a> are interfaces that accept a
-          list of inputs. These interfaces can be used for large quantities of
-          checks.
-        </li>
-        <li>
-          The <a href = "webservices">Web services</a> page provides instructions
-          for the web services.
-        </li>
-      </ul>
-      <br>
-      <!--
-      Mutalyzer <span tal:content = "structure string:${version}"></span> is
-      written completely in <a href="http://www.python.org">Python</a>. The
-      Python Scripting Language was chosen for good readability and therefore
-      easy maintenance.<br>
-      -->
-      GenBank sequences are retrieved from the
-      <a href="http://www.ncbi.nlm.nih.gov/">NCBI</a>
-      (<a href="http://eutils.ncbi.nlm.nih.gov/About/disclaimer.html"
-      >Copyright and Disclaimers</a>).<br>
-      This project is sponsored by
-      <a href = "http://www.sun.com">SUN Microsystems</a> with server
-      hardware within the scope of the Academic Excellence Grant (AEG)
-      program (award EDUD-7832-080223-CNE).<br>
-    </div>
-  </body>
-</html>
+{% block content %}
+
+<p>
+The aim of this program suite is to support checks of sequence variant
+nomenclature according to the
+<a href="http://www.hgvs.org/mutnomen/">guidelines</a> of the
+<a href="http://www.hgvs.org">Human Genome Variation Society</a>.
+</p>
+
+<p>
+Different interfaces are provided to collect the information necessary
+for the checks:
+</p>
+<ul>
+  <li>
+    The <a href = "check">Name Checker</a> takes the complete sequence
+    variant description as input and checks whether it is correct.
+  </li>
+  <li>
+    The <a href = "syntaxCheck">Syntax Checker</a> takes the complete
+    sequence variant description as input and checks whether the syntax
+    is correct.
+  </li>
+  <li>
+    The <a href = "positionConverter">Position Converter</a> can convert
+    chromosomal positions to transcript orientated positions and vice
+    versa.
+  </li>
+  <li>
+    The <a href = "snp">SNP converter</a> allows you to convert a
+    dbSNP rsId to HGVS notation.
+  </li>
+  <li>
+    The <a href = "nameGenerator">Name Generator</a> is a user friendly
+    interface that helps to make a valid HGVS variant description.
+  </li>
+  <li>
+    The <a href = "descriptionExtract">Description Extractor</a> allows
+    you to generate the HGVS variant description from a reference
+    sequence and an observed sequence.
+  </li>
+  <li>
+    The <a href = "upload">Reference File Loader</a> allows you to load and
+    use your own reference sequence.
+  </li>
+  <li>
+    The <a href="batch">Batch Checkers</a> are interfaces that accept a
+    list of inputs. These interfaces can be used for large quantities of
+    checks.
+  </li>
+  <li>
+    The <a href = "webservices">Web services</a> page provides instructions
+    for the web services.
+  </li>
+</ul>
+
+<p>
+GenBank sequences are retrieved from the
+<a href="http://www.ncbi.nlm.nih.gov/">NCBI</a>
+(<a href="http://eutils.ncbi.nlm.nih.gov/About/disclaimer.html"
+>Copyright and Disclaimers</a>).
+</p>
+
+<p>
+This project is sponsored by
+<a href = "http://www.sun.com">SUN Microsystems</a> with server
+hardware within the scope of the Academic Excellence Grant (AEG)
+program (award EDUD-7832-080223-CNE).
+</p>
+
+{% endblock content %}
diff --git a/mutalyzer/templates/nameGenerator.html b/mutalyzer/templates/nameGenerator.html
index 9e7befe7..90716289 100644
--- a/mutalyzer/templates/nameGenerator.html
+++ b/mutalyzer/templates/nameGenerator.html
@@ -1,11 +1,9 @@
-<html>
-  <head>
-    <title></title>
-  </head>
-  <body >
-<!-- Start of template -->
-<div metal:define-macro="content">
-<center><h3 tal:content = "structure string:Name Generator"></h3></center>
+{% extends "base.html" %}
+
+{% set active_page = "name-generator" %}
+{% set page_title = "Name Generator" %}
+
+{% block content %}
 
     <div id="main">
       <form id="mainform" onkeyup="update();" onchange="update();">
@@ -205,6 +203,4 @@
 
 </div>
 
-</div>
-</body>
-</html>
+{% endblock content %}
diff --git a/mutalyzer/templates/webservices.html b/mutalyzer/templates/webservices.html
index b6aa91ef..c1f65448 100644
--- a/mutalyzer/templates/webservices.html
+++ b/mutalyzer/templates/webservices.html
@@ -1,53 +1,69 @@
-<html>
-  <head>
-    <title></title>
-  </head>
-  <body>
-    <div metal:define-macro="content">
-    <center>
-      <h3>Web services</h3>
-    </center>
-    <br>
-    Most Mutalyzer functionality is programmatically available through two
-    interfaces: a SOAP web service and a HTTP/RPC+JSON web service.
-    <br>
-    <h3>SOAP web service</h3>
-    A <a href="services/?wsdl">WSDL description</a> is available
-    for easy generation of client programs in many languages. See the
-    <a href = "soap-api">annotated API</a> for detailed documentation.
-    <br>
-    <br>
-    The following are some example client programs for SOAP web service. They
-    use the <a href="soap-api#op.checkSyntax">checkSyntax</a> method
-    to determine if a variant description adheres to the <span class="helper"
-      title="Human Genome Variation Society standard variant nomenclature">
-    <a href="http://www.hgvs.org/mutnomen">HGVS</a> format</span>.
-    <ul>
-      <li>Python client using the suds library:
-        <a href="download/client-suds.py"><tt>client-suds.py</tt></a>
-      <li>Python client using the soappy library:
-        <a href="download/client-soappy.py"><tt>client-soappy.py</tt></a>
-      <li>Ruby client using the Savon library:
-        <a href="download/client-savon.rb"><tt>client-savon.rb</tt></a>
-      <li>Mono client in C#:
-        <a href="download/client-mono.cs"><tt>client-mono.cs</tt></a>
-      <li>PHP client using the PHP5 SOAP extension:
-        <a href="download/client-php.php"><tt>client-php.php</tt></a>
-    </ul>
-    Here is an example that could be used for
-      <a href="download/textmining.py">text mining</a> on a
-      <a href="downloads/textmining_sample.txt">sample</a> input file.
-    <h3>HTTP/RPC+JSON web service</h3>
-    The HTTP/RPC+JSON web service is experimental and currently undocumented.
-    It can be called using HTTP GET requests on <code tal:content = "structure string:${location}${serviceJsonLocation}/method?param=value"></code> where <code>method</code> is the name    of the method to be called and method parameters are expected as <code>param=value</code> query string parameters. Responses are JSON-encoded.
-    <br>
-    <br>
-    Example: <a tal:attributes="href string:${location}${serviceJsonLocation}/checkSyntax?variant=AB026906.1:c.274del" tal:content="structure string:checkSyntax?variant=AB026906.1:c.274del"></a>
-    <br>
-    <br>
-    For now, you can work from this example using the above mentioned
-    <a href="soap-api">annotated SOAP API</a>, since the HTTP/RPC+JSON
-    web service mirrors the functionality of the SOAP web service.
-  </div>
-  </body>
-</html>
+{% extends "base.html" %}
+
+{% set active_page = "webservices" %}
+{% set page_title = "Web Services" %}
+
+{% block content %}
+
+<p>
+Most Mutalyzer functionality is programmatically available through two
+interfaces: a SOAP web service and a HTTP/RPC+JSON web service.
+</p>
+
+<h3>SOAP web service</h3>
+
+<p>
+A <a href="services/?wsdl">WSDL description</a> is available
+for easy generation of client programs in many languages. See the
+<a href = "soap-api">annotated API</a> for detailed documentation.
+</p>
+
+<p>
+The following are some example client programs for SOAP web service. They
+use the <a href="soap-api#op.checkSyntax">checkSyntax</a> method
+to determine if a variant description adheres to the <span class="helper"
+  title="Human Genome Variation Society standard variant nomenclature">
+<a href="http://www.hgvs.org/mutnomen">HGVS</a> format</span>.
+</p>
+
+<ul>
+  <li>Python client using the suds library:
+    <a href="download/client-suds.py"><tt>client-suds.py</tt></a>
+  <li>Python client using the soappy library:
+    <a href="download/client-soappy.py"><tt>client-soappy.py</tt></a>
+  <li>Ruby client using the Savon library:
+    <a href="download/client-savon.rb"><tt>client-savon.rb</tt></a>
+  <li>Mono client in C#:
+    <a href="download/client-mono.cs"><tt>client-mono.cs</tt></a>
+  <li>PHP client using the PHP5 SOAP extension:
+    <a href="download/client-php.php"><tt>client-php.php</tt></a>
+</ul>
+
+<p>
+Here is an example that could be used for
+  <a href="download/textmining.py">text mining</a> on a
+  <a href="downloads/textmining_sample.txt">sample</a> input file.
+</p>
+
+<h3>HTTP/RPC+JSON web service</h3>
+
+<p>
+The HTTP/RPC+JSON web service is experimental and currently undocumented.
+It can be called using HTTP GET requests on
+<code>{{ location|e }}{{ serviceJsonLocation|e }}/method?param=value</code>
+where <code>method</code> is the name of the method to be called and method
+parameters are expected as <code>param=value</code> query string
+parameters. Responses are JSON-encoded.
+</p>
+
+<p>
+Example: <a href="{{ location|e }}{{ serviceJsonLocation|e }}/checkSyntax?variant=AB026906.1:c.274del">checkSyntax?variant=AB026906.1:c.274del</a>
+</p>
+
+<p>
+For now, you can work from this example using the above mentioned
+<a href="soap-api">annotated SOAP API</a>, since the HTTP/RPC+JSON
+web service mirrors the functionality of the SOAP web service.
+</p>
+
+{% endblock content %}
diff --git a/mutalyzer/website.py b/mutalyzer/website.py
index 01613a58..53e65cfd 100644
--- a/mutalyzer/website.py
+++ b/mutalyzer/website.py
@@ -134,8 +134,6 @@ class render_tal:
 
             context.addGlobal('interactive', not standalone)
 
-            context.addGlobal('location', web.ctx.homedomain + web.ctx.homepath)
-
             for name, value in self.globals.items():
                 context.addGlobal(name, value)
 
@@ -1596,6 +1594,8 @@ class Static:
         if not page:
             page = 'index'
 
-        return getattr(render_, page)()
+        args = {'location': web.ctx.homedomain + web.ctx.homepath}
+
+        return getattr(render, page)(args)
     #GET
 #Static
-- 
GitLab