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 2016/11/30 12:24:42 UTC

svn commit: r1772020 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ tobago-example/tobago-example-demo/src/main/webapp/ tobago-theme/tobago-theme-charlotteville/src/main/resources/META-INF/ ...

Author: lofwyr
Date: Wed Nov 30 12:24:42 2016
New Revision: 1772020

URL: http://svn.apache.org/viewvc?rev=1772020&view=rev
Log:
TOBAGO-1601: Building the different themes (scarborough, speyside, ...) like bootstrap builds
TOBAGO-1636: End of theme-dependent resource selection (ResourceManager)
* "min" it no longer evaluated automatically, but must be set explitictly (*.min.js etc.)
* add contextPath for theme resources

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-charlotteville/src/main/resources/META-INF/tobago-config.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-richmond/src/main/resources/META-INF/tobago-config.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/META-INF/tobago-config.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/META-INF/tobago-config.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java?rev=1772020&r1=1772019&r2=1772020&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/PageRenderer.java Wed Nov 30 12:24:42 2016
@@ -19,23 +19,6 @@
 
 package org.apache.myfaces.tobago.internal.renderkit.renderer;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import javax.faces.application.Application;
-import javax.faces.application.ViewHandler;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.portlet.MimeResponse;
-import javax.portlet.ResourceURL;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import org.apache.myfaces.tobago.application.ProjectStage;
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.UIPage;
@@ -68,6 +51,22 @@ import org.apache.myfaces.tobago.webapp.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.faces.application.Application;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.portlet.MimeResponse;
+import javax.portlet.ResourceURL;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
 // currently using tobago-jsf.js instead
 //@ResourceDependency(name="jsf.js", library="javax.faces", target="head")
 public class PageRenderer extends RendererBase {
@@ -150,6 +149,7 @@ public class PageRenderer extends Render
     }
 
     final ExternalContext externalContext = facesContext.getExternalContext();
+    final String contextPath = externalContext.getRequestContextPath();
     final Object response = externalContext.getResponse();
     final Application application = facesContext.getApplication();
     final ViewHandler viewHandler = application.getViewHandler();
@@ -216,7 +216,7 @@ public class PageRenderer extends Render
 
       // style files
       for (final String styleFile : theme.getStyleResources(productionMode)) {
-        writeStyle(writer, styleFile);
+        writeStyle(writer, contextPath + styleFile);
       }
 
       for (final String styleFile : FacesContextUtils.getStyleFiles(facesContext)) {
@@ -258,11 +258,11 @@ public class PageRenderer extends Render
 
       // render remaining script tags
       for (final String scriptFile : theme.getScriptResources(productionMode)) {
-        encodeScript(facesContext, writer, scriptFile);
+        encodeScript(writer, contextPath + scriptFile);
       }
 
       for (final String scriptFile : FacesContextUtils.getScriptFiles(facesContext)) {
-        encodeScript(facesContext, writer, scriptFile);
+        encodeScript(writer, scriptFile);
       }
 
       if (!productionMode) {
@@ -279,7 +279,7 @@ public class PageRenderer extends Render
         page.getCustomClass());
     writer.writeIdAttribute(clientId);
     HtmlRendererUtils.writeDataAttributes(facesContext, writer, page);
-
+//    writer.writeStyleAttribute(page.getStyle());
 
     writer.writeCommandMapAttribute(JsonUtils.encode(RenderUtils.getBehaviorCommands(facesContext, page)));
 
@@ -304,7 +304,7 @@ public class PageRenderer extends Render
     writer.writeAttribute(HtmlAttributes.ACCEPT_CHARSET, AbstractUIPage.FORM_ACCEPT_CHARSET, false);
     // TODO evaluate 'accept' attribute usage
     //writer.writeAttribute(HtmlAttributes.ACCEPT, );
-    writer.writeAttribute(DataAttributes.CONTEXT_PATH, externalContext.getRequestContextPath(), true);
+    writer.writeAttribute(DataAttributes.CONTEXT_PATH, contextPath, true);
 
     writer.startElement(HtmlElements.INPUT);
     writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN);
