From 0aa39fa6ba60c5109cf98f96263e6a4c5d8dcb7d Mon Sep 17 00:00:00 2001 From: Florian Gnaegi - frentix GmbH <gnaegi@frentix.com> Date: Mon, 22 Apr 2013 16:58:47 +0200 Subject: [PATCH] OO-531 fix broken url for theme.js --- .../fullWebApp/BaseFullWebappController.java | 6 +++--- .../java/org/olat/core/gui/themes/Theme.java | 17 +++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/olat/core/commons/fullWebApp/BaseFullWebappController.java b/src/main/java/org/olat/core/commons/fullWebApp/BaseFullWebappController.java index 96155d9bab6..3cb18880784 100644 --- a/src/main/java/org/olat/core/commons/fullWebApp/BaseFullWebappController.java +++ b/src/main/java/org/olat/core/commons/fullWebApp/BaseFullWebappController.java @@ -445,10 +445,10 @@ public class BaseFullWebappController extends BasicController implements Generic private void addCustomThemeJS() { Theme currentTheme = getWindowControl().getWindowBackOffice().getWindow().getGuiTheme(); if (currentTheme.hasCustomJS()) { - String fullPath = currentTheme.getFullPathToCustomJS(); - CustomJSComponent customJS = new CustomJSComponent("customThemejs", new String[] { fullPath }); + String relPath = currentTheme.getRelPathToCustomJS(); + CustomJSComponent customJS = new CustomJSComponent("customThemejs", new String[] { relPath }); if (isLogDebugEnabled()) - logDebug("injecting custom javascript from current OLAT-Theme", fullPath); + logDebug("injecting custom javascript from current OLAT-Theme", relPath); mainVc.put(customJS.getComponentName(), customJS); } } diff --git a/src/main/java/org/olat/core/gui/themes/Theme.java b/src/main/java/org/olat/core/gui/themes/Theme.java index 41fe2b275cf..8b4decc77c4 100644 --- a/src/main/java/org/olat/core/gui/themes/Theme.java +++ b/src/main/java/org/olat/core/gui/themes/Theme.java @@ -36,6 +36,8 @@ import org.olat.core.util.WebappHelper; public class Theme { private String identifyer; private String baseURI; + private String relPathToThemesDir; + private boolean hasCustomJSFile = false; private static String CUSTOMFILENAME = "theme.js"; @@ -61,7 +63,7 @@ public class Theme { * @return returns if the OLAT-Theme-Folder contains a file "theme.js" */ public boolean hasCustomJS() { - return (getCustomJSFile().exists()); + return hasCustomJSFile; } /** @@ -85,7 +87,7 @@ public class Theme { } /** - * returns the path to the custom js <br /> + * returns the relative path to the custom js <br /> * ( check first with <code>hasCustomJS()</code> )<br /> * <p> * Example usage:<br /> @@ -96,10 +98,10 @@ public class Theme { * </p> * * @return the path to the custom layout js :: - * /olat/raw/fx-olat7/themes/frentix/theme.js + * themes/frentix/theme.js */ - public String getFullPathToCustomJS() { - return baseURI + CUSTOMFILENAME; + public String getRelPathToCustomJS() { + return relPathToThemesDir + CUSTOMFILENAME; } /** @@ -110,9 +112,12 @@ public class Theme { public void init(String themeIdentifyer) { this.identifyer = themeIdentifyer; // Themes are deliverd as static resources by StaticMediaDispatcher + this.relPathToThemesDir = "themes/" + themeIdentifyer + "/"; StringOutput themePath = new StringOutput(); - StaticMediaDispatcher.renderStaticURI(themePath, "themes/" + themeIdentifyer + "/"); + StaticMediaDispatcher.renderStaticURI(themePath, relPathToThemesDir); this.baseURI = themePath.toString(); + // Check if theme has a custom JS file to tweak UI on JS level + hasCustomJSFile = getCustomJSFile().exists(); } } -- GitLab