projects
/
lgpl
/
argeo-commons.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0fff629
)
Introduce body html in theming.
author
Mathieu Baudier <mbaudier@argeo.org>
Wed, 21 Jul 2021 08:39:01 +0000
(10:39 +0200)
committer
Mathieu Baudier <mbaudier@argeo.org>
Wed, 21 Jul 2021 08:39:01 +0000
(10:39 +0200)
org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java
patch
|
blob
|
history
org.argeo.cms.ui/src/org/argeo/cms/ui/CmsTheme.java
patch
|
blob
|
history
org.argeo.cms.ui/src/org/argeo/cms/ui/util/BundleCmsTheme.java
patch
|
blob
|
history
diff --git
a/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java
b/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java
index 66333858dd933f1bb415167eba0d1eabe9f8005e..75509bd640dfec58071cceca6a219ddd93f826d7 100644
(file)
--- a/
org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java
+++ b/
org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java
@@
-90,6
+90,7
@@
public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm
if (theme != null) {
properties.put(WebClient.THEME_ID, theme.getThemeId());
properties.put(WebClient.HEAD_HTML, theme.getHtmlHeaders());
if (theme != null) {
properties.put(WebClient.THEME_ID, theme.getThemeId());
properties.put(WebClient.HEAD_HTML, theme.getHtmlHeaders());
+ properties.put(WebClient.BODY_HTML, theme.getBodyHtml());
} else {
properties.put(WebClient.THEME_ID, RWT.DEFAULT_THEME_ID);
}
} else {
properties.put(WebClient.THEME_ID, RWT.DEFAULT_THEME_ID);
}
diff --git
a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsTheme.java
b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsTheme.java
index e5089e35f65716ef02de5d15e4c73068f682f54c..c93991b274e7126bf609284015c01e574fc61a70 100644
(file)
--- a/
org.argeo.cms.ui/src/org/argeo/cms/ui/CmsTheme.java
+++ b/
org.argeo.cms.ui/src/org/argeo/cms/ui/CmsTheme.java
@@
-37,6
+37,9
@@
public interface CmsTheme {
/** Tags to be added to the header section of the HTML page. */
String getHtmlHeaders();
/** Tags to be added to the header section of the HTML page. */
String getHtmlHeaders();
+ /** The HTML body to use. */
+ String getBodyHtml();
+
/** The image registered at this path, or <code>null</code> if not found. */
Image getImage(String path);
/** The image registered at this path, or <code>null</code> if not found. */
Image getImage(String path);
diff --git
a/org.argeo.cms.ui/src/org/argeo/cms/ui/util/BundleCmsTheme.java
b/org.argeo.cms.ui/src/org/argeo/cms/ui/util/BundleCmsTheme.java
index 9a3cf9d47d87b653fcb5de6d346284e27950dc2c..6b997e6a35c4f0e691b412b1d9129a2759b4ede7 100644
(file)
--- a/
org.argeo.cms.ui/src/org/argeo/cms/ui/util/BundleCmsTheme.java
+++ b/
org.argeo.cms.ui/src/org/argeo/cms/ui/util/BundleCmsTheme.java
@@
-7,6
+7,7
@@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
@@
-15,6
+16,7
@@
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.TreeSet;
import java.util.stream.Collectors;
+import org.apache.commons.io.IOUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@
-35,6
+37,7
@@
public class BundleCmsTheme extends AbstractCmsTheme {
private final static String HEADER_CSS = "header.css";
private final static String FONTS_TXT = "fonts.txt";
private final static String HEADER_CSS = "header.css";
private final static String FONTS_TXT = "fonts.txt";
+ private final static String BODY_HTML = "body.html";
// private final static Log log = LogFactory.getLog(BundleCmsTheme.class);
// private final static Log log = LogFactory.getLog(BundleCmsTheme.class);
@@
-48,6
+51,8
@@
public class BundleCmsTheme extends AbstractCmsTheme {
private String headerCss;
private List<String> fonts = new ArrayList<>();
private String headerCss;
private List<String> fonts = new ArrayList<>();
+ private String bodyHtml="<body></body>";
+
private String basePath;
private String styleCssPath;
// private String webCssPath;
private String basePath;
private String styleCssPath;
// private String webCssPath;
@@
-123,7
+128,13
@@
public class BundleCmsTheme extends AbstractCmsTheme {
throw new IllegalArgumentException("Cannot read " + headerCssUrl, e);
}
}
throw new IllegalArgumentException("Cannot read " + headerCssUrl, e);
}
}
- }
+
+ // body
+ URL bodyUrl = themeBundle.getEntry(basePath + BODY_HTML);
+ if (bodyUrl != null) {
+ loadBodyHtml(bodyUrl);
+ }
+}
public String getHtmlHeaders() {
StringBuilder sb = new StringBuilder();
public String getHtmlHeaders() {
StringBuilder sb = new StringBuilder();
@@
-142,6
+153,13
@@
public class BundleCmsTheme extends AbstractCmsTheme {
else
return sb.toString();
}
else
return sb.toString();
}
+
+
+
+ @Override
+ public String getBodyHtml() {
+ return bodyHtml;
+ }
Set<String> addCss(Bundle themeBundle, String path) {
Set<String> paths = new TreeSet<>();
Set<String> addCss(Bundle themeBundle, String path) {
Set<String> paths = new TreeSet<>();
@@
-188,6
+206,14
@@
public class BundleCmsTheme extends AbstractCmsTheme {
}
}
}
}
+ void loadBodyHtml(URL url) {
+ try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), UTF_8))) {
+ bodyHtml= IOUtils.toString(url,StandardCharsets.UTF_8);
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Cannot load URL " + url, e);
+ }
+ }
+
void addImages(String pattern) {
Enumeration<URL> themeResources = themeBundle.findEntries(basePath, pattern, true);
if (themeResources == null)
void addImages(String pattern) {
Enumeration<URL> themeResources = themeBundle.findEntries(basePath, pattern, true);
if (themeResources == null)