diff options
author | Marc Englund <marc@vaadin.com> | 2012-10-10 13:28:10 +0300 |
---|---|---|
committer | Marc Englund <marc@vaadin.com> | 2012-10-10 13:28:10 +0300 |
commit | 1a96ed6807982ee18811954695ca8a83a4b7d318 (patch) | |
tree | 265ddb0e8da74809082e21525b5c5e4626b10f4d /theme-compiler | |
parent | 60342e38e0fae5af57a1500ef1517f035af0be30 (diff) | |
download | vaadin-framework-1a96ed6807982ee18811954695ca8a83a4b7d318.tar.gz vaadin-framework-1a96ed6807982ee18811954695ca8a83a4b7d318.zip |
Changed the convention for importing themes from e.g @import "reindeer.scss" to @import "../reindeer/reindeer.scss" to support jar/extracted cases better.
Change-Id: Ic638a91ab03059859cf3cc006ac167d2216a8cd7
Diffstat (limited to 'theme-compiler')
-rw-r--r-- | theme-compiler/src/com/vaadin/sass/resolver/VaadinResolver.java | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/resolver/VaadinResolver.java b/theme-compiler/src/com/vaadin/sass/resolver/VaadinResolver.java index 93fdf6bfec..1caf5dcac8 100644 --- a/theme-compiler/src/com/vaadin/sass/resolver/VaadinResolver.java +++ b/theme-compiler/src/com/vaadin/sass/resolver/VaadinResolver.java @@ -1,46 +1,49 @@ package com.vaadin.sass.resolver; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.w3c.css.sac.InputSource; public class VaadinResolver implements ScssStylesheetResolver { @Override public InputSource resolve(String identifier) { - String ext = ".scss"; if (identifier.endsWith(".css")) { - ext = ".css"; + // CSS support mainly for testing, don't load from classpath etc + ScssStylesheetResolver resolver = new FilesystemResolver(); + return resolver.resolve(identifier); } - // 'normalize' identifier to use in themeFile - String fileName = identifier; - if (identifier.endsWith(ext)) { - identifier = identifier.substring(0, - identifier.length() - ext.length()); - } - // also look here - String themeFile = "VAADIN/themes/" + identifier + "/" + fileName; + InputSource source = null; - // first plain file - ScssStylesheetResolver resolver = new FilesystemResolver(); - InputSource source = resolver.resolve(fileName); + Pattern pattern = Pattern + .compile("\\.\\.\\/([^\\/]+)\\/([^\\/]+\\.scss)"); + Matcher matcher = pattern.matcher(identifier); - if (source == null) { - // then file in theme - source = resolver.resolve(themeFile); - } + if (matcher.find()) { + // theme include + ScssStylesheetResolver resolver = new FilesystemResolver(); + source = resolver.resolve(identifier); - if (source == null) { - // then plain via classloader - resolver = new ClassloaderResolver(); + if (source == null) { + String themeName = matcher.group(1); + String fileName = matcher.group(2); + resolver = new ClassloaderResolver(); + String id = "VAADIN/themes/" + themeName + "/" + fileName; + source = resolver.resolve(id); + } + + } else { + ScssStylesheetResolver resolver = new FilesystemResolver(); source = resolver.resolve(identifier); - } - if (source == null) { - // then try theme via classloader - source = resolver.resolve(themeFile); + if (source == null) { + resolver = new ClassloaderResolver(); + source = resolver.resolve(identifier); + } } return source; } - } |