Skip to content

Commit

Permalink
rebased with master. added default type to configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
ancho committed May 9, 2017
1 parent 9f91a7f commit a788ee1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ public String getDefaultStatus() {
return getAsString(DEFAULT_STATUS);
}

@Override
public String getDefaultType() {
String type = getAsString(DEFAULT_TYPE);
if ( type.isEmpty() ) return null;
return type;
}

@Override
public String getDateFormat() {
return getAsString(DATE_FORMAT);
Expand Down Expand Up @@ -413,6 +420,15 @@ public void setDatabasePath(String path) {
setProperty(DB_PATH, path);
}

public void setDefaultStatus(String status) {
setProperty(DEFAULT_STATUS, status);
}

public void setDefaultType(String type) {
setProperty(DEFAULT_TYPE, type);
}


private File getAsFolder(String key) {
return (File) get(key);
}
Expand Down Expand Up @@ -465,11 +481,4 @@ private void setupDefaultTemplateFolder() {
String destinationPath = getAsString(TEMPLATE_FOLDER);
setTemplateFolder(new File(getSourceFolder(),destinationPath));
}

public void setDefaultStatus(String status) {
}

public void setDefaultType(String type) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ public interface JBakeConfiguration {
*/
String getDefaultStatus();

String DEFAULT_TYPE = "default.type";

/**
* Default type to use (in order to avoid putting it in all files)
*/
String getDefaultType();

String DATE_FORMAT = "date.format";

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jbake/parser/MarkupEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ public Map<String, Object> parse(JBakeConfiguration config, File file) {
}
}

if (config.getString(Keys.DEFAULT_TYPE) != null) {
if (config.getDefaultType() != null) {
// default type has been set
if (content.get(Crawler.Attributes.TYPE) == null) {
// file hasn't got type so use default
content.put(Crawler.Attributes.TYPE, config.getString(Keys.DEFAULT_TYPE));
content.put(Crawler.Attributes.TYPE, config.getDefaultType());
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ asciidoctor.attributes.export.prefix=
date.format=yyyy-MM-dd
# default status
default.status=draft
# default type
default.type=
# comma delimited default markdown extensions; for available extensions:
# http://www.decodified.com/pegdown/api/org/pegdown/Extensions.html
markdown.extensions=HARDWRAPS,AUTOLINKS,FENCED_CODE_BLOCKS,DEFINITIONS
Expand Down

0 comments on commit a788ee1

Please sign in to comment.