From ea16316e526017411039410fcf40e8a043ba0273 Mon Sep 17 00:00:00 2001 From: jensp Date: Sat, 20 Jan 2018 16:53:17 +0000 Subject: [PATCH] CCM NG: - Put all files for ccm-editor into one Maven module to avoid problems with TypeScript module resolution - Internal Links Command for ccm-editor git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5209 8810af33-2d31-482b-a856-94f89814c4df --- ccm-bundle-devel-wildfly-web/pom.xml | 7 +- ccm-bundle-devel/pom.xml | 7 +- ccm-cms-editor/Gruntfile.js | 17 --- ccm-cms-editor/package.json | 23 ---- ccm-cms-editor/pom.xml | 91 -------------- ccm-cms-editor/src/site/markdown/index.md | 8 -- ccm-cms-editor/src/site/site.xml | 20 ---- ccm-cms-editor/tsconfig.json | 11 -- .../librecms/contentsection/rs/Assets.java | 6 +- .../contentsection/rs/ContentItems.java | 14 ++- .../contentsection/rs/ContentSections.java | 2 +- .../java/org/librecms/pages/PagesRouter.java | 4 +- ccm-editor/Gruntfile.js | 8 +- .../main/resources/ccm-editor/ccm-editor.css | 21 +++- .../typescript/ccm-editor/ccm-cms-editor.ts | 35 ++++-- .../main/typescript/ccm-editor/ccm-editor.ts | 16 +-- pom.xml | 113 +++++++++--------- 17 files changed, 125 insertions(+), 278 deletions(-) delete mode 100644 ccm-cms-editor/Gruntfile.js delete mode 100644 ccm-cms-editor/package.json delete mode 100644 ccm-cms-editor/pom.xml delete mode 100644 ccm-cms-editor/src/site/markdown/index.md delete mode 100644 ccm-cms-editor/src/site/site.xml delete mode 100644 ccm-cms-editor/tsconfig.json rename {ccm-cms-editor => ccm-editor}/src/main/typescript/ccm-editor/ccm-cms-editor.ts (86%) diff --git a/ccm-bundle-devel-wildfly-web/pom.xml b/ccm-bundle-devel-wildfly-web/pom.xml index f8cede587..0a5ef02fb 100644 --- a/ccm-bundle-devel-wildfly-web/pom.xml +++ b/ccm-bundle-devel-wildfly-web/pom.xml @@ -69,12 +69,7 @@ ccm-editor jar - - org.librecms - ccm-cms-editor - jar - - + org.libreccm ccm-theme-foundry jar diff --git a/ccm-bundle-devel/pom.xml b/ccm-bundle-devel/pom.xml index 2736dca05..3faedc2d4 100644 --- a/ccm-bundle-devel/pom.xml +++ b/ccm-bundle-devel/pom.xml @@ -53,12 +53,7 @@ ccm-cms ${project.parent.version} - - org.librecms - ccm-cms-editor - ${project.parent.version} - - + diff --git a/ccm-cms-editor/Gruntfile.js b/ccm-cms-editor/Gruntfile.js deleted file mode 100644 index 7040b43af..000000000 --- a/ccm-cms-editor/Gruntfile.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = function(grunt) { - grunt.initConfig({ - ts: { - default : { - options: { - module: "amd", - tsconfig: true, - moduleResolution: "classic" - } - } - }, - clean: ['scripts/*.js', 'scripts/*.js.map', 'scripts/.tscache'] - }); - grunt.loadNpmTasks("grunt-ts"); - grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.registerTask("default", ["ts"]); -}; diff --git a/ccm-cms-editor/package.json b/ccm-cms-editor/package.json deleted file mode 100644 index 87ec3bc46..000000000 --- a/ccm-cms-editor/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "ccm-cms-editor", - "version": "7.0.0", - "description": "CMS modules for the ccm-editor", - "repository": { - "type": "svn", - "url": "https://svn.libreccm.org/ccm/ccm_ng/ccm-cms-editor" - }, - "author": "Jens Pelzetter", - "license": "GPL-3.0", - "dependencies": { - "font-awesome": "^4.7.0", - "requirejs": "^2.3.5", - "requirejs-domready": "^2.0.3" - }, - "devDependencies": { - "grunt": "^1.0.1", - "grunt-cli": "^1.2.0", - "grunt-contrib-clean": "^1.1.0", - "grunt-ts": "^6.0.0-beta.17", - "typescript": "^2.6.2" - } -} diff --git a/ccm-cms-editor/pom.xml b/ccm-cms-editor/pom.xml deleted file mode 100644 index d98d1147b..000000000 --- a/ccm-cms-editor/pom.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - 4.0.0 - - - UTF-8 - ${maven.build.timestamp} - yyyy-MM-dd'T'HH:mm:ss'Z'Z - - - - org.libreccm - libreccm-parent - 7.0.0-SNAPSHOT - - - org.librecms - ccm-cms-editor - 7.0.0-SNAPSHOT - jar - - LibreCMS modules for the ccm-editor - - Provides CMS specific modules for the ccm-editor. - - - - - Lesser GPL 2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1 - - - - - - org.libreccm - ccm-editor - 7.0.0-SNAPSHOT - - - - - ccm-editor - - - - src/main/resources - - - src/main/typescript - - - - - - com.github.eirslett - frontend-maven-plugin - - - - Install node.js and NPM - - install-node-and-npm - - - v6.12.3 - - - - npm install - - npm - - - - grunt build - - grunt - - - - - - - - - diff --git a/ccm-cms-editor/src/site/markdown/index.md b/ccm-cms-editor/src/site/markdown/index.md deleted file mode 100644 index c32ace84a..000000000 --- a/ccm-cms-editor/src/site/markdown/index.md +++ /dev/null @@ -1,8 +0,0 @@ -CCM Editor modules for LibreCMS ---- - -This module provides two new commands for the CCM Editor which are only useful -in combination with the LibreCMS module: - -* Insert Internal Link: Adds an internal link to a content item -* Insert Image: Inserts a image from the media library of LibreCMS diff --git a/ccm-cms-editor/src/site/site.xml b/ccm-cms-editor/src/site/site.xml deleted file mode 100644 index 6ad2244f7..000000000 --- a/ccm-cms-editor/src/site/site.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/ccm-cms-editor/tsconfig.json b/ccm-cms-editor/tsconfig.json deleted file mode 100644 index 72bca3ef9..000000000 --- a/ccm-cms-editor/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "include": [ - "./src/main/typescript/**/*" - ], - "compilerOptions": { - "rootDirs": [ - "../ccm-editor/src/main/typescript/ccm-editor", - "./src/main/typescript/ccm-editor" - ] - } -} diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/rs/Assets.java b/ccm-cms/src/main/java/org/librecms/contentsection/rs/Assets.java index 6d9cff2af..e8d0e6fc4 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/rs/Assets.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/rs/Assets.java @@ -153,7 +153,7 @@ public class Assets { @GET @Path("/") - @Produces("text/json; charset=utf-8") + @Produces("application/json; charset=utf-8") @Transactional(Transactional.TxType.REQUIRED) public List> findAssets( @PathParam("content-section") final String section, @@ -194,7 +194,7 @@ public class Assets { @GET @Path("/folders/") - @Produces("text/json; charset=utf-8") + @Produces("application/json; charset=utf-8") @Transactional(Transactional.TxType.REQUIRED) public List> findAssetsInRootFolder( @PathParam("content-section") final String section, @@ -213,7 +213,7 @@ public class Assets { @GET @Path("/folders/{folder}/") - @Produces("text/json; charset=utf-8") + @Produces("application/json; charset=utf-8") @Transactional(Transactional.TxType.REQUIRED) public List> findAssetsInFolder( @PathParam("content-section") final String section, diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/rs/ContentItems.java b/ccm-cms/src/main/java/org/librecms/contentsection/rs/ContentItems.java index cff42b6e4..7453492e1 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/rs/ContentItems.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/rs/ContentItems.java @@ -128,6 +128,8 @@ public class ContentItems { result.put("itemId", Long.toString(item.getObjectId())); + result.put("name", item.getDisplayName()); + result.put("title", item.getTitle().getValue(globalizationHelper .getNegotiatedLocale())); @@ -155,7 +157,7 @@ public class ContentItems { @GET @Path("/") - @Produces("text/json; charset=utf-8") + @Produces("application/json; charset=utf-8") @Transactional(Transactional.TxType.REQUIRED) public List> findItems( @PathParam("content-section") final String section, @@ -177,7 +179,7 @@ public class ContentItems { && (type == null || type.trim().isEmpty())) { items = itemRepo.findByNameAndContentSection(query, - contentSection); + contentSection); } else if ((query == null || query.trim().isEmpty()) && (type != null && !type.trim().isEmpty())) { @@ -202,7 +204,7 @@ public class ContentItems { @GET @Path("/folders") - @Produces("text/json; charset=utf-8") + @Produces("application/json; charset=utf-8") @Transactional(Transactional.TxType.REQUIRED) public List> findItemsInRootFolder( @PathParam("content-section") final String section, @@ -221,7 +223,7 @@ public class ContentItems { @GET @Path("/folders/{folder}/") - @Produces("text/json; charset=utf-8") + @Produces("application/json; charset=utf-8") @Transactional(Transactional.TxType.REQUIRED) public List> findItemsInFolder( @PathParam("content-section") final String section, @@ -279,11 +281,11 @@ public class ContentItems { .stream() .map(item -> createItemMapEntry(item)) .collect(Collectors.toList()); - + final List> result = new ArrayList<>(); result.addAll(subFolderEntries); result.addAll(itemEntries); - + return result; } diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/rs/ContentSections.java b/ccm-cms/src/main/java/org/librecms/contentsection/rs/ContentSections.java index f4a1a331d..18339fd32 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/rs/ContentSections.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/rs/ContentSections.java @@ -47,7 +47,7 @@ public class ContentSections { @GET @Path("/") - @Produces("text/json; charset=utf-8") + @Produces("application/json; charset=utf-8") @Transactional(Transactional.TxType.REQUIRED) public List> listContentSections() { diff --git a/ccm-cms/src/main/java/org/librecms/pages/PagesRouter.java b/ccm-cms/src/main/java/org/librecms/pages/PagesRouter.java index ece61158e..4d95f732c 100644 --- a/ccm-cms/src/main/java/org/librecms/pages/PagesRouter.java +++ b/ccm-cms/src/main/java/org/librecms/pages/PagesRouter.java @@ -200,7 +200,7 @@ public class PagesRouter { @GET @Path("/{name:[\\w\\-]+}.{lang:\\w+}.json") - @Produces("text/json") + @Produces("application/json") @Transactional(Transactional.TxType.REQUIRED) public String getRootPageAsJson( @Context @@ -433,7 +433,7 @@ public class PagesRouter { */ @GET @Path("/{page:[\\w/]+}/{name:[\\w\\-]+}.{lang:\\w+}.json") - @Produces("text/json") + @Produces("application/json") @Transactional(Transactional.TxType.REQUIRED) public String getPageAsJson( @Context diff --git a/ccm-editor/Gruntfile.js b/ccm-editor/Gruntfile.js index b78967ff4..f6e1ec9e5 100644 --- a/ccm-editor/Gruntfile.js +++ b/ccm-editor/Gruntfile.js @@ -2,16 +2,14 @@ module.exports = function(grunt) { grunt.initConfig({ ts: { default : { - src: ["src/main/typescript/**/*.ts"], + tsconfig: true, options: { - module: "amd" + module: "amd", + moduleResolution: "classic" } } }, - clean: ['scripts/*.js', 'scripts/*.js.map', 'scripts/.tscache'] }); grunt.loadNpmTasks("grunt-ts"); - grunt.loadNpmTasks('grunt-contrib-clean'); grunt.registerTask("default", ["ts"]); }; - diff --git a/ccm-editor/src/main/resources/ccm-editor/ccm-editor.css b/ccm-editor/src/main/resources/ccm-editor/ccm-editor.css index b5d3ea7fe..90bc89bbd 100644 --- a/ccm-editor/src/main/resources/ccm-editor/ccm-editor.css +++ b/ccm-editor/src/main/resources/ccm-editor/ccm-editor.css @@ -82,25 +82,34 @@ padding: 1em 0.75em; position: absolute; - left: 50%; top: 50%; + left: 50%; - margin-top: -35em; - margin-left: -20em; + margin-top: -20em; + margin-left: -35em; width: 70em; height: 40em; overflow: scroll; } +.ccm-editor-selectdialog h1 { + padding: 0.5em; + margin-bottom: 0.8em; +} + .ccm-editor-selectdialog .ccm-editor-selectdialog-closebutton { - postion: absolute; + font-size: 1em; + + padding: 0.25em; + + position: absolute; top: 0; right: 0; - width: 1em; - height: 1em; + width: 2.5em; + height: 2.5em; } .ccm-editor-selectdialog div { diff --git a/ccm-cms-editor/src/main/typescript/ccm-editor/ccm-cms-editor.ts b/ccm-editor/src/main/typescript/ccm-editor/ccm-cms-editor.ts similarity index 86% rename from ccm-cms-editor/src/main/typescript/ccm-editor/ccm-cms-editor.ts rename to ccm-editor/src/main/typescript/ccm-editor/ccm-cms-editor.ts index 79bba934c..9080e98dc 100644 --- a/ccm-cms-editor/src/main/typescript/ccm-editor/ccm-cms-editor.ts +++ b/ccm-editor/src/main/typescript/ccm-editor/ccm-cms-editor.ts @@ -38,8 +38,8 @@ export class InsertInternalLinkCommand extends CCMEditorCommand { const closeButton = dialogElem .appendChild(document.createElement("button")); - closeButton.setAttribute("id", "ccm-editor-selectdialog-closebutton"); - closeButton.textContent = "✕"; + closeButton.setAttribute("class", "ccm-editor-selectdialog-closebutton"); + closeButton.textContent = "\u2715"; closeButton.addEventListener("click", function(event){ event.preventDefault(); const bodyElem = document.getElementsByTagName("body").item(0); @@ -127,12 +127,22 @@ export class InsertInternalLinkCommand extends CCMEditorCommand { } } }); + sectionsRequest.send(); + console.log("Current sections is \"" + currentSection + "\""); // Get items let itemsUrl = contextPrefix - + "/content-sections/" - + contentSectionSelect.value - + "/items"; + + "/content-sections"; + if (!(new RegExp("^/.*").test(currentSection))) { + console.log("Current sections does not start with an \"/\", adding one..."); + itemsUrl += "/"; + } + itemsUrl += currentSection; + if (!(new RegExp(".*/$").test(currentSection))) { + console.log("Current sections does not end with an \"/\", adding one..."); + itemsUrl += "/"; + } + itemsUrl += "items"; if (filterInput.value !== null && filterInput.value.length > 0) { itemsUrl + "?query=" + filterInput.value; } @@ -156,17 +166,25 @@ export class InsertInternalLinkCommand extends CCMEditorCommand { const selectItemButton = dataTitle .appendChild(document.createElement("button")); - selectItemButton.textContent = item["title"]; + if (item["title"] === null + || item["title"].length <= 0) { + selectItemButton.textContent = item["name"]; + } else { + selectItemButton.textContent = item["title"]; + } selectItemButton .addEventListener("click", function(event) { event.preventDefault(); - document.removeChild(dialogElem); + const bodyElem = document + .getElementsByTagName("body") + .item(0); + bodyElem.removeChild(dialogElem); document.getSelection().removeAllRanges(); document.getSelection().addRange(currentRange); - document.execCommand("insertLink", + document.execCommand("createLink", false, contextPrefix + "/redirect/?oid=" @@ -180,6 +198,7 @@ export class InsertInternalLinkCommand extends CCMEditorCommand { } } }); + itemsRequest.send(); const bodyElem = document.getElementsByTagName("body").item(0); bodyElem.appendChild(dialogFragment); diff --git a/ccm-editor/src/main/typescript/ccm-editor/ccm-editor.ts b/ccm-editor/src/main/typescript/ccm-editor/ccm-editor.ts index 9b16a1d37..1ff14c851 100644 --- a/ccm-editor/src/main/typescript/ccm-editor/ccm-editor.ts +++ b/ccm-editor/src/main/typescript/ccm-editor/ccm-editor.ts @@ -387,28 +387,28 @@ export class FormatBlockCommand extends CCMEditorCommand { private findBlockElement(node: Node): Element { if (node instanceof Element) { - console.log("Current node is an element."); + // console.log("Current node is an element."); const elem: Element = node as Element; - console.log("elem.tagName = " + elem.tagName.toLowerCase()); + // console.log("elem.tagName = " + elem.tagName.toLowerCase()); if(this.values.indexOf(elem.tagName.toLowerCase()) === -1) { - console.log("elem.tagName is not in the values array."); + // console.log("elem.tagName is not in the values array."); if (elem.parentNode === null) { - console.log("elem has no parent node. Returning null."); + // console.log("elem has no parent node. Returning null."); return null; } else { - console.log("Continuing with elem.parentNode"); + // console.log("Continuing with elem.parentNode"); return this.findBlockElement(elem.parentNode); } } else { return elem; } } else { - console.log("Current node is not an element node."); + // console.log("Current node is not an element node."); if (node.parentNode === null) { - console.log("Current node has no parent, returning null."); + // console.log("Current node has no parent, returning null."); return null; } else { - console.log("Continuing with parent node..."); + // console.log("Continuing with parent node..."); return this.findBlockElement(node.parentNode); } } diff --git a/pom.xml b/pom.xml index 012194373..28ea1f650 100644 --- a/pom.xml +++ b/pom.xml @@ -39,21 +39,20 @@ - + ccm-core - + ccm-testutils ccm-xafilesystemadapter - + ccm-editor - + ccm-cms - ccm-cms-editor - + ccm-cms-types-agenda ccm-cms-types-bookmark ccm-cms-types-decisiontree @@ -61,20 +60,20 @@ ccm-cms-types-faqitem ccm-cms-types-glossaryitem ccm-cms-types-minutes - + ccm-docrepo ccm-shortcuts - + ccm-theme-foundry - + ccm-bundle-devel ccm-bundle-devel-wildfly-web ccm-bundle-devel-wildfly ccm-bundle-devel-wildfly-swarm - + ccm-archetype-module ccm-cms-archetype-contenttype @@ -291,7 +290,7 @@ - + org.apache.maven.plugins @@ -315,7 +314,7 @@ - + org.wildfly.plugins wildfly-maven-plugin @@ -323,7 +322,7 @@ true - + org.codehaus.mojo versions-maven-plugin @@ -333,10 +332,10 @@ - + - @@ -359,8 +358,8 @@ hibernate-entitymanager 5.0.10.Final - - @@ -369,9 +368,9 @@ hibernate-envers 5.0.10.Final - - org.hibernate @@ -395,7 +394,7 @@ @@ -403,7 +402,7 @@ hibernate-search-orm 5.5.4.Final - + @@ -412,7 +411,7 @@ flyway-core 4.0.3 - + org.apache.shiro @@ -424,14 +423,14 @@ shiro-web 1.3.2 - + org.primefaces primefaces 6.1 - + @@ -456,13 +455,13 @@ vaadin-themes 8.1.2 --> - - - + - + org.apache.logging.log4j log4j-bom @@ -478,9 +477,9 @@ pom import - - @@ -488,14 +487,14 @@ lucene-core 2.4.1 - + org.apache.pdfbox pdfbox 1.4.0 - + commons-beanutils @@ -560,37 +559,37 @@ bcmail-jdk16 1.46 - + org.imgscalr imgscalr-lib 4.2 - + org.jsoup jsoup 1.10.3 - + org.apache.maven maven-artifact 3.3.9 - + net.sf.jtidy jtidy r938 - + oro oro 2.0.8 - + org.bouncycastle bcprov-jdk16 @@ -627,16 +626,16 @@ 2.9.0 import pom - + - + org.codehaus.woodstox woodstox-core-asl 4.4.1 - @@ -694,7 +693,7 @@ 8.2.1.Final test - + @@ -704,8 +703,8 @@ 0.7.9 test - - @@ -720,10 +719,10 @@ 1.3 test - - @@ -732,7 +731,7 @@ 2.2 - + com.h2database @@ -742,5 +741,5 @@ - +