Changeset 20817
- Timestamp:
- 06/19/07 15:10:20 (1 year ago)
- Files:
-
- org.nuxeo.theme/trunk/nuxeo-theme-core/src/main/java/org/nuxeo/theme/themes/ThemeManager.java (modified) (3 diffs)
- org.nuxeo.theme/trunk/nuxeo-theme-jsf/src/main/java/org/nuxeo/theme/jsf/servlets/Resources.java (modified) (5 diffs)
- org.nuxeo.theme/trunk/nuxeo-theme-jsf/src/main/java/org/nuxeo/theme/jsf/servlets/Styles.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
org.nuxeo.theme/trunk/nuxeo-theme-core/src/main/java/org/nuxeo/theme/themes/ThemeManager.java
r20715 r20817 82 82 "_ inherits from _"); 83 83 84 private String renderedStyles = null; 84 private String cachedStyles = null; 85 86 private final Map<String, String> cachedResources = new HashMap<String, String>(); 85 87 86 88 public void clear() { … … 449 451 450 452 public void stylesModified() { 451 set RenderedStyles(null);453 setCachedStyles(null); 452 454 } 453 455 … … 668 670 669 671 // Cached styles 670 public String getRenderedStyles() { 671 return renderedStyles; 672 } 673 674 public void setRenderedStyles(String renderedStyles) { 675 this.renderedStyles = renderedStyles; 672 public String getCachedStyles() { 673 return cachedStyles; 674 } 675 676 public void setCachedStyles(String cachedStyles) { 677 this.cachedStyles = cachedStyles; 678 } 679 680 public String getResource(String name) { 681 return cachedResources.get(name); 682 } 683 684 public void setResource(String name, String content) { 685 cachedResources.put(name, content); 676 686 } 677 687 org.nuxeo.theme/trunk/nuxeo-theme-jsf/src/main/java/org/nuxeo/theme/jsf/servlets/Resources.java
r20757 r20817 33 33 import org.nuxeo.theme.ApplicationType; 34 34 import org.nuxeo.theme.Manager; 35 import org.nuxeo.theme.jsf.JSUtils; 35 36 import org.nuxeo.theme.jsf.Utils; 36 37 import org.nuxeo.theme.resources.ResourceType; … … 48 49 @Override 49 50 protected void doGet(final HttpServletRequest request, 50 final HttpServletResponse response) throws ServletException, IOException { 51 final HttpServletResponse response) throws ServletException, 52 IOException { 51 53 doPost(request, response); 52 54 } … … 67 69 68 70 final TypeRegistry typeRegistry = Manager.getTypeRegistry(); 71 String contentType = null; 72 String key = m.group(1); 69 73 70 String contentType = null;71 final String[] resourceNames = m.group(1).split(",");74 boolean compressJs = false; 75 final String[] resourceNames = key.split(","); 72 76 for (String resourceName : resourceNames) { 73 77 String previousContentType = contentType; 74 78 if (resourceName.endsWith(".js")) { 75 79 contentType = "text/javascript"; 80 compressJs = true; 76 81 } else if (resourceName.endsWith(".css")) { 77 82 contentType = "text/css"; … … 129 134 } 130 135 131 os.write(out.toString().getBytes()); 136 String source = out.toString(); 137 if (compressJs) { 138 source = JSUtils.compressSource(source); 139 } 140 141 os.write(source.getBytes()); 132 142 os.close(); 133 143 … … 136 146 } 137 147 138 private static void writeResource(final ResourceType resource, final OutputStream out) { 148 private static void writeResource(final ResourceType resource, 149 final OutputStream out) { 139 150 InputStream in = null; 140 151 try { org.nuxeo.theme/trunk/nuxeo-theme-jsf/src/main/java/org/nuxeo/theme/jsf/servlets/Styles.java
r20159 r20817 73 73 if (Utils.supportsGzip(request)) { 74 74 response.setHeader("Content-Encoding", "gzip"); 75 // Needed by proxy servers 76 response.setHeader("Vary", "Accept-Encoding"); 75 77 os = new GZIPOutputStream(os); 76 78 } 77 79 78 80 final ThemeManager themeManager = Manager.getThemeManager(); 79 String rendered = themeManager.get RenderedStyles();81 String rendered = themeManager.getCachedStyles(); 80 82 if (rendered == null) { 81 83 final StringBuilder sb = new StringBuilder(); … … 87 89 } 88 90 rendered = sb.toString(); 89 themeManager.set RenderedStyles(rendered);91 themeManager.setCachedStyles(rendered); 90 92 } 91 93
