Added the help pages.

master
Pacman Ghost 6 years ago
parent af18e5678b
commit adfab86c39
  1. 7
      vasl_templates/webapp/__init__.py
  2. 8
      vasl_templates/webapp/main.py
  3. 6
      vasl_templates/webapp/static/css/main.css
  4. 48
      vasl_templates/webapp/static/help/imageZoom/jquery.imageZoom.css
  5. 1
      vasl_templates/webapp/static/help/imageZoom/jquery.imageZoom.min.js
  6. BIN
      vasl_templates/webapp/static/help/imageZoom/jquery.imageZoom.png
  7. BIN
      vasl_templates/webapp/static/help/images/add-ssr.png
  8. BIN
      vasl_templates/webapp/static/help/images/add-ssr.small.png
  9. BIN
      vasl_templates/webapp/static/help/images/draggable-overlays.png
  10. BIN
      vasl_templates/webapp/static/help/images/draggable-overlays.small.png
  11. BIN
      vasl_templates/webapp/static/help/images/edit-template.png
  12. BIN
      vasl_templates/webapp/static/help/images/edit-template.small.png
  13. BIN
      vasl_templates/webapp/static/help/images/hill-621.png
  14. BIN
      vasl_templates/webapp/static/help/images/hill-621.small.png
  15. BIN
      vasl_templates/webapp/static/help/images/load-template-pack.png
  16. BIN
      vasl_templates/webapp/static/help/images/load-template-pack.small.png
  17. BIN
      vasl_templates/webapp/static/help/images/ob_setup.png
  18. BIN
      vasl_templates/webapp/static/help/images/ob_setup.small.png
  19. BIN
      vasl_templates/webapp/static/help/images/ob_vehicles.png
  20. BIN
      vasl_templates/webapp/static/help/images/ob_vehicles.small.png
  21. BIN
      vasl_templates/webapp/static/help/images/pf.png
  22. BIN
      vasl_templates/webapp/static/help/images/pf.small.png
  23. BIN
      vasl_templates/webapp/static/help/images/scenario-vasl.png
  24. BIN
      vasl_templates/webapp/static/help/images/scenario-vasl.small.png
  25. BIN
      vasl_templates/webapp/static/help/images/scenario.png
  26. BIN
      vasl_templates/webapp/static/help/images/scenario.small.png
  27. BIN
      vasl_templates/webapp/static/help/images/ssr-template.png
  28. BIN
      vasl_templates/webapp/static/help/images/ssr-template.small.png
  29. BIN
      vasl_templates/webapp/static/help/images/ssr-template2.png
  30. BIN
      vasl_templates/webapp/static/help/images/ssr-template2.small.png
  31. BIN
      vasl_templates/webapp/static/help/images/ssr.png
  32. BIN
      vasl_templates/webapp/static/help/images/ssr.small.png
  33. BIN
      vasl_templates/webapp/static/help/images/vc-vasl.png
  34. BIN
      vasl_templates/webapp/static/help/images/vc-vasl.small.png
  35. BIN
      vasl_templates/webapp/static/help/images/vc.png
  36. BIN
      vasl_templates/webapp/static/help/images/vc.small.png
  37. 292
      vasl_templates/webapp/static/help/index.html
  38. BIN
      vasl_templates/webapp/static/help/jquery-ui/images/ui-icons_444444_256x240.png
  39. BIN
      vasl_templates/webapp/static/help/jquery-ui/images/ui-icons_555555_256x240.png
  40. BIN
      vasl_templates/webapp/static/help/jquery-ui/images/ui-icons_777620_256x240.png
  41. BIN
      vasl_templates/webapp/static/help/jquery-ui/images/ui-icons_777777_256x240.png
  42. BIN
      vasl_templates/webapp/static/help/jquery-ui/images/ui-icons_cc0000_256x240.png
  43. BIN
      vasl_templates/webapp/static/help/jquery-ui/images/ui-icons_ffffff_256x240.png
  44. 7
      vasl_templates/webapp/static/help/jquery-ui/jquery-ui.min.css
  45. 13
      vasl_templates/webapp/static/help/jquery-ui/jquery-ui.min.js
  46. 5
      vasl_templates/webapp/static/help/jquery-ui/jquery-ui.structure.min.css
  47. 5
      vasl_templates/webapp/static/help/jquery-ui/jquery-ui.theme.min.css
  48. 2
      vasl_templates/webapp/static/help/jquery/jquery-3.3.1.min.js
  49. 24
      vasl_templates/webapp/static/help/main.css
  50. 32
      vasl_templates/webapp/static/help/main.js
  51. 26
      vasl_templates/webapp/static/main.js
  52. 4
      vasl_templates/webapp/templates/index.html
  53. 2
      vasl_templates/webapp/tests/test_help.py

