2017-07-12 06:43:11 +00:00
package yatwiki
2017-07-09 05:20:10 +00:00
import (
"database/sql"
"errors"
"html/template"
"net/http"
"net/url"
"time"
)
func ( this * WikiServer ) routeArchive ( w http . ResponseWriter , r * http . Request , revId int ) {
a , err := this . db . GetRevision ( revId )
if err != nil {
if err == sql . ErrNoRows {
this . serveErrorMessage ( w , errors . New ( "No such revision." ) )
return
}
this . serveErrorMessage ( w , err )
return
}
pto := DefaultPageTemplateOptions ( this . opts )
pto . CurrentPageName = a . Title
pto . CurrentPageIsArticle = true
2018-04-02 05:45:55 +00:00
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 {
infoMessageHtml += ` Click <a href=" ` + template . HTMLEscapeString ( this . opts . ExpectBaseURL + ` view/ ` + url . PathEscape ( a . Title ) ) + ` ">here</a> to see the latest revision. `
}
2017-11-18 02:04:19 +00:00
bcr := this . GetBBCodeRenderer ( )
2017-07-09 05:20:10 +00:00
pto . Content = template . HTML (
2018-04-02 05:45:55 +00:00
` <div class="info"> ` + infoMessageHtml + ` </div> ` ,
2017-07-09 05:20:10 +00:00
) + bcr . RenderHTML ( string ( a . Body ) )
pto . LoadCodeResources = bcr . CodePresent
this . servePageResponse ( w , r , pto )
return
}