Add query function

This commit is contained in:
Wancat
2022-11-05 00:13:21 +08:00
parent 4ae49b5db6
commit ae86204c84
7 changed files with 56 additions and 32 deletions

View File

@@ -11,10 +11,5 @@
<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>
{{ template "scripts" .Scripts }}
{{ end }}

View File

@@ -9,9 +9,10 @@
<ul>
{{ with .User }}
{{ .Email }}
<li><a href="dashboard">儀表板</a></li>
<li><a href="edit">編輯</a></li>
<li><a href="download">下載</a></li>
<li><a href="exec">查詢</a></li>
<li><a href="query">查詢</a></li>
{{ end }}
</nav>
{{ block "main" .Data }}

View File

@@ -0,0 +1,8 @@
{{ define "scripts" }}
<h3>常用指令</h3>
<ul>
{{ range $k, $v := . }}
<li><a href="/query?query={{ urlquery $v }}">{{ $k }}</a></li>
{{ end }}
</ul>
{{ end }}

12
templates/query.html Normal file
View File

@@ -0,0 +1,12 @@
{{ define "title" }}查詢{{ end }}
{{ define "main" }}
<h1>查詢</h1>
{{ with .Result }}
<pre><code>{{ . }}</code></pre>
{{ end }}
<form action="/query" method="GET">
<input type="text" name="query" value="{{ .Query }}" autofocus>
<input type="submit" value="查詢">
</form>
{{ template "scripts" .Scripts }}
{{ end }}