Skip to content

Commit

Permalink
Wrapped image path update with feature config option.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbullock committed Sep 28, 2018
1 parent 8b66bfe commit a108a6f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
7 changes: 4 additions & 3 deletions jbake-core/src/main/java/org/jbake/app/Crawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,10 @@ private void crawlSourceFile(final File sourceFile, final String sha1, final Str
fileContents.put(Attributes.NO_EXTENSION_URI, uri.replace("/index.html", "/"));
}


// Prevent image source url's from breaking
HtmlUtil.fixImageSourceUrls(fileContents, config);
if (config.getImgPathUpdate()) {
// Prevent image source url's from breaking
HtmlUtil.fixImageSourceUrls(fileContents, config);
}

ODocument doc = new ODocument(documentType);
doc.fromMap(fileContents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,13 @@ public boolean getImgPathPrependHost() {
public void setImgPathPrependHost(boolean imgPathPrependHost) {
setProperty(JBakeProperty.IMG_PATH_PREPEND_HOST, imgPathPrependHost);
}

@Override
public boolean getImgPathUpdate() {
return getAsBoolean(JBakeProperty.IMG_PATH_UPDATE);
}

public void setImgPathUPdate(boolean imgPathUpdate) {
setProperty(JBakeProperty.IMG_PATH_UPDATE, imgPathUpdate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,15 @@ public interface JBakeConfiguration {
boolean getUriWithoutExtension();

/**
* @return Flag indicating if image paths should be prepended with {@link #getSiteHost()} value
* @return Flag indicating if image paths should be prepended with {@link #getSiteHost()} value - see {@link #getImgPathUpdate()}
*/
boolean getImgPathPrependHost();

/**
* @return Flag indicating if image paths should be updated
*/
boolean getImgPathUpdate();

/**
* @return Version of JBake
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class JBakeProperty {
public static final String THYMELEAF_LOCALE = "thymeleaf.locale";
public static final String URI_NO_EXTENSION = "uri.noExtension";
public static final String URI_NO_EXTENSION_PREFIX = "uri.noExtension.prefix";
public static final String IMG_PATH_UPDATE = "img.path.update";
public static final String IMG_PATH_PREPEND_HOST = "img.path.prepend.host";
public static final String VERSION = "version";

Expand Down
4 changes: 3 additions & 1 deletion jbake-core/src/main/resources/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,7 @@ index.posts_per_page=3
site.host=http://www.jbake.org
# String used to separate the header from the body
header.separator=~~~~~~
# update image path
img.path.update=false
# Prepend site.host to image paths
img.path.prepend.host=true
img.path.prepend.host=true

0 comments on commit a108a6f

Please sign in to comment.