@@ -357,27 +357,15 @@ public class PageRenderer extends Render
     }
   }
 
-  private void writeStyle(final TobagoResponseWriter writer, final String styleFile)
-      throws IOException {
-    final List<String> styles = Collections.singletonList(styleFile);
-    for (final String styleString : styles) {
-      if (styleString.length() > 0) {
-        writer.startElement(HtmlElements.LINK);
-        writer.writeAttribute(HtmlAttributes.REL, "stylesheet", false);
-        writer.writeAttribute(HtmlAttributes.HREF, styleString, true);
-//          writer.writeAttribute(HtmlAttributes.MEDIA, "screen", false);
-        writer.writeAttribute(HtmlAttributes.TYPE, "text/css", false);
-        writer.endElement(HtmlElements.LINK);
-      }
-    }
+  private void writeStyle(final TobagoResponseWriter writer, final String style) throws IOException {
+    writer.startElement(HtmlElements.LINK);
+    writer.writeAttribute(HtmlAttributes.REL, "stylesheet", false);
+    writer.writeAttribute(HtmlAttributes.HREF, style, true);
+//    writer.writeAttribute(HtmlAttributes.MEDIA, "screen", false);
+    writer.writeAttribute(HtmlAttributes.TYPE, "text/css", false);
+    writer.endElement(HtmlElements.LINK);
   }
 
-//  @Override
-//  public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
-//    UIPage page = (UIPage) component;
-//    page.encodeLayoutChildren(facesContext);
-//  }
-
   @Override
   public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {
 
@@ -457,21 +445,13 @@ public class PageRenderer extends Render
     }
   }
 
