Modifying HTML template

Hi, I am currently modifying the src/main/resources/templates/app.html template to include two things:

  • a google analytics script
  • a link tag under the head tag with a path to recognize my app logo

I can easily add the google analytics script and it works, but my problem is to reference the path to the app logo.

I already tried the following:
<link rel="shortcut icon" th:href="${container}+'/www/logo.png'">
<link rel="shortcut icon" th:href="@{${container + '/www/logo.png'}}">
<link rel="shortcut icon" th:href="@{${'/app_direct/' + app.id + '/www/logo.png'}}">

but none of them worked… any ideas?

Solved this with the following:

<link rel="shortcut icon" th:href="${container}" id="fav_path">

And then I added this line:

$("#fav_path").attr("href", response.containerPath+'/www/logo.png');

at the already existing bottom script of app.html:

<script type="text/javascript" th:inline="javascript">
		function setShinyframeHeight() {
			$('#shinyframe').css('height', ($(window).height())+'px');
		}
		window.addEventListener("load", setShinyframeHeight);
		window.addEventListener("resize",  setShinyframeHeight);
		
		$(window).on('load', function() {
			var source = $("#shinyframe").attr("src");
			if (source == "") {
				$(".loading").show();
				$.post(window.location.pathname + window.location.search, function(response) {
					$("#shinyframe").attr("src", response.containerPath);
					$("#fav_path").attr("href", response.containerPath+'/www/logo.png');
					$(".loading").fadeOut("slow");
				}).fail(function(request) {
					var newDoc = document.open("text/html", "replace");
					newDoc.write(request.responseText);
					newDoc.close();
				});
			}
		});
	</script>
1 Like