From 3cc1efc75e8b7ea5380ad53bcd4bae38a434a74f Mon Sep 17 00:00:00 2001 From: Will Norris Date: Tue, 26 Apr 2016 16:25:45 -0700 Subject: [PATCH] website: serve non-HTML files as raw bytes The website has several non-HTML files that mostly serve as examples (eg: https://camlistore.org/doc/json-signing/example/signing-before.camli). Today these files are parsed and rendered the same as HTML files, which is particularly bad for these json-signing examples. Instead, they should be served raw, without any interpretation. Change-Id: I09f7de130e55da7b2e585f1a110bbbf391f2279f --- website/camweb.go | 5 +++++ website/content/{code => code.html} | 0 website/content/{community => community.html} | 0 website/content/{contributors => contributors.html} | 0 website/content/{download => download.html} | 0 5 files changed, 5 insertions(+) rename website/content/{code => code.html} (100%) rename website/content/{community => community.html} (100%) rename website/content/{contributors => contributors.html} (100%) rename website/content/{download => download.html} (100%) diff --git a/website/camweb.go b/website/camweb.go index a4af08c52..7295bf495 100644 --- a/website/camweb.go +++ b/website/camweb.go @@ -369,6 +369,11 @@ var markdownRenderer = blackfriday.HtmlRenderer(markdownHTMLFlags, "", "") // serveFile serves a file from disk, converting any markdown to HTML. func serveFile(rw http.ResponseWriter, req *http.Request, relPath, absPath string) { + if !strings.HasSuffix(absPath, ".html") && !strings.HasSuffix(absPath, ".md") { + http.ServeFile(rw, req, absPath) + return + } + data, err := ioutil.ReadFile(absPath) if err != nil { serveError(rw, req, absPath, err) diff --git a/website/content/code b/website/content/code.html similarity index 100% rename from website/content/code rename to website/content/code.html diff --git a/website/content/community b/website/content/community.html similarity index 100% rename from website/content/community rename to website/content/community.html diff --git a/website/content/contributors b/website/content/contributors.html similarity index 100% rename from website/content/contributors rename to website/content/contributors.html diff --git a/website/content/download b/website/content/download.html similarity index 100% rename from website/content/download rename to website/content/download.html