public final static String CMS_THEME_PROPERTY = "argeo.cms.theme";
public final static String CMS_THEME_BUNDLE_PROPERTY = "argeo.cms.theme.bundle";
+ private final static String HEADER_CSS = "header.css";
+ private final static String FONTS_TXT = "fonts.txt";
+
// private final static Log log = LogFactory.getLog(BundleCmsTheme.class);
private String themeId;
private Set<String> rapCssPaths = new TreeSet<>();
private Set<String> swtCssPaths = new TreeSet<>();
private Set<String> imagesPaths = new TreeSet<>();
+ private Set<String> fontsPaths = new TreeSet<>();
private String headerCss;
private List<String> fonts = new ArrayList<>();
webCssPaths = addCss(themeBundle, "/css/");
rapCssPaths = addCss(themeBundle, "/rap/");
swtCssPaths = addCss(themeBundle, "/swt/");
- addResources("*.png");
- addResources("*.gif");
- addResources("*.jpg");
- addResources("*.jpeg");
- addResources("*.svg");
- addResources("*.ico");
+ addImages("*.png");
+ addImages("*.gif");
+ addImages("*.jpg");
+ addImages("*.jpeg");
+ addImages("*.svg");
+ addImages("*.ico");
+
+ addFonts("*.woff");
+ addFonts("*.woff2");
// fonts
- URL fontsUrl = themeBundle.getEntry(basePath + "fonts.txt");
+ URL fontsUrl = themeBundle.getEntry(basePath + FONTS_TXT);
if (fontsUrl != null) {
loadFontsUrl(fontsUrl);
}
// common CSS header (plain CSS)
- URL headerCssUrl = themeBundle.getEntry(basePath + "header.css");
+ URL headerCssUrl = themeBundle.getEntry(basePath + HEADER_CSS);
if (headerCssUrl != null) {
+ // added to plain Web CSS
+ webCssPaths.add(basePath + HEADER_CSS);
+ // and it will also be used by RAP:
try (BufferedReader buffer = new BufferedReader(new InputStreamReader(headerCssUrl.openStream(), UTF_8))) {
headerCss = buffer.lines().collect(Collectors.joining("\n"));
} catch (IOException e) {
}
}
- void addResources(String pattern) {
+ void addImages(String pattern) {
Enumeration<URL> themeResources = themeBundle.findEntries(basePath, pattern, true);
if (themeResources == null)
return;
}
+ void addFonts(String pattern) {
+ Enumeration<URL> themeResources = themeBundle.findEntries(basePath, pattern, true);
+ if (themeResources == null)
+ return;
+ while (themeResources.hasMoreElements()) {
+ String resource = themeResources.nextElement().getPath();
+ // remove first '/' so that RWT registers it
+ resource = resource.substring(1);
+ if (!resource.endsWith("/")) {
+// if (resources.containsKey(resource))
+// log.warn("Overriding " + resource + " from " + themeBundle.getSymbolicName());
+// resources.put(resource, themeBRL);
+ fontsPaths.add(resource);
+ }
+
+ }
+
+ }
+
@Override
public InputStream getResourceAsStream(String resourceName) throws IOException {
URL res = themeBundle.getEntry(resourceName);
return imagesPaths;
}
+ @Override
+ public Set<String> getFontsPaths() {
+ return fontsPaths;
+ }
+
@Override
public InputStream loadPath(String path) throws IOException {
URL url = themeBundle.getResource(path);