From b1bb0d65dafed706d3ac0fc4fc6e0151b2f2ec51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20Rei=C3=9Fig?= Date: Sun, 3 Jan 2021 16:47:29 +0100 Subject: [PATCH] Remove header, section from create menu. Revert changes #22 (#24) --- .../de/mikromedia/webpages/WebpagePlugin.java | 36 ++++++++----------- .../webpages/migrations/Migration11.java | 2 ++ .../de/mikromedia/webpages/model/Webpage.java | 7 ++-- src/main/resources/migrations/migration1.json | 2 +- src/main/resources/migrations/migration4.json | 2 +- src/main/resources/migrations/migration6.json | 3 +- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/main/java/de/mikromedia/webpages/WebpagePlugin.java b/src/main/java/de/mikromedia/webpages/WebpagePlugin.java index 8adb4d1..804cfb0 100644 --- a/src/main/java/de/mikromedia/webpages/WebpagePlugin.java +++ b/src/main/java/de/mikromedia/webpages/WebpagePlugin.java @@ -231,7 +231,7 @@ public Viewable getWebpage(@PathParam("pageWebAlias") String webAlias) { dmx.fireEvent(CUSTOM_ROOT_RESOURCE_REQUESTED, context(), website, pageAlias, uriInfo); return getWebsiteTemplate(website, pageAlias); } - // 3) if no website (frontpage) exist for that prefix, we continue with our standard website for page preparation + // 3) if no website frontpage exist for that prefix, we continue with our standard website for page preparation website = getStandardWebsite(); dmx.fireEvent(WEBPAGE_REQUESTED, context(), pageAlias, STANDARD_WEBSITE_PREFIX); log.info("Preparing STANDARD FRONTPAGE view data in dmx-webpages plugin..."); @@ -239,12 +239,10 @@ public Viewable getWebpage(@PathParam("pageWebAlias") String webAlias) { // 4) check for existing pageAlias and fetch and return that webpage Webpage webpage = getWebsitesWebpage(website, pageAlias); if (webpage != null) { - Topic htmlTemplate = webpage.getHTMLTemplate(); - String templateFilename = getTemplateFileName(htmlTemplate); - log.info("Preparing WEBPAGE view data \""+webpage.getTitle().toString()+"\" for template=\"" + templateFilename + "\""); - prepareGenericViewData(templateFilename, STANDARD_WEBSITE_PREFIX, pageAlias); + log.info("Preparing WEBPAGE view data \""+webpage.getTitle().toString()+"\" ..."); + prepareGenericViewData(SIMPLE_PAGE_TEMPLATE_NAME, STANDARD_WEBSITE_PREFIX, pageAlias); preparePageViewData(webpage); - return getWebpageTemplate(webpage, templateFilename); + return getWebpageTemplate(webpage); } log.fine("=> /" + pageAlias + " webpage for standard website not found."); // 5) Check for redirects related to "standard" webpage @@ -271,18 +269,13 @@ public Viewable getWebsitePage(@PathParam("site") String sitePrefix, @PathParam( String location = "/" + sitePrefix + "/" + webAlias; // 1) Query for website topic Topic usersWebsite = getWebsiteByPrefix(sitePrefix); - // 2) Check related webpages + // 2) check related webpages Webpage webpage = getWebsitesWebpage(usersWebsite, pageAlias); - if (webpage != null && usersWebsite != null) { - Topic htmlTemplate = webpage.getHTMLTemplate(); - String templateFilename = getTemplateFileName(htmlTemplate); - prepareGenericViewData(templateFilename, sitePrefix, pageAlias); - prepareWebsiteViewData(usersWebsite, pageAlias); - log.info("Preparing WEBPAGE view data \""+webpage.getTitle().toString()+"\" for template=\"" + templateFilename - + "\", website=\"" + sitePrefix +"\""); + if (webpage != null) { dmx.fireEvent(WEBPAGE_REQUESTED, context(), pageAlias, sitePrefix); + log.info("Preparing WEBPAGE view data \""+webpage.getTitle().toString()+"\" ..."); preparePageViewData(webpage); - return getWebpageTemplate(webpage, templateFilename); + return getWebpageTemplate(webpage); } log.info("=> /" + pageAlias + " webpage for \"" +sitePrefix+ "\"s website not found."); // 3) check if it is a users redirect @@ -355,13 +348,13 @@ public Viewable processContactFormSubmission(@QueryParam("name") String name, @Q viewData("contactFormUsed", true); if (website == null) { return getIndexWebpage(); - } else if (website.equals("standard") && webalias == null) { + } else if (website.equals(STANDARD_WEBSITE_PREFIX) && webalias == null) { return getIndexWebpage(); - } else if (website.equals("standard") && webalias != null) { + } else if (website.equals(STANDARD_WEBSITE_PREFIX) && webalias != null) { return getWebpage(webalias); - } else if (!website.equals("standard") && webalias == null) { + } else if (!website.equals(STANDARD_WEBSITE_PREFIX) && webalias == null) { return getWebpage(website); - } else if (!website.equals("standard") && webalias != null) { + } else if (!website.equals(STANDARD_WEBSITE_PREFIX) && webalias != null) { return getWebsitePage(website, webalias); } else { return getIndexWebpage(); @@ -812,14 +805,14 @@ private Viewable getCustomRootResourcePage(String pageAlias) { return null; } - private Viewable getWebpageTemplate(Webpage page, String templateName) { + private Viewable getWebpageTemplate(Webpage page) { try { // while logged in users can (potentially) browse a drafted webpage if (isNotAllowedToAccessDraft(page)) { log.fine("401 => /" + page.getWebAlias() + " is a DRAFT (yet unpublished)"); return view("401"); } else { - return view(templateName); + return view(SIMPLE_PAGE_TEMPLATE_NAME); } } catch (RuntimeException re) { throw new RuntimeException("Page Template for Webpage Topic (ID: " @@ -999,6 +992,7 @@ public int compare(Section s1, Section s2) { return all; } + /** Upcoming in New in 0.9 release **/ private String getTemplateFileName(Topic templateName) { if (templateName == null) return SIMPLE_PAGE_TEMPLATE_NAME; return templateName.getUri().substring("de.mikromedia.template_".length()); diff --git a/src/main/java/de/mikromedia/webpages/migrations/Migration11.java b/src/main/java/de/mikromedia/webpages/migrations/Migration11.java index 8c8f3a9..d4cbf8b 100644 --- a/src/main/java/de/mikromedia/webpages/migrations/Migration11.java +++ b/src/main/java/de/mikromedia/webpages/migrations/Migration11.java @@ -20,7 +20,9 @@ public class Migration11 extends Migration { @Override public void run () { + /** Upcoming after New in 0.9 release **/ // Defunct: Hook in two custom webclient renderers (?) + // Fixme: ### If webclient is capable of providing identityAttributes register site.prefix as identityAttr=True // Assign new default pages Topic webpagesWs = workspaces.getWorkspace(WebpagePlugin.WEBPAGES_WS_URI); Topic bookmarksPage = dmx.getTopicByUri("de.mikromedia.bookmarks.page"); diff --git a/src/main/java/de/mikromedia/webpages/model/Webpage.java b/src/main/java/de/mikromedia/webpages/model/Webpage.java index 3cba5c1..851b8fb 100644 --- a/src/main/java/de/mikromedia/webpages/model/Webpage.java +++ b/src/main/java/de/mikromedia/webpages/model/Webpage.java @@ -1,5 +1,6 @@ package de.mikromedia.webpages.model; +import static de.mikromedia.webpages.WebpageService.AUTHOR_NAME; import static de.mikromedia.webpages.WebpageService.CUSTOM_SCRIPT_PATH; import static systems.dmx.core.Constants.*; import static de.mikromedia.webpages.WebpageService.TIME_CREATED; @@ -12,6 +13,7 @@ import static de.mikromedia.webpages.WebpageService.WEBPAGE_IS_DRAFT; import static de.mikromedia.webpages.WebpageService.WEBPAGE_TEMPLATE; import java.util.Date; +import java.util.Iterator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -105,7 +107,7 @@ public boolean isDraft() { return isDraft; } - /** public String getAuthorNames() { + public String getAuthorNames() { String nameOfAuthors = ""; List authorNames = page.getChildTopics().getTopicsOrNull(AUTHOR_NAME); if (authorNames != null) { @@ -119,7 +121,7 @@ public boolean isDraft() { } } return nameOfAuthors; - } **/ + } public JSONObject toJSON() { try { @@ -127,6 +129,7 @@ public JSONObject toJSON() { .put("title", getTitle()) .put("description", getDescription()) .put("main", getMainHTML()) + .put("author_names", getAuthorNames()) .put("modified", getModificationDate()) .put("created", getCreationDate()) .put("web_alias", getWebAlias()); diff --git a/src/main/resources/migrations/migration1.json b/src/main/resources/migrations/migration1.json index ad05968..99d15ce 100644 --- a/src/main/resources/migrations/migration1.json +++ b/src/main/resources/migrations/migration1.json @@ -438,7 +438,7 @@ { "typeUri": "dmx.webclient.view_config", "children": { - "dmx.webclient.add_to_create_menu": true, + "dmx.webclient.add_to_create_menu": false, "dmx.webclient.icon": "\uf150" } } diff --git a/src/main/resources/migrations/migration4.json b/src/main/resources/migrations/migration4.json index d2575b0..112f762 100644 --- a/src/main/resources/migrations/migration4.json +++ b/src/main/resources/migrations/migration4.json @@ -204,7 +204,7 @@ { "typeUri": "dmx.webclient.view_config", "children": { - "dmx.webclient.add_to_create_menu": true, + "dmx.webclient.add_to_create_menu": false, "dmx.webclient.icon": "\uf1dc" } } diff --git a/src/main/resources/migrations/migration6.json b/src/main/resources/migrations/migration6.json index c3130db..0f61235 100644 --- a/src/main/resources/migrations/migration6.json +++ b/src/main/resources/migrations/migration6.json @@ -112,7 +112,6 @@ "value": "Section CSS Classes", "uri": "de.mikromedia.section.css_class", "dataTypeUri": "dmx.core.text", - "indexModeUris": ["dmx.core.key"], "viewConfigTopics": [ { "typeUri": "dmx.webclient.view_config", @@ -231,7 +230,7 @@ { "typeUri": "dmx.webclient.view_config", "children": { - "dmx.webclient.add_to_create_menu": true, + "dmx.webclient.add_to_create_menu": false, "dmx.webclient.icon": "\uf15c" } }