Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of MarkupEngines, TemplateEngines and ModelExtractors #704

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ script:
- "./gradlew check --stacktrace"

jdk:
- openjdk15
- openjdk16
- openjdk11

jobs:
include:

- jdk: openjdk15
- jdk: openjdk16
os: osx

- jdk: openjdk11
Expand All @@ -42,7 +42,6 @@ jobs:
- "./gradlew -PskipSigning jacocoRootReport coveralls -i --stacktrace"

notifications:
irc: "irc.freenode.org#jbake"
webhooks:
urls:
- https://webhooks.gitter.im/e/2d332fabb02dba68a36b
Expand Down
3 changes: 1 addition & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ clone_depth: 10
environment:
TERM: dumb
matrix:
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- JAVA_HOME: C:\Program Files\Java\jdk11
- JAVA_HOME: C:\Program Files\Java\jdk15
- JAVA_HOME: C:\Program Files\Java\jdk16

install:
- SET PATH=%JAVA_HOME%\bin;%PATH%
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ plugins {
id "eclipse"
id "idea"
id "io.sdkman.vendors" version "2.0.0" apply false
id "com.github.kt3k.coveralls" version "2.10.2" apply false
id "org.sonarqube" version "3.1.1" apply false
id 'com.github.ben-manes.versions' version '0.38.0'
id "nebula.optional-base" version "5.0.3" apply false
id "com.github.kt3k.coveralls" version "2.12.0" apply false
id "org.sonarqube" version "3.2.0" apply false
id 'com.github.ben-manes.versions' version '0.39.0'
id "nebula.optional-base" version "6.0.0" apply false
id 'org.ajoberstar.grgit' version "$grgitVersion"
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
id "com.github.breadmoirai.github-release" version "2.2.12"
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions jbake-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies {
processResources {
from("src/main/resources") {
include 'default.properties'
duplicatesStrategy DuplicatesStrategy.EXCLUDE
expand jbakeVersion: project.version,
timestamp: grgit.head().dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss'['VV']'")),
gitHash: grgit.head().abbreviatedId
Expand Down
26 changes: 10 additions & 16 deletions jbake-core/src/main/java/org/jbake/app/Asset.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ public void copy() {
* @param path The starting path
*/
public void copy(File path) {
FileFilter filter = new FileFilter() {
@Override
public boolean accept(File file) {
return (!config.getAssetIgnoreHidden() || !file.isHidden()) && (file.isFile() || FileUtil.directoryOnlyIfNotIgnored(file, config));
}
};
FileFilter filter = file -> (!config.getAssetIgnoreHidden() || !file.isHidden()) && (file.isFile() || FileUtil.directoryOnlyIfNotIgnored(file, config));
copy(path, config.getDestinationFolder(), filter);
}

Expand Down Expand Up @@ -96,21 +91,20 @@ public void copySingleFile(File asset) {
* @return true if the path provided points to a file in the asset folder.
*/
public boolean isAssetFile(File path) {
boolean isAsset = false;

try {
if(FileUtil.directoryOnlyIfNotIgnored(path.getParentFile(), config)) {
if (FileUtil.isFileInDirectory(path, config.getAssetFolder())) {
isAsset = true;
} else if (FileUtil.isFileInDirectory(path, config.getContentFolder())
&& FileUtil.getNotContentFileFilter(config).accept(path)) {
isAsset = true;
}
if (FileUtil.directoryOnlyIfNotIgnored(path.getParentFile(), config)
&& (FileUtil.isFileInDirectory(path, config.getAssetFolder()) || assetsInContentFolder(path))) {
return true;
}
} catch (IOException ioe) {
LOGGER.error("Unable to determine the path to asset file {}", path.getPath(), ioe);
}
return isAsset;
return false;
}

private boolean assetsInContentFolder(File path) throws IOException {
return FileUtil.isFileInDirectory(path, config.getContentFolder())
&& FileUtil.getNotContentFileFilter(config).accept(path);
}

/**
Expand Down
8 changes: 1 addition & 7 deletions jbake-core/src/main/java/org/jbake/app/ContentStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.executor.OResultSet;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import org.jbake.launcher.SystemExit;
import org.jbake.model.DocumentModel;
import org.jbake.model.DocumentTypes;
import org.jbake.model.ModelAttributes;
Expand Down Expand Up @@ -149,8 +147,6 @@ public void close() {
}

public void shutdown() {

// Orient.instance().shutdown();
}

private void startupIfEnginesAreMissing() {
Expand All @@ -169,16 +165,14 @@ private void startupIfEnginesAreMissing() {

public void drop() {
activateOnCurrentThread();
// db.drop();

orient.drop(name);
}

private void activateOnCurrentThread() {
if (db != null) {
db.activateOnCurrentThread();
} else {
System.out.println("db is null on activate");
logger.warn("db is null on activate");
}
}

Expand Down
21 changes: 9 additions & 12 deletions jbake-core/src/main/java/org/jbake/app/Crawler.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.jbake.app;

import com.orientechnologies.orient.core.record.impl.ODocument;
import org.apache.commons.configuration2.CompositeConfiguration;
import org.apache.commons.io.FilenameUtils;
import org.jbake.app.configuration.JBakeConfiguration;
import org.jbake.app.configuration.JBakeConfigurationFactory;
import org.jbake.exception.JBakeException;
import org.jbake.launcher.SystemExit;
import org.jbake.model.DocumentModel;
import org.jbake.model.DocumentStatus;
import org.jbake.model.DocumentTypes;
Expand All @@ -19,7 +20,6 @@
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Date;
import java.util.Map;

/**
* Crawls a file system looking for content.
Expand Down Expand Up @@ -141,9 +141,8 @@ private void crawlDataFiles(File path) {
String sha1 = buildHash(sourceFile);
String uri = buildDataFileURI(sourceFile);
boolean process = true;
DocumentStatus status = DocumentStatus.NEW;
String docType = config.getDataFileDocType();
status = findDocumentStatus(uri, sha1);
DocumentStatus status = findDocumentStatus(uri, sha1);
if (status == DocumentStatus.UPDATED) {
sb.append(" : modified ");
db.deleteContent(uri);
Expand All @@ -156,8 +155,6 @@ private void crawlDataFiles(File path) {
}
if (DocumentStatus.NEW == status) {
sb.append(" : new ");
}
if (process) { // new or updated
crawlDataFile(sourceFile, sha1, uri, docType);
}
logger.info("{}", sb);
Expand Down Expand Up @@ -202,7 +199,7 @@ private String buildDataFileURI(final File sourceFile) {
String uri = FileUtil.asPath(sourceFile).replace(FileUtil.asPath(config.getDataFolder()), "");
// strip off leading /
if (uri.startsWith(FileUtil.URI_SEPARATOR_CHAR)) {
uri = uri.substring(1, uri.length());
uri = uri.substring(1);
}
return uri;
}
Expand All @@ -216,7 +213,7 @@ private String createUri(String uri) {
+ URLEncoder.encode(FilenameUtils.getBaseName(uri), StandardCharsets.UTF_8.name())
+ config.getOutputExtension();
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Missing UTF-8 encoding??", e); // Won't happen unless JDK is broken.
throw new JBakeException(SystemExit.ERROR, "Missing UTF-8 encoding??", e); // Won't happen unless JDK is broken.
}
}

Expand All @@ -229,7 +226,7 @@ private String createNoExtensionUri(String uri) {
+ "index"
+ config.getOutputExtension();
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Missing UTF-8 encoding??", e); // Won't happen unless JDK is broken.
throw new JBakeException(SystemExit.ERROR, "Missing UTF-8 encoding??", e); // Won't happen unless JDK is broken.
}
}

Expand Down Expand Up @@ -258,7 +255,7 @@ private void crawlDataFile(final File sourceFile, final String sha1, final Strin
logger.warn("{} couldn't be parsed so it has been ignored!", sourceFile);
}
} catch (Exception ex) {
throw new RuntimeException("Failed crawling file: " + sourceFile.getPath() + " " + ex.getMessage(), ex);
throw new JBakeException(SystemExit.ERROR, "Failed crawling file: " + sourceFile.getPath() + " " + ex.getMessage(), ex);
}
}

Expand Down Expand Up @@ -293,8 +290,8 @@ private void addAdditionalDocumentAttributes(DocumentModel document, File source
document.setCached(true);

if (document.getStatus().equals(ModelAttributes.Status.PUBLISHED_DATE)
&& (document.getDate() != null)
&& new Date().after(document.getDate())) {
&& (document.getDate() != null)
&& new Date().after(document.getDate())) {
document.setStatus(ModelAttributes.Status.PUBLISHED);
}

Expand Down
Loading