Skip to content

Commit

Permalink
Fix raw display of past versions
Browse files Browse the repository at this point in the history
  • Loading branch information
packrat386 committed Oct 8, 2021
1 parent d61c386 commit e0796d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion templates/show_article_version.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<hr>
<div class="article-content">{{ .Content }}</div>
<hr>
<p><a href="/versions/{{ .Title }}?raw=true">Raw</a></p>
<p><a href="/versions/{{ .Title }}?version_id={{ .VersionID}}&raw=true">Raw</a></p>
<p><a href="/articles/{{ .Title }}">Current</a></p>
<p><a href="/">Home</a></p>
</body>
Expand Down
10 changes: 5 additions & 5 deletions versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func versionHandler(w http.ResponseWriter, r *http.Request, s storage, tmpl *tem
return
}

if r.URL.Query().Get("raw") == "true" {
w.Write([]byte(content))
return
}

contentHTML, err := md2html(content)
if err != nil {
renderError(w, tmpl, err)
Expand All @@ -69,11 +74,6 @@ func versionHandler(w http.ResponseWriter, r *http.Request, s storage, tmpl *tem
Content: contentHTML,
}

if r.URL.Query().Get("raw") == "true" {
w.Write([]byte(a.Content))
return
}

render(w, tmpl, "show_article_version.tmpl", a)
}

Expand Down

0 comments on commit e0796d5

Please sign in to comment.