From 9f27f8a499adf396da56eba4732d9e34d845ca5f Mon Sep 17 00:00:00 2001 From: Martijn Vermaat <martijn@vermaat.name> Date: Wed, 11 Dec 2013 18:00:23 +0100 Subject: [PATCH] Last fixes for Jinja2 (removing TAL dependency) --- mutalyzer/templates/batch_jobs.html | 13 +- mutalyzer/templates/menu.html | 432 ---------------------------- mutalyzer/templates/skel.html | 13 - mutalyzer/website.py | 15 +- requirements.txt | 1 - 5 files changed, 19 insertions(+), 455 deletions(-) delete mode 100644 mutalyzer/templates/menu.html delete mode 100644 mutalyzer/templates/skel.html diff --git a/mutalyzer/templates/batch_jobs.html b/mutalyzer/templates/batch_jobs.html index 50f771f0..829714fa 100644 --- a/mutalyzer/templates/batch_jobs.html +++ b/mutalyzer/templates/batch_jobs.html @@ -1,6 +1,17 @@ {% extends "base.html" %} -{% set active_page = "batch-jobs" %} +{% if batchType == "NameChecker" %} + {% set active_page = "batch-name-checker" %} +{% elif batchType == "SyntaxChecker" %} + {% set active_page = "batch-syntax-checker" %} +{% elif batchType == "PositionConverter" %} + {% set active_page = "batch-position-converter" %} +{% elif batchType == "SnpConverter" %} + {% set active_page = "batch-snp-converter" %} +{% else %} + {% set active_page = "batch-jobs" %} +{% endif %} + {% set page_title = "Batch {{ batchType|e }} Interface" %} {% block content %} diff --git a/mutalyzer/templates/menu.html b/mutalyzer/templates/menu.html deleted file mode 100644 index 82437c54..00000000 --- a/mutalyzer/templates/menu.html +++ /dev/null @@ -1,432 +0,0 @@ -<html> - <head> - <link rel="shortcut icon" - href="static/images/favicon.ico" - type="image/x-icon"> - <link rel="stylesheet" - type="text/css" - href="static/css/style.css"> - <script - type="text/javascript" - language="javascript" - src="static/js/interface.js"> - </script> - <script - type="text/javascript" - language="javascript" - src="static/js/generator.js"> - </script> - <meta http-equiv="Content-Type" - content="text/html; charset=iso-8859-1"> - <title tal:content = "structure string:Mutalyzer ${version}"></title> - </head> - <body - style="background-image: url('static/images/background.gif'); - background-repeat: repeat-y;" - leftmargin="0" - topmargin="0" - marginwidth="0" - marginheight="0"> - <!-- Header --> - <a id = "top" name = "top"></a> - - <table width="98%" - border="0" - cellspacing="0" - cellpadding="0"> - <tr> - <!-- Corner logo --> - <td rowspan="2" - valign="bottom" - width="180"> - <a href="index" - target="_top"><img - src="static/images/mutalyzer_logo_bw.png" width="180" height="112" - alt="Rauzy fractal" border="0" hspace="0" vspace="0"></a></td> - <td valign="top" - bgcolor="#FFFFFF" - width="20"><img - src="static/images/1x1b.gif" height="1" width="20" border="0"> - </td> - <td align="left" - valign="bottom" - bgcolor="White" - width="98%"> - <!-- Banner --> - <center> - <a href="index"><img - src="static/images/mutalyzer_logo.png" - width="90%" - height="90" - alt="Rauzy color fractal" - border="0"></a> - </center> - </td> - </tr> - - <tr> - <td> - </td> - <td> - <table width = "100%" style = "padding:0; border:0; margin:0"> - <tr> - <td align="left"> - <a href="javascript:history.back(-1);" - class="hornav">previous page</a> - </td> - <td align="right"> - <a href="index" - class="hornav">home</a> - <a href="about" - class="hornav">about</a> - <a tal:attributes = "href string:mailto:${contactEmail}" - class="hornav">contact</a> - <a href="#bottom" class="hornav">go to bottom</a> - </td> - </tr> - </table> - </td> - </tr> - - <tr> - <td colspan="3" - bgcolor="#000000"><img - src="static/images/1x1b.gif" - height="1" - border="0"></td> - </tr> - </table> - - <table width="98%" - border="0" - cellspacing="0" - cellpadding="0"> - <tr> - <td width="180" valign="top"> - - <table id="menu" width="180" border="0" cellspacing="0" cellpadding="0"> - <tr> - <td valign="top" width="20"> - <img src="static/images/1x1b.gif" height="19" border="0"> - </td> - </tr> - - <tr tal:attributes="class active/index"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="index">Home</a> - </td> - </tr> - - <tr tal:attributes="class active/check"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="check">Name Checker</a> - </td> - </tr> - - <tr tal:attributes="class active/parse"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="syntaxCheck">Syntax Checker</a> - </td> - </tr> - - <tr tal:attributes="class active/converter"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="positionConverter">Position Converter</a> - </td> - </tr> - - <tr tal:attributes="class active/snp"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="snp">SNP Converter</a> - </td> - </tr> - - <tr tal:attributes="class active/nameGenerator"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="nameGenerator">Name Generator</a> - </td> - </tr> - - <tr tal:attributes="class active/descriptionExtract"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="descriptionExtract">Description Extractor</a> - </td> - </tr> - - <tr tal:attributes="class active/gbupload"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="upload">Reference File Loader</a> - </td> - </tr> - - <tr tal:attributes="class active/batch"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="batch">Batch Jobs</a> - </td> - </tr> - - <tr tal:attributes="class active/batchNameChecker"> - <td></td> - <td valign="baseline" width="10" class="bullet sub"></td> - <td colspan="2"> - <a href="batchNameChecker">Name Checker</a> - </td> - </tr> - - <tr tal:attributes="class active/batchSyntaxChecker"> - <td></td> - <td valign="baseline" width="10" class="bullet sub"></td> - <td colspan="2"> - <a href="batchSyntaxChecker">Syntax Checker</a> - </td> - </tr> - - <tr tal:attributes="class active/batchPositionConverter"> - <td></td> - <td valign="baseline" width="10" class="bullet sub"></td> - <td colspan="2"> - <a href="batchPositionConverter">Position Converter</a> - </td> - </tr> - - <tr tal:attributes="class active/batchSnpConverter"> - <td></td> - <td valign="baseline" width="10" class="bullet sub"></td> - <td colspan="2"> - <a href="batchSnpConverter">SNP Converter</a> - </td> - </tr> - - <tr tal:attributes="class active/webservices"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="webservices">Web services</a> - </td> - </tr> - - <tr><td> </td></tr> - - <tr tal:attributes="class active/help"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="https://humgenprojects.lumc.nl/trac/mutalyzer/wiki/MutalyzerDocumentation">Documentation</a> - </td> - </tr> - - <tr tal:attributes="class active/faq"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="https://humgenprojects.lumc.nl/trac/mutalyzer/wiki/MutalyzerFaq">FAQ</a> - </td> - </tr> - - <tr tal:attributes="class active/exercise"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="https://humgenprojects.lumc.nl/trac/mutalyzer/wiki/MutalyzerExercise">Exercise</a> - </td> - </tr> - - <tr tal:attributes="class active/disclaimer"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="https://humgenprojects.lumc.nl/trac/mutalyzer/wiki/MutalyzerDisclaimer">Disclaimer</a> - </td> - </tr> - - <tr class="menu"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - <a href="https://humgenprojects.lumc.nl/trac/mutalyzer">Feedback</a> - </td> - </tr> - - <tr><td> </td></tr> - - <tr class="menu inactive"> - <td valign="top" width="20" class="bullet"></td> - <td colspan="3"> - External Links - </td> - </tr> - - <tr class="menu"> - <td></td> - <td valign="baseline" width="10" class="bullet sub"></td> - <td colspan="2"> - <a href="http://www.genenames.org/guidelines.html" - >Human Gene Nomenclature</a> - </td> - </tr> - - <tr class="menu"> - <td></td> - <td valign="baseline" width="10" class="bullet sub"></td> - <td colspan="2"> - <a href="http://www.hgvs.org/mutnomen/" - >HGVS Variation Nomenclature</a> - </td> - </tr> - - <tr class="menu"> - <td></td> - <td valign="baseline" width="10" class="bullet sub"></td> - <td colspan="2"> - <a href="http://dx.doi.org/10.1002/humu.21427" - >HGVS Nomenclature Extension Proposal</a> - </td> - </tr> - - <tr class="menu"> - <td></td> - <td valign="baseline" width="10" class="bullet sub"></td> - <td colspan="2"> - <a href="http://www.lovd.nl/">LOVD</a> - </td> - </tr> - - <tr> - <td width="20"><img - src="static/images/1x1b.gif" - height="10" - width="20" - border="0"> - </td> - <td width="12"><img - src="static/images/1x1b.gif" - height="10" - width="10" - border="0"> - </td> - <td valign="top" width="12"><img - src="static/images/1x1b.gif" - height="10" - width="10" - border="0"> - </td> - <td valign="top" width="136"><img - src="static/images/1x1b.gif" - height="10" - width="136" - border="0"> - </td> - </tr> - </table> - - </td> - <td width="20"><img - src="static/images/1x1b.gif" - height="1" - width="20" - border="0"> - </td> - <td width="98%" valign="top"><br> - - <!-- Content --> - - <table cellpadding="0" cellspacing="0" width="100%" border="0"> - <tbody><tr> - <td width="0"></td> - <td width="0"> - - - <center> - <h2 tal:condition = "release" - tal:content = "structure string:Mutalyzer ${version}<br> - <small><small><small><small> - released on ${releaseDate} - </small></small></small></small>"></h2> - <h2 tal:condition = "not:release" - tal:content = "structure string:Mutalyzer ${version}<br> - <small><small><small><small> - development version - </small></small></small></small>"></h2> - HGVS nomenclature version - <span tal:content = "nomenclatureVersion"></span> - </center> - <p> - - <div metal:use-macro = "sitemacros/macros/content"></div> - - <!-- Navigation bar --> - <table border="0" - cellspacing="0" - cellpadding="0" - width="100%" - align="center"> - <tr> - <td colspan="2"><img - src="static/images/1x1b.gif" - width="1" - height="20" - border="0"> - </td> - </tr> - <tr> - <td bgcolor="#000000" colspan="3"><img - src="static/images/1x1b.gif" - width="100%" - height="1" - border="0"></td> - </tr> - <tr> - <td align="left"> - <a href="javascript:history.back(-1);" - class="hornav">previous page</a> - </td> - <td align="middle"> - <img src = "static/images/LUMC_24x24.png" align = "middle"> - © <tal tal:replace = "copyrightYears/0"></tal>-<tal tal:replace = "copyrightYears/1"></tal> - <a href = "http://www.lumc.nl">LUMC</a> - - - </td> - <td align="right"> - <a href="#top" class="hornav">go to top</a> - </td> - </tr> - <tr> - <!-- - <td colspan="2" - align="center">Last edited by: with /usr/bin/vim - </td> - --> - </tr> - <tr> - <td colspan="2"><img - src="static/images/1x1b.gif" - width="1" - height="10" - border="0"> - </td> - </tr> - </table> - </td> - </tr> - </table> - <a id = "bottom" name = "bottom"></a> -<div tal:condition="piwik" tal:omit-tag=""> -<!-- Piwik --> -<script type="text/javascript" tal:content="string: -var pkBaseURL = "${piwikBase}/"; -document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); -"></script><script type="text/javascript" tal:content="string: -try { -var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", ${piwikSite}); -piwikTracker.trackPageView(); -piwikTracker.enableLinkTracking(); -} catch( err ) {} -"></script><noscript><p><img tal:attributes="src string:${piwikBase}/piwik.php?idsite=${piwikSite}" style="border:0" alt="" /></p></noscript> -<!-- End Piwik Tracking Code --> -</div> - </body> -</html> diff --git a/mutalyzer/templates/skel.html b/mutalyzer/templates/skel.html deleted file mode 100644 index 4057d770..00000000 --- a/mutalyzer/templates/skel.html +++ /dev/null @@ -1,13 +0,0 @@ -<html> - <head> - <title></title> - </head> - <body> - <div metal:define-macro="content"> - <center> - <h3>Skeleton</h3> - </center> - Your text here. - </div> - </body> -</html> diff --git a/mutalyzer/website.py b/mutalyzer/website.py index 203e39b1..4af709fe 100644 --- a/mutalyzer/website.py +++ b/mutalyzer/website.py @@ -29,8 +29,6 @@ from web.contrib.template import render_jinja from lxml import etree import pkg_resources from cStringIO import StringIO -from simpletal import simpleTALES -from simpletal import simpleTAL from spyne.server.http import HttpBase import mutalyzer @@ -191,6 +189,8 @@ render_ = render_tal(pkg_resources.resource_filename('mutalyzer', 'templates'), }) # Jinja2 template render +# Todo: We rely on Apache to add a Content-Type header, we should actually +# set it ourselves. render = render_jinja(pkg_resources.resource_filename('mutalyzer', 'templates'), encoding='utf-8', globals = { @@ -913,7 +913,9 @@ class Check: output.addMessage(__file__, -1, 'INFO', 'Finished variant %s' % name) - return render.name_checker(args, prevent_caching=True) + web.header('Cache-Control', 'no-cache') + web.header('Expires', '-1') + return render.name_checker(args) #check #Check @@ -1189,10 +1191,7 @@ class BatchChecker: } # Make sure the correct page is displayed for an entrypoint - if batchType: - page = 'batch' + batchType - else: - page = 'batch' + if not batchType: batchType = 'NameChecker' if batchType in attr["batchTypes"]: @@ -1248,7 +1247,7 @@ class BatchChecker: attr["errors"].extend(map(util.message_info, O.getMessages())) - return render.batch_jobs(attr, page=page) + return render.batch_jobs(attr) #batch #BatchChecker diff --git a/requirements.txt b/requirements.txt index 4ab10349..e2e06ca3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,4 +20,3 @@ WebTest==1.4.2 cssselect==0.9.1 Jinja2==2.7.1 -e git+https://github.com/mammadori/magic-python.git#egg=Magic_file_extensions -http://www.owlfish.com/software/simpleTAL/downloads/SimpleTAL-4.3.tar.gz -- GitLab