Handle custom css overrides as external stylesheets on slideshow.

This commit is contained in:
David Russell 2016-09-28 19:59:46 +07:00
parent b0c992f9cc
commit 85b3840ebb
4 changed files with 36 additions and 5 deletions

View File

@ -376,6 +376,24 @@ public class PitchController extends Controller {
} // offline action
/*
* CustomCSS returns text/css overrides for a slideshow.
*/
public Result customCSS(String grs,
String user,
String repo,
String branch) {
PitchParams pp =
PitchParams.build(grsOnCall(grs), user, repo, branch);
Optional<SlideshowModel> ssmo = pitchService.cachedYAML(pp);
String customStyle = CUSTOM_CSS_NOT_FOUND;
if(ssmo.isPresent()) {
customStyle = ssmo.get().fetchThemeOverride();
}
return ok(customStyle).as("text/css");
} // customCss action
/*
* Gist generates and renders GitHub-Gist HTML for
* embedding within slideshows.
@ -395,4 +413,7 @@ public class PitchController extends Controller {
"GitPitch Slideshow print service temporarily unavailable.";
private static final String PITCHME_OFFLINE_ERROR =
"GitPitch Slideshow offline service temporarily unavailable.";
private static final String CUSTOM_CSS_NOT_FOUND =
"// Custom CSS not found.";
}

View File

@ -185,6 +185,17 @@ public class SlideshowModel {
return customCSS;
}
/*
* Return theme override css for slideshow.
*/
public String fetchThemeOverrideCSS() {
return com.gitpitch.controllers.routes.PitchController.customCSS(_pp.grs,
_pp.user,
_pp.repo,
_pp.branch).url();
}
/*
* Return active theme font for slideshow.
*/

View File

@ -19,13 +19,9 @@
<link href="@deps.highlightjs(offline)/@ssm.fetchHighlightCSS()" rel="stylesheet" type="text/css"/>
<link href="@deps.octicons(offline)/octicons.css" rel="stylesheet" type="text/css"/>
<link href="@deps.fontawesome(offline)/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
@SlideshowStyle()
@if(ssm.hasThemeOverride()) {
<style>
@ssm.fetchThemeOverride()
</style>
<link href="@ssm.fetchThemeOverrideCSS()" rel="stylesheet" type="text/css"/>
}
</head>
<body>

View File

@ -20,6 +20,9 @@ GET /pitchme/offline/:grs/:user/:repo/:b/:t/PITCHME.zip com.gitpitch.cont
# Handle GitHub OAuth Callback
# GET /pitchme/authorized com.gitpitch.controllers.AuthController.authorized(code:String ?= null, state:String ?= null)
# Serve PITCHME.css custom theme styling.
GET /pitchme/custom-css/:grs/:user/:repo/:b/PITCHME.css com.gitpitch.controllers.PitchController.customCSS(grs:String, user:String, repo:String, b:String)
# Serve PITCHME.md markdown.
GET /pitchme/markdown/:grs/:user/:repo/:b/PITCHME.md com.gitpitch.controllers.PitchController.markdown(grs:String, user:String, repo:String, b:String)