Skip to content

Commit 31234a3

Browse files
authored
Merge pull request #75 from pavelsne/iss67
Add dynamic (c) date in page footer (#67) resolved
2 parents 5230359 + d760c27 commit 31234a3

File tree

5 files changed

+54
-29
lines changed

5 files changed

+54
-29
lines changed

internal/resources/templates/layout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var Layout = `
4646
<footer>
4747
<div class="ui container">
4848
<div class="ui center links item brand footertext">
49-
<a href="http://www.g-node.org"><img class="ui mini footericon" src="https://projects.g-node.org/assets/gnode-bootstrap-theme/1.2.0-snapshot/img/gnode-icon-50x50-transparent.png"/>© G-Node, 2016-2019</a>
49+
<a href="http://www.g-node.org"><img class="ui mini footericon" src="https://projects.g-node.org/assets/gnode-bootstrap-theme/1.2.0-snapshot/img/gnode-icon-50x50-transparent.png"/>© G-Node, 2016-{{.CurrentYear}}</a>
5050
<a href="https://gin.g-node.org/G-Node/Info/wiki/about">About</a>
5151
<a href="https://gin.g-node.org/G-Node/Info/wiki/imprint">Imprint</a>
5252
<a href="https://gin.g-node.org/G-Node/Info/wiki/contact">Contact</a>

internal/web/fail.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package web
33
import (
44
"html/template"
55
"net/http"
6+
"time"
67

78
"github.com/G-Node/gin-valid/internal/config"
89
"github.com/G-Node/gin-valid/internal/log"
@@ -27,17 +28,20 @@ func fail(w http.ResponseWriter, status int, message string) {
2728
w.Write([]byte(message))
2829
return
2930
}
31+
year, _, _ := time.Now().Date()
3032
srvcfg := config.Read()
3133
errinfo := struct {
32-
StatusCode int
33-
StatusText string
34-
Message string
35-
GinURL string
34+
StatusCode int
35+
StatusText string
36+
Message string
37+
GinURL string
38+
CurrentYear int
3639
}{
3740
status,
3841
http.StatusText(status),
3942
message,
4043
srvcfg.GINAddresses.WebURL,
44+
year,
4145
}
4246
tmpl.Execute(w, &errinfo)
4347
}

internal/web/results.go

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,14 @@ func renderInProgress(w http.ResponseWriter, r *http.Request, badge []byte, vali
168168
// Parse results into html template and serve it
169169
head := fmt.Sprintf("%s validation for %s/%s", validator, user, repo)
170170
srvcfg := config.Read()
171+
year, _, _ := time.Now().Date()
171172
info := struct {
172-
Badge template.HTML
173-
Header string
174-
Content string
175-
GinURL string
176-
}{template.HTML(badge), head, string(progressmsg), srvcfg.GINAddresses.WebURL}
173+
Badge template.HTML
174+
Header string
175+
Content string
176+
GinURL string
177+
CurrentYear int
178+
}{template.HTML(badge), head, string(progressmsg), srvcfg.GINAddresses.WebURL, year}
177179

178180
err = tmpl.ExecuteTemplate(w, "layout", info)
179181
if err != nil {
@@ -210,13 +212,15 @@ func renderBIDSResults(w http.ResponseWriter, r *http.Request, badge []byte, con
210212

211213
// Parse results into html template and serve it
212214
head := fmt.Sprintf("BIDS validation for %s/%s", user, repo)
215+
year, _, _ := time.Now().Date()
213216
srvcfg := config.Read()
214217
info := struct {
215218
Badge template.HTML
216219
Header string
217220
*BidsResultStruct
218-
GinURL string
219-
}{template.HTML(badge), head, &resBIDS, srvcfg.GINAddresses.WebURL}
221+
GinURL string
222+
CurrentYear int
223+
}{template.HTML(badge), head, &resBIDS, srvcfg.GINAddresses.WebURL, year}
220224

221225
err = tmpl.ExecuteTemplate(w, "layout", info)
222226
if err != nil {
@@ -245,13 +249,15 @@ func renderNIXResults(w http.ResponseWriter, r *http.Request, badge []byte, cont
245249

246250
// Parse results into html template and serve it
247251
head := fmt.Sprintf("NIX validation for %s/%s", user, repo)
252+
year, _, _ := time.Now().Date()
248253
srvcfg := config.Read()
249254
info := struct {
250-
Badge template.HTML
251-
Header string
252-
Content string
253-
GinURL string
254-
}{template.HTML(badge), head, string(content), srvcfg.GINAddresses.WebURL}
255+
Badge template.HTML
256+
Header string
257+
Content string
258+
GinURL string
259+
CurrentYear int
260+
}{template.HTML(badge), head, string(content), srvcfg.GINAddresses.WebURL, year}
255261

256262
err = tmpl.ExecuteTemplate(w, "layout", info)
257263
if err != nil {
@@ -281,12 +287,14 @@ func renderODMLResults(w http.ResponseWriter, r *http.Request, badge []byte, con
281287
// Parse results into html template and serve it
282288
head := fmt.Sprintf("odML validation for %s/%s", user, repo)
283289
srvcfg := config.Read()
290+
year, _, _ := time.Now().Date()
284291
info := struct {
285-
Badge template.HTML
286-
Header string
287-
Content string
288-
GinURL string
289-
}{template.HTML(badge), head, string(content), srvcfg.GINAddresses.WebURL}
292+
Badge template.HTML
293+
Header string
294+
Content string
295+
GinURL string
296+
CurrentYear int
297+
}{template.HTML(badge), head, string(content), srvcfg.GINAddresses.WebURL, year}
290298

291299
err = tmpl.ExecuteTemplate(w, "layout", info)
292300
if err != nil {

internal/web/user.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,14 @@ func LoginGet(w http.ResponseWriter, r *http.Request) {
167167
fail(w, http.StatusInternalServerError, "something went wrong")
168168
return
169169
}
170+
year, _, _ := time.Now().Date()
170171
srvcfg := config.Read()
171172
data := struct {
172-
GinURL string
173+
GinURL string
174+
CurrentYear int
173175
}{
174176
srvcfg.GINAddresses.WebURL,
177+
year,
175178
}
176179
tmpl.Execute(w, &data)
177180
}
@@ -297,15 +300,18 @@ func ListRepos(w http.ResponseWriter, r *http.Request) {
297300
reposInactive = append(reposInactive, rhinfo)
298301
}
299302
}
303+
year, _, _ := time.Now().Date()
300304
srvcfg := config.Read()
301305
allrepos := struct {
302-
Active []repoHooksInfo
303-
Inactive []repoHooksInfo
304-
GinURL string
306+
Active []repoHooksInfo
307+
Inactive []repoHooksInfo
308+
GinURL string
309+
CurrentYear int
305310
}{
306311
reposActive,
307312
reposInactive,
308313
srvcfg.GINAddresses.WebURL,
314+
year,
309315
}
310316
tmpl.Execute(w, &allrepos)
311317
}
@@ -455,15 +461,18 @@ func ShowRepo(w http.ResponseWriter, r *http.Request) {
455461
if err != nil {
456462
hooks = make(map[string]ginhook)
457463
}
464+
year, _, _ := time.Now().Date()
458465
srvcfg := config.Read()
459466
repohi := struct {
460467
gogs.Repository
461-
Hooks map[string]ginhook
462-
GinURL string
468+
Hooks map[string]ginhook
469+
GinURL string
470+
CurrentYear int
463471
}{
464472
repoinfo,
465473
hooks,
466474
srvcfg.GINAddresses.WebURL,
475+
year,
467476
}
468477
tmpl.Execute(w, &repohi)
469478
}

internal/web/validate.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"os/exec"
1212
"path/filepath"
1313
"strings"
14+
"time"
1415

1516
"gopkg.in/yaml.v2"
1617

@@ -619,11 +620,14 @@ func PubValidateGet(w http.ResponseWriter, r *http.Request) {
619620
fail(w, http.StatusInternalServerError, "something went wrong")
620621
return
621622
}
623+
year, _, _ := time.Now().Date()
622624
srvcfg := config.Read()
623625
data := struct {
624-
GinURL string
626+
GinURL string
627+
CurrentYear int
625628
}{
626629
srvcfg.GINAddresses.WebURL,
630+
year,
627631
}
628632
tmpl.Execute(w, &data)
629633
}

0 commit comments

Comments
 (0)