use of com.google.gitiles.DebugRenderer in project gitiles by GerritCodeReview.
the class DevServer method createRootedDocServlet.
private Servlet createRootedDocServlet(DebugRenderer renderer, String docRoot) {
File docRepo = new File(docRoot);
FileKey repoKey = FileKey.exact(docRepo, FS.DETECTED);
RepositoryResolver<HttpServletRequest> resolver = (req, name) -> {
try {
return RepositoryCache.open(repoKey, true);
} catch (IOException e) {
throw new RepositoryNotFoundException(repoKey.getFile(), e);
}
};
return new RootedDocServlet(resolver, new RootedDocAccess(docRepo), renderer);
}
use of com.google.gitiles.DebugRenderer in project gitiles by GerritCodeReview.
the class DevServer method appHandler.
private Handler appHandler() {
DebugRenderer renderer = new DebugRenderer(STATIC_PREFIX, Arrays.asList(cfg.getStringList("gitiles", null, "customTemplates")), sourceRoot.resolve("gitiles-servlet/src/main/resources/com/google/gitiles/templates").toString(), firstNonNull(cfg.getString("gitiles", null, "siteTitle"), "Gitiles"));
String docRoot = cfg.getString("gitiles", null, "docroot");
Servlet servlet;
if (!Strings.isNullOrEmpty(docRoot)) {
servlet = createRootedDocServlet(renderer, docRoot);
} else {
servlet = new GitilesServlet(cfg, renderer, null, null, null, null, null, null, null);
}
ServletContextHandler handler = new ServletContextHandler();
handler.setContextPath("");
handler.addServlet(new ServletHolder(servlet), "/*");
return handler;
}
Aggregations