From 228b5bf36cfb11b7bcf76ed351b919b793ac6989 Mon Sep 17 00:00:00 2001 From: shaoying Date: Mon, 9 Jul 2018 00:43:05 +0800 Subject: [PATCH] mac add web.travel.command2 --- src/contexts/ctx.go | 1 + src/contexts/mdb/mdb.go | 1 + usr/template/travel.html | 150 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 148 insertions(+), 4 deletions(-) diff --git a/src/contexts/ctx.go b/src/contexts/ctx.go index c90e9302..1b17e54c 100644 --- a/src/contexts/ctx.go +++ b/src/contexts/ctx.go @@ -1941,6 +1941,7 @@ func (m *Message) Cap(key string, arg ...string) string { // {{{ var CGI = template.FuncMap{ "meta": func(arg ...interface{}) string { // {{{ + //meta meta [key [index]] if len(arg) == 0 { return "" } diff --git a/src/contexts/mdb/mdb.go b/src/contexts/mdb/mdb.go index 71769e99..a9284f23 100644 --- a/src/contexts/mdb/mdb.go +++ b/src/contexts/mdb/mdb.go @@ -276,6 +276,7 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心", } msg := m.Spawn().Cmd("query", fmt.Sprintf("select %s from %s %s %s %s %s %s", field, table, where, group, order, limit, offset), other) + m.Copy(msg, "append") if m.Optioni("query", msg.Code()); !m.Options("save") { m.Color(31, table).Echo(" %s %s %s %s %s %v\n", where, group, order, limit, offset, m.Meta["other"]) } diff --git a/usr/template/travel.html b/usr/template/travel.html index 2d769027..a895f009 100644 --- a/usr/template/travel.html +++ b/usr/template/travel.html @@ -11,9 +11,6 @@ cursor:pointer; background-color:lightgray; } - code { - font-size:14px; - } .name { padding-left:10px; text-align:left; @@ -36,6 +33,9 @@ padding:10px; margin:0px; } + code { + font-size:14px; + } @@ -100,6 +100,147 @@ {{end}} +{{define "command2"}} +{{$meta := .}} +
command +
+ {{$l := index .append|len}} + {{if gt $l 0}} + {{$first := index .append 0}} + {{range $i, $k := index . $first}} +
+ {{$command := index $meta "key" $i}} + {{range $key := index $meta "append"}} +
+ {{if eq $key "input"}} + + {{else if eq $key "key"}} + {{$command}} + {{else}} + {{index $meta $key $i}} + {{end}} +
+ {{end}} + + +
+ {{end}} + {{end}} +
+
+
+
+
+ +{{end}} + {{define "command"}}
command @@ -127,8 +268,8 @@
-
+