You've already forked microservices
mirror of
https://github.com/ebosas/microservices.git
synced 2025-08-24 20:08:55 +02:00
Template active links, spacing
This commit is contained in:
@@ -67,7 +67,7 @@ func handleHome(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
t := template.Must(template.ParseFS(filesTempl, "template/template.html", "template/navbar.html", "template/home.html"))
|
||||
t.ExecuteTemplate(w, "layout", nil)
|
||||
t.ExecuteTemplate(w, "layout", map[string]string{"Page": "home"})
|
||||
}
|
||||
|
||||
// handleMessages handles the messages page.
|
||||
@@ -88,6 +88,7 @@ func handleMessages(cr *redis.Client) func(w http.ResponseWriter, r *http.Reques
|
||||
data := map[string]interface{}{
|
||||
"Data": cacheData,
|
||||
"Json": string(cacheJSON),
|
||||
"Page": "messages",
|
||||
}
|
||||
|
||||
// funcMap := template.FuncMap{"ftime": timeutil.FormatDuration}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{{ define "content" -}}
|
||||
{{define "content" -}}
|
||||
<div class="container position-relative h-75">
|
||||
<div class="position-absolute bottom-50 start-0 w-100 translate-middle-y">
|
||||
<div class="row">
|
||||
@@ -18,4 +18,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- end}}
|
@@ -1,6 +1,6 @@
|
||||
{{ define "content" -}}
|
||||
{{define "content" -}}
|
||||
<div class="container">
|
||||
<h3 class="my-4 ps-2">Recent messages ({{ .Data.Count }}/{{ .Data.Total }})</h3>
|
||||
<h3 class="my-4 ps-2">Recent messages ({{.Data.Count}}/{{.Data.Total}})</h3>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -10,18 +10,18 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{- range .Data.Messages }}
|
||||
{{- range .Data.Messages}}
|
||||
<tr>
|
||||
<td>{{ .TimeFmt }} ago</td>
|
||||
<td>{{ .Text }}</td>
|
||||
<td>{{ .Source }}</td>
|
||||
<td>{{.TimeFmt}} ago</td>
|
||||
<td>{{.Text}}</td>
|
||||
<td>{{.Source}}</td>
|
||||
</tr>
|
||||
{{- else }}
|
||||
{{- else}}
|
||||
<tr>
|
||||
<td colspan="3">No messages</td>
|
||||
</tr>
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- end}}
|
@@ -1,14 +1,14 @@
|
||||
{{ define "navbar" -}}
|
||||
{{define "navbar" -}}
|
||||
<nav class="navbar navbar-expand navbar-light bg-transparent">
|
||||
<div class="container-fluid">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/">Home</a>
|
||||
<a class='nav-link{{if and (and . .Page) (eq .Page "home")}} active{{end}}' href="/">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/messages">Messages</a>
|
||||
<a class='nav-link{{if and (and . .Page) (eq .Page "messages")}} active{{end}}' href="/messages">Messages</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
{{- end }}
|
||||
{{- end}}
|
@@ -1,4 +1,4 @@
|
||||
{{ define "layout" -}}
|
||||
{{define "layout" -}}
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -6,15 +6,15 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="static/build/style.css">
|
||||
{{ if and . .Json }}<script>window.__DATA="{{ .Json }}"</script>{{ end }}
|
||||
{{if and . .Json}}<script>window.__DATA="{{.Json}}"</script>{{end -}}
|
||||
</head>
|
||||
<body>
|
||||
<div id="root" class="vh-100">
|
||||
{{ template "navbar" . }}
|
||||
{{ template "content" . }}
|
||||
{{template "navbar" .}}
|
||||
{{template "content" .}}
|
||||
</div>
|
||||
<script src="http://127.0.0.1:8000/index.js"></script>
|
||||
<!-- <script src="static/build/index.js"></script> -->
|
||||
</body>
|
||||
</html>
|
||||
{{- end }}
|
||||
{{- end}}
|
Reference in New Issue
Block a user