diff --git a/src/main/java/com/thecoderscorner/web/hugojoomla/JoomlaContent.java b/src/main/java/com/thecoderscorner/web/hugojoomla/JoomlaContent.java index 72fb7f7..4145fce 100644 --- a/src/main/java/com/thecoderscorner/web/hugojoomla/JoomlaContent.java +++ b/src/main/java/com/thecoderscorner/web/hugojoomla/JoomlaContent.java @@ -119,7 +119,7 @@ public JoomlaImage getBodyImage() { } public boolean isPublished() { - return status == 0 || status == 1; + return status == 1; } public String getParent() { diff --git a/src/main/java/com/thecoderscorner/web/hugojoomla/JoomlaHugoConverter.java b/src/main/java/com/thecoderscorner/web/hugojoomla/JoomlaHugoConverter.java index ebc65a8..5a9a4ff 100644 --- a/src/main/java/com/thecoderscorner/web/hugojoomla/JoomlaHugoConverter.java +++ b/src/main/java/com/thecoderscorner/web/hugojoomla/JoomlaHugoConverter.java @@ -98,10 +98,8 @@ public void performConversion() { "select C.id as id, U.username as username, C.created as created, C.modified as modified, C.introtext as intro, " + " C.`fulltext` as full, D.path as path, C.title as title, C.alias as alias,\n" + " C.metadesc as metadesc, C.images as images, C.state as state, D.alias as catAlias \n" + - "from REPLSTR_content C, REPLSTR_users U, REPLSTR_categories D\n" + - "where C.created_by = U.id\n" + - " and D.id = C.catid\n" + - " and D.path <> 'uncategorised'\n"; + "from REPLSTR_content C LEFT JOIN REPLSTR_users U ON (U.id = C.created_by) LEFT JOIN REPLSTR_categories D ON (D.id = C.catid)\n" + + "where D.path <> 'uncategorised'\n"; articleQuery = articleQuery.replace("REPLSTR", dbExtension); List content = template.query(articleQuery, (resultSet, i) -> new JoomlaContent( @@ -120,7 +118,7 @@ public void performConversion() { resultSet.getString("catAlias") )); - content.stream().filter(JoomlaContent::isPublished).forEach(c-> { + content.stream().forEach(c-> { nastyContentChecker.checkForNastyContent(c); Path path = Paths.get(pathToOutput); logger.info("processing {} {} {}", c.getTitle(), c.getCategory(), c.getAlias()); @@ -129,10 +127,6 @@ public void performConversion() { buildTomlOutput(c, newPath.resolve(c.getAlias() + ".md"), this.contentTemplate, this.htmltomarkdown); }); - content.stream().filter(c-> !c.isPublished()).forEach( - c->logger.info("Skipping deleted content {} {}", c.getTitle(), c.getId()) - ); - performCategoryConversion(); performCustomHtmlModulesConversion(); @@ -148,8 +142,7 @@ private void performCategoryConversion() { "SELECT C.id AS id, C.alias AS alias, C.description AS description, C.path AS path,\n" + " C.created_time AS created_time, C.modified_time AS modified_time, C.published AS published, C.description description, C.title AS title,\n" + " C.metadesc AS metadesc, P.alias AS parent\n" + - "FROM REPLSTR_categories C, REPLSTR_categories P\n" + - "WHERE C.parent_id = P.id\n"; + "FROM REPLSTR_categories C LEFT JOIN REPLSTR_categories P ON (P.id = C.parent_id)\n"; sqlCat = sqlCat.replace("REPLSTR", dbExtension); List content = template.query(sqlCat, (resultSet, i) -> new JoomlaContent( resultSet.getInt("id"), @@ -245,8 +238,8 @@ public void buildTomlOutput(JoomlaContent content, Path resolve, Template templa private String urlSorter(String body) { String sqlForArticleLink = "SELECT C.alias AS alias, D.path AS path\n" + - "FROM REPLSTR_content C, REPLSTR_categories D\n" + - "WHERE C.id=? AND C.catid = D.id\n"; + "FROM REPLSTR_content C LEFT JOIN REPLSTR_categories D ON c.catid = D.id\n" + + "WHERE C.id=?\n"; sqlForArticleLink = sqlForArticleLink.replace("REPLSTR", dbExtension); Pattern linkPattern = Pattern.compile("index.php.option=com_content.amp.view=article.amp.id=([0-9]*).amp.catid=([0-9]*).amp.Itemid=([0-9]*)"); diff --git a/src/main/resources/categoryPage.toml.ftl b/src/main/resources/categoryPage.toml.ftl deleted file mode 100644 index b08cb6d..0000000 --- a/src/main/resources/categoryPage.toml.ftl +++ /dev/null @@ -1,17 +0,0 @@ -<#-- @ftlvariable name="joomlaData" type="com.thecoderscorner.web.hugojoomla.JoomlaContent" --> ---- -title: "${joomlaData.title}" -description: "${joomlaData.metadesc}" -date: "${joomlaData.modifiedDateAsText}" -author: "${joomlaData.author}" -showChildren: true -type: "category" - -menu: - main: - name: "${joomlaData.title}" - identifier: "${joomlaData.alias}" - parent: "${joomlaData.category}" ---- - -${body} \ No newline at end of file diff --git a/src/main/resources/categoryPage.yaml.ftl b/src/main/resources/categoryPage.yaml.ftl index 30b6131..8d78621 100644 --- a/src/main/resources/categoryPage.yaml.ftl +++ b/src/main/resources/categoryPage.yaml.ftl @@ -2,8 +2,11 @@ --- title: "${joomlaData.title}" description: "${joomlaData.metadesc}" -date: "${joomlaData.modifiedDateAsText}" +date: "${joomlaData.createdDateAsText}" +lastmod: "${joomlaData.modifiedDateAsText}" +<#if joomlaData.author??> author: "${joomlaData.author}" + showChildren: true type: "category" @@ -11,7 +14,9 @@ menu: main: name: "${joomlaData.title}" identifier: "${joomlaData.alias}" +<#if joomlaData.category??> parent: "${joomlaData.category}" + --- -${body} \ No newline at end of file +${body} diff --git a/src/main/resources/customHtmlModule.yaml.ftl b/src/main/resources/customHtmlModule.yaml.ftl index 5f9505f..e23bfdb 100644 --- a/src/main/resources/customHtmlModule.yaml.ftl +++ b/src/main/resources/customHtmlModule.yaml.ftl @@ -1,3 +1,3 @@ <#-- @ftlvariable name="joomlaData" type="com.thecoderscorner.web.hugojoomla.JoomlaContent" --> -${body} \ No newline at end of file +${body} diff --git a/src/main/resources/defaultPage.toml.ftl b/src/main/resources/defaultPage.toml.ftl deleted file mode 100644 index 9497994..0000000 --- a/src/main/resources/defaultPage.toml.ftl +++ /dev/null @@ -1,17 +0,0 @@ -<#-- @ftlvariable name="joomlaData" type="com.thecoderscorner.web.hugojoomla.JoomlaContent" --> -+++ -title = "${joomlaData.title}" -description = "${joomlaData.metadesc}" -tags = [ ${tags} ] -type = "blog" -date = "${joomlaData.modifiedDateAsText}" -author = "${joomlaData.author}" -<#if joomlaData.introImage.isImagePresent()> -banner = "${joomlaData.introImage.url}" - -menu = "${joomlaData.parent}" -+++ -<#if joomlaData.bodyImage.isImagePresent() > - ${joomlaData.bodyImage.alt} - -${body} \ No newline at end of file diff --git a/src/main/resources/defaultPage.yaml.ftl b/src/main/resources/defaultPage.yaml.ftl index 004ebbb..0ba1bb0 100644 --- a/src/main/resources/defaultPage.yaml.ftl +++ b/src/main/resources/defaultPage.yaml.ftl @@ -4,12 +4,20 @@ title: "${joomlaData.title}" description: "${joomlaData.metadesc}" tags: [ ${tags} ] type: "post" -date: "${joomlaData.modifiedDateAsText}" +date: "${joomlaData.createdDateAsText}" +lastmod: "${joomlaData.modifiedDateAsText}" +<#if joomlaData.author??> author: "${joomlaData.author}" + <#if joomlaData.introImage.isImagePresent()> banner: "${joomlaData.introImage.url}" +<#if joomlaData.parent??> menu: "${joomlaData.parent}" + +<#if !joomlaData.isPublished()> +draft: true + --- <#if joomlaData.bodyImage.isImagePresent() > ${joomlaData.bodyImage.alt}