forked from x/ContextOS
opt wiki.js
This commit is contained in:
parent
53af2e0481
commit
d14fe90543
@ -1123,6 +1123,37 @@ func (m *Message) Parse(arg interface{}) string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
func (m *Message) ToHTML() string {
|
||||
cmd := strings.Join(m.Meta["detail"], " ")
|
||||
result := []string{}
|
||||
if len(m.Meta["append"]) > 0 {
|
||||
result = append(result, "<table>")
|
||||
result = append(result, "<caption>", cmd, "</caption>")
|
||||
m.Table(func(maps map[string]string, list []string, line int) bool {
|
||||
if line == -1 {
|
||||
result = append(result, "<tr>")
|
||||
for _, v := range list {
|
||||
result = append(result, "<th>", v, "</th>")
|
||||
}
|
||||
result = append(result, "</tr>")
|
||||
return true
|
||||
}
|
||||
result = append(result, "<tr>")
|
||||
for _, v := range list {
|
||||
result = append(result, "<td>", v, "</td>")
|
||||
}
|
||||
result = append(result, "</tr>")
|
||||
return true
|
||||
})
|
||||
result = append(result, "</table>")
|
||||
} else {
|
||||
result = append(result, "<pre><code>")
|
||||
result = append(result, fmt.Sprintf("%s", m.Find("shy", false).Conf("prompt")), cmd, "\n")
|
||||
result = append(result, m.Meta["result"]...)
|
||||
result = append(result, "</code></pre>")
|
||||
}
|
||||
return strings.Join(result, "")
|
||||
}
|
||||
|
||||
func (m *Message) Gdb(arg ...interface{}) interface{} {
|
||||
if g := m.Sess("gdb", false); g != nil {
|
||||
|
@ -40,10 +40,8 @@ type NFS struct {
|
||||
func dir(m *ctx.Message, name string, level int, deep bool, dir_type string, trip int, dir_reg *regexp.Regexp, fields []string, format string) {
|
||||
back, e := os.Getwd()
|
||||
m.Assert(e)
|
||||
os.Chdir(name)
|
||||
defer os.Chdir(back)
|
||||
|
||||
if fs, e := ioutil.ReadDir("."); m.Assert(e) {
|
||||
if fs, e := ioutil.ReadDir(name); m.Assert(e) {
|
||||
for _, f := range fs {
|
||||
if f.Name() == "." || f.Name() == ".." {
|
||||
continue
|
||||
@ -53,7 +51,7 @@ func dir(m *ctx.Message, name string, level int, deep bool, dir_type string, tri
|
||||
continue
|
||||
}
|
||||
|
||||
f, e := os.Stat(f.Name())
|
||||
f, e := os.Stat(path.Join(name, f.Name()))
|
||||
if e != nil {
|
||||
m.Log("info", "%s", e)
|
||||
continue
|
||||
@ -91,11 +89,11 @@ func dir(m *ctx.Message, name string, level int, deep bool, dir_type string, tri
|
||||
case "line":
|
||||
nline := 0
|
||||
if f.IsDir() {
|
||||
d, e := ioutil.ReadDir(f.Name())
|
||||
d, e := ioutil.ReadDir(path.Join(name, f.Name()))
|
||||
m.Assert(e)
|
||||
nline = len(d)
|
||||
} else {
|
||||
f, e := os.Open(f.Name())
|
||||
f, e := os.Open(path.Join(name, f.Name()))
|
||||
m.Assert(e)
|
||||
defer f.Close()
|
||||
|
||||
@ -108,7 +106,7 @@ func dir(m *ctx.Message, name string, level int, deep bool, dir_type string, tri
|
||||
m.Add("append", "line", nline)
|
||||
case "hash":
|
||||
if f.IsDir() {
|
||||
d, e := ioutil.ReadDir(f.Name())
|
||||
d, e := ioutil.ReadDir(path.Join(name, f.Name()))
|
||||
m.Assert(e)
|
||||
meta := []string{}
|
||||
for _, v := range d {
|
||||
@ -121,7 +119,7 @@ func dir(m *ctx.Message, name string, level int, deep bool, dir_type string, tri
|
||||
break
|
||||
}
|
||||
|
||||
f, e := ioutil.ReadFile(f.Name())
|
||||
f, e := ioutil.ReadFile(path.Join(name, f.Name()))
|
||||
m.Assert(e)
|
||||
h := sha1.Sum(f)
|
||||
m.Add("append", "hash", hex.EncodeToString(h[:]))
|
||||
@ -129,7 +127,7 @@ func dir(m *ctx.Message, name string, level int, deep bool, dir_type string, tri
|
||||
}
|
||||
}
|
||||
if f.IsDir() && deep {
|
||||
dir(m, f.Name(), level+1, deep, dir_type, trip, dir_reg, fields, format)
|
||||
dir(m, path.Join(name, f.Name()), level+1, deep, dir_type, trip, dir_reg, fields, format)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -858,6 +858,12 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
return
|
||||
}},
|
||||
"componet": &ctx.Command{Name: "componet [group [order [arg...]]]", Help: "添加组件, group: 组件分组, arg...: 组件参数", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
if len(arg) > 0 && arg[0] == "share" {
|
||||
m.Cmd("aaa.role", arg[1], "componet", arg[2], "command", arg[3:])
|
||||
m.Echo("%s/?componet_group=%s&relay=%s", m.Conf("serve", "site"), arg[2], m.Cmdx("aaa.relay", "share", arg[1]))
|
||||
return
|
||||
}
|
||||
|
||||
switch len(arg) {
|
||||
case 0:
|
||||
m.Cmdy("ctx.config", "componet")
|
||||
@ -971,7 +977,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
}
|
||||
}
|
||||
}
|
||||
msg.Log("fuck", "what %v", val)
|
||||
msg.Log("fuck", "%s", msg.Option("componet_name"))
|
||||
|
||||
// 添加设备
|
||||
arg = arg[:0]
|
||||
|
@ -64,9 +64,19 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
map[string]interface{}{"name": "viewport", "content": "width=device-width, initial-scale=0.7, user-scalable=no"},
|
||||
}, "favicon": "favicon.ico", "styles": []interface{}{"example.css", "code.css"}},
|
||||
|
||||
map[string]interface{}{"componet_name": "com", "componet_help": "com", "componet_tmpl": "componet",
|
||||
"componet_view": "ComList", "componet_init": "initComList",
|
||||
"componet_ctx": "web.code", "componet_cmd": "componet", "componet_args": []interface{}{"share", "@role", "@componet_group", "@tips"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "role", "value": "tech", "label": "role"},
|
||||
map[string]interface{}{"type": "text", "name": "tips", "value": "schedule", "label": "tips"},
|
||||
map[string]interface{}{"type": "button", "value": "共享页面"},
|
||||
},
|
||||
},
|
||||
|
||||
map[string]interface{}{"componet_name": "text", "componet_help": "text", "componet_tmpl": "componet",
|
||||
"componet_view": "ScheduleText", "componet_init": "initScheduleText",
|
||||
"componet_ctx": "web.code", "componet_cmd": "schedule", "componet_args": []interface{}{"@time", "@name", "@place"}, "inputs": []interface{}{
|
||||
"componet_ctx": "web.code", "componet_cmd": "schedule",
|
||||
"componet_args": []interface{}{"@time", "@name", "@place"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "time", "value": "", "label": "time"},
|
||||
map[string]interface{}{"type": "text", "name": "name", "value": "", "label": "name"},
|
||||
map[string]interface{}{"type": "text", "name": "place", "value": "", "label": "place"},
|
||||
@ -77,6 +87,15 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
map[string]interface{}{"componet_name": "list", "componet_help": "list", "componet_tmpl": "componet",
|
||||
"componet_view": "ScheduleList", "componet_init": "initScheduleList",
|
||||
"componet_ctx": "web.code", "componet_cmd": "schedule",
|
||||
"inputs": []interface{}{
|
||||
map[string]interface{}{"type": "choice", "name": "view", "value": "summary", "label": "显示字段", "choice": []interface{}{
|
||||
map[string]interface{}{"name": "默认", "value": "default"},
|
||||
map[string]interface{}{"name": "行程", "value": "order"},
|
||||
map[string]interface{}{"name": "总结", "value": "summary"},
|
||||
}},
|
||||
map[string]interface{}{"type": "button", "value": "刷新行程"},
|
||||
},
|
||||
"display_result": "",
|
||||
},
|
||||
|
||||
map[string]interface{}{"componet_name": "tail", "componet_tmpl": "tail",
|
||||
@ -229,6 +248,11 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
}, Help: "文档管理"},
|
||||
"schedule": &ctx.Config{Name: "schedule", Value: map[string]interface{}{
|
||||
"data": []interface{}{},
|
||||
"view": map[string]interface{}{
|
||||
"default": []interface{}{"面试时间", "面试公司", "面试地点", "面试轮次", "题目类型", "面试题目", "面试总结"},
|
||||
"summary": []interface{}{"面试公司", "面试轮次", "题目类型", "面试题目", "面试总结"},
|
||||
"order": []interface{}{"面试时间", "面试公司", "面试地点"},
|
||||
},
|
||||
"maps": map[string]interface{}{"baidu": "<a href='baidumap://map/direction?region=&origin=&destination=%s'>%s</a>"},
|
||||
}, Help: "闪存"},
|
||||
|
||||
@ -405,16 +429,39 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
"schedule": &ctx.Command{Name: "schedule [time name place]", Help: "行程安排", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
if len(arg) == 0 { // 会话列表
|
||||
m.Confm("schedule", "data", func(index int, value map[string]interface{}) {
|
||||
m.Add("append", "time", kit.Format(value["time"]))
|
||||
m.Add("append", "name", kit.Format(value["name"]))
|
||||
m.Add("append", "place", fmt.Sprintf(m.Conf("schedule", "maps.baidu"), value["place"], value["place"]))
|
||||
for _, v := range kit.View([]string{m.Option("view")}, m.Confm("schedule", "view")) {
|
||||
if v == "面试地点" {
|
||||
m.Add("append", "面试地点", fmt.Sprintf(m.Conf("schedule", "maps.baidu"), value["面试地点"], value["面试地点"]))
|
||||
continue
|
||||
}
|
||||
m.Add("append", v, kit.Format(value[v]))
|
||||
}
|
||||
})
|
||||
m.Table()
|
||||
return
|
||||
}
|
||||
m.Conf("schedule", []string{"data", "-1"}, map[string]interface{}{
|
||||
"time": arg[0], "name": arg[1], "place": arg[2],
|
||||
})
|
||||
|
||||
view := "default"
|
||||
if m.Confs("schedule", arg[0]) {
|
||||
view, arg = arg[0], arg[1:]
|
||||
}
|
||||
|
||||
data := map[string]interface{}{}
|
||||
for _, k := range kit.View([]string{view}, m.Confm("schedule", "view")) {
|
||||
if len(arg) == 0 {
|
||||
data[k] = ""
|
||||
continue
|
||||
}
|
||||
data[k], arg = arg[0], arg[1:]
|
||||
}
|
||||
|
||||
extra := map[string]interface{}{}
|
||||
for i := 0; i < len(arg)-1; i += 2 {
|
||||
data[arg[i]] = arg[i+1]
|
||||
}
|
||||
data["extra"] = extra
|
||||
|
||||
m.Conf("schedule", []string{"data", "-1"}, data)
|
||||
return
|
||||
}},
|
||||
|
||||
|
@ -14,42 +14,77 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"toolkit"
|
||||
)
|
||||
|
||||
var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
||||
Caches: map[string]*ctx.Cache{},
|
||||
Configs: map[string]*ctx.Config{
|
||||
"wiki_dir": &ctx.Config{Name: "wiki_dir", Value: "usr/wiki", Help: "路由数量"},
|
||||
"wiki_favor": &ctx.Config{Name: "wiki_favor", Value: "lamp.md", Help: "路由数量"},
|
||||
"login": &ctx.Config{Name: "login", Value: map[string]interface{}{"check": "false"}, Help: "默认组件"},
|
||||
"componet": &ctx.Config{Name: "componet", Value: map[string]interface{}{
|
||||
"index": []interface{}{
|
||||
map[string]interface{}{"componet_name": "wiki", "componet_tmpl": "head", "metas": []interface{}{
|
||||
map[string]interface{}{"name": "viewport", "content": "width=device-width, initial-scale=0.7, user-scalable=no"},
|
||||
}, "favicon": "favicon.ico", "styles": []interface{}{"example.css", "wiki.css"}},
|
||||
map[string]interface{}{"componet_name": "header", "componet_tmpl": "fieldset",
|
||||
"componet_view": "Header", "componet_init": "initHeader",
|
||||
"title": "shylinux 天行健,君子以自强不息",
|
||||
},
|
||||
|
||||
map[string]interface{}{"componet_name": "tree", "componet_tmpl": "fieldset",
|
||||
"componet_view": "Tree", "componet_init": "initTree",
|
||||
"componet_ctx": "web.wiki", "componet_cmd": "wiki_tree", "arguments": []interface{}{"@wiki_class"},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "text", "componet_tmpl": "fieldset",
|
||||
"componet_view": "Text", "componet_init": "initText",
|
||||
"componet_ctx": "web.wiki", "componet_cmd": "wiki_text", "arguments": []interface{}{"@wiki_favor"},
|
||||
},
|
||||
|
||||
map[string]interface{}{"componet_name": "footer", "componet_tmpl": "fieldset",
|
||||
"componet_view": "Footer", "componet_init": "initFooter",
|
||||
"title": "shycontext 地势坤,君子以厚德载物",
|
||||
},
|
||||
map[string]interface{}{"componet_name": "tail", "componet_tmpl": "tail",
|
||||
"scripts": []interface{}{"toolkit.js", "context.js", "example.js", "wiki.js"},
|
||||
},
|
||||
},
|
||||
}, Help: "组件列表"},
|
||||
"componet_group": &ctx.Config{Name: "component_group", Value: "index", Help: "默认组件"},
|
||||
|
||||
"wiki_level": &ctx.Config{Name: "wiki_level", Value: "wiki/自然/编程", Help: "路由数量"},
|
||||
"wiki_favor": &ctx.Config{Name: "wiki_favor", Value: "index.md", Help: "路由数量"},
|
||||
|
||||
"wiki_dir": &ctx.Config{Name: "wiki_dir", Value: "wiki", Help: "路由数量"},
|
||||
"wiki_list": &ctx.Config{Name: "wiki_list", Value: []interface{}{}, Help: "路由数量"},
|
||||
"wiki_list_show": &ctx.Config{Name: "wiki_list_show", Value: map[string]interface{}{
|
||||
"md": true,
|
||||
}, Help: "路由数量"},
|
||||
"bench_disable": &ctx.Config{Name: "bench_disable", Value: "true", Help: "工作流"},
|
||||
"login": &ctx.Config{Name: "login", Value: map[string]interface{}{
|
||||
"check": "false",
|
||||
}, Help: "默认组件"},
|
||||
|
||||
"componet_group": &ctx.Config{Name: "component_group", Value: "index", Help: "默认组件"},
|
||||
"componet": &ctx.Config{Name: "componet", Value: map[string]interface{}{
|
||||
"index": []interface{}{
|
||||
map[string]interface{}{"name": "head", "template": "head"},
|
||||
map[string]interface{}{"name": "header", "template": "header"},
|
||||
map[string]interface{}{"name": "list", "template": "list",
|
||||
"componet_ctx": "web.wiki", "componet_cmd": "wiki_list", "arguments": []interface{}{"time", "time_r"},
|
||||
"pre_run": true,
|
||||
},
|
||||
map[string]interface{}{"name": "text", "template": "text",
|
||||
"componet_ctx": "web.wiki", "componet_cmd": "wiki_body", "arguments": []interface{}{"@wiki_favor"},
|
||||
"pre_run": true,
|
||||
},
|
||||
map[string]interface{}{"name": "footer", "template": "footer"},
|
||||
map[string]interface{}{"name": "tail", "template": "tail"},
|
||||
},
|
||||
}, Help: "组件列表"},
|
||||
},
|
||||
Commands: map[string]*ctx.Command{
|
||||
"wiki_tree": &ctx.Command{Name: "wiki_tree", Help: "wiki_tree", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
m.Cmdy("nfs.dir", path.Join(m.Confx("wiki_level"), kit.Select(m.Option("wiki_class"), arg, 0)), "dir_sort", "time_r")
|
||||
return
|
||||
}},
|
||||
"wiki_text": &ctx.Command{Name: "wiki_text", Help: "wiki_text", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
which := m.Cmdx("nfs.path", path.Join(m.Confx("wiki_level"), m.Option("wiki_class"), m.Confx("wiki_favor", arg, 0)))
|
||||
|
||||
if ls, e := ioutil.ReadFile(which); e == nil {
|
||||
buffer := bytes.NewBuffer([]byte{})
|
||||
temp, e := template.New("temp").Funcs(ctx.CGI).Parse(string(ls))
|
||||
if e != nil {
|
||||
m.Log("info", "parse %s %s", which, e)
|
||||
}
|
||||
temp.Execute(buffer, m)
|
||||
ls = buffer.Bytes()
|
||||
|
||||
ls = markdown.ToHTML(ls, nil, nil)
|
||||
m.Echo(string(ls))
|
||||
} else {
|
||||
m.Echo(m.Cmd("nfs.dir", path.Join(m.Confx("wiki_level"), m.Option("wiki_class")),
|
||||
"dir_deep", "dir_type", "dir", "time", "path").ToHTML())
|
||||
}
|
||||
return
|
||||
}},
|
||||
"wiki_list": &ctx.Command{Name: "wiki_list sort_field sort_order", Help: "wiki_list", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
sort_field, sort_order := "time", "time_r"
|
||||
if len(arg) > 0 {
|
||||
@ -59,12 +94,13 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
||||
sort_order, arg = arg[0], arg[1:]
|
||||
}
|
||||
|
||||
md, e := ioutil.ReadDir(m.Conf("wiki_dir"))
|
||||
dir := path.Join(m.Conf("wiki_dir"), m.Option("wiki_class"))
|
||||
md, e := ioutil.ReadDir(dir)
|
||||
m.Assert(e)
|
||||
|
||||
for _, v := range md {
|
||||
if strings.HasSuffix(v.Name(), ".md") {
|
||||
f, e := os.Open(path.Join(m.Conf("wiki_dir"), v.Name()))
|
||||
f, e := os.Open(path.Join(dir, v.Name()))
|
||||
m.Assert(e)
|
||||
defer f.Close()
|
||||
|
||||
@ -112,23 +148,6 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
||||
})
|
||||
return
|
||||
}},
|
||||
"wiki_body": &ctx.Command{Name: "wiki_body", Help: "wiki_body", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
which := path.Join(m.Conf("wiki_dir"), m.Confx("wiki_favor", arg, 0))
|
||||
if ls, e := ioutil.ReadFile(which); e == nil {
|
||||
|
||||
buffer := bytes.NewBuffer([]byte{})
|
||||
temp, e := template.New("temp").Funcs(ctx.CGI).Parse(string(ls))
|
||||
if e != nil {
|
||||
m.Log("info", "parse %s %s", which, e)
|
||||
}
|
||||
temp.Execute(buffer, m)
|
||||
ls = buffer.Bytes()
|
||||
|
||||
ls = markdown.ToHTML(ls, nil, nil)
|
||||
m.Echo(string(ls))
|
||||
}
|
||||
return
|
||||
}},
|
||||
|
||||
"/wiki_tags": &ctx.Command{Name: "/wiki_tags ", Help: "博客", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
if len(arg) > 0 {
|
||||
|
@ -26,44 +26,6 @@
|
||||
clear:both;
|
||||
}
|
||||
|
||||
fieldset table.append {
|
||||
font-size:14px;
|
||||
overflow: auto;
|
||||
}
|
||||
fieldset table.append tr:hover {
|
||||
background-color:lightgreen;
|
||||
}
|
||||
fieldset table.append th {
|
||||
font-family:monospace;
|
||||
background-color:lightgreen;
|
||||
cursor:pointer;
|
||||
}
|
||||
fieldset table.append th.order {
|
||||
background-color:red;
|
||||
cursor:pointer;
|
||||
}
|
||||
fieldset table.append td {
|
||||
max-width:1200px;
|
||||
font-family:monospace;
|
||||
padding-left: 10px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
fieldset table.append td.clip {
|
||||
background-color:red;
|
||||
}
|
||||
fieldset table.append td:hover {
|
||||
background-color:red;
|
||||
}
|
||||
fieldset code.result pre {
|
||||
color:white;
|
||||
font-size:14px;
|
||||
background-color:#272822;
|
||||
overflow:scroll;
|
||||
padding:5px;
|
||||
border:solid 2px green;
|
||||
border-left:solid 4px green;
|
||||
margin:0;
|
||||
}
|
||||
fieldset code.result pre.clipboard {
|
||||
height:2em;
|
||||
}
|
||||
@ -115,4 +77,9 @@
|
||||
fieldset.KitList li>input {
|
||||
background-color:rgba(0,0,0,0.2);
|
||||
}
|
||||
/* ----- ScheduleList ----- */
|
||||
fieldset.ScheduleList table.append td {
|
||||
max-width:240px;
|
||||
min-width:100px;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,8 @@
|
||||
var page = Page({
|
||||
initComList: function(page, field, option, append, result) {
|
||||
return
|
||||
},
|
||||
|
||||
initScheduleText: function(page, field, option, append, result) {
|
||||
option.ondaemon = function(msg) {
|
||||
page.reload()
|
||||
@ -521,9 +525,6 @@ var page = Page({
|
||||
var page = this
|
||||
switch (action) {
|
||||
case "scroll":
|
||||
if (event.target == document.body) {
|
||||
kit.ScrollPage(event, page.conf)
|
||||
}
|
||||
break
|
||||
case "keymap":
|
||||
if (event.key == "Escape") {
|
||||
@ -563,9 +564,6 @@ var page = Page({
|
||||
init: function(exp) {
|
||||
var page = this
|
||||
var body = document.body
|
||||
body.onkeydown = function(event) {
|
||||
page.onaction(event, body, "scroll")
|
||||
}
|
||||
body.onkeyup = function(event) {
|
||||
page.onaction(event, body, "keymap")
|
||||
}
|
||||
@ -575,8 +573,8 @@ var page = Page({
|
||||
var append = field.querySelector("table.append")
|
||||
var result = field.querySelector("code.result pre")
|
||||
page.OrderForm(page, field, option, append, result)
|
||||
page.OrderTable(append)
|
||||
page.OrderCode(result)
|
||||
append && page.OrderTable(append)
|
||||
result && page.OrderCode(result)
|
||||
|
||||
var init = page[field.dataset.init]
|
||||
if (typeof init == "function") {
|
||||
|
@ -39,7 +39,14 @@ ctx = context = {
|
||||
ret.push(one)
|
||||
}
|
||||
|
||||
typeof cb == "function" && ret.forEach(cb)
|
||||
var list = []
|
||||
typeof cb == "function" && ret.forEach(function(value, index, array) {
|
||||
var item = cb(value, index, array)
|
||||
item && list.push(item)
|
||||
})
|
||||
if (list.length > 0) {
|
||||
return list
|
||||
}
|
||||
return ret
|
||||
},
|
||||
|
||||
|
@ -4,3 +4,49 @@ html, body {
|
||||
margin:0px;
|
||||
background-color:#d8d8d8;
|
||||
}
|
||||
|
||||
fieldset table {
|
||||
font-size:14px;
|
||||
overflow: auto;
|
||||
border:solid 1px green;
|
||||
}
|
||||
fieldset table caption {
|
||||
font-size:18px;
|
||||
font-style:italic;
|
||||
border:solid 1px green;
|
||||
}
|
||||
fieldset table tr:hover {
|
||||
background-color:lightgreen;
|
||||
}
|
||||
fieldset table th {
|
||||
font-family:monospace;
|
||||
background-color:lightgreen;
|
||||
cursor:pointer;
|
||||
}
|
||||
fieldset table th.order {
|
||||
background-color:red;
|
||||
cursor:pointer;
|
||||
}
|
||||
fieldset table td {
|
||||
max-width:1200px;
|
||||
font-family:monospace;
|
||||
padding-left: 10px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
fieldset table td.clip {
|
||||
background-color:red;
|
||||
}
|
||||
fieldset table td:hover {
|
||||
background-color:red;
|
||||
}
|
||||
|
||||
fieldset pre code, fieldset code pre {
|
||||
color:white;
|
||||
font-size:14px;
|
||||
background-color:#272822;
|
||||
overflow:scroll;
|
||||
padding:5px;
|
||||
border:solid 2px green;
|
||||
border-left:solid 4px green;
|
||||
display:block;
|
||||
}
|
||||
|
@ -2,8 +2,32 @@ exp = example = {
|
||||
__proto__: ctx,
|
||||
_init: function(page) {
|
||||
page.__proto__ = this
|
||||
|
||||
var body = document.body
|
||||
body.onkeydown = function(event) {
|
||||
page.onscroll && page.onscroll(event, body, "scroll")
|
||||
}
|
||||
return this
|
||||
},
|
||||
initHeader: function(field, option, output) {
|
||||
return [{"text": ["shylinux", "div", "title"]}]
|
||||
},
|
||||
initBanner: function(field, option, output) {
|
||||
return [{"text": ["shylinux", "div", "title"]}]
|
||||
},
|
||||
initFooter: function(field, option) {
|
||||
return [{"text": ["shycontext", "div", "title"]}]
|
||||
},
|
||||
onscroll: function(event, target, action) {
|
||||
var page = this
|
||||
switch (action) {
|
||||
case "scroll":
|
||||
if (event.target == document.body) {
|
||||
kit.ScrollPage(event, page.conf)
|
||||
}
|
||||
break
|
||||
}
|
||||
},
|
||||
reload: function() {
|
||||
location.reload()
|
||||
},
|
||||
|
@ -74,6 +74,9 @@ kit = toolkit = {
|
||||
}
|
||||
child.data["style"] = str.join("")
|
||||
}
|
||||
if (child.click) {
|
||||
child.data["onclick"] = child.click
|
||||
}
|
||||
|
||||
if (child.include) {
|
||||
child.data["src"] = child.include[0]
|
||||
@ -109,19 +112,20 @@ kit = toolkit = {
|
||||
child.data["innerText"] = child.button[0]
|
||||
child.data["onclick"] = child.button[1]
|
||||
|
||||
} else if (child.click) {
|
||||
child.data["onclick"] = child.click[0]
|
||||
} else if (child.tree) {
|
||||
child.type = "ul"
|
||||
child.list = child.tree
|
||||
|
||||
} else if (child.fork) {
|
||||
child.type = "li"
|
||||
child.list = [
|
||||
{"text": [child.fork[0], "div"]},
|
||||
{"text": [child.fork[0], "div"], "click": (child.fork.length>2? child.fork[2]: "")},
|
||||
{"type": "ul", "list": child.fork[1]},
|
||||
]
|
||||
|
||||
} else if (child.leaf) {
|
||||
child.type = "li"
|
||||
child.data["innerText"] = child.leaf[0]
|
||||
child.list = [{"text": [child.leaf[0], "div"]}]
|
||||
if (child.leaf.length > 1 && typeof child.leaf[1] == "function") {
|
||||
child.data["onclick"] = function(event) {
|
||||
child.leaf[1](event, node)
|
||||
@ -131,7 +135,7 @@ kit = toolkit = {
|
||||
} else if (child.view) {
|
||||
child.data["className"] = child.view[0]
|
||||
child.type = child.view.length > 1? child.view[1]: "div"
|
||||
child.view.length > 2 && (child.data["innerText"] = child.view[2])
|
||||
child.view.length > 2 && (child.data["innerHTML"] = child.view[2])
|
||||
child.view.length > 3 && (child.name = child.view[3])
|
||||
|
||||
} else if (child.text) {
|
||||
@ -340,6 +344,9 @@ kit = toolkit = {
|
||||
}
|
||||
})
|
||||
},
|
||||
OrderLink: function(link) {
|
||||
link.target = "_blank"
|
||||
},
|
||||
|
||||
CopyText: function(text) {
|
||||
text = window.getSelection().toString()
|
||||
|
22
usr/librarys/wiki.css
Normal file
22
usr/librarys/wiki.css
Normal file
@ -0,0 +1,22 @@
|
||||
fieldset.Tree>div.output li>div:hover {
|
||||
background-color:green;
|
||||
}
|
||||
fieldset.Tree>div.output>div.tree li {
|
||||
display:inline;
|
||||
}
|
||||
fieldset.Tree>div.output>div.tree li div {
|
||||
float:left;
|
||||
padding:5px;
|
||||
border:solid 1px green;
|
||||
}
|
||||
fieldset.Tree>div.output>div.list {
|
||||
clear:both;
|
||||
padding-top:5px;
|
||||
}
|
||||
|
||||
fieldset.Text>div.output>div.menu li>div:hover {
|
||||
background-color:red;
|
||||
}
|
||||
fieldset.Text>div.output>div.text {
|
||||
position:relative;
|
||||
}
|
@ -1,392 +1,140 @@
|
||||
var wiki = {
|
||||
layout: {
|
||||
header: {
|
||||
height: 40,
|
||||
},
|
||||
nav: {
|
||||
min_width: 240,
|
||||
border_width: 2,
|
||||
},
|
||||
article: {
|
||||
padding: 20,
|
||||
max_width: 1000,
|
||||
},
|
||||
footer: {
|
||||
height: 40,
|
||||
},
|
||||
var page = Page({
|
||||
initTree: function(field, option, output) {
|
||||
ctx.Runs(page, option, function(msg) {
|
||||
output.innerHTML = ""
|
||||
var back = [{"button": ["知识", function(event) {
|
||||
ctx.Search({"wiki_class": "", "wiki_favor": ""})
|
||||
}]}]
|
||||
ctx.Search("wiki_class").split("/").forEach(function(value, index, array) {
|
||||
if (value) {
|
||||
var favor = []
|
||||
for (var i = 0; i <= index; i++) {
|
||||
favor.push(array[i])
|
||||
}
|
||||
favor.push("")
|
||||
back.push({"button": [value, function(event) {
|
||||
ctx.Search({"wiki_class": favor.join("/"), "wiki_favor":""})
|
||||
}]})
|
||||
}
|
||||
})
|
||||
|
||||
var ui = kit.AppendChild(output, [
|
||||
{"view": ["back"], "list": back},
|
||||
{"view": ["tree"], "list": [{"tree": ctx.Table(msg, function(value, index) {
|
||||
if (value.filename.endsWith("/")) {
|
||||
return {"leaf": [value.filename, function(event, target) {
|
||||
ctx.Search({"wiki_class": ctx.Search("wiki_class")+value.filename, "wiki_favor": ""})
|
||||
}]}
|
||||
}
|
||||
})}]},
|
||||
{"view": ["list"], "list": [{"tree": ctx.Table(msg, function(value, index) {
|
||||
if (!value.filename.endsWith("/")) {
|
||||
return {"leaf": [value.filename, function(event, target) {
|
||||
ctx.Search("wiki_favor", value.filename)
|
||||
}]}
|
||||
}
|
||||
})}]},
|
||||
])
|
||||
})
|
||||
return
|
||||
},
|
||||
initList: function(field, option, output) {
|
||||
ctx.Runs(page, option, function(msg) {
|
||||
output.innerHTML = ""
|
||||
kit.AppendChild(output, [{"tree": ctx.Table(msg, function(value, index) {
|
||||
return {"leaf": [value.file, function(event, target) {
|
||||
ctx.Search("wiki_favor", value.file)
|
||||
}]}
|
||||
})}])
|
||||
})
|
||||
return
|
||||
},
|
||||
initText: function(field, option, output) {
|
||||
ctx.Runs(page, option, function(msg) {
|
||||
if (!msg.result) {
|
||||
return
|
||||
}
|
||||
output.innerHTML = ""
|
||||
var ui = kit.AppendChild(output, [
|
||||
{"view": ["menu", "div", "", "menu"]},
|
||||
{"view": ["text", "div", msg.result.join(""), "text"]},
|
||||
])
|
||||
|
||||
ui.text.querySelectorAll("table").forEach(function(value, index, array) {
|
||||
kit.OrderTable(value, field)
|
||||
})
|
||||
|
||||
ui.text.querySelectorAll("a").forEach(function(value, index, array) {
|
||||
kit.OrderLink(value, field)
|
||||
})
|
||||
|
||||
|
||||
var i = 0, j = 0, k = 0
|
||||
var h0 = [], h2 = [], h3 = []
|
||||
ui.text.querySelectorAll("h2,h3,h4").forEach(function(value, index, array) {
|
||||
var id = ""
|
||||
var level = 0
|
||||
var text = value.innerText
|
||||
var ratio = parseInt(value.offsetTop/field.scrollHeight*100)
|
||||
|
||||
if (value.tagName == "H2") {
|
||||
j=k=0
|
||||
h2 = []
|
||||
id = ++i+"."
|
||||
text = id+" "+text
|
||||
h0.push({"fork": [text+" ("+ratio+"%)", h2, function(event) {
|
||||
console.log(text)
|
||||
location.hash = id
|
||||
}]})
|
||||
} else if (value.tagName == "H3") {
|
||||
k=0
|
||||
h3 = []
|
||||
id = i+"."+(++j)
|
||||
text = id+" "+text
|
||||
h2.push({"fork": [text+" ("+ratio+"%)", h3, function(event) {
|
||||
console.log(text)
|
||||
location.hash = id
|
||||
}]})
|
||||
} else if (value.tagName == "H4") {
|
||||
id = i+"."+(++j)+"."+(++k)
|
||||
text = id+" "+text
|
||||
h3.push({"leaf": [text+" ("+ratio+"%)", function(event) {
|
||||
console.log(text)
|
||||
location.hash = id
|
||||
}]})
|
||||
}
|
||||
value.innerText = text
|
||||
value.id = id
|
||||
})
|
||||
kit.AppendChild(ui.menu, [{"tree": h0}])
|
||||
})
|
||||
return
|
||||
},
|
||||
|
||||
show_result: false,
|
||||
show_height: "30px",
|
||||
hide_height: "14px",
|
||||
scroll_x: 50,
|
||||
scroll_y: 50,
|
||||
}
|
||||
|
||||
function set_layout() {
|
||||
var nav = document.querySelector("nav")
|
||||
var article = document.querySelector("article")
|
||||
|
||||
if (window.innerWidth > 600) {
|
||||
nav.className = "fixed"
|
||||
wiki.layout.article.width = window.innerWidth - nav.offsetWidth- 2*wiki.layout.article.padding
|
||||
article.style.width = wiki.layout.article.width+"px"
|
||||
var space = wiki.layout.article.width - wiki.layout.article.max_width
|
||||
article.style["margin-right"] = (space>0 ? space/2: 0) + "px"
|
||||
} else {
|
||||
nav.className = ""
|
||||
article.style.width = ""
|
||||
|
||||
var space = wiki.layout.article.width - article.style.maxWidth
|
||||
if (space > 0) {
|
||||
article.style.marginRight = space / 2
|
||||
onaction: function(event, target, action) {
|
||||
var page = this
|
||||
switch (action) {
|
||||
case "scroll":
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
init: function(exp) {
|
||||
var page = this
|
||||
document.querySelectorAll("body>fieldset").forEach(function(field) {
|
||||
var option = field.querySelector("form.option")
|
||||
var output = field.querySelector("div.output")
|
||||
|
||||
function action(event, cmd) {
|
||||
var target = event.target
|
||||
var dataset = target.dataset
|
||||
|
||||
switch (cmd) {
|
||||
case "toggle_nav":
|
||||
var nav = document.querySelector("nav")
|
||||
nav.hidden = !nav.hidden
|
||||
set_layout(event)
|
||||
break
|
||||
case "toggle_list":
|
||||
var list = event.target.nextElementSibling
|
||||
list.hidden = !list.hidden
|
||||
break
|
||||
case "scroll":
|
||||
if (target.tagName == "BODY") {
|
||||
scroll_page(event, wiki)
|
||||
var init = page[field.dataset.init]
|
||||
if (typeof init == "function") {
|
||||
var conf = init(field, option, output)
|
||||
if (conf) {
|
||||
kit.AppendChild(output, conf)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
function init_layout() {
|
||||
var header = document.querySelector("header")
|
||||
var nav = document.querySelector("nav")
|
||||
var article = document.querySelector("article")
|
||||
var footer = document.querySelector("footer")
|
||||
|
||||
wiki.layout.nav.height = window.innerHeight - wiki.layout.header.height - wiki.layout.footer.height
|
||||
wiki.layout.article.min_height = window.innerHeight - wiki.layout.header.height - wiki.layout.footer.height - 2*wiki.layout.article.padding
|
||||
|
||||
header.style.height = wiki.layout.header.height+"px"
|
||||
footer.style.height = wiki.layout.footer.height+"px"
|
||||
nav.style.height = wiki.layout.nav.height-wiki.layout.nav.border_width+"px"
|
||||
nav.style.minWidth = wiki.layout.nav.min_width+"px"
|
||||
nav.style.marginTop = wiki.layout.header.height+"px"
|
||||
article.style.minHeight = wiki.layout.article.min_height+"px"
|
||||
article.style.marginTop = wiki.layout.header.height+"px"
|
||||
article.style.padding = wiki.layout.article.padding+"px"
|
||||
article.style.maxWidth = wiki.layout.article.max_width+"px"
|
||||
|
||||
set_layout()
|
||||
}
|
||||
function init_menu() {
|
||||
var max = 0;
|
||||
var min = 1000;
|
||||
var list = [];
|
||||
var hs = ["h2", "h3", "h4"];
|
||||
for (var i = 0; i < hs.length; i++) {
|
||||
var head = document.getElementsByTagName(hs[i]);
|
||||
for (var j = 0; j < head.length; j++) {
|
||||
head[j].id = hs[i]+"_"+j
|
||||
head[j].onclick = function(event) {
|
||||
location.hash=event.target.id
|
||||
}
|
||||
list.push({"level": hs[i], "position": head[j].offsetTop, "title": head[j].innerText, "hash": head[j].id})
|
||||
if (head[j].offsetTop > max) {
|
||||
max = head[j].offsetTop;
|
||||
}
|
||||
if (head[j].offsetTop < min) {
|
||||
min = head[j].offsetTop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
max = max - min;
|
||||
for (var i = 0; i < list.length-1; i++) {
|
||||
for (var j = i+1; j < list.length; j++) {
|
||||
if (list[j].position < list[i].position) {
|
||||
var a = list[i];
|
||||
list[i] = list[j];
|
||||
list[j] = a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var index = [-1, 0, 0]
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i].level == "h2") {
|
||||
index[0]++;
|
||||
index[1]=0;
|
||||
index[2]=0;
|
||||
} else if (list[i].level == "h3") {
|
||||
index[1]++;
|
||||
index[2]=0;
|
||||
} else {
|
||||
index[2]++;
|
||||
}
|
||||
|
||||
list[i].index4 = index[2];
|
||||
list[i].index3 = index[1];
|
||||
list[i].index2 = index[0];
|
||||
}
|
||||
|
||||
var m = document.getElementsByClassName("menu");
|
||||
for (var i = 0; i < m.length; i++) {
|
||||
for (var j = 0; j < list.length; j++) {
|
||||
var text = list[j].index2+"."
|
||||
if (list[j].level == "h3") {
|
||||
text += list[j].index3
|
||||
} else if (list[j].level == "h4") {
|
||||
text += list[j].index3+"."+list[j].index4
|
||||
}
|
||||
|
||||
text += " "
|
||||
text += list[j].title;
|
||||
|
||||
var h = document.getElementById(list[j].hash)
|
||||
h.innerText = text
|
||||
|
||||
var one = append_child(m[i], "li")
|
||||
var a = append_child(one, "a")
|
||||
a.href = "#"+list[j].hash;
|
||||
a.innerText = text+" ("+parseInt((list[j].position-min)/max*100)+"%)";
|
||||
|
||||
one.className = list[j].level;
|
||||
}
|
||||
}
|
||||
}
|
||||
function init_link() {
|
||||
var link = document.querySelector("nav .link");
|
||||
document.querySelectorAll("article a").forEach(function(item) {
|
||||
append_child(append_child(link, "li", {"innertText": item.innerText}), "a", {
|
||||
"href": item.href,
|
||||
"innerText": item.href,
|
||||
})
|
||||
})
|
||||
}
|
||||
function init_code() {
|
||||
var fuck = kit.isMobile? 22: 16
|
||||
|
||||
document.querySelectorAll("article pre").forEach(function(item, i) {
|
||||
var nu = insert_before(item, "div", {"className": "number1"})
|
||||
|
||||
var line = (item.clientHeight-10)/fuck
|
||||
for (var j = 1; j <= line; j++) {
|
||||
append_child(nu, "div", {
|
||||
"style": {
|
||||
"fontSize": kit.isMobile?"20px":"14px",
|
||||
"lineHeight": kit.isMobile?"22px":"16px",
|
||||
},
|
||||
"id": "code"+i+"_"+"line"+j,
|
||||
"onclick": function(event) {
|
||||
location.href = "#"+event.target.id
|
||||
},
|
||||
}).appendChild(document.createTextNode(""+j));
|
||||
}
|
||||
|
||||
item.onclick = function(event) {
|
||||
window.getSelection().toString() && document.execCommand("copy")
|
||||
}
|
||||
})
|
||||
}
|
||||
function init_table(event) {
|
||||
var append = document.querySelectorAll("article table").forEach(add_sort)
|
||||
}
|
||||
function adjust() {
|
||||
window.setTimeout(function(){
|
||||
window.scrollBy(0, -80)
|
||||
}, 100)
|
||||
}
|
||||
|
||||
window.onresize = function (event) {
|
||||
init_layout()
|
||||
}
|
||||
window.onload = function(event) {
|
||||
init_menu()
|
||||
init_link()
|
||||
init_code()
|
||||
init_table()
|
||||
init_layout()
|
||||
}
|
||||
|
||||
function modify_node(which, html) {
|
||||
var node = which
|
||||
if (typeof which == "string") {
|
||||
node = document.querySelector(which)
|
||||
}
|
||||
|
||||
html && typeof html == "string" && (node.innerHTML = html)
|
||||
if (html && typeof html == "object") {
|
||||
for (var k in html) {
|
||||
if (typeof html[k] == "object") {
|
||||
for (var d in html[k]) {
|
||||
node[k][d] = html[k][d]
|
||||
}
|
||||
continue
|
||||
}
|
||||
node[k] = html[k]
|
||||
}
|
||||
}
|
||||
return node
|
||||
}
|
||||
function create_node(element, html) {
|
||||
var node = document.createElement(element)
|
||||
return modify_node(node, html)
|
||||
}
|
||||
function append_child(parent, element, html) {
|
||||
var elm = create_node(element, html)
|
||||
parent.append(elm)
|
||||
return elm
|
||||
}
|
||||
function insert_before(self, element, html) {
|
||||
var elm = create_node(element, html)
|
||||
return self.parentElement.insertBefore(elm, self)
|
||||
}
|
||||
|
||||
function format(str) {
|
||||
if (str.indexOf("http") == 0 && str.indexOf("<a href") == -1) {
|
||||
return "<a href='"+str+"' target='_blank'>"+str+"</a>"
|
||||
}
|
||||
return str
|
||||
}
|
||||
function sort_table(table, index, sort_asc) {
|
||||
var list = table.querySelectorAll("tr")
|
||||
var new_list = []
|
||||
|
||||
var is_time = true
|
||||
var is_number = true
|
||||
for (var i = 1; i < list.length; i++) {
|
||||
var value = Date.parse(list[i].childNodes[index].innerText)
|
||||
if (!(value > 0)) {
|
||||
is_time = false
|
||||
}
|
||||
|
||||
var value = parseInt(list[i].childNodes[index].innerText)
|
||||
if (!(value >= 0 || value <= 0)) {
|
||||
is_number = false
|
||||
}
|
||||
|
||||
new_list.push(list[i])
|
||||
}
|
||||
|
||||
var sort_order = ""
|
||||
if (is_time) {
|
||||
if (sort_asc) {
|
||||
method = function(a, b) {return Date.parse(a) > Date.parse(b)}
|
||||
sort_order = "time"
|
||||
} else {
|
||||
method = function(a, b) {return Date.parse(a) < Date.parse(b)}
|
||||
sort_order = "time_r"
|
||||
}
|
||||
} else if (is_number) {
|
||||
if (sort_asc) {
|
||||
method = function(a, b) {return parseInt(a) > parseInt(b)}
|
||||
sort_order = "int"
|
||||
} else {
|
||||
method = function(a, b) {return parseInt(a) < parseInt(b)}
|
||||
sort_order = "int_r"
|
||||
}
|
||||
} else {
|
||||
if (sort_asc) {
|
||||
method = function(a, b) {return a > b}
|
||||
sort_order = "str"
|
||||
} else {
|
||||
method = function(a, b) {return a < b}
|
||||
sort_order = "str_r"
|
||||
}
|
||||
}
|
||||
|
||||
list = new_list
|
||||
new_list = []
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
list[i].parentElement && list[i].parentElement.removeChild(list[i])
|
||||
for (var j = i+1; j < list.length; j++) {
|
||||
if (typeof method == "function" && method(list[i].childNodes[index].innerText, list[j].childNodes[index].innerText)) {
|
||||
var temp = list[i]
|
||||
list[i] = list[j]
|
||||
list[j] = temp
|
||||
}
|
||||
}
|
||||
new_list.push(list[i])
|
||||
}
|
||||
|
||||
for (var i = 0; i < new_list.length; i++) {
|
||||
table.appendChild(new_list[i])
|
||||
}
|
||||
return sort_order
|
||||
}
|
||||
function add_sort(append, field, cb) {
|
||||
append.onclick = function(event) {
|
||||
var target = event.target
|
||||
var dataset = target.dataset
|
||||
var nodes = target.parentElement.childNodes
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i] == target) {
|
||||
if (target.tagName == "TH") {
|
||||
dataset["sort_asc"] = (dataset["sort_asc"] == "1") ? 0: 1
|
||||
sort_table(append, i, dataset["sort_asc"] == "1")
|
||||
} else if (target.tagName == "TD") {
|
||||
var tr = target.parentElement.parentElement.querySelector("tr")
|
||||
if (tr.childNodes[i].innerText.startsWith(field)) {
|
||||
typeof cb == "function" && cb(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function scroll_page(event, page) {
|
||||
var body = document.querySelector("body")
|
||||
|
||||
switch (event.key) {
|
||||
case "h":
|
||||
if (event.ctrlKey) {
|
||||
window.scrollBy(-page.scroll_x*10, 0)
|
||||
} else {
|
||||
window.scrollBy(-page.scroll_x, 0)
|
||||
}
|
||||
break
|
||||
case "H":
|
||||
window.scrollBy(-body.scrollWidth, 0)
|
||||
break
|
||||
case "l":
|
||||
if (event.ctrlKey) {
|
||||
window.scrollBy(page.scroll_x*10, 0)
|
||||
} else {
|
||||
window.scrollBy(page.scroll_x, 0)
|
||||
}
|
||||
break
|
||||
case "L":
|
||||
window.scrollBy(body.scrollWidth, 0)
|
||||
break
|
||||
case "j":
|
||||
if (event.ctrlKey) {
|
||||
window.scrollBy(0, page.scroll_y*10)
|
||||
} else {
|
||||
window.scrollBy(0, page.scroll_y)
|
||||
}
|
||||
break
|
||||
case "J":
|
||||
window.scrollBy(0, body.scrollHeight)
|
||||
break
|
||||
case "k":
|
||||
if (event.ctrlKey) {
|
||||
window.scrollBy(0, -page.scroll_y*10)
|
||||
} else {
|
||||
window.scrollBy(0, -page.scroll_y)
|
||||
}
|
||||
break
|
||||
case "K":
|
||||
window.scrollBy(0, -body.scrollHeight)
|
||||
break
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
},
|
||||
conf: {
|
||||
scroll_x: 50,
|
||||
scroll_y: 50,
|
||||
},
|
||||
})
|
||||
|
@ -1,25 +1,3 @@
|
||||
{{define "head"}}
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
{{range $index, $meta := option . "metas"}}
|
||||
<meta name="{{index $meta "name"}}" content="{{index $meta "content"}}">
|
||||
{{end}}
|
||||
|
||||
<title>{{options . "componet_name"}}</title>
|
||||
<link rel="shortcut icon" type="image/ico" href="/static/librarys/{{options . "favicon"}}">
|
||||
{{range $index, $lib := option . "styles"}}
|
||||
<link rel="stylesheet" type="text/css" href="/static/librarys/{{$lib}}"></link>
|
||||
{{end}}
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var conf = {
|
||||
toolkit_view: {{conf . "route" "toolkit_view"}},
|
||||
bench_data: {{option . "bench_data"}},
|
||||
}
|
||||
</script>
|
||||
{{end}}
|
||||
{{define "toolkit"}}
|
||||
<fieldset class="{{options . "componet_view"}}" data-init="{{options . "componet_init"}}">
|
||||
<div>{{options . "componet_name"}}({{options . "componet_help"}})</div>
|
||||
@ -31,8 +9,8 @@
|
||||
{{$msg := .}}
|
||||
|
||||
<form class="option {{options . "componet_name"}}"
|
||||
data-componet_group="{{options . "componet_group"}}"
|
||||
data-componet_name="{{options . "componet_name"}}"
|
||||
data-componet_group="{{options . "componet_group"}}"
|
||||
{{$form_type := options . "form_type"}} {{if eq $form_type "upload"}}
|
||||
method="POST" action="/upload" enctype="multipart/form-data" target="_blank"
|
||||
{{end}}>
|
||||
@ -112,10 +90,3 @@
|
||||
wx.error(function(res){})
|
||||
</script>
|
||||
{{end}}
|
||||
{{define "tail"}}
|
||||
{{range $index, $lib := option . "scripts"}}
|
||||
<script src="/static/librarys/{{$lib}}"></script>
|
||||
{{end}}
|
||||
</body>
|
||||
{{end}}
|
||||
|
||||
|
@ -1,198 +1,29 @@
|
||||
{{define "head"}}
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.7">
|
||||
<title>{{option .Meta "page_title"}}</title>
|
||||
<style>
|
||||
html, body {
|
||||
height:100%;
|
||||
width:100%;
|
||||
margin:0px;
|
||||
background-color:#d8d8d8;
|
||||
}
|
||||
fieldset {
|
||||
margin-top:8px;
|
||||
}
|
||||
legend {
|
||||
font-size:16px;
|
||||
font-weight:bold;
|
||||
font-family:monospace;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
textarea.clipboard {
|
||||
color:white;
|
||||
background-color:#272822;
|
||||
width:600px;
|
||||
}
|
||||
form.option div {
|
||||
float:left;
|
||||
}
|
||||
form.option hr {
|
||||
clear:both;
|
||||
}
|
||||
form.option label.keymap {
|
||||
color:red;
|
||||
display:none;
|
||||
}
|
||||
form.option label.keymap.show {
|
||||
display:inline;
|
||||
}
|
||||
form.option input {
|
||||
margin-right:10px;
|
||||
}
|
||||
form.option input.cmd {
|
||||
color:white;
|
||||
background-color:#272822;
|
||||
padding-left:10px;
|
||||
width:600px;
|
||||
}
|
||||
form.option.exec input {
|
||||
color:white;
|
||||
background-color:#272822;
|
||||
padding-left:10px;
|
||||
width:600px;
|
||||
}
|
||||
form.option select {
|
||||
margin-right:10px;
|
||||
}
|
||||
table.append {
|
||||
font-size:14px;
|
||||
}
|
||||
table.append th {
|
||||
font-family:monospace;
|
||||
background-color:lightgreen;
|
||||
cursor:pointer;
|
||||
}
|
||||
table.append th.order {
|
||||
background-color:red;
|
||||
cursor:pointer;
|
||||
}
|
||||
table.append td {
|
||||
font-family:monospace;
|
||||
padding-left: 10px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
code.result pre {
|
||||
color:white;
|
||||
font-size:14px;
|
||||
background-color:#272822;
|
||||
overflow:scroll;
|
||||
padding:5px;
|
||||
border:solid 2px green;
|
||||
border-left:solid 4px green;
|
||||
margin:0;
|
||||
}
|
||||
code.result pre.clipboard {
|
||||
height:2em;
|
||||
}
|
||||
</style>
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
{{range $index, $meta := option . "metas"}}
|
||||
<meta name="{{index $meta "name"}}" content="{{index $meta "content"}}">
|
||||
{{end}}
|
||||
|
||||
</head>
|
||||
<body onkeyup="return onaction(event, 'keymap')">
|
||||
<title>{{options . "componet_name"}}</title>
|
||||
<link rel="shortcut icon" type="image/ico" href="/static/librarys/{{options . "favicon"}}">
|
||||
{{range $index, $lib := option . "styles"}}
|
||||
<link rel="stylesheet" type="text/css" href="/static/librarys/{{$lib}}"></link>
|
||||
{{end}}
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var conf = {
|
||||
toolkit_view: {{conf . "route" "toolkit_view"}},
|
||||
bench_data: {{option . "bench_data"}},
|
||||
}
|
||||
</script>
|
||||
{{end}}
|
||||
|
||||
{{define "void"}}{{end}}
|
||||
|
||||
{{define "detail"}}{{detail .}}{{end}}
|
||||
{{define "option"}}{{option .}}{{end}}
|
||||
{{define "append"}}{{append .}}{{end}}
|
||||
{{define "result"}}{{result .}}{{end}}
|
||||
|
||||
{{define "clipboard"}}
|
||||
<fieldset><legend>clipboard</legend>
|
||||
<datalist id="clipstack"></datalist>
|
||||
<datalist id="clistack"></datalist>
|
||||
<textarea class="clipboard"></textarea>
|
||||
</fieldset>
|
||||
{{end}}
|
||||
|
||||
{{define "componet"}}
|
||||
<fieldset><legend title="{{option .Meta "help"}}">{{option .Meta "help"}}({{option .Meta "context"}}.{{option .Meta "command"}})</legend>
|
||||
{{$form_type := option . "form_type"|meta}}
|
||||
|
||||
{{if eq $form_type "upload"}}
|
||||
{{end}}
|
||||
<form class="option {{option .Meta "name"}}"
|
||||
data-last_componet_group="{{option . "last_componet_group"|meta}}"
|
||||
data-last_componet_order="{{option . "last_componet_order"|meta}}"
|
||||
data-componet_group="{{option . "componet_group"|meta}}"
|
||||
data-componet_order="{{option . "componet_order"|meta}}"
|
||||
data-componet_name="{{option . "name"|meta}}"
|
||||
data-componet_help="{{option . "help"|meta}}"
|
||||
{{if eq $form_type "upload"}}
|
||||
method="POST" action="/upload" enctype="multipart/form-data"
|
||||
onsubmit="onaction(event,'upload')"
|
||||
{{end}}
|
||||
>
|
||||
<input style="display:none"></input>
|
||||
{{range $index, $input := option . "inputs"}}
|
||||
<div>
|
||||
{{$type := index $input "type"}}
|
||||
{{if index $input "label"}}
|
||||
<label>{{index $input "label"}} : </label>
|
||||
{{end}}
|
||||
{{if eq $type "button"}}
|
||||
<input type="button" onclick="return onaction(event, 'command')" value="{{index $input "label"}}">
|
||||
{{else if eq $type "submit"}}
|
||||
<input type="submit" value="{{index $input "value"}}">
|
||||
{{else if eq $type "file"}}
|
||||
<input type="file" name="{{index $input "name"}}">
|
||||
{{else if eq $type "choice"}}
|
||||
{{$default_value := index $input "value"}}
|
||||
<select name="{{index $input "name"}}" onchange="return onaction(event, 'command')">
|
||||
{{range $index, $value := index $input "choice"}}
|
||||
{{$val := index $value "value"}}
|
||||
{{if eq $default_value $val}}
|
||||
<option value="{{index $value "value"}}" selected>{{index $value "name"}}</option>
|
||||
{{else}}
|
||||
<option value="{{index $value "value"}}">{{index $value "name"}}</option>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</select>
|
||||
{{else}}
|
||||
<input
|
||||
name="{{index $input "name"}}"
|
||||
value="{{index $input "value"}}"
|
||||
class="{{index $input "class"}}"
|
||||
{{if index $input "clipstack"}}
|
||||
list="{{index $input "clipstack"}}"
|
||||
{{else}}
|
||||
list="clipstack"
|
||||
{{end}}
|
||||
onclick="return onaction(event, 'click')"
|
||||
onkeyup="return onaction(event, 'input')">
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
<hr/>
|
||||
</form>
|
||||
{{if eq $form_type "upload"}}
|
||||
{{end}}
|
||||
|
||||
{{if index .Meta "display_append"}}
|
||||
{{option .Meta "display_append"}}
|
||||
{{else}}
|
||||
<table class="append {{option .Meta "name"}}">
|
||||
{{$msg := .}}
|
||||
<tr>{{range $field := append .}}<th>{{$field}}</th>{{end}}</tr>
|
||||
{{range $line := table .}}
|
||||
<tr>{{range $field := append $msg}}<td>{{index $line $field|unescape}}</td>{{end}}</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
{{end}}
|
||||
|
||||
{{if index .Meta "display_result"}}
|
||||
{{option .Meta "display_result"}}
|
||||
{{else}}
|
||||
<code class="result {{option .Meta "name"}}"><pre>{{result .Meta}}</pre></code>
|
||||
{{end}}
|
||||
</fieldset>
|
||||
{{end}}
|
||||
|
||||
{{define "tail"}}
|
||||
<script src="/library/context.js"></script>
|
||||
<script src="/library/base.js"></script>
|
||||
</body>
|
||||
{{range $index, $lib := option . "scripts"}}
|
||||
<script src="/static/librarys/{{$lib}}"></script>
|
||||
{{end}}
|
||||
</body>
|
||||
{{end}}
|
||||
|
||||
|
@ -1,221 +0,0 @@
|
||||
{{define "head"}}
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.7">
|
||||
<link rel="shortcut icon" type="image/ico" href="/favicon.ico">
|
||||
<title>{{option .Meta "page_title"}}</title>
|
||||
<style>
|
||||
html, body {
|
||||
background-color:#d8d8d8;
|
||||
width:100%;
|
||||
height:100%;
|
||||
margin:0px;
|
||||
}
|
||||
header {
|
||||
color:white;
|
||||
font-size:20px;
|
||||
font-family:monospace;
|
||||
text-align:center;
|
||||
background-color:#0747a6;
|
||||
width:100%;
|
||||
position:fixed;
|
||||
}
|
||||
header .title {
|
||||
padding:6px;
|
||||
}
|
||||
header .toggle {
|
||||
cursor:pointer;
|
||||
width:40px;
|
||||
position:absolute;
|
||||
left:20px;
|
||||
top:5px;
|
||||
}
|
||||
header .toggle:hover {
|
||||
background-color:blue;
|
||||
}
|
||||
header .search {
|
||||
position:absolute;
|
||||
right:20px;
|
||||
top:5px;
|
||||
}
|
||||
header .search input {
|
||||
font-size:14px;
|
||||
background-color:#91d7f5;
|
||||
padding:4px;
|
||||
width:60px;
|
||||
}
|
||||
header .search input:focus {
|
||||
width:120px;
|
||||
}
|
||||
|
||||
nav {
|
||||
overflow:auto;
|
||||
float:left;
|
||||
max-width:400px;
|
||||
border:solid 2px green;
|
||||
}
|
||||
nav.fixed {
|
||||
position:fixed;
|
||||
}
|
||||
nav>ul {
|
||||
padding:0;
|
||||
margin:0;
|
||||
}
|
||||
nav>ul>li>div {
|
||||
cursor:pointer;
|
||||
font-size:18px;
|
||||
background-color:green;
|
||||
padding-left:10px;
|
||||
padding:5px;
|
||||
width:100%;
|
||||
}
|
||||
nav>ul>li>ul>li {
|
||||
padding:5px;
|
||||
}
|
||||
nav>ul>li>ul>li:hover {
|
||||
background-color:green;
|
||||
}
|
||||
nav>ul>li>ul>li>a {
|
||||
text-decoration-line:none;
|
||||
}
|
||||
nav>ul>li>ul>li .mono {
|
||||
font-family:monospace;
|
||||
}
|
||||
|
||||
article {
|
||||
clear:both;
|
||||
float:right;
|
||||
}
|
||||
article h2 {
|
||||
cursor:alias;
|
||||
}
|
||||
article h3 {
|
||||
cursor:alias;
|
||||
}
|
||||
article h4 {
|
||||
cursor:alias;
|
||||
}
|
||||
|
||||
article table {
|
||||
border-collapse:collapse;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
article table caption {
|
||||
font-weight:bold;
|
||||
border:2px solid green;
|
||||
}
|
||||
article table tr:hover {
|
||||
background:lightgreen;
|
||||
}
|
||||
article table th {
|
||||
background:lightgreen;
|
||||
border:2px solid green;
|
||||
text-align:center;
|
||||
padding:0;
|
||||
}
|
||||
article table th:hover {
|
||||
background-color:red;
|
||||
cursor:pointer;
|
||||
}
|
||||
article table td {
|
||||
border:2px solid green;
|
||||
text-align:center;
|
||||
padding:3px;
|
||||
}
|
||||
article table td:hover {
|
||||
background-color:red;
|
||||
}
|
||||
|
||||
article pre {
|
||||
color:white;
|
||||
background-color:#272822;
|
||||
overflow:scroll;
|
||||
padding:5px;
|
||||
border:solid 2px green;
|
||||
max-width:800px;
|
||||
margin:0;
|
||||
margin-bottom:10px;
|
||||
font-size:14px;
|
||||
line-height:16px;
|
||||
}
|
||||
article div.number1 {
|
||||
color:#ff9800;
|
||||
font-family:monospace;
|
||||
background-color:#272822;
|
||||
text-align:right;
|
||||
padding:5px 0;
|
||||
border:solid green 2px;
|
||||
margin-bottom:10px;
|
||||
float:left;
|
||||
}
|
||||
article div.number1 div {
|
||||
padding: 0 5px;
|
||||
}
|
||||
article div.number1 div:hover {
|
||||
cursor:alias;
|
||||
background-color:red;
|
||||
}
|
||||
|
||||
footer {
|
||||
color:white;
|
||||
font-size:20px;
|
||||
font-family:monospace;
|
||||
text-align:center;
|
||||
background-color:red;
|
||||
text-align:center;
|
||||
vertical-align:middle;
|
||||
clear:both;
|
||||
}
|
||||
footer .title {
|
||||
padding:6px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onkeydown="action(event, 'scroll')">
|
||||
{{end}}
|
||||
|
||||
{{define "header"}}
|
||||
<header>
|
||||
<div class="toggle" onclick="action(event, 'toggle_nav')">三</div>
|
||||
<div class="search"><input type="text" placeholder="搜索"></div>
|
||||
<div class="title">shylinux 天行健,君子以自强不息</div>
|
||||
</header>
|
||||
{{end}}
|
||||
|
||||
{{define "list"}}
|
||||
<nav>
|
||||
<ul>
|
||||
<li><div onclick="action(event, 'toggle_list')">文档</div>
|
||||
<ul class="list" hidden>
|
||||
{{range $i, $l := table .}}
|
||||
<li>
|
||||
<a href="?wiki_favor={{index $l "file"}}">{{index $l "file"}}</a><br/>
|
||||
<span class="mono"> {{index $l "time"}} </span>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</li>
|
||||
<li><div onclick="action(event, 'toggle_list')">目录</div>
|
||||
<ul class="menu" onclick="adjust(this)"></ul>
|
||||
</li>
|
||||
<li><div onclick="action(event, 'toggle_list')">链接</div>
|
||||
<ul class="link" hidden></ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{end}}
|
||||
|
||||
{{define "text"}}
|
||||
<article>{{result .|meta|unescape}}</article>
|
||||
{{end}}
|
||||
|
||||
{{define "footer"}}
|
||||
<footer><div class="title">shycontext 地势坤,君子以厚德载物</div></footer>
|
||||
{{end}}
|
||||
|
||||
{{define "tail"}}
|
||||
<script src="/static/librarys/context.js"></script>
|
||||
<script src="/static/librarys/wiki.js"></script>
|
||||
</body>
|
||||
{{end}}
|
@ -1,7 +0,0 @@
|
||||
## 简介
|
||||
MySQL 是一个开源的关系数据库管理系统。
|
||||
|
||||
- 官网: <https://www.mysql.com>
|
||||
- MAC客户端: <https://sequelpro.com/download#auto-start>
|
||||
|
||||
变量的定义与引用: <https://www.cnblogs.com/EasonJim/p/7966918.html>
|
0
usr/wiki/自然/编程/前端小程序/chrome.md
Normal file
0
usr/wiki/自然/编程/前端小程序/chrome.md
Normal file
0
usr/wiki/自然/编程/前端小程序/index.md
Normal file
0
usr/wiki/自然/编程/前端小程序/index.md
Normal file
0
usr/wiki/自然/编程/前端小程序/javascript.md
Normal file
0
usr/wiki/自然/编程/前端小程序/javascript.md
Normal file
0
usr/wiki/自然/编程/前端小程序/nodejs.md
Normal file
0
usr/wiki/自然/编程/前端小程序/nodejs.md
Normal file
0
usr/wiki/自然/编程/前端小程序/weixin.md
Normal file
0
usr/wiki/自然/编程/前端小程序/weixin.md
Normal file
0
usr/wiki/自然/编程/后端技术栈/consul.md
Normal file
0
usr/wiki/自然/编程/后端技术栈/consul.md
Normal file
0
usr/wiki/自然/编程/后端技术栈/kafka.md
Normal file
0
usr/wiki/自然/编程/后端技术栈/kafka.md
Normal file
0
usr/wiki/自然/编程/后端技术栈/linux.md
Normal file
0
usr/wiki/自然/编程/后端技术栈/linux.md
Normal file
37
usr/wiki/自然/编程/后端技术栈/mysql.md
Normal file
37
usr/wiki/自然/编程/后端技术栈/mysql.md
Normal file
@ -0,0 +1,37 @@
|
||||
## 简介
|
||||
|
||||
MySQL 是一个开源的关系型数据库管理系统。
|
||||
|
||||
- 官网: <https://www.mysql.com/>
|
||||
- 源码: <https://dev.mysql.com/downloads/file/?id=482483>
|
||||
- 文档: <https://dev.mysql.com/doc/refman/5.6/en>
|
||||
- 开源: <https://github.com/mysql/mysql-server>
|
||||
|
||||
## 基础命令
|
||||
|
||||
## 存储引擎
|
||||
|
||||
- 下载: <https://dev.mysql.com/downloads/mysql/5.6.html#downloads>
|
||||
|
||||
- 博客: <http://blog.codinglabs.org/articles/theory-of-mysql-index.html>
|
||||
|
||||
变量的定义与引用: <https://www.cnblogs.com/EasonJim/p/7966918.html>
|
||||
|
||||
show engines
|
||||
show engine innodb status
|
||||
show variables
|
||||
|
||||
show databases
|
||||
create database demo
|
||||
drop database demo
|
||||
use demo
|
||||
|
||||
show tables
|
||||
create table t(a int unsigned not null, b char(10), primary key(a))
|
||||
drop table t
|
||||
|
||||
select * from t;
|
||||
insert into t values()
|
||||
update t set b='1234'
|
||||
delete from t
|
||||
|
0
usr/wiki/自然/编程/后端技术栈/python.md
Normal file
0
usr/wiki/自然/编程/后端技术栈/python.md
Normal file
@ -1,11 +1,11 @@
|
||||
## 简介
|
||||
|
||||
Redis是一个使用ANSI C编写的开源、支持网络、基于内存、可持久性的键值对存储数据库。
|
||||
Redis是最流行的键值对存储数据库。
|
||||
|
||||
- 维基百科: <https://zh.wikipedia.org/wiki/Redis>
|
||||
- 官网: <https://redis.io](https://redis.io>
|
||||
- 源码: <https://shylinux.com/wiki/redis-4.0.11>
|
||||
- github: <https://github.com/antirez/redis>
|
||||
- 官网: <https://redis.io>
|
||||
- 源码: <http://download.redis.io/releases/redis-4.0.9.tar.gz>
|
||||
- 文档: <https://redis.io/documentation>
|
||||
|
||||
## 源码安装
|
||||
```
|
0
usr/wiki/自然/编程/后端技术栈/thrift.md
Normal file
0
usr/wiki/自然/编程/后端技术栈/thrift.md
Normal file
0
usr/wiki/自然/编程/后端技术栈/uwsgi.md
Normal file
0
usr/wiki/自然/编程/后端技术栈/uwsgi.md
Normal file
0
usr/wiki/自然/编程/终端工具链/git.md
Normal file
0
usr/wiki/自然/编程/终端工具链/git.md
Normal file
0
usr/wiki/自然/编程/终端工具链/tmux.md
Normal file
0
usr/wiki/自然/编程/终端工具链/tmux.md
Normal file
0
usr/wiki/自然/编程/终端工具链/vim.md
Normal file
0
usr/wiki/自然/编程/终端工具链/vim.md
Normal file
0
usr/wiki/自然/编程/终端工具链/zsh.md
Normal file
0
usr/wiki/自然/编程/终端工具链/zsh.md
Normal file
Loading…
x
Reference in New Issue
Block a user