diff --git a/vasl_templates/webapp/data/default-template-pack/scenario.j2 b/vasl_templates/webapp/data/default-template-pack/scenario.j2 index 2f2ce87..fdb7069 100644 --- a/vasl_templates/webapp/data/default-template-pack/scenario.j2 +++ b/vasl_templates/webapp/data/default-template-pack/scenario.j2 @@ -1,4 +1,9 @@ +{%if APP_NAME%} {%endif%} diff --git a/vasl_templates/webapp/main.py b/vasl_templates/webapp/main.py index 851bd30..0f7fd5b 100644 --- a/vasl_templates/webapp/main.py +++ b/vasl_templates/webapp/main.py @@ -8,7 +8,9 @@ from flask import request, render_template, jsonify, send_file, redirect, url_fo from vasl_templates.webapp import app from vasl_templates.webapp.utils import MsgStore +import vasl_templates.webapp.config.constants from vasl_templates.webapp.config.constants import BASE_DIR, DATA_DIR +from vasl_templates.webapp import globvars startup_msg_store = MsgStore() # store messages generated during startup _check_versions = True @@ -65,10 +67,20 @@ _APP_CONFIG_DEFAULTS = { # Bodhgaya, India (APR/19) @app.route( "/app-config" ) def get_app_config(): """Get the application config.""" - return jsonify( { + vals = { key: app.config.get( key, default ) for key,default in _APP_CONFIG_DEFAULTS.items() - } ) + } + for key in ["APP_NAME","APP_VERSION","APP_DESCRIPTION","APP_HOME_URL"]: + vals[ key ] = getattr( vasl_templates.webapp.config.constants, key ) + try: + from vasl_templates.webapp.vassal import VassalShim + vals[ "VASSAL_VERSION" ] = VassalShim().get_version() + except: #pylint: disable=bare-except + pass + if globvars.vasl_mod: + vals["VASL_VERSION"] = globvars.vasl_mod.vasl_version + return jsonify( vals ) # --------------------------------------------------------------------- diff --git a/vasl_templates/webapp/static/main.js b/vasl_templates/webapp/static/main.js index f3a3ea2..c95942f 100644 --- a/vasl_templates/webapp/static/main.js +++ b/vasl_templates/webapp/static/main.js @@ -492,7 +492,7 @@ function update_page_load_status( id ) function show_startup_msgs( msgs, msg_type ) { if ( msg_type in msgs ) { for ( var i=0 ; i < msgs[msg_type].length ; ++i ) - doShowNotificationMsg( msg_type, msgs[msg_type][i] ) ; + doShowNotificationMsg( msg_type, msgs[msg_type][i] ) ; } } diff --git a/vasl_templates/webapp/static/snippets.js b/vasl_templates/webapp/static/snippets.js index 0516abd..ee80060 100644 --- a/vasl_templates/webapp/static/snippets.js +++ b/vasl_templates/webapp/static/snippets.js @@ -124,7 +124,16 @@ function make_snippet( $btn, params, extra_params, show_date_warnings ) var template_id = $btn.data( "id" ) ; var snippet_save_name = null ; + // add server constants + if ( ! getUrlParam( "no_app_config_snippet_params" ) ) { + params.APP_NAME = gAppConfig.APP_NAME ; + params.APP_VERSION = gAppConfig.APP_VERSION ; + params.VASSAL_VERSION = gAppConfig.VASSAL_VERSION ; + params.VASL_VERSION = gAppConfig.VASL_VERSION ; + } + // add simple parameters + params.TIMESTAMP = (new Date()).toISOString() ; params.IMAGES_BASE_URL = gUserSettings["scenario-images-source"] == SCENARIO_IMAGES_SOURCE_INTERNET ? gAppConfig.ONLINE_IMAGES_URL_BASE : APP_URL_BASE + gImagesBaseUrl ; diff --git a/vasl_templates/webapp/tests/test_vassal.py b/vasl_templates/webapp/tests/test_vassal.py index 402fb16..fb010fb 100644 --- a/vasl_templates/webapp/tests/test_vassal.py +++ b/vasl_templates/webapp/tests/test_vassal.py @@ -35,7 +35,7 @@ def test_full_update( webapp, webdriver ): """Test updating a scenario that contains the full set of snippets.""" # initialize - control_tests = init_webapp( webapp, webdriver, vsav_persistence=1, + control_tests = init_webapp( webapp, webdriver, vsav_persistence=1, no_app_config_snippet_params=1, reset = lambda ct: ct.set_data_dir( dtype="real" ) )