mirror of
https://github.com/gitpitch/gitpitch.git
synced 2024-04-18 07:30:55 +08:00
Added API to presentation raw file content.
This commit is contained in:
parent
7a294929b0
commit
fe53cf81bb
|
@ -2,17 +2,17 @@
|
||||||
* MIT License
|
* MIT License
|
||||||
*
|
*
|
||||||
* Copyright (c) 2016 David Russell
|
* Copyright (c) 2016 David Russell
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
* in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
* furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
@ -361,7 +361,7 @@ public class PitchController extends Controller {
|
||||||
String theme,
|
String theme,
|
||||||
String pitchme,
|
String pitchme,
|
||||||
String notes) {
|
String notes) {
|
||||||
|
|
||||||
|
|
||||||
PitchParams pp =
|
PitchParams pp =
|
||||||
PitchParams.build(grsOnCall(grs),
|
PitchParams.build(grsOnCall(grs),
|
||||||
|
@ -406,6 +406,39 @@ public class PitchController extends Controller {
|
||||||
return ok(com.gitpitch.views.html.Gist.render(gid, deps));
|
return ok(com.gitpitch.views.html.Gist.render(gid, deps));
|
||||||
} // gist action
|
} // gist action
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Raw returns file content identified by path.
|
||||||
|
*/
|
||||||
|
public CompletionStage<Result> raw(String grs,
|
||||||
|
String user,
|
||||||
|
String repo,
|
||||||
|
String branch,
|
||||||
|
String path) {
|
||||||
|
|
||||||
|
PitchParams pp =
|
||||||
|
PitchParams.build(grsOnCall(grs), user, repo, branch);
|
||||||
|
log.debug("raw: pp={}, path={}", pp, path);
|
||||||
|
|
||||||
|
String offline = request().getQueryString("offline");
|
||||||
|
log.debug("raw: pp={}, path={}, offline={}", pp, path, offline != null);
|
||||||
|
|
||||||
|
Optional<File> fileo = pitchService.raw(pp, path);
|
||||||
|
|
||||||
|
if (fileo.isPresent()) {
|
||||||
|
|
||||||
|
log.debug("raw: pp={}, path={} file is found.");
|
||||||
|
File file = fileo.get();
|
||||||
|
return CompletableFuture.completedFuture(ok(file));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
log.debug("raw: pp={}, path={} file not found.");
|
||||||
|
return CompletableFuture.completedFuture(notFound());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // raw action
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine GRS on call, explicitly defined or default.
|
* Determine GRS on call, explicitly defined or default.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* MIT License
|
* MIT License
|
||||||
*
|
*
|
||||||
* Copyright (c) 2016 David Russell
|
* Copyright (c) 2016 David Russell
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
* in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
* furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
@ -114,6 +114,6 @@ public final class Dependencies {
|
||||||
private static final String FONTAWE = "/font-awesome/";
|
private static final String FONTAWE = "/font-awesome/";
|
||||||
private static final String OCTICONS = "/octicons/";
|
private static final String OCTICONS = "/octicons/";
|
||||||
private static final String HIGHLIGHT = "/highlight.js/";
|
private static final String HIGHLIGHT = "/highlight.js/";
|
||||||
|
|
||||||
private static final String DEFAULT_CDN = "/assets/libs";
|
private static final String DEFAULT_CDN = "/assets/libs";
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
* MIT License
|
* MIT License
|
||||||
*
|
*
|
||||||
* Copyright (c) 2016 David Russell
|
* Copyright (c) 2016 David Russell
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
* in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
* furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
@ -280,4 +280,13 @@ public class PitchService {
|
||||||
return zip;
|
return zip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return file at path, else Optional.empty.
|
||||||
|
*/
|
||||||
|
public Optional<File> raw(PitchParams pp, String path) {
|
||||||
|
|
||||||
|
File rawFile = diskService.asFile(pp, path);
|
||||||
|
return rawFile.exists() ? Optional.of(rawFile) : Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
# Map static resources from the /public folder to the /assets URL path
|
# Map static resources from the /public folder to the /assets URL path
|
||||||
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
|
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
|
||||||
|
|
||||||
|
# Serve GitPitch raw file content.
|
||||||
|
GET /pitchme/raw/:grs/:user/:repo/:b/*path com.gitpitch.controllers.PitchController.raw(grs: String, user: String, repo: String, b: String, path: String)
|
||||||
|
|
||||||
# Serve GitPitch GIST iFrame for {gid}.
|
# Serve GitPitch GIST iFrame for {gid}.
|
||||||
GET /pitchme/gist/:gid com.gitpitch.controllers.PitchController.gist(gid:String)
|
GET /pitchme/gist/:gid com.gitpitch.controllers.PitchController.gist(gid:String)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user