mirror of
https://github.com/gitpitch/gitpitch.git
synced 2024-04-18 07:30:55 +08:00
Added new (bg) color slide delim, plus color arg support on code and gist delims.
This commit is contained in:
parent
dff755f869
commit
de375fbd66
|
@ -30,6 +30,7 @@ import com.gitpitch.services.VideoService;
|
|||
import com.gitpitch.services.GISTService;
|
||||
import com.gitpitch.services.CodeService;
|
||||
import com.gitpitch.services.ShortcutsService;
|
||||
import com.gitpitch.services.SlideService;
|
||||
import com.gitpitch.git.GRSManager;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
@ -57,6 +58,7 @@ public class MarkdownModel implements Markdown {
|
|||
private final GISTService gistService;
|
||||
private final CodeService codeService;
|
||||
private final ShortcutsService shortcutsService;
|
||||
private final SlideService slideService;
|
||||
private final GRSManager grsManager;
|
||||
private final MarkdownRenderer mrndr;
|
||||
private final String markdown;
|
||||
|
@ -69,6 +71,7 @@ public class MarkdownModel implements Markdown {
|
|||
GISTService gistService,
|
||||
CodeService codeService,
|
||||
ShortcutsService shortcutsService,
|
||||
SlideService slideService,
|
||||
GRSManager grsManager,
|
||||
@Nullable @Assisted MarkdownRenderer mrndr) {
|
||||
|
||||
|
@ -77,6 +80,7 @@ public class MarkdownModel implements Markdown {
|
|||
this.gistService = gistService;
|
||||
this.codeService = codeService;
|
||||
this.shortcutsService = shortcutsService;
|
||||
this.slideService = slideService;
|
||||
this.grsManager = grsManager;
|
||||
this.mrndr = mrndr;
|
||||
|
||||
|
@ -185,6 +189,8 @@ public class MarkdownModel implements Markdown {
|
|||
return gistService.build(md, dp, pp, yOpts, this);
|
||||
} else if(codeDelimFound(dp)) {
|
||||
return codeService.build(md, dp, pp, yOpts, this);
|
||||
} else if(colorDelimFound(dp)) {
|
||||
return slideService.buildColorBackground(md, dp, pp, yOpts, this);
|
||||
}
|
||||
|
||||
if (yOpts != null && yOpts.hasImageBg()) {
|
||||
|
@ -415,6 +421,10 @@ public class MarkdownModel implements Markdown {
|
|||
return dp.get(DELIM_QUERY_CODE) != null;
|
||||
}
|
||||
|
||||
private boolean colorDelimFound(DelimParams dp) {
|
||||
return dp.get(DELIM_QUERY_COLOR) != null;
|
||||
}
|
||||
|
||||
private String delimiter(String md) {
|
||||
return (md.startsWith(hSlideDelim)) ? horizDelim() : vertDelim();
|
||||
}
|
||||
|
@ -652,6 +662,8 @@ public class MarkdownModel implements Markdown {
|
|||
"\" data-background-size=\"";
|
||||
public static final String MD_IMAGE_COLOR =
|
||||
"\" data-background-color=\"";
|
||||
public static final String MD_BG_COLOR =
|
||||
"<!-- .slide: data-background=\"";
|
||||
public static final String MD_CLOSER = "\" -->";
|
||||
public static final String MD_SPACER = "\n";
|
||||
public static final String DATA_IMAGE_ATTR = "data-background-image=";
|
||||
|
|
|
@ -53,6 +53,7 @@ public class SlideService {
|
|||
*
|
||||
* 1. Clean delimiter and
|
||||
* 2. Optionally slide bg-image based on YAMLOptions.hasImageBg.
|
||||
* 3. Or slide color delimiter.
|
||||
*/
|
||||
public String build(String md,
|
||||
DelimParams dp,
|
||||
|
@ -61,26 +62,61 @@ public class SlideService {
|
|||
MarkdownModel mdm) {
|
||||
|
||||
StringBuffer structure = new StringBuffer(mdm.extractDelim(md));
|
||||
try {
|
||||
|
||||
String slideType = mdm.isHorizontal(md) ?
|
||||
mdm.horizDelim() : mdm.vertDelim();
|
||||
try {
|
||||
|
||||
structure = new StringBuffer(mdm.extractDelim(md))
|
||||
.append(MarkdownModel.MD_SPACER);
|
||||
|
||||
String yamlBg = null;
|
||||
if (yOpts != null && yOpts.hasImageBg()) {
|
||||
yamlBg = imageService.buildBackground(pp, yOpts);
|
||||
String yamlBg = imageService.buildBackground(pp, yOpts);
|
||||
structure.append(yamlBg).append(MarkdownModel.MD_SPACER);
|
||||
} else {
|
||||
String cbg = buildColorMarkdown(dp);
|
||||
if(cbg != null) {
|
||||
structure.append(cbg).append(MarkdownModel.MD_SPACER);
|
||||
}
|
||||
}
|
||||
|
||||
if (yamlBg != null) {
|
||||
structure.append(yamlBg).append(MarkdownModel.MD_SPACER);
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
log.warn("build: ex={}", ex);
|
||||
}
|
||||
|
||||
log.debug("build: returning structure={}", structure.toString());
|
||||
|
||||
return structure.toString();
|
||||
}
|
||||
|
||||
public String buildColorBackground(String md,
|
||||
DelimParams dp,
|
||||
PitchParams pp,
|
||||
YAMLOptions yOpts,
|
||||
MarkdownModel mdm) {
|
||||
|
||||
StringBuffer structure = new StringBuffer(mdm.extractDelim(md));
|
||||
|
||||
try {
|
||||
|
||||
structure = new StringBuffer(mdm.extractDelim(md))
|
||||
.append(MarkdownModel.MD_SPACER);
|
||||
|
||||
String bg = buildColorMarkdown(dp);
|
||||
if(bg != null) {
|
||||
structure.append(bg).append(MarkdownModel.MD_SPACER);
|
||||
}
|
||||
|
||||
} catch(Exception ex) {
|
||||
log.warn("buildColorDelim: ex={}", ex);
|
||||
}
|
||||
|
||||
log.debug("buildColorDelim: returning structure={}", structure.toString());
|
||||
return structure.toString();
|
||||
}
|
||||
|
||||
private String buildColorMarkdown(DelimParams dp) {
|
||||
String bgColor = dp.get(MarkdownModel.DELIM_QUERY_COLOR, null);
|
||||
String bg = MarkdownModel.MD_BG_COLOR + bgColor + MarkdownModel.MD_CLOSER;
|
||||
return bgColor != null ? bg : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user