Extract getPageBase
This commit is contained in:
parent
1af1ae164c
commit
419571daf6
57
main.go
57
main.go
|
@ -281,22 +281,33 @@ func (h *historyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
err = t.Execute(w, historyPage{
|
||||
pageBaseInfo: pageBaseInfo{
|
||||
BaseURL: ClientID,
|
||||
RedirectURI: RedirectURI,
|
||||
},
|
||||
Session: sess,
|
||||
Title: "History of " + cleanTitle(page),
|
||||
Name: page,
|
||||
History: history,
|
||||
})
|
||||
pageBase := getPageBase()
|
||||
pageData := historyPage{
|
||||
pageBaseInfo: pageBase,
|
||||
Session: sess,
|
||||
Title: "History of " + cleanTitle(page),
|
||||
Name: page,
|
||||
History: history,
|
||||
}
|
||||
|
||||
err = t.Execute(w, pageData)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func getPageBase() pageBaseInfo {
|
||||
clientID := ClientID
|
||||
redirectURI := RedirectURI
|
||||
|
||||
pageBase := pageBaseInfo{
|
||||
BaseURL: clientID,
|
||||
RedirectURI: redirectURI,
|
||||
}
|
||||
return pageBase
|
||||
}
|
||||
|
||||
func (h *saveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
|
||||
|
@ -395,11 +406,9 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
`, html.EscapeString(pageText)))
|
||||
}
|
||||
|
||||
pageBase := getPageBase()
|
||||
data := editPage{
|
||||
pageBaseInfo: pageBaseInfo{
|
||||
BaseURL: ClientID,
|
||||
RedirectURI: RedirectURI,
|
||||
},
|
||||
pageBaseInfo: pageBase,
|
||||
Session: sess,
|
||||
Title: cleanTitle(page),
|
||||
Content: pageText,
|
||||
|
@ -500,11 +509,9 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
)
|
||||
pageText = md.RenderToString([]byte(pageText))
|
||||
|
||||
pageBase := getPageBase()
|
||||
data := indexPage{
|
||||
pageBaseInfo: pageBaseInfo{
|
||||
BaseURL: ClientID,
|
||||
RedirectURI: RedirectURI,
|
||||
},
|
||||
pageBaseInfo: pageBase,
|
||||
Session: sess,
|
||||
Title: cleanTitle(page),
|
||||
Content: template.HTML(pageText),
|
||||
|
@ -574,15 +581,13 @@ func (h *recentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
pageBase := getPageBase()
|
||||
err = t.Execute(w, recentPage{
|
||||
pageBaseInfo: pageBaseInfo{
|
||||
BaseURL: ClientID,
|
||||
RedirectURI: RedirectURI,
|
||||
},
|
||||
Session: sess,
|
||||
Title: "Recent changes",
|
||||
Name: "Recent changes",
|
||||
Recent: changes,
|
||||
pageBaseInfo: pageBase,
|
||||
Session: sess,
|
||||
Title: "Recent changes",
|
||||
Name: "Recent changes",
|
||||
Recent: changes,
|
||||
})
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
|
|
Loading…
Reference in New Issue
Block a user