diff --git a/app/com/gitpitch/models/MarkdownModel.java b/app/com/gitpitch/models/MarkdownModel.java index b90132c..7bacfd2 100644 --- a/app/com/gitpitch/models/MarkdownModel.java +++ b/app/com/gitpitch/models/MarkdownModel.java @@ -179,11 +179,17 @@ public class MarkdownModel implements Markdown { yOpts.fetchImageBgSize(pp) : YAMLOptions.DEFAULT_BG_SIZE; String defaultBgColor = (yOpts != null) ? yOpts.fetchImageBgColor(pp) : YAMLOptions.DEFAULT_BG_COLOR; + String defaultBgPosition = (yOpts != null) ? + yOpts.fetchImageBgPosition(pp) : YAMLOptions.DEFAULT_BG_POSITION; return new StringBuffer(delimiter(md)) .append(imageService.buildBackground(md, - dp, pp, defaultBgSize, defaultBgColor, this)) - .toString(); + dp, + pp, + defaultBgSize, + defaultBgColor, + defaultBgPosition, + this)).toString(); } else if (gistDelimFound(dp)) { return gistService.build(md, dp, pp, yOpts, this); @@ -647,6 +653,7 @@ public class MarkdownModel implements Markdown { 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_POSITION = "position"; public static final String DELIM_QUERY_FILE = "file"; public static final String DELIM_QUERY_TITLE = "title"; @@ -662,6 +669,8 @@ public class MarkdownModel implements Markdown { "\" data-background-size=\""; public static final String MD_IMAGE_COLOR = "\" data-background-color=\""; + public static final String MD_IMAGE_POSITION = + "\" data-background-position=\""; public static final String MD_BG_COLOR = ""; diff --git a/app/com/gitpitch/services/ImageService.java b/app/com/gitpitch/services/ImageService.java index 3b67841..d02c62d 100644 --- a/app/com/gitpitch/services/ImageService.java +++ b/app/com/gitpitch/services/ImageService.java @@ -46,7 +46,8 @@ public class ImageService { return buildBackground(yOpts.fetchImageBg(pp), yOpts.fetchImageBgSize(pp), - yOpts.fetchImageBgColor(pp)); + yOpts.fetchImageBgColor(pp), + yOpts.fetchImageBgPosition(pp)); } public String buildBackground(String md, @@ -54,18 +55,21 @@ public class ImageService { PitchParams pp, String defaultSize, String defaultColor, + String defaultPos, MarkdownModel mdm) { String bgUrl = dp.get(MarkdownModel.DELIM_QUERY_IMAGE); bgUrl = mdm.linkLive(pp, bgUrl); String bgSize = dp.get(MarkdownModel.DELIM_QUERY_SIZE, defaultSize); String bgColor = dp.get(MarkdownModel.DELIM_QUERY_COLOR, defaultColor); - return buildBackground(bgUrl, bgSize, bgColor); + String bgPos = dp.get(MarkdownModel.DELIM_QUERY_POSITION, defaultPos); + return buildBackground(bgUrl, bgSize, bgColor, bgPos); } private String buildBackground(String bgUrl, String bgSize, - String bgColor) { + String bgColor, + String bgPosition) { return new StringBuffer(MarkdownModel.MD_SPACER) .append(MarkdownModel.MD_IMAGE_OPEN) @@ -74,6 +78,8 @@ public class ImageService { .append(bgSize) .append(MarkdownModel.MD_IMAGE_COLOR) .append(bgColor) + .append(MarkdownModel.MD_IMAGE_POSITION) + .append(bgPosition) .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 232c8fd..a737e80 100644 --- a/app/com/gitpitch/utils/YAMLOptions.java +++ b/app/com/gitpitch/utils/YAMLOptions.java @@ -213,6 +213,15 @@ public final class YAMLOptions { } } + public String fetchImageBgPosition(PitchParams pp) { + String bgPosition = _yProps.get(IMAGE_BG_POSITION_OPTION); + if (bgPosition == null) { + return DEFAULT_BG_POSITION; + } else { + return bgPosition; + } + } + public String fetchTransition(PitchParams pp) { String transition = _yProps.get(TRANSITION_OPTION); @@ -390,6 +399,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_BG_POSITION = "center"; 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"; @@ -405,6 +415,7 @@ public final class YAMLOptions { 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 IMAGE_BG_POSITION_OPTION = "background-position"; private static final String TRANSITION_OPTION = "transition"; private static final String AUTOSLIDE_OPTION = "autoslide"; private static final String LOOP_OPTION = "loop";