mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
mac add what?
This commit is contained in:
parent
231ef878e6
commit
7a6d28dac2
32
Makefile
32
Makefile
@ -18,11 +18,8 @@ install_all: install
|
|||||||
touch etc/login.txt
|
touch etc/login.txt
|
||||||
touch etc/history.txt
|
touch etc/history.txt
|
||||||
|
|
||||||
build:
|
|
||||||
go build $(BENCH)
|
|
||||||
|
|
||||||
run:
|
run:
|
||||||
etc/run.sh 2>var/error.log
|
etc/bootstrap.sh
|
||||||
|
|
||||||
tar:
|
tar:
|
||||||
[ -e tar ] || mkdir tar
|
[ -e tar ] || mkdir tar
|
||||||
@ -45,26 +42,19 @@ tar_all: tar darwin linux64
|
|||||||
mv bench.linux64 tar/bin/
|
mv bench.linux64 tar/bin/
|
||||||
tar zcvf tar.tgz tar
|
tar zcvf tar.tgz tar
|
||||||
|
|
||||||
|
linux64:
|
||||||
|
GOARCH=amd64 GOOS=linux go build $(BENCH) -o bench.linux64
|
||||||
|
linux32:
|
||||||
|
GOARCH=386 GOOS=linux go build $(BENCH) -o bench.linux32
|
||||||
|
linux_arm:
|
||||||
|
GOARCH=arm GOOS=linux go build $(BENCH) -o bench.linux.arm
|
||||||
darwin:
|
darwin:
|
||||||
GOARCH=amd64 GOOS=darwin go build $(BENCH)
|
GOARCH=amd64 GOOS=darwin go build $(BENCH) -o bench.darwin
|
||||||
mv bench bench.darwin
|
|
||||||
|
|
||||||
win64:
|
win64:
|
||||||
GOARCH=amd64 GOOS=windows go build $(BENCH)
|
GOARCH=amd64 GOOS=windows go build $(BENCH) -o bench.win64.exe
|
||||||
mv bench.exe bench_1.0_win64.exe
|
|
||||||
win32:
|
win32:
|
||||||
GOARCH=386 GOOS=windows go build $(BENCH)
|
GOARCH=386 GOOS=windows go build $(BENCH) -o bench.win32.exe
|
||||||
mv bench.exe bench_1.0_win32.exe
|
|
||||||
|
|
||||||
linux64:
|
|
||||||
GOARCH=amd64 GOOS=linux go build $(BENCH)
|
|
||||||
mv bench bench.linux64
|
|
||||||
linux32:
|
|
||||||
GOARCH=386 GOOS=linux go build $(BENCH)
|
|
||||||
mv bench bench_1.0_linux32
|
|
||||||
linux_arm:
|
|
||||||
GOARCH=arm GOOS=linux go build $(BENCH)
|
|
||||||
mv bench bench_1.0_linux_arm
|
|
||||||
|
|
||||||
|
|
||||||
DOTS=etc/dotsfile
|
DOTS=etc/dotsfile
|
||||||
@ -93,5 +83,5 @@ load_dotsfile:\
|
|||||||
~/.vim/syntax/shy.vim: $(DOTS)/shy.vim
|
~/.vim/syntax/shy.vim: $(DOTS)/shy.vim
|
||||||
cp $< $@
|
cp $< $@
|
||||||
|
|
||||||
.PHONY: tar
|
.PHONY: tar run
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
bench=bench
|
|
||||||
[ `uname` = "Darwin" ] && bench=bin/bench.darwin
|
[ `uname` = "Darwin" ] && bench=bin/bench.darwin
|
||||||
[ `uname` = "Linux" ] && bench=bin/bench.linux64
|
[ `uname` = "Linux" ] && bench=bin/bench.linux64
|
||||||
[ -e "$bench" ] || bench=bench
|
[ -e "$bench" ] || bench=bench
|
||||||
|
|
||||||
|
echo "bench: $bench"> var/boot.log
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
$bench stdio && break
|
$bench stdio 2>var/error.log && break
|
||||||
echo "bench run error"
|
echo "bench run error"
|
||||||
echo "restarting..."
|
echo "restarting..."
|
||||||
sleep 3
|
sleep 3
|
||||||
|
@ -4,5 +4,4 @@ source etc/exit_local.shy
|
|||||||
config save counter.json counter
|
config save counter.json counter
|
||||||
~stdio
|
~stdio
|
||||||
config save history.json history
|
config save history.json history
|
||||||
return hello
|
|
||||||
|
|
||||||
|
10
etc/init.shy
10
etc/init.shy
@ -3,5 +3,15 @@
|
|||||||
~code
|
~code
|
||||||
config load counter.json counter
|
config load counter.json counter
|
||||||
|
|
||||||
|
~aaa
|
||||||
|
login root root
|
||||||
|
~find aaa.root
|
||||||
|
config right right.role root
|
||||||
|
~aaa
|
||||||
|
login void void
|
||||||
|
right void owner login add from root
|
||||||
|
right void owner login add from root
|
||||||
|
|
||||||
source etc/local.shy
|
source etc/local.shy
|
||||||
|
|
||||||
~shy
|
~shy
|
||||||
|
@ -316,7 +316,6 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range exports {
|
for _, v := range exports {
|
||||||
m.Log("info", "export %v", v)
|
|
||||||
if v["file"] != "" {
|
if v["file"] != "" {
|
||||||
m.Sess("nfs").Copy(msg, "option").Copy(msg, "append").Copy(msg, "result").Cmd("export", v["file"])
|
m.Sess("nfs").Copy(msg, "option").Copy(msg, "append").Copy(msg, "result").Cmd("export", v["file"])
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ func open(m *ctx.Message, name string, arg ...int) (string, *os.File, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.Log("info", "open %s", name)
|
m.Log("info", "open %s", name)
|
||||||
f, e := os.OpenFile(name, flag, os.ModePerm)
|
f, e := os.OpenFile(name, flag, 0660)
|
||||||
return name, f, e
|
return name, f, e
|
||||||
}
|
}
|
||||||
func dir(m *ctx.Message, name string, level int, deep bool, trip int, fields []string) {
|
func dir(m *ctx.Message, name string, level int, deep bool, trip int, fields []string) {
|
||||||
@ -1075,13 +1075,11 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
}
|
}
|
||||||
w.Flush()
|
w.Flush()
|
||||||
default:
|
default:
|
||||||
m.Log("fuck", "what ---%v", m.Meta)
|
|
||||||
for _, v := range m.Meta["result"] {
|
for _, v := range m.Meta["result"] {
|
||||||
f.WriteString(v)
|
f.WriteString(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Log("fuck", "what ---%v", m.Meta)
|
m.Set("append").Set("result").Add("append", "directory", name).Echo(name)
|
||||||
m.Set("append").Set("result").Echo(name)
|
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"pwd": &ctx.Command{Name: "pwd [all] | [[index] path] ", Help: "工作目录,all: 查看所有, index path: 设置路径, path: 设置当前路径", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"pwd": &ctx.Command{Name: "pwd [all] | [[index] path] ", Help: "工作目录,all: 查看所有, index path: 设置路径, path: 设置当前路径", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
@ -1167,6 +1165,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
p := path.Join(m.Confv("paths", 0).(string), arg[0])
|
p := path.Join(m.Confv("paths", 0).(string), arg[0])
|
||||||
qrcode.WriteFile(strings.Join(arg[1:], ""), qrcode.Medium, size, p)
|
qrcode.WriteFile(strings.Join(arg[1:], ""), qrcode.Medium, size, p)
|
||||||
m.Log("info", "genqr %s", p)
|
m.Log("info", "genqr %s", p)
|
||||||
|
m.Append("directory", p)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
@ -230,10 +230,6 @@ func (web *WEB) Start(m *ctx.Message, arg ...string) bool {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(arg) == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
web.Caches["protocol"] = &ctx.Cache{Name: "protocol", Value: m.Confx("protocol", arg, 2), Help: "服务协议"}
|
web.Caches["protocol"] = &ctx.Cache{Name: "protocol", Value: m.Confx("protocol", arg, 2), Help: "服务协议"}
|
||||||
web.Caches["address"] = &ctx.Cache{Name: "address", Value: m.Confx("address", arg, 1), Help: "服务地址"}
|
web.Caches["address"] = &ctx.Cache{Name: "address", Value: m.Confx("address", arg, 1), Help: "服务地址"}
|
||||||
m.Log("info", "%d %s://%s", m.Capi("nserve", 1), m.Cap("protocol"), m.Cap("stream", m.Cap("address")))
|
m.Log("info", "%d %s://%s", m.Capi("nserve", 1), m.Cap("protocol"), m.Cap("stream", m.Cap("address")))
|
||||||
@ -825,7 +821,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
if msg.Appends("directory") {
|
if msg.Appends("directory") {
|
||||||
m.Append("page_redirect", fmt.Sprintf("/download/%s", msg.Append("directory")))
|
m.Append("download_file", fmt.Sprintf("/download/%s", msg.Append("directory")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ function copy_to_clipboard(text) {
|
|||||||
insert_child(clipstack, "option").value = text
|
insert_child(clipstack, "option").value = text
|
||||||
clipstack.childElementCount > 3 && clipstack.removeChild(clipstack.lastElementChild)
|
clipstack.childElementCount > 3 && clipstack.removeChild(clipstack.lastElementChild)
|
||||||
}
|
}
|
||||||
|
|
||||||
function send_command(form, cb) {
|
function send_command(form, cb) {
|
||||||
var data = {}
|
var data = {}
|
||||||
for (var key in form.dataset) {
|
for (var key in form.dataset) {
|
||||||
@ -49,6 +50,7 @@ function send_command(form, cb) {
|
|||||||
typeof(cb) == "function" && cb(msg)
|
typeof(cb) == "function" && cb(msg)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_argument(form, target) {
|
function check_argument(form, target) {
|
||||||
for (var i = 0; i < form.length-1; i++) {
|
for (var i = 0; i < form.length-1; i++) {
|
||||||
if (form[i] == target) {
|
if (form[i] == target) {
|
||||||
@ -62,6 +64,36 @@ function check_argument(form, target) {
|
|||||||
}
|
}
|
||||||
send_command(form)
|
send_command(form)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ncommand = 3
|
||||||
|
function add_fieldset() {
|
||||||
|
var name = "command"+ncommand++
|
||||||
|
|
||||||
|
var fieldset = append_child(document.querySelector("body"), "fieldset")
|
||||||
|
append_child(fieldset, "legend", {"innerText": name})
|
||||||
|
|
||||||
|
var option = append_child(fieldset, "form", {
|
||||||
|
"className": "option "+name,
|
||||||
|
"dataset": {
|
||||||
|
"componet_group": "index",
|
||||||
|
"componet_name": "command",
|
||||||
|
"componet_name_alias": name,
|
||||||
|
"componet_name_order": ncommand-1,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
append_child(option, "input", {"style": {"display": "none"}})
|
||||||
|
|
||||||
|
append_child(option, "input", {
|
||||||
|
"name": "cmd",
|
||||||
|
"className": "cmd",
|
||||||
|
"onkeyup": function(event){onaction(event, "input")}
|
||||||
|
}).focus()
|
||||||
|
|
||||||
|
var append = append_child(fieldset, "table", {"className": "append "+name})
|
||||||
|
append_child(append_child(fieldset, "code", {"className": "result "+name}), "pre")
|
||||||
|
}
|
||||||
|
|
||||||
function onaction(event, action) {
|
function onaction(event, action) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "submit":
|
case "submit":
|
||||||
@ -162,10 +194,40 @@ function onaction(event, action) {
|
|||||||
event.target.dataset["history_last"] = history.length-1
|
event.target.dataset["history_last"] = history.length-1
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case "b":
|
case "v":
|
||||||
if (event.ctrlKey && event.key == "b") {
|
if (event.ctrlKey && event.key == "v") {
|
||||||
add_fieldset()
|
add_fieldset()
|
||||||
}
|
}
|
||||||
|
case "q":
|
||||||
|
if (event.ctrlKey && event.key == "q") {
|
||||||
|
var can_remove = false
|
||||||
|
var order = -1
|
||||||
|
for (var p = event.target; p.parentElement && p.tagName != "FIELDSET"; p = p.parentElement) {
|
||||||
|
if (p.tagName == "FORM" && p.dataset["componet_name_alias"]) {
|
||||||
|
can_remove = true
|
||||||
|
order = p.dataset["componet_name_order"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (p && can_remove) {
|
||||||
|
p.parentElement.removeChild(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;order < ncommand; order++) {
|
||||||
|
var input = document.querySelector("form.option.command"+order+" input[name=cmd]")
|
||||||
|
if (input) {
|
||||||
|
input.focus()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (;order > 0; order--) {
|
||||||
|
var input = document.querySelector("form.option.command"+order+" input[name=cmd]")
|
||||||
|
if (input) {
|
||||||
|
input.focus()
|
||||||
|
ncommand = order+1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
console.log(event)
|
console.log(event)
|
||||||
if (event.target.dataset["last_char"] == "j" && event.key == "k") {
|
if (event.target.dataset["last_char"] == "j" && event.key == "k") {
|
||||||
@ -204,6 +266,7 @@ function onaction(event, action) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var inputs = {}
|
var inputs = {}
|
||||||
var ninput = 0
|
var ninput = 0
|
||||||
var keymap = ['a', 'b', 'c']
|
var keymap = ['a', 'b', 'c']
|
||||||
@ -352,7 +415,6 @@ function init_download(event) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_context() {
|
function init_context() {
|
||||||
var append = document.querySelector("table.append.ctx")
|
var append = document.querySelector("table.append.ctx")
|
||||||
if (!append) {
|
if (!append) {
|
||||||
@ -459,7 +521,6 @@ function init_command() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_userinfo() {
|
function init_userinfo() {
|
||||||
var append = document.querySelector("table.append.userinfo")
|
var append = document.querySelector("table.append.userinfo")
|
||||||
if (!append) {
|
if (!append) {
|
||||||
@ -478,26 +539,6 @@ function init_userinfo() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var ncommand = 3
|
|
||||||
function add_fieldset() {
|
|
||||||
var name = "command"+ncommand++
|
|
||||||
|
|
||||||
var fieldset = append_child(document.querySelector("body"), "fieldset")
|
|
||||||
append_child(fieldset, "legend", {"innerText": name})
|
|
||||||
|
|
||||||
var option = append_child(fieldset, "form", {"className": "option "+name})
|
|
||||||
option.dataset["componet_group"] = "index"
|
|
||||||
option.dataset["componet_name"] = "command"
|
|
||||||
option.dataset["componet_name_alias"] = name
|
|
||||||
append_child(option, "input").style["display"] = "none"
|
|
||||||
append_child(option, "input", {"name": "cmd", "className": "cmd", "onkeyup": function(event){
|
|
||||||
onaction(event, "input")
|
|
||||||
}}).focus()
|
|
||||||
|
|
||||||
var append = append_child(fieldset, "table", {"className": "append "+name})
|
|
||||||
append_child(append_child(fieldset, "code", {"className": "result "+name}), "pre")
|
|
||||||
}
|
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
init_option()
|
init_option()
|
||||||
init_append()
|
init_append()
|
||||||
|
@ -109,14 +109,16 @@ context = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var msg = JSON.parse(xhr.responseText||'{"result":[]}');
|
var msg = JSON.parse(xhr.responseText||'{"result":[]}')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var msg = {"result": [xhr.responseText]}
|
var msg = {"result": [xhr.responseText]}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(msg)
|
console.log(msg)
|
||||||
msg.result && console.log(msg.result.join(""));
|
msg.result && console.log(msg.result.join(""))
|
||||||
if (msg.page_redirect) {
|
if (msg.download_file) {
|
||||||
|
window.open(msg.download_file.join(""))
|
||||||
|
} else if (msg.page_redirect) {
|
||||||
location.href = msg.page_redirect.join("")
|
location.href = msg.page_redirect.join("")
|
||||||
} else if (msg.page_refresh) {
|
} else if (msg.page_refresh) {
|
||||||
location.reload()
|
location.reload()
|
||||||
@ -139,6 +141,13 @@ function append_child(parent, element, html) {
|
|||||||
html && typeof html == "string" && (elm.innerHTML = html)
|
html && typeof html == "string" && (elm.innerHTML = html)
|
||||||
if (typeof html == "object") {
|
if (typeof html == "object") {
|
||||||
for (var k in html) {
|
for (var k in html) {
|
||||||
|
if (typeof html[k] == "object") {
|
||||||
|
for (var d in html[k]) {
|
||||||
|
elm[k][d] = html[k][d]
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
elm[k] = html[k]
|
elm[k] = html[k]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,8 @@
|
|||||||
height:2em;
|
height:2em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<script src="/librarys/context.js"></script>
|
||||||
|
<script src="/librarys/code.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body onkeyup="return onaction(event, 'keymap')">
|
<body onkeyup="return onaction(event, 'keymap')">
|
||||||
{{end}}
|
{{end}}
|
||||||
@ -205,7 +206,5 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "tail"}}
|
{{define "tail"}}
|
||||||
<script src="/librarys/context.js"></script>
|
|
||||||
<script src="/librarys/code.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user