Add Template layouts, load session hashkey

This commit is contained in:
Wancat
2022-11-04 22:44:25 +08:00
parent bc1095fc61
commit bca1735393
7 changed files with 77 additions and 38 deletions

20
templates/dashboard.html Normal file
View File

@@ -0,0 +1,20 @@
{{ define "main" }}
<h1>Ledger Quick Note</h1>
<form action="/new" method="POST">
<label>Action:
{{ range .Templates }}
<input type="radio" name="action" value="{{ .Name }}">{{ .Name }}</option>
{{ end }}
</label><br>
<label>Amount: <input name="amount" type="number"></label><br>
<label>Account: <input name="account" type="text"></label></br>
<label>Tx Name: <input name="name" type="text"></label></br>
<input type="submit">
</form>
<h2>Scripts</h2>
<ul>
{{ range $k, $v := .Scripts }}
<li><a href="/exec?name={{ $k }}">{{ $k }}</a></li>
{{ end }}
</ul>
{{ end }}

View File

@@ -1,20 +1,3 @@
{{ define "main" }}
<h1>Ledger Quick Note</h1>
<form action="/new" method="POST">
<label>Action:
{{ range .Templates }}
<input type="radio" name="action" value="{{ .Name }}">{{ .Name }}</option>
{{ end }}
</label><br>
<label>Amount: <input name="amount" type="number"></label><br>
<label>Account: <input name="account" type="text"></label></br>
<label>Tx Name: <input name="name" type="text"></label></br>
<input type="submit">
</form>
<h2>Scripts</h2>
<ul>
{{ range $k, $v := .Scripts }}
<li><a href="/exec?name={{ $k }}">{{ $k }}</a></li>
{{ end }}
</ul>
{{ end }}

View File

@@ -5,7 +5,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
{{ block "main" . }}
<nav>
{{ with .User }}
{{ .Email }}
{{ end }}
</nav>
{{ block "main" .Data }}
{{ end }}
</body>

View File

@@ -2,5 +2,5 @@
{{ define "main" }}
<p><strong>Success</strong></p>
<pre><code>{{ .Tx }}</code></pre>
<p><a href="/">Back to home</a></p>
<p><a href="/dashboard">Back to home</a></p>
{{ end }}