Skip to content

Commit

Permalink
Remove header, section from create menu. Revert
Browse files Browse the repository at this point in the history
changes #22 (#24)
  • Loading branch information
mukil committed Jan 3, 2021
1 parent c65d639 commit b1bb0d6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 27 deletions.
36 changes: 15 additions & 21 deletions src/main/java/de/mikromedia/webpages/WebpagePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,18 @@ 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...");
prepareWebsiteViewData(website, 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
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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: "
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/de/mikromedia/webpages/model/Webpage.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -105,7 +107,7 @@ public boolean isDraft() {
return isDraft;
}

/** public String getAuthorNames() {
public String getAuthorNames() {
String nameOfAuthors = "";
List<RelatedTopic> authorNames = page.getChildTopics().getTopicsOrNull(AUTHOR_NAME);
if (authorNames != null) {
Expand All @@ -119,14 +121,15 @@ public boolean isDraft() {
}
}
return nameOfAuthors;
} **/
}

public JSONObject toJSON() {
try {
return new JSONObject()
.put("title", getTitle())
.put("description", getDescription())
.put("main", getMainHTML())
.put("author_names", getAuthorNames())
.put("modified", getModificationDate())
.put("created", getCreationDate())
.put("web_alias", getWebAlias());
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/migrations/migration1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/migrations/migration4.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/migrations/migration6.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
Expand Down

0 comments on commit b1bb0d6

Please sign in to comment.