Search in sources :

Example 1 with SanitizedContent

use of com.google.template.soy.data.SanitizedContent in project gerrit by GerritCodeReview.

the class IndexServlet method getTemplateData.

static SoyMapData getTemplateData(String canonicalURL, String cdnPath) throws URISyntaxException {
    String canonicalPath = computeCanonicalPath(canonicalURL);
    String staticPath = "";
    if (cdnPath != null) {
        staticPath = cdnPath;
    } else if (canonicalPath != null) {
        staticPath = canonicalPath;
    }
    // The resource path must be typed as safe for use in a script src.
    // TODO(wyatta): Upgrade this to use an appropriate safe URL type.
    SanitizedContent sanitizedStaticPath = UnsafeSanitizedContentOrdainer.ordainAsSafe(staticPath, SanitizedContent.ContentKind.TRUSTED_RESOURCE_URI);
    return new SoyMapData("canonicalPath", canonicalPath, "staticResourcePath", sanitizedStaticPath);
}
Also used : SoyMapData(com.google.template.soy.data.SoyMapData) SanitizedContent(com.google.template.soy.data.SanitizedContent)

Example 2 with SanitizedContent

use of com.google.template.soy.data.SanitizedContent in project gitiles by GerritCodeReview.

the class RepositoryIndexServlet method renderReadme.

private static Map<String, Object> renderReadme(HttpServletRequest req, RevWalk walk, GitilesView view, Config cfg, RevObject head) throws IOException {
    RevTree rootTree;
    try {
        rootTree = walk.parseTree(head);
    } catch (IncorrectObjectTypeException notTreeish) {
        return null;
    }
    ReadmeHelper readme = new ReadmeHelper(walk.getObjectReader(), GitilesView.path().copyFrom(view).setRevision(Revision.HEAD).setPathPart("/").build(), MarkdownConfig.get(cfg), rootTree, req.getRequestURI());
    readme.scanTree(rootTree);
    if (readme.isPresent()) {
        SanitizedContent html = readme.render();
        if (html != null) {
            return ImmutableMap.<String, Object>of("readmeHtml", html);
        }
    }
    return null;
}
Also used : SanitizedContent(com.google.template.soy.data.SanitizedContent) IncorrectObjectTypeException(org.eclipse.jgit.errors.IncorrectObjectTypeException) RevObject(org.eclipse.jgit.revwalk.RevObject) RevTree(org.eclipse.jgit.revwalk.RevTree)

Aggregations

SanitizedContent (com.google.template.soy.data.SanitizedContent)2 SoyMapData (com.google.template.soy.data.SoyMapData)1 IncorrectObjectTypeException (org.eclipse.jgit.errors.IncorrectObjectTypeException)1 RevObject (org.eclipse.jgit.revwalk.RevObject)1 RevTree (org.eclipse.jgit.revwalk.RevTree)1