You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by th...@apache.org on 2013/10/29 21:40:31 UTC
[3/4] git commit: TAP-2197: @Import without stack puts imported
stylesheet before the core stack ones. Also adds a symbol for disabling
TAP5-2169: Core stack is not included by default
TAP-2197: @Import without stack puts imported stylesheet before the core
stack ones. Also adds a symbol for disabling TAP5-2169: Core stack is
not included by default
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/26d62122
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/26d62122
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/26d62122
Branch: refs/heads/master
Commit: 26d62122995348bcde8ceffe6b0dd046d220116f
Parents: 534d67c
Author: Thiago H. de Paula Figueiredo <th...@apache.org>
Authored: Tue Oct 29 18:26:50 2013 -0200
Committer: Thiago H. de Paula Figueiredo <th...@apache.org>
Committed: Tue Oct 29 18:26:50 2013 -0200
----------------------------------------------------------------------
.../org/apache/tapestry5/SymbolConstants.java | 9 ++++++
.../services/ajax/JavaScriptSupportImpl.java | 14 +++++++--
.../tapestry5/modules/JavaScriptModule.java | 2 +-
.../tapestry5/modules/TapestryModule.java | 11 ++++++-
.../AtImportWithoutStackButWithStylesheet.tml | 5 ++++
.../integration/app1/AtImportTests.groovy | 30 ++++++++++++++++++++
.../integration/app1/App1TestCase.java | 2 +-
.../AtImportWithoutStackButWithStylesheet.java | 25 ++++++++++++++++
8 files changed, 93 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/26d62122/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java b/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
index ccea4a0..0299ee9 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
@@ -412,5 +412,14 @@ public class SymbolConstants
* @since 5.4
*/
public static final String SESSION_LOCKING_ENABLED = "tapestry.session-locking-enabled";
+
+ /**
+ * If true (the default), then Tapestry will automatically include the "core" stack in all
+ * pages.
+ *
+ * @since 5.4
+ * @see https://issues.apache.org/jira/browse/TAP5-2169
+ */
+ public static final String INCLUDE_CORE_STACK = "tapestry.include-core-stack";
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/26d62122/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
index d53ea91..2d207b8 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
@@ -29,6 +29,8 @@ import org.apache.tapestry5.json.JSONArray;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.javascript.*;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@@ -309,7 +311,13 @@ public class JavaScriptSupportImpl implements JavaScriptSupport
JavaScriptStack stack = javascriptStackSource.getStack(stackName);
- for (String dependentStackname : stack.getStacks())
+ // TAP5-2197: the stacks are added in reverse order because now this method
+ // adds a stack's stylesheets in the head of the stylesheets array, not in the
+ // end, avoiding the TAP5-2197 bug.
+ final List<String> reversedStacks = new ArrayList<String>(stack.getStacks());
+ Collections.reverse(reversedStacks);
+
+ for (String dependentStackname : reversedStacks)
{
addAssetsFromStack(dependentStackname);
}
@@ -321,7 +329,9 @@ public class JavaScriptSupportImpl implements JavaScriptSupport
linker.addLibrary(libraryURL);
}
- stylesheetLinks.addAll(stack.getStylesheets());
+ // TAP5-2197: to avoid @Import'ed stylesheets to appear after the core ones,
+ // the latter ones are now always added in the head of stylesheetLinks, not the tail.
+ stylesheetLinks.addAll(0, stack.getStylesheets());
for (String moduleName : stack.getModules())
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/26d62122/tapestry-core/src/main/java/org/apache/tapestry5/modules/JavaScriptModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/JavaScriptModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/JavaScriptModule.java
index bd09290..5bf0782 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/JavaScriptModule.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/modules/JavaScriptModule.java
@@ -221,7 +221,7 @@ public class JavaScriptModule
@Contribute(ModuleManager.class)
public static void setupBaseModules(MappedConfiguration<String, Object> configuration,
- @Path("${tapestry.asset.root}/underscore-1.5.1.js")
+ @Path("${tapestry.asset.root}/underscore-1.5.2.js")
Resource underscore,
@Path("${tapestry.asset.root}/jquery-shim.js")
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/26d62122/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
index da8043c..6848cb2 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
@@ -1729,6 +1729,9 @@ public final class TapestryModule
@Symbol(SymbolConstants.PRODUCTION_MODE)
boolean productionMode,
+
+ @Symbol(SymbolConstants.INCLUDE_CORE_STACK)
+ final boolean includeCoreStack,
final ValidationDecoratorFactory validationDecoratorFactory)
{
@@ -1809,7 +1812,10 @@ public final class TapestryModule
configuration.add("ClientBehaviorSupport", clientBehaviorSupport, "after:JavaScriptSupport");
configuration.add("Heartbeat", heartbeat);
configuration.add("ValidationDecorator", defaultValidationDecorator);
- configuration.add("ImportCoreStack", importCoreStack);
+
+ if (includeCoreStack) {
+ configuration.add("ImportCoreStack", importCoreStack);
+ }
if (productionMode)
{
@@ -2112,6 +2118,9 @@ public final class TapestryModule
// TAP5-2070 keep the old behavior, defaults to false
configuration.add(MetaDataConstants.UNKNOWN_ACTIVATION_CONTEXT_CHECK, false);
+
+ // TAP5-2197
+ configuration.add(SymbolConstants.INCLUDE_CORE_STACK, true);
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/26d62122/tapestry-core/src/test/app1/AtImportWithoutStackButWithStylesheet.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/AtImportWithoutStackButWithStylesheet.tml b/tapestry-core/src/test/app1/AtImportWithoutStackButWithStylesheet.tml
new file mode 100644
index 0000000..3095770
--- /dev/null
+++ b/tapestry-core/src/test/app1/AtImportWithoutStackButWithStylesheet.tml
@@ -0,0 +1,5 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+ <p>
+ Testing <a href="https://issues.apache.org/jira/browse/TAP5-2197">TAP5-2197</a>
+ </p>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/26d62122/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AtImportTests.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AtImportTests.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AtImportTests.groovy
new file mode 100644
index 0000000..b2d9184
--- /dev/null
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AtImportTests.groovy
@@ -0,0 +1,30 @@
+package org.apache.tapestry5.integration.app1
+
+import org.apache.tapestry5.integration.GroovyTapestryCoreTestCase
+import org.apache.tapestry5.test.TapestryTestConfiguration
+import org.testng.annotations.Test
+
+@TapestryTestConfiguration(webAppFolder = "src/test/app1", browserStartCommand = "*googlechrome")
+class AtImportTests extends GroovyTapestryCoreTestCase
+{
+
+ /**
+ * Test for https://issues.apache.org/jira/browse/TAP5-2197.
+ */
+ @Test
+ void at_import_without_stack_but_with_stylesheet_gets_core_stack_after_included_stylesheet()
+ {
+
+ final String locatorTemplate = "//link[contains(@href, 'via-import.css')]/preceding-sibling::link[contains(@href, '%s.css')]"
+
+ open("/AtImportWithoutStackButWithStylesheet")
+
+ assert isElementPresent(String.format(locatorTemplate, "bootstrap"))
+ assert isElementPresent(String.format(locatorTemplate, "tapestry"))
+ assert isElementPresent(String.format(locatorTemplate, "exception-frame"))
+ assert isElementPresent(String.format(locatorTemplate, "tapestry-console"))
+ assert isElementPresent(String.format(locatorTemplate, "tree"))
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/26d62122/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/App1TestCase.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/App1TestCase.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/App1TestCase.java
index 6ca5457..633b657 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/App1TestCase.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/App1TestCase.java
@@ -7,7 +7,7 @@ import org.apache.tapestry5.test.TapestryTestConfiguration;
* Base class for tests that use the src/test/app1 application; this makes it possible
* to run the test class directly, as it will have the correct configuration.
*/
-@TapestryTestConfiguration(webAppFolder = "src/test/app1")
+@TapestryTestConfiguration(webAppFolder = "src/test/app1", browserStartCommand = "*googlechrome")
public abstract class App1TestCase extends TapestryCoreTestCase
{
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/26d62122/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/AtImportWithoutStackButWithStylesheet.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/AtImportWithoutStackButWithStylesheet.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/AtImportWithoutStackButWithStylesheet.java
new file mode 100644
index 0000000..7147314
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/AtImportWithoutStackButWithStylesheet.java
@@ -0,0 +1,25 @@
+// Copyright The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.annotations.Import;
+
+/**
+ * Page class to test <a href="https://issues.apache.org/jira/browse/TAP5-2197">TAP5-2197</a>.
+ */
+@Import(stylesheet = "context:css/via-import.css")
+public class AtImportWithoutStackButWithStylesheet
+{
+
+}