add link to raw source page when viewing a specific revision

This commit is contained in:
mappu 2018-04-02 17:54:24 +12:00
parent ec116a09b8
commit b080a6f017
2 changed files with 12 additions and 0 deletions

View File

@ -11,6 +11,8 @@ var subresourceNonce = time.Now().Unix()
type pageTemplateOptions struct {
CurrentPageIsArticle bool
CurrentPageName string
CurrentPageIsRev bool
CurrentPageRev int64
WikiTitle string
Content template.HTML
BaseURL string
@ -114,6 +116,13 @@ function els(e,s){ // no js exec in innerHTML
<path d="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z" />
</svg>
</div></a>
{{if .CurrentPageIsRev }}
<a href="{{.BaseURL}}raw/{{.CurrentPageRev}}" title="Page Source"><div class="sprite">
<svg viewBox="0 0 24 24">
<path d="M8,3A2,2 0 0,0 6,5V9A2,2 0 0,1 4,11H3V13H4A2,2 0 0,1 6,15V19A2,2 0 0,0 8,21H10V19H8V14A2,2 0 0,0 6,12A2,2 0 0,0 8,10V5H10V3M16,3A2,2 0 0,1 18,5V9A2,2 0 0,0 20,11H21V13H20A2,2 0 0,0 18,15V19A2,2 0 0,1 16,21H14V19H16V14A2,2 0 0,1 18,12A2,2 0 0,1 16,10V5H14V3H16Z" />
</svg>
</div></a>
{{end}}
{{end}}
</div>
<div id="tr1" style="display:none;"></div>

View File

@ -25,6 +25,9 @@ func (this *WikiServer) routeArchive(w http.ResponseWriter, r *http.Request, rev
pto.CurrentPageName = a.Title
pto.CurrentPageIsArticle = true
pto.CurrentPageRev = int64(revId)
pto.CurrentPageIsRev = true
infoMessageHtml := `You are viewing a specific revision of this page, last modified ` +
time.Unix(a.Modified, 0).In(this.loc).Format(this.opts.DateFormat) + `. `
if !a.IsDeleted {