Browse Source

Adds option to supply a Markdown formatted blob of text to be displayed
as a header in the output.

Caleb Fangmeier 7 years ago
parent
commit
0b949b7977
2 changed files with 13 additions and 4 deletions
  1. 7 3
      filval/plotting.py
  2. 6 1
      filval/templates/dashboard.j2

+ 7 - 3
filval/plotting.py

@@ -41,7 +41,7 @@ class Plot:
         self.arg_dicts = arg_dicts if arg_dicts is not None else {}
 
 
-MD = Markdown(extensions=['mdx_math'],
+MD = Markdown(extensions=['mdx_math', 'tables'],
               extension_configs={'mdx_math': {'enable_dollar_delimiter': True}})
 
 lp.latexify(params={'pgf.texsystem': 'pdflatex',
@@ -130,7 +130,7 @@ def simple_plot(thx, *args, log=None, **kwargs):
 
 
 def generate_dashboard(plots, title, output='dashboard.html', template='dashboard.j2',
-                       source=None, ana_source=None, config=None):
+                       source=None, ana_source=None, config=None, header=None):
     from jinja2 import Environment, PackageLoader, select_autoescape
     from os.path import join, isdir
     from os import mkdir
@@ -158,6 +158,9 @@ def generate_dashboard(plots, title, output='dashboard.html', template='dashboar
     if not isdir('output'):
         mkdir('output')
 
+    if header is not None:
+        header = MD.convert(header)
+
     dashboard_path = join('output', output)
     with open(dashboard_path, 'w') as tempout:
         templ = env.get_template(template)
@@ -166,7 +169,8 @@ def generate_dashboard(plots, title, output='dashboard.html', template='dashboar
             title=title,
             source=source,
             ana_source=ana_source,
-            config=config
+            config=config,
+            header=header,
         ))
     return dashboard_path
 

+ 6 - 1
filval/templates/dashboard.j2

@@ -29,6 +29,11 @@ MathJax.Hub.Config({
     <div class="row">
         <a href="./" class="button"> Go Up <span class="glyphicon glyphicon-circle-arrow-left"></span> </a>
     </div>
+    {% if header %}
+    <div class="row">
+        {{ header|safe }}
+    </div>
+    {% endif %}
 {% for r, plot_row in enumerate(plots) %}
   <div class="row">
   {% for c, plot in enumerate(plot_row) %}
@@ -128,7 +133,7 @@ MathJax.Hub.Config({
 </div>
 </body>
 <style>
-.modal-dialog {width:900px;}
+.modal-dialog {width:90%;}
 .thumbnail {margin-bottom:6px;}
 .modal-title {text-align:center;}
 </style>