Introduce publishing styles.
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 27 Oct 2020 08:51:31 +0000 (09:51 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 27 Oct 2020 08:51:31 +0000 (09:51 +0100)
publishing/org.argeo.publishing.ui/src/org/argeo/cms/text/TextSection.java
publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/AbstractDbkViewer.java
publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/DocumentTextEditor.java
publishing/org.argeo.publishing.ui/src/org/argeo/publishing/ui/PublishingApp.java
publishing/org.argeo.publishing.ui/src/org/argeo/publishing/ui/PublishingStyle.java [new file with mode: 0644]

index b7b07797f922e0d66e38b7b1baa942eee08830b7..ef4bb0f38d2cbc39908320f14bcdf085e519e191 100644 (file)
@@ -1,7 +1,6 @@
 package org.argeo.cms.text;
 
 import javax.jcr.Node;
-import javax.jcr.RepositoryException;
 
 import org.argeo.cms.ui.util.CmsUiUtils;
 import org.argeo.cms.ui.viewers.Section;
@@ -13,18 +12,15 @@ public class TextSection extends Section implements CmsNames {
        private String defaultTextStyle = TextStyles.TEXT_DEFAULT;
        private String titleStyle;
 
-       public TextSection(Composite parent, int style, Node node)
-                       throws RepositoryException {
+       public TextSection(Composite parent, int style, Node node) {
                this(parent, findSection(parent), style, node);
        }
 
-       public TextSection(TextSection section, int style, Node node)
-                       throws RepositoryException {
+       public TextSection(TextSection section, int style, Node node) {
                this(section, section.getParentSection(), style, node);
        }
 
-       private TextSection(Composite parent, Section parentSection, int style,
-                       Node node) throws RepositoryException {
+       private TextSection(Composite parent, Section parentSection, int style, Node node) {
                super(parent, parentSection, style, node);
                CmsUiUtils.style(this, TextStyles.TEXT_SECTION);
        }
@@ -38,8 +34,7 @@ public class TextSection extends Section implements CmsNames {
                        return titleStyle;
                // TODO make base H styles configurable
                Integer relativeDepth = getRelativeDepth();
-               return relativeDepth == 0 ? TextStyles.TEXT_TITLE : TextStyles.TEXT_H
-                               + relativeDepth;
+               return relativeDepth == 0 ? TextStyles.TEXT_TITLE : TextStyles.TEXT_H + relativeDepth;
        }
 
        public void setDefaultTextStyle(String defaultTextStyle) {
index a00c31664adb5992dad90798b56cc53d37f60629..39ae080152dfc0ca5c58ed621b486b512553ba9b 100644 (file)
@@ -20,9 +20,9 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.text.Paragraph;
+import org.argeo.cms.text.SectionTitle;
 import org.argeo.cms.text.TextInterpreter;
 import org.argeo.cms.text.TextSection;
-import org.argeo.cms.text.SectionTitle;
 import org.argeo.cms.ui.CmsEditable;
 import org.argeo.cms.ui.CmsImageManager;
 import org.argeo.cms.ui.CmsView;
index 9dc7e1002dea7e68d91f6f4eb1a28532b5a05f75..7bb5132e35bff8b00da88815240edc7536781df3 100644 (file)
@@ -13,8 +13,7 @@ import org.eclipse.swt.widgets.Composite;
 public class DocumentTextEditor extends AbstractDbkViewer {
        private static final long serialVersionUID = 6049661610883342325L;
 
-       public DocumentTextEditor(Composite parent, int style, Node textNode, CmsEditable cmsEditable)
-                       throws RepositoryException {
+       public DocumentTextEditor(Composite parent, int style, Node textNode, CmsEditable cmsEditable) {
                super(new TextSection(parent, style, textNode), style, cmsEditable);
                refresh();
                getMainSection().setLayoutData(CmsUiUtils.fillWidth());
index 00deae94af9ddc38ce3e044c5d48a5af987ad3a3..22bd2bbe18d06b93b7a633ac9b2d7b4fc34f478e 100644 (file)
@@ -13,6 +13,7 @@ import org.apache.commons.logging.LogFactory;
 import org.argeo.api.NodeUtils;
 import org.argeo.cms.ui.AbstractCmsApp;
 import org.argeo.cms.ui.CmsApp;
+import org.argeo.cms.ui.CmsUiProvider;
 import org.argeo.docbook.ui.DocBookTypes;
 import org.argeo.docbook.ui.DocumentPage;
 import org.argeo.jcr.Jcr;
@@ -32,6 +33,8 @@ public class PublishingApp extends AbstractCmsApp {
        private String pid;
        private String defaultThemeId;
 
+       private CmsUiProvider landingPage;
+
        public void init(Map<String, String> properties) {
                defaultThemeId = properties.get("defaultThemeId");
                pid = properties.get(Constants.SERVICE_PID);
@@ -63,7 +66,13 @@ public class PublishingApp extends AbstractCmsApp {
                } catch (RepositoryException e) {
                        throw new IllegalStateException(e);
                }
-               Control page = new DocumentPage().createUiPart(parent, indexNode);
+
+               Control page;
+               if (landingPage != null) {
+                       page = landingPage.createUiPart(parent, indexNode);
+               } else {
+                       page = new DocumentPage().createUiPart(parent, indexNode);
+               }
                return (Composite) page;
        }
 
@@ -82,4 +91,9 @@ public class PublishingApp extends AbstractCmsApp {
        protected String getThemeId(String uiName) {
                return defaultThemeId;
        }
+
+       public void setLandingPage(CmsUiProvider landingPage) {
+               this.landingPage = landingPage;
+       }
+
 }
diff --git a/publishing/org.argeo.publishing.ui/src/org/argeo/publishing/ui/PublishingStyle.java b/publishing/org.argeo.publishing.ui/src/org/argeo/publishing/ui/PublishingStyle.java
new file mode 100644 (file)
index 0000000..825ae66
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.publishing.ui;
+
+import org.argeo.cms.ui.util.CmsStyle;
+
+/** Publishing styles. */
+public enum PublishingStyle implements CmsStyle {
+       page;
+
+       @Override
+       public String getClassPrefix() {
+               return "argeo-publishing";
+       }
+
+}