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

mac add what?

This commit is contained in:
shaoying 2018-11-14 00:34:36 +08:00
parent 231ef878e6
commit 7a6d28dac2
10 changed files with 107 additions and 64 deletions

View File

@ -18,11 +18,8 @@ install_all: install
touch etc/login.txt
touch etc/history.txt
build:
go build $(BENCH)
run:
etc/run.sh 2>var/error.log
etc/bootstrap.sh
tar:
[ -e tar ] || mkdir tar
@ -45,26 +42,19 @@ tar_all: tar darwin linux64
mv bench.linux64 tar/bin/
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:
GOARCH=amd64 GOOS=darwin go build $(BENCH)
mv bench bench.darwin
GOARCH=amd64 GOOS=darwin go build $(BENCH) -o bench.darwin
win64:
GOARCH=amd64 GOOS=windows go build $(BENCH)
mv bench.exe bench_1.0_win64.exe
GOARCH=amd64 GOOS=windows go build $(BENCH) -o bench.win64.exe
win32:
GOARCH=386 GOOS=windows go build $(BENCH)
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
GOARCH=386 GOOS=windows go build $(BENCH) -o bench.win32.exe
DOTS=etc/dotsfile
@ -93,5 +83,5 @@ load_dotsfile:\
~/.vim/syntax/shy.vim: $(DOTS)/shy.vim
cp $< $@
.PHONY: tar
.PHONY: tar run

View File

@ -1,12 +1,13 @@
#!/usr/bin/env bash
bench=bench
[ `uname` = "Darwin" ] && bench=bin/bench.darwin
[ `uname` = "Linux" ] && bench=bin/bench.linux64
[ -e "$bench" ] || bench=bench
echo "bench: $bench"> var/boot.log
while true; do
$bench stdio && break
$bench stdio 2>var/error.log && break
echo "bench run error"
echo "restarting..."
sleep 3

View File

@ -4,5 +4,4 @@ source etc/exit_local.shy
config save counter.json counter
~stdio
config save history.json history
return hello

View File

@ -3,5 +3,15 @@
~code
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
~shy

View File

@ -316,7 +316,6 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
}
for _, v := range exports {
m.Log("info", "export %v", v)
if v["file"] != "" {
m.Sess("nfs").Copy(msg, "option").Copy(msg, "append").Copy(msg, "result").Cmd("export", v["file"])
}

View File

@ -69,7 +69,7 @@ func open(m *ctx.Message, name string, arg ...int) (string, *os.File, error) {
}
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
}
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()
default:
m.Log("fuck", "what ---%v", m.Meta)
for _, v := range m.Meta["result"] {
f.WriteString(v)
}
}
m.Log("fuck", "what ---%v", m.Meta)
m.Set("append").Set("result").Echo(name)
m.Set("append").Set("result").Add("append", "directory", name).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) {
@ -1167,6 +1165,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
p := path.Join(m.Confv("paths", 0).(string), arg[0])
qrcode.WriteFile(strings.Join(arg[1:], ""), qrcode.Medium, size, p)
m.Log("info", "genqr %s", p)
m.Append("directory", p)
}
}},

View File

@ -230,10 +230,6 @@ func (web *WEB) Start(m *ctx.Message, arg ...string) bool {
return true
})
if len(arg) == 0 {
return false
}
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: "服务地址"}
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") {
m.Append("page_redirect", fmt.Sprintf("/download/%s", msg.Append("directory")))
m.Append("download_file", fmt.Sprintf("/download/%s", msg.Append("directory")))
return
}

View File

@ -9,6 +9,7 @@ function copy_to_clipboard(text) {
insert_child(clipstack, "option").value = text
clipstack.childElementCount > 3 && clipstack.removeChild(clipstack.lastElementChild)
}
function send_command(form, cb) {
var data = {}
for (var key in form.dataset) {
@ -49,6 +50,7 @@ function send_command(form, cb) {
typeof(cb) == "function" && cb(msg)
})
}
function check_argument(form, target) {
for (var i = 0; i < form.length-1; i++) {
if (form[i] == target) {
@ -62,6 +64,36 @@ function check_argument(form, target) {
}
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) {
switch (action) {
case "submit":
@ -162,10 +194,40 @@ function onaction(event, action) {
event.target.dataset["history_last"] = history.length-1
break
}
case "b":
if (event.ctrlKey && event.key == "b") {
case "v":
if (event.ctrlKey && event.key == "v") {
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:
console.log(event)
if (event.target.dataset["last_char"] == "j" && event.key == "k") {
@ -204,6 +266,7 @@ function onaction(event, action) {
break
}
}
var inputs = {}
var ninput = 0
var keymap = ['a', 'b', 'c']
@ -352,7 +415,6 @@ function init_download(event) {
})
}
}
function init_context() {
var append = document.querySelector("table.append.ctx")
if (!append) {
@ -459,7 +521,6 @@ function init_command() {
}
})
}
function init_userinfo() {
var append = document.querySelector("table.append.userinfo")
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() {
init_option()
init_append()

View File

@ -109,14 +109,16 @@ context = {
}
try {
var msg = JSON.parse(xhr.responseText||'{"result":[]}');
var msg = JSON.parse(xhr.responseText||'{"result":[]}')
} catch (e) {
var msg = {"result": [xhr.responseText]}
}
console.log(msg)
msg.result && console.log(msg.result.join(""));
if (msg.page_redirect) {
msg.result && console.log(msg.result.join(""))
if (msg.download_file) {
window.open(msg.download_file.join(""))
} else if (msg.page_redirect) {
location.href = msg.page_redirect.join("")
} else if (msg.page_refresh) {
location.reload()
@ -139,6 +141,13 @@ function append_child(parent, element, html) {
html && typeof html == "string" && (elm.innerHTML = html)
if (typeof html == "object") {
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]
}
}

View File

@ -97,7 +97,8 @@
height:2em;
}
</style>
<script src="/librarys/context.js"></script>
<script src="/librarys/code.js"></script>
</head>
<body onkeyup="return onaction(event, 'keymap')">
{{end}}
@ -205,7 +206,5 @@
{{end}}
{{define "tail"}}
<script src="/librarys/context.js"></script>
<script src="/librarys/code.js"></script>
</body>
{{end}}