-  private void encodeScript(final FacesContext facesContext, final TobagoResponseWriter writer, final String script)
-      throws IOException {
-    final List<String> list;
-    list = new ArrayList<String>();
-    list.add(script);
-    for (final String src : list) {
-      if (StringUtils.isNotBlank(src)) {
-        writer.startElement(HtmlElements.SCRIPT);
-        writer.writeAttribute(HtmlAttributes.SRC, src, true);
+  private void encodeScript(final TobagoResponseWriter writer, final String script) throws IOException {
+    writer.startElement(HtmlElements.SCRIPT);
+    writer.writeAttribute(HtmlAttributes.SRC, script, true);
 //   XXX with defer activated, pages are not shown reliable
 //        writer.writeAttribute(HtmlAttributes.DEFER, true);
-        writer.writeAttribute(HtmlAttributes.TYPE, "text/javascript", false);
-        writer.endElement(HtmlElements.SCRIPT);
-      }
-    }
+    writer.writeAttribute(HtmlAttributes.TYPE, "text/javascript", false);
+    writer.endElement(HtmlElements.SCRIPT);
   }
 
   private String getMethod(final UIPage page) {

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml?rev=1772020&r1=1772019&r2=1772020&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/main.xhtml Wed Nov 30 12:24:42 2016
@@ -24,7 +24,7 @@
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns="http://www.w3.org/1999/xhtml">
   <f:view locale="#{clientConfigController.locale}">
-    <tc:page applicationIcon="/icon/favicon.ico" label="#{demoBundle.pageTitle} - #{title}" id="page">
+    <tc:page applicationIcon="#{request.contextPath}/icon/favicon.ico" label="#{demoBundle.pageTitle} - #{title}" id="page">
 
       <!--
             <tc:dataAttribute name="tobago-log-level" value="DEBUG"/>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-charlotteville/src/main/resources/META-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-charlotteville/src/main/resources/META-INF/tobago-config.xml?rev=1772020&r1=1772019&r2=1772020&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-charlotteville/src/main/resources/META-INF/tobago-config.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-charlotteville/src/main/resources/META-INF/tobago-config.xml Wed Nov 30 12:24:42 2016
@@ -37,11 +37,11 @@
       <versioned>true</versioned>
       <resources production="true">
         <excludes>
-          <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.js"/>
-          <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.css"/>
+          <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"/>
+          <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"/>
         </excludes>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/charlotteville/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.js"/>
-        <style name="/org/apache/myfaces/tobago/renderkit/html/charlotteville/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.css"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/charlotteville/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"/>
+        <style name="/org/apache/myfaces/tobago/renderkit/html/charlotteville/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"/>
       </resources>
       <resources production="false">
         <excludes>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-richmond/src/main/resources/META-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-richmond/src/main/resources/META-INF/tobago-config.xml?rev=1772020&r1=1772019&r2=1772020&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-richmond/src/main/resources/META-INF/tobago-config.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-richmond/src/main/resources/META-INF/tobago-config.xml Wed Nov 30 12:24:42 2016
@@ -37,11 +37,11 @@
       <versioned>true</versioned>
       <resources production="true">
         <excludes>
-          <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.js"/>
-          <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.css"/>
+          <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"/>
+          <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"/>
         </excludes>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/richmond/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.js"/>
-        <style name="/org/apache/myfaces/tobago/renderkit/html/richmond/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.css"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/richmond/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"/>
+        <style name="/org/apache/myfaces/tobago/renderkit/html/richmond/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"/>
       </resources>
       <resources production="false">
         <excludes>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/META-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/META-INF/tobago-config.xml?rev=1772020&r1=1772019&r2=1772020&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/META-INF/tobago-config.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/META-INF/tobago-config.xml Wed Nov 30 12:24:42 2016
@@ -37,11 +37,11 @@
       <versioned>true</versioned>
       <resources production="true">
         <excludes>
-          <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.js"/>
-          <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.css"/>
+          <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"/>
+          <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"/>
         </excludes>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.js"/>
-        <style name="/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.css"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"/>
+        <style name="/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"/>
       </resources>
       <resources production="false">
         <excludes>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/META-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/META-INF/tobago-config.xml?rev=1772020&r1=1772019&r2=1772020&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/META-INF/tobago-config.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/META-INF/tobago-config.xml Wed Nov 30 12:24:42 2016
@@ -37,11 +37,11 @@
       <versioned>true</versioned>
       <resources production="true">
         <excludes>
-          <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.js"/>
-          <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.css"/>
+          <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"/>
+          <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"/>
         </excludes>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/speyside/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.js"/>
-        <style name="/org/apache/myfaces/tobago/renderkit/html/speyside/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.css"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/speyside/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"/>
+        <style name="/org/apache/myfaces/tobago/renderkit/html/speyside/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"/>
       </resources>
       <resources production="false">
         <excludes>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml?rev=1772020&r1=1772019&r2=1772020&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml Wed Nov 30 12:24:42 2016
@@ -357,19 +357,19 @@
         </renderer>
       </renderers>
       <resources production="true">
-        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/jquery/jquery-2.2.4.js"/>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/jquery-ui/1.12.1.custom/jquery-ui.js"/>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/tether/1.1.1/js/tether.js"/>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.js"/>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/moment/2.13.0/moment-with-locales.js"/>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.js"/>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js"/>
-        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/typeahead/0.11.1-patched-with-1212/typeahead.js"/>
-        <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/tether/1.1.1/css/tether.css"/>
-        <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.css"/>
-        <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/font-awesome/4.6.1/css/font-awesome.css"/>
-        <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css"/>
-        <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/jquery/jquery-2.2.4.min.js"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/jquery-ui/1.12.1.custom/jquery-ui.min.js"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/tether/1.1.1/js/tether.min.js"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/moment/2.13.0/moment-with-locales.min.js"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.min.js"/>
+        <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/typeahead/0.11.1-patched-with-1212/typeahead.min.js"/>
+        <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/tether/1.1.1/css/tether.min.css"/>
+        <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"/>
+        <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/font-awesome/4.6.1/css/font-awesome.min.css"/>
+        <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.min.css"/>
+        <style name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css"/>
       </resources>
       <resources production="false">
         <script name="/org/apache/myfaces/tobago/renderkit/html/standard/standard/jquery/jquery-2.2.4.js"/>