1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 08:48:06 +08:00

add Volcanos

This commit is contained in:
shaoying 2019-12-07 20:21:52 +08:00
parent 07f530721f
commit 40b6b437a4
10 changed files with 117 additions and 27 deletions

View File

@ -226,3 +226,15 @@ func ExecuteStr(m *Message, w io.Writer, p string) error {
tmpl, _ = tmpl.Parse(p)
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()
}

View File

@ -6,7 +6,6 @@ import (
mis "github.com/shylinux/toolkits"
"fmt"
"io/ioutil"
"net/http"
"os"
"path"
@ -98,7 +97,7 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
},
map[string]interface{}{"name": "tail",
"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":
// 查看文档
p := path.Join(path.Join("var/share", h))
if _, e := os.Stat(p); e == nil {
// 读取缓存
m.Log("info", "read cache %v", p)
r := m.Optionv("request").(*http.Request)
w := m.Optionv("response").(http.ResponseWriter)
http.ServeFile(w, r, p)
break
if !m.Options("force") {
if _, e := os.Stat(p); e == nil {
// 读取缓存
m.Log("info", "read cache %v", p)
r := m.Optionv("request").(*http.Request)
w := m.Optionv("response").(http.ResponseWriter)
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(string(b))
}
m.Echo(ctx.Execute(m, "share.tmpl"))
// 生成文档
m.Cmdy("ssh._route", value["dream"], "web.wiki.note", value["code"])
if f, _, e := kit.Create(p); e == nil {

View File

@ -1,6 +1,7 @@
kit share "共享" public "web.chat.share" \
select "" name type values "wiki file" \
text "miss.md" name story imports plugin_story view long \
feature display chart \
button "共享"
kit note "记事本" public "_:web.wiki.note" "@you" \
@ -46,6 +47,6 @@ kit chart "图表" public "web.wiki.chart" \
textarea "" name happy half 4 height "200px" \
select "" name type values "white red yellow green blue black" action auto \
select "" name type values "black blue green yellow red white" action auto \
feature display svg \
feature display chart \
button "查看"

View File

@ -680,3 +680,4 @@ var page = Page({
setTimeout(update, 1)
},
})

View File

@ -1219,7 +1219,11 @@ function Plugin(page, pane, field, inits, runs) {
},
}, function(type, msg, cb) {var meta = arguments.callee.meta
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("导出数据", {
"": function(value, name, line) {
@ -1698,3 +1702,40 @@ function Output(plugin, type, msg, cb, target, option) {
output.onimport(type, msg, cb)
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
View 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
View File

@ -0,0 +1,6 @@
window.onload = function() {
Volcanos("shy", {}, [], function(can) {
can.load()
})
}

1
usr/librarys/volcanos.js Symbolic link
View File

@ -0,0 +1 @@
../volcanos/volcanos.js

17
usr/local/wiki/volcano.md Normal file
View 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模块"}}

View File

@ -1,13 +1,10 @@
<style>
div.story.code {
color:white;
font-size:14px;
font-family:monospace;
background-color:#272822;
white-space:pre;
padding:10px;
overflow:auto;
border:solid 3px green;
max-height:640px;
}
</style>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>{{options . "title"}}</title>
<link rel="shortcut icon" type="image/ico" href="/static/librarys/{{options . "favicon"}}">
<link rel="stylesheet" type="text/css" href="/static/librarys/share.css">
<script src="/static/volcanos/volcanos.js"></script>
<script src="/static/librarys/share.js"></script>
</head>
<body>