diff --git a/ds/common.go b/ds/common.go new file mode 100644 index 00000000..14750c2a --- /dev/null +++ b/ds/common.go @@ -0,0 +1,5 @@ +package ds + +type Common struct { + Page string `json:"-"` +} diff --git a/http_bin.go b/http_bin.go index 62115a19..a1ec1aed 100644 --- a/http_bin.go +++ b/http_bin.go @@ -16,10 +16,12 @@ func (h *HTTP) ViewBin(w http.ResponseWriter, r *http.Request) { inputBin := params["bin"] type Data struct { + ds.Common Bin ds.Bin `json:"bin"` Files []ds.File `json:"files"` } var data Data + data.Page = "viewbin" bin, found, err := h.dao.Bin().GetById(inputBin) if err != nil { diff --git a/http_index.go b/http_index.go index 54082bd1..c0ad2cbd 100644 --- a/http_index.go +++ b/http_index.go @@ -12,10 +12,13 @@ import ( func (h *HTTP) Index(w http.ResponseWriter, r *http.Request) { type Data struct { + ds.Common Bin ds.Bin `json:"bin"` } var data Data + data.Page = "front" + bin := &ds.Bin{} bin.Expiration = time.Now().UTC().Add(h.expirationDuration) err := h.dao.Bin().Insert(bin) @@ -35,7 +38,14 @@ func (h *HTTP) Index(w http.ResponseWriter, r *http.Request) { func (h *HTTP) About(w http.ResponseWriter, r *http.Request) { //w.Header().Set("Cache-Control", "max-age=900") - if err := h.templates.ExecuteTemplate(w, "about", nil); err != nil { + type Data struct { + ds.Common + Bin ds.Bin `json:"bin"` + } + var data Data + data.Page = "about" + + if err := h.templates.ExecuteTemplate(w, "about", data); err != nil { fmt.Printf("Failed to execute template: %s\n", err.Error()) http.Error(w, "Errno 302", http.StatusInternalServerError) return @@ -44,9 +54,11 @@ func (h *HTTP) About(w http.ResponseWriter, r *http.Request) { func (h *HTTP) API(w http.ResponseWriter, r *http.Request) { type Data struct { + ds.Common Bin ds.Bin `json:"bin"` } var data Data + data.Page = "api" //w.Header().Set("Cache-Control", "max-age=900") if err := h.templates.ExecuteTemplate(w, "api", data); err != nil { @@ -59,9 +71,11 @@ func (h *HTTP) API(w http.ResponseWriter, r *http.Request) { func (h *HTTP) APISpec(w http.ResponseWriter, r *http.Request) { type Data struct { + ds.Common Bin ds.Bin `json:"bin"` } var data Data + data.Page = "api" w.Header().Set("Content-Type", "application/json") //w.Header().Set("Cache-Control", "max-age=900") diff --git a/templates/topbar.tpl b/templates/topbar.tpl index dbbd994a..7e2edbd4 100644 --- a/templates/topbar.tpl +++ b/templates/topbar.tpl @@ -1,9 +1,13 @@ {{ define "topbar" }} +