mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
add Volcanos
This commit is contained in:
parent
07f530721f
commit
40b6b437a4
@ -226,3 +226,15 @@ func ExecuteStr(m *Message, w io.Writer, p string) error {
|
|||||||
tmpl, _ = tmpl.Parse(p)
|
tmpl, _ = tmpl.Parse(p)
|
||||||
return tmpl.Execute(w, m)
|
return tmpl.Execute(w, m)
|
||||||
}
|
}
|
||||||
|
func Execute(m *Message, p string) string {
|
||||||
|
m.Log("fuck", "waht %v", path.Join(m.Conf("route", "template_dir"), "/*.tmpl"))
|
||||||
|
t := template.Must(template.New("render").Funcs(CGI).ParseGlob(path.Join(m.Conf("route", "template_dir"), "/*.tmpl")))
|
||||||
|
for _, v := range t.Templates() {
|
||||||
|
m.Log("fuck", "waht %v", v.Name())
|
||||||
|
}
|
||||||
|
buf := bytes.NewBuffer(make([]byte, 0, 1024))
|
||||||
|
t.ExecuteTemplate(buf, p, m)
|
||||||
|
m.Log("fuck", "waht %v", p)
|
||||||
|
m.Log("fuck", "waht %v", buf)
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
mis "github.com/shylinux/toolkits"
|
mis "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -98,7 +97,7 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
|
|||||||
},
|
},
|
||||||
map[string]interface{}{"name": "tail",
|
map[string]interface{}{"name": "tail",
|
||||||
"tmpl": "tail", "scripts": []interface{}{
|
"tmpl": "tail", "scripts": []interface{}{
|
||||||
"toolkit.js", "context.js", "example.js", "chat.js",
|
"volcanos.js", "toolkit.js", "context.js", "example.js", "chat.js",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -509,19 +508,22 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
|
|||||||
case "wiki":
|
case "wiki":
|
||||||
// 查看文档
|
// 查看文档
|
||||||
p := path.Join(path.Join("var/share", h))
|
p := path.Join(path.Join("var/share", h))
|
||||||
if _, e := os.Stat(p); e == nil {
|
if !m.Options("force") {
|
||||||
// 读取缓存
|
if _, e := os.Stat(p); e == nil {
|
||||||
m.Log("info", "read cache %v", p)
|
// 读取缓存
|
||||||
r := m.Optionv("request").(*http.Request)
|
m.Log("info", "read cache %v", p)
|
||||||
w := m.Optionv("response").(http.ResponseWriter)
|
r := m.Optionv("request").(*http.Request)
|
||||||
http.ServeFile(w, r, p)
|
w := m.Optionv("response").(http.ResponseWriter)
|
||||||
break
|
http.ServeFile(w, r, p)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.Option("title", fmt.Sprintf("%v:%v", value["dream"], value["code"]))
|
||||||
|
m.Option("favicon", "favicon.ico")
|
||||||
// 生成模板
|
// 生成模板
|
||||||
if b, e := ioutil.ReadFile("usr/template/share.tmpl"); e == nil {
|
m.Echo(ctx.Execute(m, "share.tmpl"))
|
||||||
m.Echo(string(b))
|
|
||||||
}
|
|
||||||
// 生成文档
|
// 生成文档
|
||||||
m.Cmdy("ssh._route", value["dream"], "web.wiki.note", value["code"])
|
m.Cmdy("ssh._route", value["dream"], "web.wiki.note", value["code"])
|
||||||
if f, _, e := kit.Create(p); e == nil {
|
if f, _, e := kit.Create(p); e == nil {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
kit share "共享" public "web.chat.share" \
|
kit share "共享" public "web.chat.share" \
|
||||||
select "" name type values "wiki file" \
|
select "" name type values "wiki file" \
|
||||||
text "miss.md" name story imports plugin_story view long \
|
text "miss.md" name story imports plugin_story view long \
|
||||||
|
feature display chart \
|
||||||
button "共享"
|
button "共享"
|
||||||
|
|
||||||
kit note "记事本" public "_:web.wiki.note" "@you" \
|
kit note "记事本" public "_:web.wiki.note" "@you" \
|
||||||
@ -46,6 +47,6 @@ kit chart "图表" public "web.wiki.chart" \
|
|||||||
textarea "" name happy half 4 height "200px" \
|
textarea "" name happy half 4 height "200px" \
|
||||||
select "" name type values "white red yellow green blue black" action auto \
|
select "" name type values "white red yellow green blue black" action auto \
|
||||||
select "" name type values "black blue green yellow red white" action auto \
|
select "" name type values "black blue green yellow red white" action auto \
|
||||||
feature display svg \
|
feature display chart \
|
||||||
button "查看"
|
button "查看"
|
||||||
|
|
||||||
|
@ -680,3 +680,4 @@ var page = Page({
|
|||||||
setTimeout(update, 1)
|
setTimeout(update, 1)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1219,7 +1219,11 @@ function Plugin(page, pane, field, inits, runs) {
|
|||||||
},
|
},
|
||||||
}, function(type, msg, cb) {var meta = arguments.callee.meta
|
}, function(type, msg, cb) {var meta = arguments.callee.meta
|
||||||
type != meta.type && plugin.Save(meta.type, output), meta.type = type
|
type != meta.type && plugin.Save(meta.type, output), meta.type = type
|
||||||
!plugin.Load(type, output) && Output(plugin, type || feature.display, msg || plugin.msg, cb, output, option)
|
if (type == "chart") {
|
||||||
|
can.chat.Output(can, plugin, type || feature.display, msg || plugin.msg, cb, output, option)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
!plugin.Load(type, output) && (type=="chart"? can.chat.Output: Output)(plugin, type || feature.display, msg || plugin.msg, cb, output, option)
|
||||||
}),
|
}),
|
||||||
onexport: shy("导出数据", {
|
onexport: shy("导出数据", {
|
||||||
"": function(value, name, line) {
|
"": function(value, name, line) {
|
||||||
@ -1698,3 +1702,40 @@ function Output(plugin, type, msg, cb, target, option) {
|
|||||||
output.onimport(type, msg, cb)
|
output.onimport(type, msg, cb)
|
||||||
return plugin.Outputs[type] = target, target.Output = output
|
return plugin.Outputs[type] = target, target.Output = output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var can = Volcanos("chat", {
|
||||||
|
Plugin: shy("构造插件", function(can) {}),
|
||||||
|
Output: shy("构造组件", function(can, plugin, type, msg, cb, target, option) {
|
||||||
|
type = "table"
|
||||||
|
var output = Volcanos(type, {
|
||||||
|
user: can.user, node: can.node,
|
||||||
|
core: can.core, type: can.type,
|
||||||
|
oncarte: plugin.oncarte,
|
||||||
|
run: plugin.run,
|
||||||
|
size: function(cb) {
|
||||||
|
plugin.onfigure.meta.size(function(width, height) {
|
||||||
|
cb(width, height)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [type], function(output) {
|
||||||
|
target.oncontextmenu = function(event) {
|
||||||
|
plugin.oncarte(event, shy("", output.onchoice, output.onchoice.list, function(event, value, meta) {
|
||||||
|
typeof meta[value] == "function"? meta[value](event, can, msg, cb, target, option):
|
||||||
|
typeof output[value] == "function"? output[value](event, can, msg, cb, target, option):
|
||||||
|
typeof plugin[value] == "function"? plugin[value](event, can, msg, cb, target, option): null
|
||||||
|
return true
|
||||||
|
}))
|
||||||
|
event.stopPropagation()
|
||||||
|
event.preventDefault()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
output.load().onimport.init(output, msg, cb, target, option)
|
||||||
|
})
|
||||||
|
kit.Item(output.onaction, function(key, cb) {target[key] = function(event) {
|
||||||
|
output.onaction(event, can, msg, cb, target, option)
|
||||||
|
}})
|
||||||
|
plugin[type] = output, output.target = target, target.Output = output
|
||||||
|
}),
|
||||||
|
Input: shy("构造控件", function(can, plugin, type, meta, target, option) {
|
||||||
|
}),
|
||||||
|
}, [], function(can) {can.load()})
|
||||||
|
12
usr/librarys/share.css
Normal file
12
usr/librarys/share.css
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
div.story.code {
|
||||||
|
color:white;
|
||||||
|
font-size:14px;
|
||||||
|
font-family:monospace;
|
||||||
|
background-color:#272822;
|
||||||
|
white-space:pre;
|
||||||
|
padding:10px;
|
||||||
|
border:solid 3px green;
|
||||||
|
max-height:640px;
|
||||||
|
overflow:auto;
|
||||||
|
}
|
||||||
|
|
6
usr/librarys/share.js
Normal file
6
usr/librarys/share.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
window.onload = function() {
|
||||||
|
Volcanos("shy", {}, [], function(can) {
|
||||||
|
can.load()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
1
usr/librarys/volcanos.js
Symbolic link
1
usr/librarys/volcanos.js
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../volcanos/volcanos.js
|
17
usr/local/wiki/volcano.md
Normal file
17
usr/local/wiki/volcano.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# {{title "Volcanos.js"}}
|
||||||
|
|
||||||
|
volcanos是一个前端框架。
|
||||||
|
模块化
|
||||||
|
通过建立脚本的依赖关系,按需加载相关文件,从而更加高效的组织项目文件。
|
||||||
|
{{chart "chain" `
|
||||||
|
Volcanos
|
||||||
|
Volcanos
|
||||||
|
Volcanos
|
||||||
|
Volcanos
|
||||||
|
`}}
|
||||||
|
|
||||||
|
## {{section "type模块"}}
|
||||||
|
## {{section "core模块"}}
|
||||||
|
## {{section "node模块"}}
|
||||||
|
## {{section "misc模块"}}
|
||||||
|
## {{section "device模块"}}
|
@ -1,13 +1,10 @@
|
|||||||
<style>
|
<!DOCTYPE html>
|
||||||
div.story.code {
|
<head>
|
||||||
color:white;
|
<meta charset="utf-8">
|
||||||
font-size:14px;
|
<title>{{options . "title"}}</title>
|
||||||
font-family:monospace;
|
<link rel="shortcut icon" type="image/ico" href="/static/librarys/{{options . "favicon"}}">
|
||||||
background-color:#272822;
|
<link rel="stylesheet" type="text/css" href="/static/librarys/share.css">
|
||||||
white-space:pre;
|
<script src="/static/volcanos/volcanos.js"></script>
|
||||||
padding:10px;
|
<script src="/static/librarys/share.js"></script>
|
||||||
overflow:auto;
|
</head>
|
||||||
border:solid 3px green;
|
<body>
|
||||||
max-height:640px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user