mirror of
https://github.com/gitpitch/gitpitch.git
synced 2024-04-18 07:30:55 +08:00
RFE #24 support for multiple presentations within single repo.
A new parameter (p) on slideshow URLs accepts a relative path to a custom directory within a repo where PITCHME.* can be found for a given presentation. If (p) is not specified, the default behavior using the root directory within the repo is preserved. This feature supports the creation and management of multiple presentations within a single repo (branch), potentially sharing common assets such as images, styles, etc. The following changes were required to support this feature: - Optional parameter (p) on slideshow urls - Each (p) generates isolated print PDF - Each (p) generates isolated offline ZIP - Caching of YAML and Markdown is now (p) aware
This commit is contained in:
parent
8b8cc52d33
commit
c41167dacc
|
@ -124,11 +124,13 @@ public class PitchController extends Controller {
|
|||
String branch,
|
||||
String grs,
|
||||
String theme,
|
||||
String pitchme,
|
||||
String notes,
|
||||
String offline) {
|
||||
|
||||
PitchParams pp =
|
||||
PitchParams.build(grsOnCall(grs), user, repo, branch, theme, notes);
|
||||
PitchParams.build(grsOnCall(grs),
|
||||
user, repo, branch, theme, pitchme, notes);
|
||||
boolean isOffline =
|
||||
(offline == null) ? false : Boolean.parseBoolean(offline);
|
||||
Optional<GitRepoModel> grmo = pitchService.cachedRepo(pp);
|
||||
|
@ -188,12 +190,14 @@ public class PitchController extends Controller {
|
|||
String repo,
|
||||
String branch,
|
||||
String theme,
|
||||
String pitchme,
|
||||
String notes,
|
||||
String fragments,
|
||||
String offline) {
|
||||
|
||||
PitchParams pp =
|
||||
PitchParams.build(grsOnCall(grs), user, repo, branch, theme, notes);
|
||||
PitchParams.build(grsOnCall(grs),
|
||||
user, repo, branch, theme, pitchme, notes);
|
||||
boolean printing =
|
||||
(fragments == null) ? false : !Boolean.parseBoolean(fragments);
|
||||
boolean isOffline =
|
||||
|
@ -249,10 +253,12 @@ public class PitchController extends Controller {
|
|||
public CompletionStage<Result> markdown(String grs,
|
||||
String user,
|
||||
String repo,
|
||||
String branch) {
|
||||
String branch,
|
||||
String pitchme) {
|
||||
|
||||
PitchParams pp =
|
||||
PitchParams.build(grsOnCall(grs), user, repo, branch);
|
||||
PitchParams.build(grsOnCall(grs),
|
||||
user, repo, branch, null, pitchme);
|
||||
Optional<MarkdownModel> mdmo = pitchService.cachedMarkdown(pp);
|
||||
|
||||
if (mdmo.isPresent()) {
|
||||
|
@ -297,10 +303,12 @@ public class PitchController extends Controller {
|
|||
String repo,
|
||||
String branch,
|
||||
String theme,
|
||||
String pitchme,
|
||||
String notes) {
|
||||
|
||||
PitchParams pp =
|
||||
PitchParams.build(grsOnCall(grs), user, repo, branch, theme, notes);
|
||||
PitchParams.build(grsOnCall(grs),
|
||||
user, repo, branch, theme, pitchme, notes);
|
||||
Optional<File> pdfo = pitchService.cachedPDF(pp);
|
||||
|
||||
if (pdfo.isPresent()) {
|
||||
|
@ -339,11 +347,13 @@ public class PitchController extends Controller {
|
|||
String repo,
|
||||
String branch,
|
||||
String theme,
|
||||
String pitchme,
|
||||
String notes) {
|
||||
|
||||
|
||||
PitchParams pp =
|
||||
PitchParams.build(grsOnCall(grs), user, repo, branch, theme, notes);
|
||||
PitchParams.build(grsOnCall(grs),
|
||||
user, repo, branch, theme, pitchme, notes);
|
||||
log.debug("offline: pp={}", pp);
|
||||
|
||||
Optional<File> zipo = pitchService.cachedZip(pp);
|
||||
|
|
|
@ -67,14 +67,14 @@ public abstract class GRSService {
|
|||
/*
|
||||
* Return zero if file download completes successfully.
|
||||
*/
|
||||
public int download(PitchParams pp, String filename) {
|
||||
public int download(PitchParams pp, String filename, String filePath) {
|
||||
|
||||
int status = 999;
|
||||
|
||||
GRS grs = grsManager.get(pp);
|
||||
GRSService grsService = grsManager.getService(grs);
|
||||
Path branchPath = diskService.ensure(pp);
|
||||
String grsLink = raw(pp, filename, true);
|
||||
String grsLink = raw(pp, filePath, true);
|
||||
log.debug("download: grsLink={}", grsLink);
|
||||
|
||||
if (grsService.call(pp, grsLink)) {
|
||||
|
|
|
@ -516,8 +516,10 @@ public class MarkdownModel implements Markdown {
|
|||
.append(pp.user)
|
||||
.append(SLASH)
|
||||
.append(pp.repo)
|
||||
.append(QMARK_BRANCH)
|
||||
.append(PARAM_BRANCH)
|
||||
.append(pp.branch)
|
||||
.append(PARAM_PITCHME)
|
||||
.append(pp.pitchme)
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
@ -580,7 +582,8 @@ public class MarkdownModel implements Markdown {
|
|||
private static final String MD_VSLIDE_GIST = "?gist=";
|
||||
|
||||
private static final String SLASH = "/";
|
||||
private static final String QMARK_BRANCH = "?b=";
|
||||
private static final String PARAM_BRANCH = "?b=";
|
||||
private static final String PARAM_PITCHME = "&p=";
|
||||
private static final String MD_LINK_DELIM = "](";
|
||||
private static final String MD_LINK_ABS = "http";
|
||||
private static final String MD_LINK_SLASH = "/";
|
||||
|
|
|
@ -75,14 +75,17 @@ public class SlideshowModel {
|
|||
com.gitpitch.controllers.routes.PitchController.markdown(pp.grs,
|
||||
pp.user,
|
||||
pp.repo,
|
||||
pp.branch).url();
|
||||
pp.branch,
|
||||
pp.pitchme).url();
|
||||
|
||||
this._pretty = new StringBuffer(SLASH)
|
||||
.append(this._pp.user)
|
||||
.append(SLASH)
|
||||
.append(this._pp.repo)
|
||||
.append(QMARK_BRANCH)
|
||||
.append(PARAM_BRANCH)
|
||||
.append(this._pp.branch)
|
||||
.append(PARAM_PITCHME)
|
||||
.append(this._pp.pitchme)
|
||||
.toString();
|
||||
|
||||
this._cacheKey = genKey(pp);
|
||||
|
@ -109,8 +112,10 @@ public class SlideshowModel {
|
|||
.append(pp.user)
|
||||
.append(SLASH)
|
||||
.append(pp.repo)
|
||||
.append(QMARK_BRANCH)
|
||||
.append(PARAM_BRANCH)
|
||||
.append(pp.branch)
|
||||
.append(PARAM_PITCHME)
|
||||
.append(pp.pitchme)
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
@ -387,7 +392,8 @@ public class SlideshowModel {
|
|||
}
|
||||
|
||||
private static final String SLASH = "/";
|
||||
private static final String QMARK_BRANCH = "?b=";
|
||||
private static final String PARAM_BRANCH = "?b=";
|
||||
private static final String PARAM_PITCHME = "&p=";
|
||||
private static final String PITCHME_YAML = "PITCHME.yaml";
|
||||
/*
|
||||
* Model prefix identifier for cache key generator.
|
||||
|
|
|
@ -98,6 +98,16 @@ public class DiskService {
|
|||
return ensure(bwd(pp));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Ensure PitchParams branch working sub-directory exists.
|
||||
*/
|
||||
public Path ensure(PitchParams pp, String subdir) {
|
||||
|
||||
return (subdir != null) ?
|
||||
ensure(asPath(pp, subdir)) : ensure(bwd(pp));
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure PitchParams branch working directory exists.
|
||||
*/
|
||||
|
|
|
@ -248,7 +248,8 @@ public class GitService {
|
|||
|
||||
GRS grs = grsManager.get(pp);
|
||||
GRSService grsService = grsManager.getService(grs);
|
||||
int downYAML = grsService.download(pp, PITCHME_YAML);
|
||||
int downYAML = grsService.download(pp,
|
||||
PitchParams.PITCHME_YAML, pp.YAML());
|
||||
boolean downOk = downYAML == STATUS_OK;
|
||||
log.debug("fetchYAML: pp={}, downloaded YAML={}", pp, downYAML);
|
||||
|
||||
|
@ -317,7 +318,8 @@ public class GitService {
|
|||
GRS grs = grsManager.get(pp);
|
||||
GRSService grsService = grsManager.getService(grs);
|
||||
|
||||
int downStatus = grsService.download(pp, PITCHME_MD);
|
||||
int downStatus = grsService.download(pp,
|
||||
PitchParams.PITCHME_MD, pp.MD());
|
||||
|
||||
if (downStatus == STATUS_OK) {
|
||||
|
||||
|
@ -403,8 +405,6 @@ public class GitService {
|
|||
private static final String GHUB_REPO_META =
|
||||
"https://api.github.com/repos/";
|
||||
private static final String GIT_MASTER = "master";
|
||||
private static final String PITCHME_MD = "PITCHME.md";
|
||||
private static final String PITCHME_YAML = "PITCHME.yaml";
|
||||
private static final String SLASH = "/";
|
||||
private static final int HTTP_OK = 200;
|
||||
private static final int STATUS_OK = 0;
|
||||
|
|
|
@ -181,11 +181,13 @@ public class OfflineService {
|
|||
|
||||
int status = STATUS_UNDEF;
|
||||
|
||||
Path zipRoot = null;
|
||||
|
||||
try {
|
||||
|
||||
Path zipRoot = prepareZipRoot(pp);
|
||||
zipRoot = prepareZipRoot(pp);
|
||||
|
||||
status = fetchOnlineMarkdown(pp);
|
||||
status = fetchOnlineMarkdown(pp, zipRoot);
|
||||
|
||||
if (status == STATUS_OK)
|
||||
status = processMarkdown(pp, zipRoot, ssmo);
|
||||
|
@ -197,13 +199,13 @@ public class OfflineService {
|
|||
status = fetchSlideshowHTML(pp, zipRoot);
|
||||
|
||||
if (status == STATUS_OK)
|
||||
fetchFixedDependencies(pp);
|
||||
fetchFixedDependencies(pp, zipRoot);
|
||||
|
||||
if (status == STATUS_OK)
|
||||
fetchYAMLDependencies(pp);
|
||||
fetchYAMLDependencies(pp, zipRoot);
|
||||
|
||||
if (status == STATUS_OK)
|
||||
status = buildZip(pp);
|
||||
status = buildZip(pp, zipRoot);
|
||||
|
||||
} catch (Exception zex) {
|
||||
log.warn("generateZip: pp={}, ex={}", zex);
|
||||
|
@ -212,9 +214,9 @@ public class OfflineService {
|
|||
/*
|
||||
* Clean up artifacts if failed to generate zip.
|
||||
*/
|
||||
if (status != STATUS_OK) {
|
||||
diskService.delete(pp, PITCHME_ZIP);
|
||||
diskService.deepDelete(pp, ZIP_ROOT_DIR);
|
||||
if (status != STATUS_OK && zipRoot != null) {
|
||||
diskService.delete(zipRoot.resolve(PITCHME_ZIP));
|
||||
diskService.deepDelete(zipRoot.resolve(ZIP_ROOT_DIR).toFile());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,23 +227,29 @@ public class OfflineService {
|
|||
* Prepare zip archive root directory on disk.
|
||||
*/
|
||||
private Path prepareZipRoot(PitchParams pp) {
|
||||
return diskService.ensure(diskService.asPath(pp, ZIP_ROOT_DIR));
|
||||
Path zipRoot = diskService.ensure(pp);
|
||||
if(pp.pitchme != null) {
|
||||
zipRoot = zipRoot.resolve(pp.pitchme);
|
||||
}
|
||||
zipRoot = zipRoot.resolve(ZIP_ROOT_DIR);
|
||||
return diskService.ensure(zipRoot);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fetch online PITCHME.md into ZIP_MD_DIR.
|
||||
*/
|
||||
private int fetchOnlineMarkdown(PitchParams pp) {
|
||||
private int fetchOnlineMarkdown(PitchParams pp, Path zipRoot) {
|
||||
|
||||
String murl =
|
||||
com.gitpitch.controllers.routes.PitchController.markdown(pp.grs,
|
||||
pp.user,
|
||||
pp.repo,
|
||||
pp.branch)
|
||||
pp.branch,
|
||||
pp.pitchme)
|
||||
.absoluteURL(isEncrypted(), hostname());
|
||||
|
||||
Path zipMdPath =
|
||||
diskService.ensure(diskService.asPath(pp, ZIP_MD_DIR));
|
||||
diskService.ensure(zipRoot.resolve(ZIP_MD_DIR));
|
||||
return diskService.download(pp,
|
||||
zipMdPath, murl, PITCHME_ONLINE_MD,
|
||||
grsManager.get(pp).getHeaders());
|
||||
|
@ -258,6 +266,7 @@ public class OfflineService {
|
|||
pp.branch,
|
||||
pp.grs,
|
||||
pp.theme,
|
||||
pp.pitchme,
|
||||
pp.notes,
|
||||
ENABLED)
|
||||
.absoluteURL(isEncrypted(), hostname());
|
||||
|
@ -277,6 +286,7 @@ public class OfflineService {
|
|||
pp.repo,
|
||||
pp.branch,
|
||||
pp.theme,
|
||||
pp.pitchme,
|
||||
pp.notes,
|
||||
ENABLED,
|
||||
ENABLED)
|
||||
|
@ -289,11 +299,11 @@ public class OfflineService {
|
|||
/*
|
||||
* Fetch fixed JS and CSS dependencies for GitPitch slideshow.
|
||||
*/
|
||||
private void fetchFixedDependencies(PitchParams pp)
|
||||
private void fetchFixedDependencies(PitchParams pp, Path zipRoot)
|
||||
throws java.io.IOException {
|
||||
|
||||
Path destPath =
|
||||
diskService.ensure(diskService.asPath(pp, ZIP_ASSETS_DIR));
|
||||
diskService.ensure(zipRoot.resolve(ZIP_ASSETS_DIR));
|
||||
|
||||
if(env.isProd()) {
|
||||
|
||||
|
@ -328,7 +338,7 @@ public class OfflineService {
|
|||
int status = STATUS_UNDEF;
|
||||
|
||||
String consumed = null;
|
||||
Path mdOnlinePath = diskService.asPath(pp, PITCHME_ONLINE_PATH);
|
||||
Path mdOnlinePath = zipRoot.resolve(PITCHME_ONLINE_PATH);
|
||||
File mdOnlineFile = mdOnlinePath.toFile();
|
||||
|
||||
if (mdOnlineFile.exists()) {
|
||||
|
@ -349,7 +359,7 @@ public class OfflineService {
|
|||
}).collect(Collectors.joining("\n"));
|
||||
|
||||
Path mdOfflinePath =
|
||||
diskService.asPath(pp, PITCHME_OFFLINE_PATH);
|
||||
zipRoot.resolve(PITCHME_OFFLINE_PATH);
|
||||
Files.write(mdOfflinePath, consumed.getBytes());
|
||||
|
||||
fetchOnlineAssets(pp, zipRoot);
|
||||
|
@ -375,15 +385,15 @@ public class OfflineService {
|
|||
|
||||
List<String> assetUrls = null;
|
||||
|
||||
Path mdOnelinePath = diskService.asPath(pp, PITCHME_ONLINE_PATH);
|
||||
File mdOnlineFile = mdOnelinePath.toFile();
|
||||
Path mdOnlinePath = zipRoot.resolve(PITCHME_ONLINE_PATH);
|
||||
File mdOnlineFile = mdOnlinePath.toFile();
|
||||
|
||||
if (mdOnlineFile.exists()) {
|
||||
|
||||
MarkdownModel markdownModel =
|
||||
(MarkdownModel) markdownModelFactory.create(null);
|
||||
|
||||
try (Stream<String> stream = Files.lines(mdOnelinePath)) {
|
||||
try (Stream<String> stream = Files.lines(mdOnlinePath)) {
|
||||
|
||||
assetUrls = stream.map(md -> {
|
||||
return markdownModel.offlineAssets(md);
|
||||
|
@ -391,9 +401,8 @@ public class OfflineService {
|
|||
|
||||
log.debug("fetchOnlineAssets: assetUrls={}", assetUrls);
|
||||
|
||||
Path zipMdAssetsPath =
|
||||
diskService.ensure(diskService.asPath(pp,
|
||||
ZIP_MD_ASSETS_DIR));
|
||||
Path zipMdAssetsPath = zipRoot.resolve(ZIP_MD_ASSETS_DIR);
|
||||
zipMdAssetsPath = diskService.ensure(zipMdAssetsPath);
|
||||
|
||||
List<String> fetched = new ArrayList<String>();
|
||||
|
||||
|
@ -419,7 +428,7 @@ public class OfflineService {
|
|||
/*
|
||||
* Fetch PITCHME.yaml dependencies into zip archive.
|
||||
*/
|
||||
private void fetchYAMLDependencies(PitchParams pp) {
|
||||
private void fetchYAMLDependencies(PitchParams pp, Path zipRoot) {
|
||||
|
||||
GRSService grsService =
|
||||
grsManager.getService(grsManager.get(pp));
|
||||
|
@ -433,8 +442,7 @@ public class OfflineService {
|
|||
String logoName = FilenameUtils.getName(logoUrl);
|
||||
|
||||
Path zipAssetsPath =
|
||||
diskService.ensure(diskService.asPath(pp,
|
||||
ZIP_ASSETS_DIR));
|
||||
diskService.ensure(zipRoot.resolve(ZIP_ASSETS_DIR));
|
||||
diskService.download(pp, zipAssetsPath,
|
||||
logoUrl, logoName, grsManager.get(pp).getHeaders());
|
||||
log.debug("fetchYAMLDependencies: downloaded logo={}", logoUrl);
|
||||
|
@ -453,7 +461,7 @@ public class OfflineService {
|
|||
*/
|
||||
if (yOpts == null || !yOpts.mathEnabled(pp)) {
|
||||
|
||||
Path destPath = diskService.asPath(pp, ZIP_ASSETS_DIR);
|
||||
Path destPath = zipRoot.resolve(ZIP_ASSETS_DIR);
|
||||
String revealVersion =
|
||||
configuration.getString("gitpitch.dependency.revealjs");
|
||||
Path mathPluginPath = Paths.get(destPath.toString(),
|
||||
|
@ -474,12 +482,13 @@ public class OfflineService {
|
|||
/*
|
||||
* Build PITCHME.zip.
|
||||
*/
|
||||
private int buildZip(PitchParams pp) {
|
||||
private int buildZip(PitchParams pp, Path zipRoot) {
|
||||
|
||||
/*
|
||||
* Remove PITCHME_ONLINE_MD from zip directory.
|
||||
*/
|
||||
diskService.delete(pp, PITCHME_ONLINE_PATH);
|
||||
Path onlinePath = zipRoot.resolve(PITCHME_ONLINE_PATH);
|
||||
diskService.delete(onlinePath);
|
||||
|
||||
/*
|
||||
* CMD: zip -r PITCHME.zip PITCHME
|
||||
|
@ -490,8 +499,8 @@ public class OfflineService {
|
|||
PITCHME_ZIP,
|
||||
ZIP_ROOT_DIR};
|
||||
|
||||
Path bwd = diskService.bwd(pp);
|
||||
return shellService.exec(ZIP_CMD, pp, bwd, cmd);
|
||||
Path zipWd = diskService.ensure(pp, pp.pitchme);
|
||||
return shellService.exec(ZIP_CMD, pp, zipWd, cmd);
|
||||
}
|
||||
|
||||
public boolean isEncrypted() {
|
||||
|
@ -515,9 +524,9 @@ public class OfflineService {
|
|||
}
|
||||
|
||||
private static final String ZIP_ROOT_DIR = "PITCHME";
|
||||
private static final String ZIP_MD_DIR = "PITCHME/assets/md";
|
||||
private static final String ZIP_MD_ASSETS_DIR = "PITCHME/assets/md/assets";
|
||||
private static final String ZIP_ASSETS_DIR = "PITCHME/assets";
|
||||
private static final String ZIP_MD_DIR = "assets/md";
|
||||
private static final String ZIP_MD_ASSETS_DIR = "assets/md/assets";
|
||||
private static final String ZIP_ASSETS_DIR = "assets";
|
||||
private static final String PITCHME_ONLINE_MD = "PITCHME.mdo";
|
||||
private static final String PITCHME_OFFLINE_MD = "PITCHME.md";
|
||||
private static final String PITCHME_ONLINE_PATH =
|
||||
|
|
|
@ -34,6 +34,7 @@ import play.libs.ws.*;
|
|||
|
||||
import javax.inject.*;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
|
@ -188,14 +189,14 @@ public class PitchService {
|
|||
*/
|
||||
public Optional<File> cachedPDF(PitchParams pp) {
|
||||
|
||||
File pdfFile = diskService.asFile(pp, PITCHME_PDF);
|
||||
File pdfFile = diskService.asFile(pp, pp.PDF());
|
||||
long pdfAge = System.currentTimeMillis() - pdfFile.lastModified();
|
||||
|
||||
log.debug("cachedPDF: pdfAge={}, max={}, file={}",
|
||||
pdfAge, cacheTimeout.pdf(pp), pdfFile);
|
||||
|
||||
if (pdfAge > cacheTimeout.pdf(pp)) {
|
||||
diskService.delete(pp, PITCHME_PDF);
|
||||
diskService.delete(pp, pp.PDF());
|
||||
}
|
||||
|
||||
return pdfFile.exists() ? Optional.of(pdfFile) : Optional.empty();
|
||||
|
@ -234,15 +235,16 @@ public class PitchService {
|
|||
*/
|
||||
public Optional<File> cachedZip(PitchParams pp) {
|
||||
|
||||
File zipFile = diskService.asFile(pp, PITCHME_ZIP);
|
||||
Path zipPath = diskService.ensure(pp, pp.pitchme);
|
||||
File zipFile = zipPath.resolve(PITCHME_ZIP).toFile();
|
||||
long zipAge = System.currentTimeMillis() - zipFile.lastModified();
|
||||
|
||||
log.debug("cachedZip: zipAge={}, max={}, file={}",
|
||||
zipAge, cacheTimeout.zip(pp), zipFile);
|
||||
|
||||
if (zipAge > cacheTimeout.zip(pp)) {
|
||||
diskService.delete(pp, PITCHME_ZIP);
|
||||
diskService.deepDelete(pp, PITCHME_ZIP_DIR);
|
||||
diskService.delete(zipPath.resolve(PITCHME_ZIP));
|
||||
diskService.deepDelete(zipPath.resolve(PITCHME_ZIP_DIR).toFile());
|
||||
log.debug("cachedZip: deleted expired zip artifacts.");
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public class PrintService {
|
|||
CompletableFuture<Void> syncFuture =
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
|
||||
Path branchPath = diskService.ensure(pp);
|
||||
Path branchPath = diskService.ensure(pp, pp.pitchme);
|
||||
int pdfStatus = generatePDF(pp);
|
||||
|
||||
if (pdfStatus != STATUS_OK) {
|
||||
|
@ -149,8 +149,8 @@ public class PrintService {
|
|||
|
||||
log.debug("generatePDF: pp={}", pp);
|
||||
Path branchPath = diskService.ensure(pp);
|
||||
diskService.delete(pp, PITCHME_PDF);
|
||||
String filePath = diskService.asFile(pp, PITCHME_PDF).toString();
|
||||
diskService.delete(pp, pp.PDF());
|
||||
String filePath = diskService.asFile(pp, pp.PDF()).toString();
|
||||
|
||||
String slideshowUrl =
|
||||
com.gitpitch.controllers.routes.PitchController.slideshow(pp.grs,
|
||||
|
@ -158,6 +158,7 @@ public class PrintService {
|
|||
pp.repo,
|
||||
pp.branch,
|
||||
pp.theme,
|
||||
pp.pitchme,
|
||||
pp.notes,
|
||||
PRINT_NO_FRAGS,
|
||||
null)
|
||||
|
|
|
@ -88,6 +88,7 @@ public class GitRepoRenderer {
|
|||
_grm.name(),
|
||||
_pp.branch,
|
||||
_pp.theme,
|
||||
_pp.pitchme,
|
||||
_pp.notes, null).toString();
|
||||
|
||||
this._slideshowURL = com.gitpitch.controllers.routes.PitchController
|
||||
|
@ -96,13 +97,15 @@ public class GitRepoRenderer {
|
|||
_grm.name(),
|
||||
_pp.branch,
|
||||
_pp.theme,
|
||||
_pp.pitchme,
|
||||
_pp.notes, null, null).toString();
|
||||
|
||||
this._markdownURL = com.gitpitch.controllers.routes.PitchController
|
||||
.markdown(_pp.grs,
|
||||
_grm.owner(),
|
||||
_grm.name(),
|
||||
_pp.branch).toString();
|
||||
_pp.branch,
|
||||
_pp.pitchme).toString();
|
||||
|
||||
Optional<GRS> grso =
|
||||
this._grsServices.stream()
|
||||
|
@ -269,6 +272,7 @@ public class GitRepoRenderer {
|
|||
_grm.name(),
|
||||
_pp.branch,
|
||||
theme,
|
||||
_pp.pitchme,
|
||||
_pp.notes, null).toString();
|
||||
}
|
||||
|
||||
|
@ -384,6 +388,7 @@ public class GitRepoRenderer {
|
|||
_pp.branch,
|
||||
grs,
|
||||
_pp.theme,
|
||||
_pp.pitchme,
|
||||
_pp.notes,
|
||||
null)
|
||||
.absoluteURL(isEncrypted(),
|
||||
|
@ -394,6 +399,7 @@ public class GitRepoRenderer {
|
|||
_pp.branch,
|
||||
grs,
|
||||
_pp.theme,
|
||||
_pp.pitchme,
|
||||
_pp.notes, null).toString();
|
||||
}
|
||||
|
||||
|
@ -404,6 +410,7 @@ public class GitRepoRenderer {
|
|||
_pp.branch,
|
||||
_pp.grs,
|
||||
theme,
|
||||
_pp.pitchme,
|
||||
_pp.notes,
|
||||
null).toString();
|
||||
}
|
||||
|
@ -415,6 +422,7 @@ public class GitRepoRenderer {
|
|||
_pp.repo,
|
||||
_pp.branch,
|
||||
_pp.theme,
|
||||
_pp.pitchme,
|
||||
_pp.notes).toString();
|
||||
}
|
||||
|
||||
|
@ -425,6 +433,7 @@ public class GitRepoRenderer {
|
|||
_pp.repo,
|
||||
_pp.branch,
|
||||
_pp.theme,
|
||||
_pp.pitchme,
|
||||
_pp.notes).toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ public class PitchParams {
|
|||
public String theme;
|
||||
public String notes;
|
||||
public String grs;
|
||||
public String pitchme;
|
||||
|
||||
private PitchParams(String grs,
|
||||
String user,
|
||||
|
@ -63,6 +64,16 @@ public class PitchParams {
|
|||
String repo,
|
||||
String branch,
|
||||
String theme,
|
||||
String pitchme) {
|
||||
|
||||
this(grs, user, repo, branch, theme, pitchme, null);
|
||||
}
|
||||
private PitchParams(String grs,
|
||||
String user,
|
||||
String repo,
|
||||
String branch,
|
||||
String theme,
|
||||
String pitchme,
|
||||
String notes) {
|
||||
|
||||
this.grs = grs;
|
||||
|
@ -76,6 +87,7 @@ public class PitchParams {
|
|||
else
|
||||
this.theme = DEFAULT_THEME;
|
||||
|
||||
this.pitchme = pitchme;
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
|
@ -108,9 +120,20 @@ public class PitchParams {
|
|||
String repo,
|
||||
String branch,
|
||||
String theme,
|
||||
String pitchme) {
|
||||
|
||||
return new PitchParams(grs, user, repo, branch, theme, pitchme);
|
||||
}
|
||||
|
||||
public static PitchParams build(String grs,
|
||||
String user,
|
||||
String repo,
|
||||
String branch,
|
||||
String theme,
|
||||
String pitchme,
|
||||
String notes) {
|
||||
|
||||
return new PitchParams(grs, user, repo, branch, theme, notes);
|
||||
return new PitchParams(grs, user, repo, branch, theme, pitchme, notes);
|
||||
}
|
||||
|
||||
public static boolean isDarkTheme(String theme) {
|
||||
|
@ -126,6 +149,21 @@ public class PitchParams {
|
|||
.toString();
|
||||
}
|
||||
|
||||
public String MD() {
|
||||
return (pitchme != null) ?
|
||||
pitchme + SLASH + PITCHME_MD : PITCHME_MD;
|
||||
}
|
||||
|
||||
public String YAML() {
|
||||
return (pitchme != null) ?
|
||||
pitchme + SLASH + PITCHME_YAML : PITCHME_YAML;
|
||||
}
|
||||
|
||||
public String PDF() {
|
||||
return (pitchme != null) ?
|
||||
pitchme + SLASH + PITCHME_PDF : PITCHME_PDF;
|
||||
}
|
||||
|
||||
public boolean isMaster() {
|
||||
return GIT_MASTER.equals(this.branch);
|
||||
}
|
||||
|
@ -163,6 +201,8 @@ public class PitchParams {
|
|||
.append(branch)
|
||||
.append(" [ ")
|
||||
.append(theme)
|
||||
.append(", ")
|
||||
.append(pitchme)
|
||||
.append(" ]")
|
||||
.toString();
|
||||
}
|
||||
|
@ -177,6 +217,9 @@ public class PitchParams {
|
|||
return DEFAULT_THEMES.contains(themeName);
|
||||
}
|
||||
|
||||
public static final String PITCHME_MD = "PITCHME.md";
|
||||
public static final String PITCHME_YAML = "PITCHME.yaml";
|
||||
public static final String PITCHME_PDF = "PITCHME.pdf";
|
||||
public static final String DEFAULT_THEME = "white";
|
||||
public static final String DEFAULT_THEME_CSS = "white.css";
|
||||
private static final List<String> DARK_THEMES =
|
||||
|
|
12
conf/routes
12
conf/routes
|
@ -9,10 +9,10 @@ GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset
|
|||
GET /pitchme/gist/:gid com.gitpitch.controllers.PitchController.gist(gid:String)
|
||||
|
||||
# Serve PITCHME.pdf.
|
||||
GET /pitchme/print/:grs/:user/:repo/:b/:t/PITCHME.pdf com.gitpitch.controllers.PitchController.print(grs:String, user:String, repo:String, b:String, t:String, n:String ?= null)
|
||||
GET /pitchme/print/:grs/:user/:repo/:b/:t/PITCHME.pdf com.gitpitch.controllers.PitchController.print(grs:String, user:String, repo:String, b:String, t:String, p:String ?= null, n:String ?= null)
|
||||
|
||||
# Serve PITCHME.zip.
|
||||
GET /pitchme/offline/:grs/:user/:repo/:b/:t/PITCHME.zip com.gitpitch.controllers.PitchController.offline(grs:String, user:String, repo:String, b:String, t:String, n:String ?= null)
|
||||
GET /pitchme/offline/:grs/:user/:repo/:b/:t/PITCHME.zip com.gitpitch.controllers.PitchController.offline(grs:String, user:String, repo:String, b:String, t:String, p:String ?= null, n:String ?= null)
|
||||
|
||||
# Redirect to GitHub OAuth Access Request
|
||||
# GET /pitchme/authreq com.gitpitch.controllers.AuthController.authreq()
|
||||
|
@ -21,16 +21,16 @@ GET /pitchme/offline/:grs/:user/:repo/:b/:t/PITCHME.zip com.gitpitch.cont
|
|||
# GET /pitchme/authorized com.gitpitch.controllers.AuthController.authorized(code:String ?= null, state:String ?= null)
|
||||
|
||||
# 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)
|
||||
GET /pitchme/markdown/:grs/:user/:repo/:b/PITCHME.md com.gitpitch.controllers.PitchController.markdown(grs:String, user:String, repo:String, b:String, p:String ?= null)
|
||||
|
||||
# Serve PITCHME.md slideshow.
|
||||
GET /pitchme/slideshow/:grs/:user/:repo/:b com.gitpitch.controllers.PitchController.slideshow(grs:String, user:String, repo:String, b:String, t:String ?= null, n:String ?= null, fragments:String ?= null, offline:String ?= null)
|
||||
GET /pitchme/slideshow/:grs/:user/:repo/:b com.gitpitch.controllers.PitchController.slideshow(grs:String, user:String, repo:String, b:String, t:String ?= null, p:String ?= null, n:String ?= null, fragments:String ?= null, offline:String ?= null)
|
||||
|
||||
# Serve PITCHME.md landing page.
|
||||
GET /:user/:repo/:b com.gitpitch.controllers.PitchController.landing(user:String, repo:String, b:String, grs:String ?= null, t:String ?= null, n:String?= null, offline:String ?= null)
|
||||
GET /:user/:repo/:b com.gitpitch.controllers.PitchController.landing(user:String, repo:String, b:String, grs:String ?= null, t:String ?= null, p:String?= null, n:String ?= null, offline:String ?= null)
|
||||
|
||||
# Serve PITCHME.md landing page, short URI format.
|
||||
GET /:user/:repo com.gitpitch.controllers.PitchController.landing(user:String, repo:String, b:String ?= null, grs:String ?= null, t:String ?= null, n:String?= null, offline:String ?= null)
|
||||
GET /:user/:repo com.gitpitch.controllers.PitchController.landing(user:String, repo:String, b:String ?= null, grs:String ?= null, t:String ?= null, p:String?= null, n:String ?= null, offline:String ?= null)
|
||||
|
||||
# Catch-all route redirect to website.
|
||||
GET /*path com.gitpitch.controllers.PitchController.catchall(path:String)
|
||||
|
|
Loading…
Reference in New Issue
Block a user