Skip to content

Commit

Permalink
Merge pull request #24 from rimas-kudelis/master
Browse files Browse the repository at this point in the history
Some small fixes
  • Loading branch information
davetcc authored Feb 20, 2024
2 parents d8630e3 + e7c646e commit 8b89562
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public JoomlaImage getBodyImage() {
}

public boolean isPublished() {
return status == 0 || status == 1;
return status == 1;
}

public String getParent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<JoomlaContent> content = template.query(articleQuery, (resultSet, i) -> new JoomlaContent(
Expand All @@ -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());
Expand All @@ -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();

Expand All @@ -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<JoomlaContent> content = template.query(sqlCat, (resultSet, i) -> new JoomlaContent(
resultSet.getInt("id"),
Expand Down Expand Up @@ -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]*)");
Expand Down
17 changes: 0 additions & 17 deletions src/main/resources/categoryPage.toml.ftl

This file was deleted.

9 changes: 7 additions & 2 deletions src/main/resources/categoryPage.yaml.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@
---
title: "${joomlaData.title}"
description: "${joomlaData.metadesc}"
date: "${joomlaData.modifiedDateAsText}"
date: "${joomlaData.createdDateAsText}"
lastmod: "${joomlaData.modifiedDateAsText}"
<#if joomlaData.author??>
author: "${joomlaData.author}"
</#if>
showChildren: true
type: "category"

menu:
main:
name: "${joomlaData.title}"
identifier: "${joomlaData.alias}"
<#if joomlaData.category??>
parent: "${joomlaData.category}"
</#if>
---

${body}
${body}
2 changes: 1 addition & 1 deletion src/main/resources/customHtmlModule.yaml.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<#-- @ftlvariable name="joomlaData" type="com.thecoderscorner.web.hugojoomla.JoomlaContent" -->

${body}
${body}
17 changes: 0 additions & 17 deletions src/main/resources/defaultPage.toml.ftl

This file was deleted.

10 changes: 9 additions & 1 deletion src/main/resources/defaultPage.yaml.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
<#if joomlaData.introImage.isImagePresent()>
banner: "${joomlaData.introImage.url}"
</#if>
<#if joomlaData.parent??>
menu: "${joomlaData.parent}"
</#if>
<#if !joomlaData.isPublished()>
draft: true
</#if>
---
<#if joomlaData.bodyImage.isImagePresent() >
<img class="${joomlaData.bodyImage.htmlClass} titleimg" alt="${joomlaData.bodyImage.alt}" src="${joomlaData.bodyImage.url}"/>
Expand Down

0 comments on commit 8b89562

Please sign in to comment.