diff --git a/.gitignore b/.gitignore index 15cd579..8d1ef4f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ server.pid .classpath .project .settings/ +.DS_Store diff --git a/app/com/gitpitch/models/MarkdownModel.java b/app/com/gitpitch/models/MarkdownModel.java index 12798cd..096d19f 100644 --- a/app/com/gitpitch/models/MarkdownModel.java +++ b/app/com/gitpitch/models/MarkdownModel.java @@ -173,10 +173,12 @@ public class MarkdownModel implements Markdown { String defaultBgSize = (yOpts != null) ? yOpts.fetchImageBgSize(pp) : YAMLOptions.DEFAULT_BG_SIZE; + String defaultBgColor = (yOpts != null) ? + yOpts.fetchImageBgColor(pp) : YAMLOptions.DEFAULT_BG_COLOR; return new StringBuffer(delimiter(md)) .append(imageService.buildBackground(md, - dp, pp, defaultBgSize, this)) + dp, pp, defaultBgSize, defaultBgColor, this)) .toString(); } else if (gistDelimFound(dp)) { @@ -634,6 +636,7 @@ public class MarkdownModel implements Markdown { public static final String DELIM_QUERY_CODE = "code"; public static final String DELIM_QUERY_LANG = "lang"; public static final String DELIM_QUERY_SIZE = "size"; + public static final String DELIM_QUERY_COLOR = "color"; public static final String DELIM_QUERY_FILE = "file"; public static final String DELIM_QUERY_TITLE = "title"; @@ -647,6 +650,8 @@ public class MarkdownModel implements Markdown { ""; public static final String MD_SPACER = "\n"; public static final String DATA_IMAGE_ATTR = "data-background-image="; diff --git a/app/com/gitpitch/services/ImageService.java b/app/com/gitpitch/services/ImageService.java index df178d3..3b67841 100644 --- a/app/com/gitpitch/services/ImageService.java +++ b/app/com/gitpitch/services/ImageService.java @@ -44,28 +44,36 @@ public class ImageService { public String buildBackground(PitchParams pp, YAMLOptions yOpts) { - return buildBackground(yOpts.fetchImageBg(pp), yOpts.fetchImageBgSize(pp)); + return buildBackground(yOpts.fetchImageBg(pp), + yOpts.fetchImageBgSize(pp), + yOpts.fetchImageBgColor(pp)); } public String buildBackground(String md, DelimParams dp, PitchParams pp, String defaultSize, + String defaultColor, MarkdownModel mdm) { String bgUrl = dp.get(MarkdownModel.DELIM_QUERY_IMAGE); bgUrl = mdm.linkLive(pp, bgUrl); String bgSize = dp.get(MarkdownModel.DELIM_QUERY_SIZE, defaultSize); - return buildBackground(bgUrl, bgSize); + String bgColor = dp.get(MarkdownModel.DELIM_QUERY_COLOR, defaultColor); + return buildBackground(bgUrl, bgSize, bgColor); } - private String buildBackground(String bgUrl, String bgSize) { + private String buildBackground(String bgUrl, + String bgSize, + String bgColor) { return new StringBuffer(MarkdownModel.MD_SPACER) .append(MarkdownModel.MD_IMAGE_OPEN) .append(bgUrl) .append(MarkdownModel.MD_IMAGE_SIZE) .append(bgSize) + .append(MarkdownModel.MD_IMAGE_COLOR) + .append(bgColor) .append(MarkdownModel.MD_CLOSER) .append(MarkdownModel.MD_SPACER) .toString(); diff --git a/app/com/gitpitch/utils/YAMLOptions.java b/app/com/gitpitch/utils/YAMLOptions.java index 66e7f0f..51d548e 100644 --- a/app/com/gitpitch/utils/YAMLOptions.java +++ b/app/com/gitpitch/utils/YAMLOptions.java @@ -183,6 +183,15 @@ public final class YAMLOptions { } } + public String fetchImageBgColor(PitchParams pp) { + String bgColor = _yProps.get(IMAGE_BG_COLOR_OPTION); + if (bgColor == null) { + return DEFAULT_BG_COLOR; + } else { + return bgColor; + } + } + public String fetchTransition(PitchParams pp) { String transition = _yProps.get(TRANSITION_OPTION); @@ -359,6 +368,7 @@ public final class YAMLOptions { public static final String PITCHME_YAML = "PITCHME.yaml"; public static final String DEFAULT_BG_SIZE = "100% 100%"; + public static final String DEFAULT_BG_COLOR = " "; public static final String DEFAULT_TRANSITION = "slide"; public static final String MATHJAX_DEFAULT = "TeX-MML-AM_CHTML"; public static final String HIGHLIGHT_DARK_DEFAULT = "github-gist.css"; @@ -373,6 +383,7 @@ public final class YAMLOptions { private static final String LOGO_POSITION_OPTION = "logo-position"; private static final String IMAGE_BG_OPTION = "background"; private static final String IMAGE_BG_SIZE_OPTION = "background-size"; + private static final String IMAGE_BG_COLOR_OPTION = "background-color"; private static final String TRANSITION_OPTION = "transition"; private static final String AUTOSLIDE_OPTION = "autoslide"; private static final String LOOP_OPTION = "loop";