aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/data.go2
-rw-r--r--backend/templates/home.html24
-rw-r--r--backend/templates/home_log.html24
-rw-r--r--backend/templates/logs_display.html23
4 files changed, 27 insertions, 46 deletions
diff --git a/backend/data.go b/backend/data.go
index e841669..8922aca 100644
--- a/backend/data.go
+++ b/backend/data.go
@@ -75,7 +75,7 @@ func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string
},
"next": func(i int) int { return i + 1 },
"before": func(i int) int { return i - 1 },
- }).ParseFS(templates, fmt.Sprintf("templates/%s.html", name), "templates/base.html")
+ }).ParseFS(templates, "templates/logs_display.html", fmt.Sprintf("templates/%s.html", name), "templates/base.html")
if err != nil {
panic(err)
}
diff --git a/backend/templates/home.html b/backend/templates/home.html
index 37236ba..1a6b158 100644
--- a/backend/templates/home.html
+++ b/backend/templates/home.html
@@ -5,25 +5,5 @@
{{ .Description }}
</p>
</div>
-<article>
- {{ range .Logs }}
- <article>
- <h2><a href="/log/{{ .Slug }}">{{ .LogTitle }}</a></h2>
- <figure>
- <a href="/log/{{ .Slug }}"><img src="{{ .Img.Src }}" alt="{{ .Img.Alt }}"></a>
- <figcaption>{{ .Img.Legend }}</figcaption>
- </figure>
- <p>
- {{ .Description }}
- </p>
- </article>
- {{ end }}
- {{ if ne .PagesNumber 1 }}
- <div class="pagination">
- {{ if ne .CurrentPage 1 }}<a href="?page={{ before .CurrentPage }}">Précédent</a>{{else}}<p></p>{{end}}
- <p>{{ .CurrentPage }}/{{ .PagesNumber }}</p>
- {{ if ne .CurrentPage .PagesNumber }}<a href="?page={{ next .CurrentPage }}">Suivant</a>{{else}}<p></p>{{end}}
- </div>
- {{ end }}
-</article>
-{{end}} \ No newline at end of file
+{{ template "logs_display" . }}
+{{end}}
diff --git a/backend/templates/home_log.html b/backend/templates/home_log.html
index dd5fdc1..2301ffd 100644
--- a/backend/templates/home_log.html
+++ b/backend/templates/home_log.html
@@ -1,23 +1 @@
-{{define "body"}}
-<article>
- {{ range .Logs }}
- <article>
- <h2><a href="/log/{{ .Slug }}">{{ .LogTitle }}</a></h2>
- <figure>
- <a href="/log/{{ .Slug }}"><img src="{{ .Img.Src }}" alt="{{ .Img.Alt }}"></a>
- <figcaption>{{ .Img.Legend }}</figcaption>
- </figure>
- <p>
- {{ .Description }}
- </p>
- </article>
- {{ end }}
- {{ if ne .PagesNumber 1 }}
- <div class="pagination">
- {{ if ne .CurrentPage 1 }}<a href="?page={{ before .CurrentPage }}">Précédent</a>{{else}}<p></p>{{end}}
- <p>{{ .CurrentPage }}/{{ .PagesNumber }}</p>
- {{ if ne .CurrentPage .PagesNumber }}<a href="?page={{ next .CurrentPage }}">Suivant</a>{{else}}<p></p>{{end}}
- </div>
- {{ end }}
-</article>
-{{end}}
+{{define "body"}}{{ template "logs_display" . }}{{end}}
diff --git a/backend/templates/logs_display.html b/backend/templates/logs_display.html
new file mode 100644
index 0000000..d76d7c2
--- /dev/null
+++ b/backend/templates/logs_display.html
@@ -0,0 +1,23 @@
+{{define "logs_display"}}
+<article>
+ {{ range .Logs }}
+ <article>
+ <h2><a href="/log/{{ .Slug }}">{{ .LogTitle }}</a></h2>
+ <figure>
+ <a href="/log/{{ .Slug }}"><img src="{{ .Img.Src }}" alt="{{ .Img.Alt }}"></a>
+ <figcaption>{{ .Img.Legend }}</figcaption>
+ </figure>
+ <p>
+ {{ .Description }}
+ </p>
+ </article>
+ {{ end }}
+ {{ if ne .PagesNumber 1 }}
+ <div class="pagination">
+ {{ if ne .CurrentPage 1 }}<a href="?page={{ before .CurrentPage }}">Précédent</a>{{else}}<p></p>{{end}}
+ <p>{{ .CurrentPage }}/{{ .PagesNumber }}</p>
+ {{ if ne .CurrentPage .PagesNumber }}<a href="?page={{ next .CurrentPage }}">Suivant</a>{{else}}<p></p>{{end}}
+ </div>
+ {{ end }}
+</article>
+{{end}}