From 17329d688b04310a900ce276186fb285f082ebf3 Mon Sep 17 00:00:00 2001 From: David Russell Date: Mon, 14 May 2018 16:15:55 +0700 Subject: [PATCH] Image delimiter repeat and transition param support. --- app/com/gitpitch/models/MarkdownModel.java | 12 ++++++++++++ app/com/gitpitch/services/ImageService.java | 20 +++++++++++++++++--- app/com/gitpitch/utils/YAMLOptions.java | 11 +++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/app/com/gitpitch/models/MarkdownModel.java b/app/com/gitpitch/models/MarkdownModel.java index 7bacfd2..a31e487 100644 --- a/app/com/gitpitch/models/MarkdownModel.java +++ b/app/com/gitpitch/models/MarkdownModel.java @@ -181,6 +181,10 @@ public class MarkdownModel implements Markdown { yOpts.fetchImageBgColor(pp) : YAMLOptions.DEFAULT_BG_COLOR; String defaultBgPosition = (yOpts != null) ? yOpts.fetchImageBgPosition(pp) : YAMLOptions.DEFAULT_BG_POSITION; + String defaultBgRepeat = (yOpts != null) ? + yOpts.fetchImageBgRepeat(pp) : YAMLOptions.DEFAULT_BG_REPEAT; + String defaultBgTransition = (yOpts != null) ? + yOpts.fetchTransition(pp) : YAMLOptions.DEFAULT_TRANSITION; return new StringBuffer(delimiter(md)) .append(imageService.buildBackground(md, @@ -189,6 +193,8 @@ public class MarkdownModel implements Markdown { defaultBgSize, defaultBgColor, defaultBgPosition, + defaultBgRepeat, + defaultBgTransition, this)).toString(); } else if (gistDelimFound(dp)) { @@ -654,6 +660,8 @@ public class MarkdownModel implements Markdown { 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_REPEAT = "repeat"; + public static final String DELIM_QUERY_TRANSITION = "transition"; public static final String DELIM_QUERY_FILE = "file"; public static final String DELIM_QUERY_TITLE = "title"; @@ -671,6 +679,10 @@ public class MarkdownModel implements Markdown { "\" data-background-color=\""; public static final String MD_IMAGE_POSITION = "\" data-background-position=\""; + public static final String MD_IMAGE_REPEAT = + "\" data-background-repeat=\""; + public static final String MD_IMAGE_TRANSITION = + "\" data-background-transition=\""; public static final String MD_BG_COLOR = ""; diff --git a/app/com/gitpitch/services/ImageService.java b/app/com/gitpitch/services/ImageService.java index d02c62d..9338821 100644 --- a/app/com/gitpitch/services/ImageService.java +++ b/app/com/gitpitch/services/ImageService.java @@ -47,7 +47,9 @@ public class ImageService { return buildBackground(yOpts.fetchImageBg(pp), yOpts.fetchImageBgSize(pp), yOpts.fetchImageBgColor(pp), - yOpts.fetchImageBgPosition(pp)); + yOpts.fetchImageBgPosition(pp), + yOpts.fetchImageBgRepeat(pp), + yOpts.fetchTransition(pp)); } public String buildBackground(String md, @@ -56,6 +58,8 @@ public class ImageService { String defaultSize, String defaultColor, String defaultPos, + String defaultRepeat, + String defaultTransition, MarkdownModel mdm) { String bgUrl = dp.get(MarkdownModel.DELIM_QUERY_IMAGE); @@ -63,13 +67,19 @@ public class ImageService { String bgSize = dp.get(MarkdownModel.DELIM_QUERY_SIZE, defaultSize); String bgColor = dp.get(MarkdownModel.DELIM_QUERY_COLOR, defaultColor); String bgPos = dp.get(MarkdownModel.DELIM_QUERY_POSITION, defaultPos); - return buildBackground(bgUrl, bgSize, bgColor, bgPos); + String bgRepeat = + dp.get(MarkdownModel.DELIM_QUERY_REPEAT, defaultRepeat); + String bgTransition = + dp.get(MarkdownModel.DELIM_QUERY_TRANSITION, defaultTransition); + return buildBackground(bgUrl, bgSize, bgColor, bgPos, bgRepeat, bgTransition); } private String buildBackground(String bgUrl, String bgSize, String bgColor, - String bgPosition) { + String bgPosition, + String bgRepeat, + String bgTransition) { return new StringBuffer(MarkdownModel.MD_SPACER) .append(MarkdownModel.MD_IMAGE_OPEN) @@ -80,6 +90,10 @@ public class ImageService { .append(bgColor) .append(MarkdownModel.MD_IMAGE_POSITION) .append(bgPosition) + .append(MarkdownModel.MD_IMAGE_REPEAT) + .append(bgRepeat) + .append(MarkdownModel.MD_IMAGE_TRANSITION) + .append(bgTransition) .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 a737e80..5c1194c 100644 --- a/app/com/gitpitch/utils/YAMLOptions.java +++ b/app/com/gitpitch/utils/YAMLOptions.java @@ -222,6 +222,15 @@ public final class YAMLOptions { } } + public String fetchImageBgRepeat(PitchParams pp) { + String bgRepeat = _yProps.get(IMAGE_BG_REPEAT_OPTION); + if (bgRepeat == null) { + return DEFAULT_BG_REPEAT; + } else { + return bgRepeat; + } + } + public String fetchTransition(PitchParams pp) { String transition = _yProps.get(TRANSITION_OPTION); @@ -400,6 +409,7 @@ public final class YAMLOptions { 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_BG_REPEAT = " "; 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"; @@ -416,6 +426,7 @@ public final class YAMLOptions { 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 IMAGE_BG_REPEAT_OPTION = "background-repeat"; private static final String TRANSITION_OPTION = "transition"; private static final String AUTOSLIDE_OPTION = "autoslide"; private static final String LOOP_OPTION = "loop";