You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2020/07/08 18:51:20 UTC
[myfaces-tobago] branch master updated: TOBAGO-2048:
Theme.getVersion() returns null
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new be4ac82 TOBAGO-2048: Theme.getVersion() returns null
be4ac82 is described below
commit be4ac82cc28c9dc72ea0ab3705464fbb41f02ca1
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Wed Jul 8 20:50:59 2020 +0200
TOBAGO-2048: Theme.getVersion() returns null
---
.../main/java/org/apache/myfaces/tobago/context/ThemeImpl.java | 4 +++-
.../myfaces/tobago/internal/config/TobagoConfigParser.java | 5 +++++
.../org/apache/myfaces/tobago/config/tobago-config-5.0.xsd | 9 +++++++++
.../tobago/internal/config/TobagoConfigMergingUnitTest.java | 6 +++++-
tobago-core/src/test/resources/tobago-config-5.0-replace.xml | 1 +
tobago-core/src/test/resources/tobago-config-5.0.xml | 2 ++
tobago-example/tobago-example-demo/src/main/webapp/main.xhtml | 2 +-
.../src/main/resources/META-INF/tobago-config.xml | 1 +
.../src/main/resources/META-INF/tobago-config.xml | 1 +
.../src/main/resources/META-INF/tobago-config.xml | 1 +
.../src/main/resources/META-INF/tobago-config.xml | 1 +
.../src/main/resources/META-INF/tobago-config.xml | 1 +
12 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java
index fd6eb0c..92aa282 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java
@@ -218,7 +218,9 @@ public class ThemeImpl implements Theme, Serializable {
} else {
builder.append("null");
}
- builder.append(", \nproductionScripts=[");
+ builder.append(" version='");
+ builder.append(version);
+ builder.append("', \nproductionScripts=[");
for (final ThemeScript s : productionScripts) {
builder.append("\n");
builder.append(s);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java
index d1e0df2..4a4fe5a 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java
@@ -94,6 +94,7 @@ public class TobagoConfigParser extends TobagoConfigEntityResolver {
*/
@Deprecated
private static final int VERSIONED = -1407102089;
+ private static final int VERSION = 351608024;
private static final int RESOURCES = -1983070683;
private static final int INCLUDES = 90259659;
private static final int EXCLUDES = 1994055129;
@@ -380,6 +381,10 @@ public class TobagoConfigParser extends TobagoConfigEntityResolver {
currentTheme = null;
break;
+ case VERSION:
+ currentTheme.setVersion(text);
+ break;
+
case RESOURCES:
production = null;
break;
diff --git a/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-5.0.xsd b/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-5.0.xsd
index 3e7410d..4858b04 100644
--- a/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-5.0.xsd
+++ b/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-5.0.xsd
@@ -319,6 +319,15 @@
</xs:documentation>
</xs:annotation>
</xs:element>
+ <xs:element name="version" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ The version of the theme. The version string will be encoded into the
+ resource path, to avoid caching problems. The version can be accessed by
+ #{tobagoContext.theme.version}.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element name="resources" type="tobago:resources-type" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigMergingUnitTest.java b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigMergingUnitTest.java
index c051e34..85959f7 100644
--- a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigMergingUnitTest.java
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigMergingUnitTest.java
@@ -19,6 +19,7 @@
package org.apache.myfaces.tobago.internal.config;
+import org.apache.myfaces.tobago.context.Theme;
import org.apache.myfaces.tobago.context.ThemeScript;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -161,9 +162,12 @@ public class TobagoConfigMergingUnitTest {
}
config.resolveThemes();
- final ThemeScript[] scripts = config.getDefaultTheme().getScriptResources(true);
+ final Theme defaultTheme = config.getDefaultTheme();
+ final ThemeScript[] scripts = defaultTheme.getScriptResources(true);
Assertions.assertArrayEquals(ex, scripts);
+
+ Assertions.assertEquals("some-version-2", defaultTheme.getVersion());
}
public static TobagoConfigImpl loadAndMerge(final String... names)
diff --git a/tobago-core/src/test/resources/tobago-config-5.0-replace.xml b/tobago-core/src/test/resources/tobago-config-5.0-replace.xml
index c059526..6a1f15a 100644
--- a/tobago-core/src/test/resources/tobago-config-5.0-replace.xml
+++ b/tobago-core/src/test/resources/tobago-config-5.0-replace.xml
@@ -39,6 +39,7 @@
<theme-definition>
<name>my-theme-3</name>
<fallback>my-theme-1</fallback>
+ <version>some-version-2</version>
<resources production="true">
<includes>
<script name="script-3-replacement.js" priority="3"/>
diff --git a/tobago-core/src/test/resources/tobago-config-5.0.xml b/tobago-core/src/test/resources/tobago-config-5.0.xml
index 240ffa9..3ad1320 100644
--- a/tobago-core/src/test/resources/tobago-config-5.0.xml
+++ b/tobago-core/src/test/resources/tobago-config-5.0.xml
@@ -56,6 +56,7 @@
<theme-definition>
<name>my-theme-1</name>
<display-name>My Theme 1</display-name>
+ <version>some-version-1</version>
<resources production="true">
<includes>
<script name="script-1.js" priority="1"/>
@@ -78,6 +79,7 @@
<theme-definition>
<name>my-theme-2</name>
<fallback>my-theme-1</fallback>
+ <version>some-version-1</version>
<resources production="false"/>
</theme-definition>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml
index 548ab30..e83bfbc 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml
@@ -84,7 +84,7 @@
<tc:operation name="hide" for="info"/>
</tc:button>
</f:facet>
- <tc:out label="Theme:" value="#{themeController.localizedTheme}"/>
+ <tc:out label="Theme:" value="#{themeController.localizedTheme} (#{themeController.theme.version})"/>
<tc:out label="Locale:" value="#{localeController.localizedLocale}"/>
<tc:out label="Project Stage:" value="#{facesContext.application.projectStage}"/>
<tc:out label="CSP mode:" value="#{tobagoConfig.contentSecurityPolicy.mode}"/>
diff --git a/tobago-theme/tobago-theme-charlotteville/src/main/resources/META-INF/tobago-config.xml b/tobago-theme/tobago-theme-charlotteville/src/main/resources/META-INF/tobago-config.xml
index e61b48f..c71faca 100644
--- a/tobago-theme/tobago-theme-charlotteville/src/main/resources/META-INF/tobago-config.xml
+++ b/tobago-theme/tobago-theme-charlotteville/src/main/resources/META-INF/tobago-config.xml
@@ -33,6 +33,7 @@
<name>charlotteville</name>
<display-name>Charlotteville</display-name>
<fallback>standard</fallback>
+ <version>${project.version}</version>
<resources production="true">
<includes>
<style name="/tobago/charlotteville/${project.version}/css/tobago.min.css"/>
diff --git a/tobago-theme/tobago-theme-roxborough/src/main/resources/META-INF/tobago-config.xml b/tobago-theme/tobago-theme-roxborough/src/main/resources/META-INF/tobago-config.xml
index 74ca743..09200da 100644
--- a/tobago-theme/tobago-theme-roxborough/src/main/resources/META-INF/tobago-config.xml
+++ b/tobago-theme/tobago-theme-roxborough/src/main/resources/META-INF/tobago-config.xml
@@ -33,6 +33,7 @@
<name>roxborough</name>
<display-name>Roxborough</display-name>
<fallback>standard</fallback>
+ <version>${project.version}</version>
<resources production="true">
<includes>
<style name="/tobago/roxborough/${project.version}/css/tobago.min.css"/>
diff --git a/tobago-theme/tobago-theme-scarborough/src/main/resources/META-INF/tobago-config.xml b/tobago-theme/tobago-theme-scarborough/src/main/resources/META-INF/tobago-config.xml
index 0857c2f..7982e2b 100644
--- a/tobago-theme/tobago-theme-scarborough/src/main/resources/META-INF/tobago-config.xml
+++ b/tobago-theme/tobago-theme-scarborough/src/main/resources/META-INF/tobago-config.xml
@@ -33,6 +33,7 @@
<name>scarborough</name>
<display-name>Scarborough</display-name>
<fallback>standard</fallback>
+ <version>${project.version}</version>
<resources production="true">
<includes>
<style name="/tobago/scarborough/${project.version}/css/tobago.min.css"/>
diff --git a/tobago-theme/tobago-theme-speyside/src/main/resources/META-INF/tobago-config.xml b/tobago-theme/tobago-theme-speyside/src/main/resources/META-INF/tobago-config.xml
index d7c5d9d..0de2481 100644
--- a/tobago-theme/tobago-theme-speyside/src/main/resources/META-INF/tobago-config.xml
+++ b/tobago-theme/tobago-theme-speyside/src/main/resources/META-INF/tobago-config.xml
@@ -33,6 +33,7 @@
<name>speyside</name>
<display-name>Speyside</display-name>
<fallback>standard</fallback>
+ <version>${project.version}</version>
<resources production="true">
<includes>
<style name="/tobago/speyside/${project.version}/css/tobago.min.css"/>
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
index 9ab01ee..babb8cc 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
@@ -35,6 +35,7 @@
<theme-definition>
<name>standard</name>
<display-name>Standard Theme</display-name>
+ <version>${project.version}</version>
<resources production="true">
<includes>
<script name="/webjars/webcomponents__custom-elements/1.2.1/custom-elements.min.js"/>