From 1af1ae164cbcd5c2988df4c256898a62543505ea Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Mon, 18 May 2020 21:12:49 +0200 Subject: [PATCH] Add redirect uri to page --- main.go | 33 +++++++++++++++++++++++++++++---- templates/layout.html | 6 ++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index c41696d..d210532 100644 --- a/main.go +++ b/main.go @@ -80,7 +80,13 @@ type PagesRepository interface { RecentChanges() ([]Change, error) } +type pageBaseInfo struct { + BaseURL string + RedirectURI string +} + type indexPage struct { + pageBaseInfo Session *Session Title string Name string @@ -89,6 +95,7 @@ type indexPage struct { } type editPage struct { + pageBaseInfo Session *Session Title string Content string @@ -98,6 +105,7 @@ type editPage struct { } type historyPage struct { + pageBaseInfo Session *Session Title string Name string @@ -105,6 +113,7 @@ type historyPage struct { } type recentPage struct { + pageBaseInfo Session *Session Title string Name string @@ -273,6 +282,10 @@ func (h *historyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } err = t.Execute(w, historyPage{ + pageBaseInfo: pageBaseInfo{ + BaseURL: ClientID, + RedirectURI: RedirectURI, + }, Session: sess, Title: "History of " + cleanTitle(page), Name: page, @@ -383,6 +396,10 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } data := editPage{ + pageBaseInfo: pageBaseInfo{ + BaseURL: ClientID, + RedirectURI: RedirectURI, + }, Session: sess, Title: cleanTitle(page), Content: pageText, @@ -484,6 +501,10 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { pageText = md.RenderToString([]byte(pageText)) data := indexPage{ + pageBaseInfo: pageBaseInfo{ + BaseURL: ClientID, + RedirectURI: RedirectURI, + }, Session: sess, Title: cleanTitle(page), Content: template.HTML(pageText), @@ -554,10 +575,14 @@ func (h *recentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } err = t.Execute(w, recentPage{ - Session: sess, - Title: "Recent changes", - Name: "Recent changes", - Recent: changes, + pageBaseInfo: pageBaseInfo{ + BaseURL: ClientID, + RedirectURI: RedirectURI, + }, + Session: sess, + Title: "Recent changes", + Name: "Recent changes", + Recent: changes, }) if err != nil { http.Error(w, err.Error(), 500) diff --git a/templates/layout.html b/templates/layout.html index 4cd71af..341881b 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -5,6 +5,7 @@ + {{ .Title }} - Wiki @@ -209,6 +210,11 @@ {{ template "content" . }} +
+ Wiki + — created by Peter Stuifzand +
+ {{ block "footer_scripts" . }}