diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java index b981cf962c..e550781cf7 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java @@ -34,6 +34,7 @@ import org.openhab.ui.basic.render.RenderException; import org.openhab.ui.basic.render.WidgetRenderer; import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @@ -63,11 +64,13 @@ public class PageRenderer extends AbstractWidgetRenderer { private final Logger logger = LoggerFactory.getLogger(PageRenderer.class); private List widgetRenderers = new ArrayList<>(); + private final String bundleVersion; @Activate public PageRenderer(final BundleContext bundleContext, final @Reference TranslationProvider i18nProvider, final @Reference ItemUIRegistry itemUIRegistry, final @Reference LocaleProvider localeProvider) { super(bundleContext, i18nProvider, itemUIRegistry, localeProvider); + bundleVersion = FrameworkUtil.getBundle(PageRenderer.class).getVersion().toString(); } @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) @@ -93,11 +96,6 @@ public void removeWidgetRenderer(WidgetRenderer widgetRenderer) { */ public StringBuilder processPage(String id, String sitemap, String label, EList children, boolean async) throws RenderException { - String snippet = getSnippet(async ? "layer" : "main"); - snippet = snippet.replaceAll("%main.offline-msg%", localizeText("@text/main.offline-msg")); - snippet = snippet.replaceAll("%main.long-polling-mode-msg%", localizeText("@text/main.long-polling-mode-msg")); - snippet = snippet.replaceAll("%id%", id); - // if the label contains a value span, we remove this span as // the title of a page/layer cannot deal with this // Note: we can have a span here, if the parent widget had a label @@ -107,12 +105,17 @@ public StringBuilder processPage(String id, String sitemap, String label, EList< if (labelPlain.contains("[") && labelPlain.endsWith("]")) { labelPlain = labelPlain.replace("[", "").replace("]", ""); } - snippet = snippet.replace("%label%", escapeHtml(labelPlain)); - snippet = snippet.replace("%servletname%", WebAppServlet.SERVLET_PATH); - snippet = snippet.replace("%sitemap%", sitemap); - snippet = snippet.replace("%icon_type%", ICON_TYPE); - snippet = snippet.replace("%inline%", config.isInlineSvgEnabled() ? "true" : "false"); - snippet = snippet.replace("%sitemapquery%", String.format("?sitemap=%s", sitemap)); + String snippet = getSnippet(async ? "layer" : "main") // + .replaceAll("%main.offline-msg%", localizeText("@text/main.offline-msg")) // + .replaceAll("%main.long-polling-mode-msg%", localizeText("@text/main.long-polling-mode-msg")) // + .replaceAll("%id%", id) // + .replaceAll("%version%", bundleVersion) // + .replace("%label%", escapeHtml(labelPlain)) // + .replace("%servletname%", WebAppServlet.SERVLET_PATH) // + .replace("%sitemap%", sitemap) // + .replace("%icon_type%", ICON_TYPE) // + .replace("%inline%", config.isInlineSvgEnabled() ? "true" : "false") // + .replace("%sitemapquery%", String.format("?sitemap=%s", sitemap)); String[] parts = snippet.split("%children%"); @@ -268,6 +271,7 @@ public CharSequence renderSitemapList(Set sitemapProviders) thr listSnippet = listSnippet.replace("%items%", sb.toString()); return getSnippet("main_static") // + .replaceAll("%version%", bundleVersion) // .replace("%title%", "Basic UI") // .replace("%htmlclass%", "page-welcome-sitemaps") // .replace("%relpath%", "") // @@ -367,6 +371,7 @@ public CharSequence renderSettings() throws RenderException { "enabled", "", false, sb); return getSnippet("main_static") // + .replaceAll("%version%", bundleVersion) // .replace("%title%", localizeText("@text/preferences.title")) // .replace("%htmlclass%", "") // .replace("%relpath%", "../") // diff --git a/bundles/org.openhab.ui.basic/src/main/resources/snippets/main.html b/bundles/org.openhab.ui.basic/src/main/resources/snippets/main.html index 71edc748ea..5ebac4ec22 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/snippets/main.html +++ b/bundles/org.openhab.ui.basic/src/main/resources/snippets/main.html @@ -26,9 +26,9 @@ - + - + +