@ -8,7 +8,7 @@ import logging.config
from flask import Flask
import yaml
from vasl_templates.webapp.config.constants import APP_NAME, BASE_DIR
from vasl_templates.webapp.config.constants import APP_NAME, APP_VERSION, BASE_DIR
# ---------------------------------------------------------------------
@ -53,4 +53,7 @@ import vasl_templates.webapp.snippets #pylint: disable=cyclic-import
@app.context_processor
def inject_template_params():
"""Inject template parameters into Jinja2."""
return { "APP_NAME": APP_NAME }
return {
"APP_NAME": APP_NAME,
"APP_VERSION": APP_VERSION,
}

@ -21,8 +21,12 @@ def main():
def show_help():
"""Show the help page."""
url = url_for( "static", filename="help/index.html" )
if request.args.get( "embedded" ):
url += "?embedded=1"
args = []
for arg in ("embedded","tab"):
if request.args.get( arg ):
args.append( "{}={}".format( arg, request.args[arg] ) )
if args:
url += "?{}".format( "&".join( args ) )
return redirect( url, code=302 )
# ---------------------------------------------------------------------

@ -67,6 +67,12 @@ ul, ol { margin: 0.5em 0 0 1.25em ; br}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#tabs-help.ui-tabs-panel { background: #fff ; }
#tabs-help iframe { width: 100% ; height: 99% ; border: none ; }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
fieldset { margin: 0 5px 5px 5px ; padding: 10px ; border: 1px solid #888 ; background: #ffffff ; border-radius: 0 10px 0 0 ; }
fieldset legend { padding: 0 0.2em 0 0.2em ; font-style: italic ; font-weight: bold ; }

@ -0,0 +1,48 @@
div.jquery-image-zoom {
line-height: 0;
font-size: 0;
z-index: 10;
border: 5px solid #fff;
background: #eee; /* TM 25jan15: Added this to make it easier to see images with transparent backgrounds. */
margin: -5px;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
div.jquery-image-zoom a {
background: url(jquery.imageZoom.png) no-repeat;
display: block;
width: 25px;
height: 25px;
position: absolute;
left: -17px;
top: -17px;
/* IE-users are prolly used to close-link in right-hand corner */
*left: auto;
*right: -17px;
text-decoration: none;
text-indent: -100000px;
outline: 0;
z-index: 11;
}
div.jquery-image-zoom a:hover {
background-position: left -25px;
}
div.jquery-image-zoom img,
div.jquery-image-zoom embed,
div.jquery-image-zoom object,
div.jquery-image-zoom div {
width: 100%;
height: 100%;
margin: 0;
}

@ -0,0 +1 @@
jQuery.fn.imageZoom=function(c,b){var a=c.extend({speed:200,dontFadeIn:1,hideClicked:1,imageMargin:30,className:"jquery-image-zoom",loading:"Loading..."},b);a.doubleSpeed=a.speed/4;c(document).keydown(function(d){if(d.keyCode==27){c("div.jquery-image-zoom a").click()}});return this.click(function(k){var h=c(k.target);var g=h.is("a")?h:h.parents("a");g=(g&&g.is("a")&&g.attr("href").search(/(.*)\.(jpg|jpeg|gif|png|bmp|tif|tiff)$/gi)!=-1)?g:false;var i=(g&&g.find("img").length)?g.find("img"):false;c("div.jquery-image-zoom a").click();if(g){g.oldText=g.text();g.setLoadingImg=function(){if(i){i.css({opacity:"0.5"})}else{g.text(a.loading)}};g.setNotLoadingImg=function(){if(i){i.css({opacity:"1"})}else{g.text(g.oldText)}};var d=g.attr("href");if(c("div."+a.className+' img[src="'+d+'"]').length){return false}var j=function(l){g.setNotLoadingImg();var u=i?i:g;var q=i?a.hideClicked:0;var p=u.offset();var n={width:u.outerWidth(),height:u.outerHeight(),left:p.left,top:p.top};var o=c('<div><img src="'+d+'" alt=""/></div>').css("position","absolute").appendTo(document.body);var m={width:l.width,height:l.height};var s={width:c(window).width(),height:c(window).height()};if(m.width>(s.width-a.imageMargin*2)){var r=s.width-a.imageMargin*2;m.height=(r/m.width)*m.height;m.width=r}if(m.height>(s.height-a.imageMargin*2)){var t=s.height-a.imageMargin*2;m.width=(t/m.height)*m.width;m.height=t}m.left=(s.width-m.width)/2+c(window).scrollLeft();m.top=(s.height-m.height)/2+c(window).scrollTop();var e=c('<a href="#">Close</a>').appendTo(o).hide();if(q){g.css("visibility","hidden")}o.addClass(a.className).css(n).animate(m,a.speed,function(){e.fadeIn(a.doubleSpeed)});var v=function(){e.fadeOut(a.doubleSpeed,function(){o.animate(n,a.speed,function(){g.css("visibility","visible");o.remove()})});return false};o.click(v);e.click(v)};var f=new Image();f.src=d;if(f.complete){j(f)}else{g.setLoadingImg();f.onload=function(){j(f)}}return false}})};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

@ -4,13 +4,297 @@
<head>
<meta charset="utf-8">
<title> VASL Templates </title>
<style>
* { margin: 0 ; padding: 0 }
</style>
<link rel="stylesheet" type="text/css" href="jquery-ui/jquery-ui.min.css" />
<link rel="stylesheet" type="text/css" href="imageZoom/jquery.imageZoom.css" />
<link rel="stylesheet" type="text/css" href="main.css" />
</head>
<body>
This is the help page.
<!-- ----------------------------------------------------------------- -->
<div id="helptabs" style="display:none;">
<ul>
<li> <a href="#helptabs-installation">Installation</a>
<li> <a href="#helptabs-userguide">User Guide</a>
<li> <a href="#helptabs-templatepacks">Template packs</a>
<li> <a href="#helptabs-fordevelopers">For developers</a>
</ul>
<div id="helptabs-content">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="helptabs-installation">
<p> <em>VASL Templates</em> is a web application that runs in a browser, but since it hasn't been set up as a web site on the public internet, you will need to run the web server yourself.
<p> As a convenience, a program is provided that bundles the web server together with an embedded browser, so that it runs as if it were a normal desktop application.
<h2> Installing on Windows </h2>
<p> If you're using Windows, you should get the pre-built version from <a href="https://github.com/pacman-ghost/vasl-templates/releases" target="_blank">Github</a>, unpack it somewhere, then run <tt>vasl-templates.exe</tt>
<p> If the program won't start because a DLL is missing from your computer, install the <a href="https://www.microsoft.com/en-in/download/details.aspx?id=48145" target="_blank">VC2015 runtime</a> (get the 32-bit version, <tt>vc_redist.x86.exe</tt>, even if you are running 64-bit Windows).
<p> If you don't see anything in the main window, check the notes below about configuring OpenGL.
<h2> Running from source </h2>
<p> If you're on a Mac or Linux, you can run the program directly from the source code. Get a copy from <a href="https://github.com/pacman-ghost/vasl-templates" target="_blank">Github</a> in the usual way, by <tt>git clone</tt>'ing it, or downloading a ZIP and unpacking it somewhere.
<p> The web server was written and tested using Python 3.6, but it doesn't do anything particulaly funky, so any recent version of Python <em>should</em> work.
<p> While not essential, it is <em>strongly</em> recommended that you set up a <a href="https://virtualenv.pypa.io/en/stable/" target="_blank">virtual environment</a> first. Then, install the requirements:
<div class="code">
pip install .
</div>
<h4> Running the desktop application </h4>
<p> To run the program as a desktop application, you will need to install Qt 5.10.0. While your distro may have it as a package, I didn't have much luck on Fedora 27, and had to install it manually using their <a href="https://www.qt.io/download" target="_blank">installer</a>.
<p> Then, just run the <tt>vasl-templates</tt> command.
<h4> Running just the web server </h4>
<p> The simpler option is to just run the web server:
<div class="code">
python vasl_templates/webapp/run_server.py
</div>
and then connect to it in a browser at <tt>http://localhost:5010</tt>.
<h2> I'm having problems running the desktop application </h2>
<p> The desktop application uses OpenGL for the embedded browser, so if you are getting error messages about OpenGL, or the main window is not displaying properly, you can try configuring OpenGL to work in a different way.
<p> Create a file called <tt>debug.cfg</tt> in <tt>$/lib/vasl_templates/webapp/config/</tt> (the same directory that contains a file called <tt>app.cfg</tt>) that looks like this:
<div class="code">
[Debug]
OPENGL_TYPE = AA_UseSoftwareOpenGL
</div>
Other possible values are <tt>AA_UseDesktopOpenGL</tt> and <tt>AA_UseOpenGLES</tt>.
<p> If you're on Windows, <a href="https://doc.qt.io/qt-5/windows-requirements.html" target="_blank">this page</a> might also help.
<p> In the worst case, you can set up your <tt>debug.cfg</tt> file like this:
<div class="code">
[Debug]
DISABLE_WEBENGINEVIEW = 1
</div>
The program will then not attempt to create the embedded browser, and will just start the web server, which you can then connect to in an external browser at <tt>http://localhost:5010</tt>.
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="helptabs-userguide">
<p> <img src="images/hill-621.png" class="preview" style="width:20em;float:right;">
<em>VASL Templates</em> makes it easier to set up <a href="http://vasl.info" target="_blank">VASL</a> scenarios, and we'll show how by walking through a setup of everyone's favorite scenario, <em>Hill 621</em>.
<p> Click on the screenshot to the right to see the finished scenario, in all it's glory.
<h2> Adding the scenario details </h2>
<p> <img src="images/scenario.png" class="preview" style="width:20em;float:left;">
First, we enter the basic details about the scenario.
<p> Click on one of the <em>Snippet</em> buttons, and the program will generate an HTML snippet and put it into your clipboard, which you can then copy into a VASL label.
<br clear="all">
<p> <img src="images/draggable-overlays.png" class="preview" style="width:20em;float:right;">
To create a label in VASL, open the <em>Draggable Overlays</em> window, and drag a label onto the main window.
<p> Labels come in two parts, which are accessible via the right-click menu, or press Ctrl-L and Ctrl-2 to access each one. I always just use the first line, so I delete everything in line 2.
<p> The thick black box indicates that the label is selected. If you click elsewhere on the main window, it goes away, and the label will remain in place even if you click on it, or try to drag it. To select it again, Shift-click somewhere in the box, and you will be able to move it around, or edit it. This can sometimes be difficult to find, since it's not visible on-screen, but it will be in the middle (vertically and horizontally) of the label.
<br clear="all">
<p> <img src="images/scenario-vasl.png" class="preview" style="width:20em;float:left;">
Once you have a label in VASL, copy the HTML snippet generated above into it.
<p> Repeat the process to add the ELR and SAN for both players, and you will now have two labels that you can position in the VASL scenario.
<h2> Adding victory conditions and SSR's </h2>
<p> <img src="images/vc.png" class="preview" style="width:20em;float:left;">
Adding the scenario's victory conditions is straight-forward. We're generating <em>HTML</em> snippets, so we can type in things like <tt>&amp;ge;</tt> to get <tt>&ge;</tt> in the VASL label.
<img src="images/vc-vasl.png" class="preview" style="display:block;width:15em;margin:0.5em 0 0 2em;">
<p> &nbsp;
<p> Note that we explicitly set a width for the snippet (240px), which caused the text to wrap onto a new line. You could also do this by manually inserting <tt>&lt;br&gt;</tt> tags where you want line-breaks.
<br clear="all">
<p> <img src="images/add-ssr.png" class="preview" style="width:15em;float:right;">
To add SSR's, click on the green plus button in the SSR section and add the SSR text.
<p> Click on the OK button when you're done, or press Ctrl-Enter.
<p> If you want to go back and change the text of an SSR, just double-click on it.
<br clear="all">
<p> <img src="images/ssr.png" class="preview" style="width:25em;float:right;">
Once they're all in, click on the <em>Snippet</em> button to get a nicely formatted bullet list.
<h2> Adding each player's OB </h2>
<p> <img src="images/ob_vehicles.png" class="preview" style="width:20em;float:right;">
Adding each vehicle and ordnance for each player is just a matter of selecting them from a list, and the generated HTML snippet will produce a table of information for each one (see right). Very handy if you have a menagerie of armor and you're, say, looking for something that can fire Smoke.
<p> The scenario date is taken into account when generating these tables e.g. APCR for the Pz IVH is A5<sup>2</sup>, but since the program knows the scenario is set in 1944, it just shows A5. Had the scenario been set in 1941, it wouldn't be shown at all.
<br clear="all">
<p> <img src="images/ob_setup.png" class="preview" style="width:15em;float:left;">
We can also add ad-hoc notes describing where and how units should setup.
<p> Click on the icon in each note to generate its snippet, or Shift-click on it.
<br clear="all">
<p> <img src="images/pf.png" class="preview" style="width:15em;float:right;">
Finally, if special support weapons such as PF and BAZ are in play, snippets are available with information for them, and as with vehicles/ordnance, they are date-aware and update themselves accordingly.
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="helptabs-templatepacks">
<h2 style="margin-top:0;"> How template files work </h2>
<p> The HTML snippets are generated from <em>template files</em>, which are simply text files that contain the HTML you want to insert into the VASL labels, but with placeholders for the scenario name, victory conditions, each player's OB, etc. The user enters these details into the program, and when they want to generate a snippet, all the placeholders are replaced in the template with the real values, thus producing an HTML snippet specific to that scenario.
<p> The template files can be found in <tt>$/lib/vasl_templates/webapp/data/default-template-pack/</tt> (where <tt>$</tt> is where you've installed the program).
<h2> Placeholders and template conditionals </h2>
<p> <img src="images/ssr-template.png" class="preview" style="width:20em;float:right;">
We'll take a look at the <tt>ssr.j2</tt> file, which is used to generate snippets for the SSR's.
<p> Open the file in a text editor (if you're on Windows, you will probably need to right-click on the file and choose <em>Open with...</em>), and you'll see something like this:
<div class="code">
&lt;html&gt;
&lt;table style="
{%if SSR_WIDTH%} width: {{SSR_WIDTH}} ; {%endif%}
"&gt;
&lt;tr&gt;
&lt;td style="
background: #f0f0f0 ;
border-bottom: 1px solid #c0c0c0 ;
"&gt;
&lt;b&gt;Scenario Special Rules&lt;/b&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;ul style="margin:0 0 0 10px;"&gt;
{%for ssr in SSR%}
&lt;li&gt; {{ssr}}
{%endfor%}
&lt;/ul&gt;
&lt;/table&gt;
&lt;/html&gt;
</div>
<p> The template looks like normal HTML, but with some extra stuff. Things that look like <tt>{% ... %}</tt> are commands to the template processor. At the top of the file, we see this:
<div class="code">
&lt;table style="
{%if SSR_WIDTH%} width: {{SSR_WIDTH}} ; {%endif%}
"&gt;
</div>
This is saying <em>if the user has specified SSR_WIDTH, then insert into the generated HTML snippet everything up to the next <tt>{%endif%}</tt></em>. In this case, that's the following:
<div class="code">
width: {{SSR_WIDTH}} ;
</div>
Things that look like <tt>{{...}}</tt> are the actual values entered by the user into the UI, in this case, the SSR width.
<p> So, if the user has specified a width of, say <em>300px</em>, this is what will be inserted into the final HTML snippet:
<div class="code">
&lt;table style="width: 300px ;"&gt;
</div>
But if the user hasn't specified anything for this field, what's between the <tt>{%if ...%}</tt> and <tt>{%endif%}</tt> will be ignored, and we get this:
<div class="code">
&lt;table style=""&gt;
</div>
<h2> Looping over lists </h2>
<p> There will often be multiple SSR's, and near the bottom of the file, we can see how these are handled:
<div class="code">
&lt;ul style="margin:0 0 0 10px;"&gt;
{%for ssr in SSR%}
&lt;li&gt; {{ssr}}
{%endfor%}
&lt;/ul&gt;
</div>
This sets up an HTML list (<tt>&lt;ul&gt;</tt>) and repeats everything between the <tt>{%for ...%}</tt> and <tt>{%endfor%}</tt>, once for each entry in the <tt>SSR</tt> variable, which contains the SSR's entered by the user in the UI. Each time around, <tt>{{ssr}}</tt> will be updated to hold the next entry, which will be inserted into the generated HTML snippet as a <tt>&lt;li&gt;</tt> node.
<p> <img src="images/ssr-template2.png" class="preview" style="width:20em;float:right;">
If the user had entered the SSR's as shown in the screenshot, then we would get the following inserted into the generated HTML snippet:
<div class="code">
&lt;ul style="margin:0 0 0 10px;"&gt;
&lt;li&gt; This is an SSR.
&lt;li&gt; This is &lt;em&gt;also&lt;/em&gt; an SSR.
&lt;li&gt; And one more.
&lt;/ul&gt;
</div>
Note that if they enter HTML into the SSR text, it will be inserted verbatim into the HTML snippet, thus allowing them to format the content.
<h2> Template packs </h2>
<p> If you want to customize how the HTML snippets are generated, you could just edit the files directly, but the down-side of doing this is that if you install a new version of the program, you will lose your changes.
<p><img src="images/load-template-pack.png" class="preview" style="width:10em;float:right;">
A better way is to create your own set of template files, ZIP them up and load it as a <em>template pack</em>.
<p> If you're running the desktop program, you can specify the template pack to start with, so that you don't have to manually upload it each time i.e.
<div class="code">
vasl-template.exe --template-pack my-template-pack.zip
</div>
You can specify a ZIP file, or the directory containing the files (probably easier).
<p> <img src="images/edit-template.png" class="preview" style="width:20em;float:left;">
When you're writing a new template file, it would be painful to have to ZIP up and upload a new template pack every time you made a change, so you can edit templates directly within the program (see screenshot).
<p> Changes you make are live i.e. they will take effect immediately, but note that there is no way to save your changes, so once you're happy with how the template is working, you need to copy it out and save it somewhere.
<br clear="all">
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="helptabs-fordevelopers">
<h2 style="margin-top:0;"> Setting up </h2>
<p> After cloning the repo, install the <em>developer</em> requirements:
<div class="code">
pip install --editable .[dev]
</div>
The tests use <a href="http://pytest.org" target="_blank">pytest</a> and Selenium WebDriver, so you will need <tt>geckodriver</tt> and <tt>chromedriver</tt> somewhere in your PATH. The driver to use can be specified via the <tt>--webdriver</tt> parameter, and you can also run the tests headless e.g
<div class="code">
pytest --webdriver chrome --headless
</div>
<p> Note that since <tt>pylint</tt> is run as part of these tests, this should be done from the root directory of the repo.
<p> <small><em>NOTE: Internet Explorer is also supported as a WebDriver, but due to differences in the way it works, some tests are currently failing for this.</em></small>
<h2> Code lint'ing </h2>
<p> Python code is checked using <tt>pylint</tt> (installed during the <tt>pip install</tt> above), which should be run from the root directory of the repo.
<p> Javascript is checked using <a href="http://jshint.com" target="_blank"><tt>jshint</tt></a>, run using <a href="https://www.mozilla.org/rhino" target="_blank">Rhino</a>, both of which need to be installed manually. Then, set the <tt>JSHINT_RHINO</tt> environment variable to point to the script that will run <tt>jshint</tt> using Rhino e.g.
<div class="code">
export JSHINT_RHINO=~/bin/jshint-2.6.3/dist/jshint-rhino.js
</div>
Note that both of these are run as part of a normal <tt>pytest</tt> run.
<h2> Creating a pre-compiled package </h2>
<p> It is possible to compile the desktop application down to a single binary. This is typically done for the benefit of Windows users, but also works for other platforms. From the root directory of the repo:
<div class="code">
python _freeze.py --output c:\temp\vasl-templates.zip
</div>
The script will compile the program, then package it all up with the necessary support files into a single archive file.
</div>
<!-- ----------------------------------------------------------------- -->
</div> <!-- #helptabs-content -->
</div> <!-- #helptabs -->
</body>
<script src="jquery/jquery-3.3.1.min.js"></script>
<script src="jquery-ui/jquery-ui.min.js"></script>
<script src="imageZoom/jquery.imageZoom.min.js"></script>
<script src="main.js"></script>
<script src="../utils.js"></script>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,24 @@
* { margin: 0 ; padding: 0 }
html { height: 100% ; }
body { height: 100% ; overflow: hidden ; }
h2 { margin-top: 1em ; clear: both ; }
h4 { margin-top: 0.5em ; clear: both ; }
p { margin-top: 0.5em ; }
.code { white-space: pre ; font-family: monospace ; margin: 0 1em 1em 2em ; }
/* -------------------------------------------------------------------- */
#helptabs { width: 100% ; height: calc(100% - 50px) ; background: none ; border: none ; }
#helptabs-content { height: 100% ; margin-top: 10px ; overflow: auto ; }
#helptabs .ui-tabs-nav { font-size: 75% ; text-align: right ; padding-right: 15px ; }
#helptabs .ui-tabs-nav { background: none ; border-width: 0 0 1px 0 ; }
#helptabs .ui-tabs-nav li { float: none ; display: inline-block ; margin-bottom: -4px ; }
#helptabs .ui-tabs-nav a { color: #888 ; }
#helptabs .ui-tabs-active { background: #ddd ; border-color: #ccc ; }
#helptabs .ui-tabs-active a { color: #444 ; }
#helptabs .ui-tabs-panel { padding: 0.5em 1em 0.5em 1em ; }

@ -0,0 +1,32 @@
// --------------------------------------------------------------------
$(document).ready( function() {
// initialize image previews
$( "img.preview" ).each( function() {
// check if the image is floating and add a margin
var float = $(this).css( "float" ) ;
if ( float === "left" )
$(this).css( "margin-right", "1em" ) ;
else if ( float === "right" )
$(this).css( "margin-left", "1em" ) ;
// wrap the image in a link
var url = $(this).attr( "src" ) ;
$(this).attr( "src", url.substring(0,url.length-4)+".small.png" ) ;
$(this).wrap( "<a href='" + url + "'></a>" ).imageZoom( $ ) ;
} ) ;
// initialize the tabs
if ( getUrlParam( "embedded" ) ) {
$( "#helptabs li:eq(0)" ).remove() ;
$( "#helptabs-installation" ).remove() ;
}
$("#helptabs").tabs().show() ;
$("#helptabs .ui-tabs-nav a").click( function() { $(this).blur() ; } ) ;
// check if we should auto-select a tab
var tab_id = getUrlParam( "tab" ) ;
if ( tab_id )
$( "a[href='#helptabs-" + tab_id + "']" ).click() ;
} ) ;

@ -597,17 +597,27 @@ function adjust_footer_vspacers()
function show_help()
{
// check if we need to load the HELP tab
var $tab = $("#tabs-help") ;
if ( $tab.find( "iframe" ).length === 0 ) {
var $iframe = $("#tabs-help iframe") ;
if ( ! $iframe.attr( "src" ) ) {
// yup - make it so
// NOTE: We show the help in an iframe so that we can use the same files elsewhere e.g. on the web site or Github.
var buf = [ "<iframe src='" + gHelpUrl + "?embedded=1'",
" style='width:100%;height:100%;border:none;'",
">",
"</iframe>"
] ;
$tab.append( buf.join("") ) ;
$iframe.attr( "src", gHelpUrl + "?embedded=1&tab=userguide'" ) ;
$("#tabs .ui-tabs-tab[aria-controls='tabs-help']").show() ;
setTimeout( function() { // nb: give the iframe time to become visible
// insert the app name/version
var pos = $iframe.position() ;
var buf = [ "<div style='display:none;",
"font-size: 1.8em; color: #555;",
"position: absolute; top: " + Math.ceil(pos.top) + "px; left: " + Math.ceil(pos.left) + "px;",
"padding-left: 5px;",
"'>",
gAppName + " <small>(" + gAppVersion + ")</small>",
"</div>",
] ;
var $elem = $( buf.join("") ) ;
$iframe.after( $elem ) ;
$elem.fadeIn( 500 ) ;
}, 200 ) ;
}
// show the HELP tab

@ -244,11 +244,12 @@
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="tabs-help">
<iframe></iframe>
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
</div>
</div> <!-- #tabs -->
<div id="watermark" style="display:none;">
<img src="{{url_for('static',filename='images/watermark.png')}}">
@ -285,6 +286,7 @@
<script src="{{url_for('static',filename='jszip/jszip.min.js')}}"></script>
<script>
gAppName = "{{APP_NAME}}" ;
gAppVersion = "{{APP_VERSION}}" ;
gImagesBaseUrl = "{{url_for('static',filename='images')}}" ;
gGetTemplatePackUrl = "{{url_for('get_template_pack')}}" ;
gGetDefaultScenarioUrl = "{{url_for('get_default_scenario')}}" ;

@ -24,7 +24,7 @@ def test_help( webapp, webdriver ):
# show the help
select_menu_option( "show_help" )
webdriver.switch_to.frame( find_child( "#tabs-help iframe" ) )
assert "This is the help page." in webdriver.page_source
assert "everyone's favorite scenario" in webdriver.page_source
webdriver.switch_to.default_content()
# make sure that the HELP tab is now visible

Loading…
Cancel
Save