Include the build git info in the SCENARIO template.

master
Pacman Ghost 2 years ago committed by Pacman Ghost
parent 4762a36eb6
commit a09286bc50
  1. 13
      vasl_templates/utils.py
  2. 2
      vasl_templates/webapp/data/default-template-pack/scenario.j2
  3. 11
      vasl_templates/webapp/main.py
  4. 26
      vasl_templates/webapp/static/main.js
  5. 1
      vasl_templates/webapp/static/snippets.js
  6. 1
      vasl_templates/webapp/templates/load-vo-notes-image-cache.html
  7. 1
      vasl_templates/webapp/templates/national-capabilities.html

@ -6,7 +6,8 @@ import logging
import traceback
import json
from vasl_templates.webapp.config.constants import BASE_DIR
from vasl_templates.webapp import app
from vasl_templates.webapp.config.constants import BASE_DIR, IS_FROZEN
# ---------------------------------------------------------------------
@ -32,6 +33,16 @@ def get_build_info():
return result
def get_build_git_info():
"""Get the git details for the current build."""
if IS_FROZEN:
build_info = get_build_info()
if build_info:
return build_info[ "git_info" ]
elif app.config.get( "IS_CONTAINER" ):
return os.environ.get( "BUILD_GIT_INFO" )
return None
# ---------------------------------------------------------------------
def catch_exceptions( caption="EXCEPTION", retval=None ):

@ -1,5 +1,5 @@
<html> <!-- vasl-templates:id {{SNIPPET_ID}} -->
{%if APP_NAME%}<!-- Generated by {{APP_NAME}} {{APP_VERSION}}:
{%if APP_NAME%}<!-- Generated by {{APP_NAME}} {{APP_VERSION}}{%if BUILD_GIT_INFO%} ({{BUILD_GIT_INFO}}){%endif%}:
Time: {{TIMESTAMP}}
VASSAL:{%if VASSAL_VERSION %} {{VASSAL_VERSION}} {%else%} - {%endif%}
VASL: {%if VASL_VERSION%} {{VASL_VERSION}} {%else%} - {%endif%}

@ -19,7 +19,7 @@ import vasl_templates.webapp.config.constants
from vasl_templates.webapp.config.constants import BASE_DIR, DATA_DIR, IS_FROZEN
from vasl_templates.webapp import globvars
from vasl_templates.webapp.lfa import DEFAULT_LFA_DICE_HOTNESS_WEIGHTS, DEFAULT_LFA_DICE_HOTNESS_THRESHOLDS
from vasl_templates.utils import get_build_info
from vasl_templates.utils import get_build_info, get_build_git_info
# NOTE: This is used to stop multiple instances of the program from running (see main.py in the desktop app).
INSTANCE_ID = uuid.uuid4().hex
@ -232,6 +232,9 @@ def get_program_info():
"APP_VERSION": vasl_templates.webapp.config.constants.APP_VERSION,
"VASSAL_VERSION": VassalShim.get_version()
}
build_git_info = get_build_git_info()
if build_git_info:
params[ "BUILD_GIT_INFO" ] = build_git_info
if globvars.vasl_mod:
params[ "VASL_VERSION" ] = globvars.vasl_mod.vasl_version
params[ "VASL_REAL_VERSION" ] = globvars.vasl_mod.vasl_real_version
@ -266,12 +269,10 @@ def get_program_info():
to_localtime( datetime.utcfromtimestamp( build_info["timestamp"] ) ),
"%H:%M (%d %b %Y)"
)
params[ "BUILD_GIT_INFO" ] = build_info[ "git_info" ]
# check if we are running inside a Docker container
if app.config.get( "IS_CONTAINER" ):
# yup - return related information
params[ "BUILD_GIT_INFO" ] = os.environ.get( "BUILD_GIT_INFO" )
params[ "DOCKER_IMAGE_NAME" ] = os.environ.get( "DOCKER_IMAGE_NAME" )
params[ "DOCKER_IMAGE_TIMESTAMP" ] = datetime.strftime(
parse_timestamp( os.environ.get( "DOCKER_IMAGE_TIMESTAMP" ) ),
@ -307,7 +308,9 @@ def get_program_info():
check_df( _asa_scenarios )
check_df( _roar_scenarios )
return render_template( "program-info-content.html", **params )
if request.args.get( "f" ) == "html":
return render_template( "program-info-content.html", **params )
return jsonify( params )
# ---------------------------------------------------------------------

@ -1,4 +1,5 @@
gAppConfig = {} ;
gProgramInfo = {} ;
gDefaultTemplatePack = null ;
gTemplatePack = {} ;
gHasPlayerFlag = {} ;
@ -794,6 +795,12 @@ function update_page_load_status( id )
} ).fail( function( xhr, status, errorMsg ) {
showErrorMsg( "Can't get the startup messages:<div class='pre'>" + escapeHTML(errorMsg) + "</div>" ) ;
} ) ;
// get the program info (nb: we need this, but it's not required during startup)
getProgramInfo( function( resp ) {
gProgramInfo = resp ;
}, function( errorMsg ) {
showErrorMsg( "Can't get the program info:<div class='pre'>" + escapeHTML(errorMsg) + "</div>" ) ;
} ) ;
}
}
@ -1211,14 +1218,13 @@ function show_program_info()
var $dlg = $(this) ;
$dlg.find( ".content" ).hide() ;
$dlg.find( ".loader" ).show() ;
var url = gGetProgramInfoUrl + "?tz_offset=" + -new Date().getTimezoneOffset() ;
$.get( url, function( resp ) {
getProgramInfo( function( resp ) {
$dlg.find( ".loader" ).hide() ;
$dlg.find( ".content" ).html( resp ).fadeIn( 250 ) ;
} ).fail( function( xhr, status, errorMsg ) {
}, function( errorMsg ) {
showErrorMsg( "Can't get the program info:<div class='pre'>" + escapeHTML(errorMsg) + "</div>" ) ;
$dlg.dialog( "close" ) ;
} ) ;
}, "html" ) ;
},
beforeClose: function() {
gProgramInfoDlgState = getDialogState( $(this) ) ;
@ -1231,6 +1237,18 @@ function show_program_info()
} ) ;
}
function getProgramInfo( onSuccess, onError, format )
{
// get the program info
var url = gGetProgramInfoUrl + "?tz_offset=" + -new Date().getTimezoneOffset() ;
if ( format )
url += "&f=" + format ;
$.get( url, function( resp ) {
onSuccess( resp ) ;
} ).fail( function( xhr, status, errorMsg ) {
onError( errorMsg ) ;
} ) ;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function show_help()

@ -125,6 +125,7 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
}
// add simple parameters
params.BUILD_GIT_INFO = gProgramInfo.BUILD_GIT_INFO ;
params.TIMESTAMP = (new Date()).toISOString() ;
params.IMAGES_BASE_URL = gUserSettings["scenario-images-source"] == SCENARIO_IMAGES_SOURCE_INTERNET ?
gAppConfig.ONLINE_IMAGES_URL_BASE :

@ -34,6 +34,7 @@ img#vo-note { max-width: 95% ; border: 1px dotted #666 ; border-radius: 5px ; pa
<script>
gAppConfig = {} ;
gProgramInfo = {} ;
gTemplatePack = {} ;
gVehicleOrdnanceNotes = {} ;
gTotalEntries = 0 ;

@ -29,6 +29,7 @@
<script>
gAppConfig = {} ;
gProgramInfo = {} ;
gUserSettings = {} ;
gTemplatePack = null ;
gGetTemplatePackUrl = "{{url_for('get_template_pack')}}" ;

Loading…
Cancel
Save