forked from x/icebergs
fix language
This commit is contained in:
parent
5051a7d2c1
commit
251d28ccc6
@ -49,11 +49,14 @@ func SessCreate(m *ice.Message, username string) string {
|
||||
return m.Option(ice.MSG_SESSID, m.Cmdx(SESS, mdb.CREATE, username))
|
||||
}
|
||||
func SessCheck(m *ice.Message, sessid string) bool {
|
||||
m.Options(ice.MSG_USERNICK, "", ice.MSG_USERNAME, "", ice.MSG_USERROLE, VOID, ice.MSG_LANGUAGE, "", "aaa.checker", logs.FileLine(-1))
|
||||
m.Options(ice.MSG_USERNICK, "", ice.MSG_USERNAME, "", ice.MSG_USERROLE, VOID, ice.MSG_CHECKER, logs.FileLine(-1))
|
||||
return sessid != "" && m.Cmdy(SESS, CHECK, sessid, logs.FileLineMeta(-1)).Option(ice.MSG_USERNAME) != ""
|
||||
}
|
||||
func SessAuth(m *ice.Message, value ice.Any, arg ...string) *ice.Message {
|
||||
language := kit.Format(kit.Value(value, LANGUAGE))
|
||||
language := kit.Select(m.Option(ice.MSG_LANGUAGE), kit.Format(kit.Value(value, LANGUAGE)))
|
||||
kit.If(language == "", func() {
|
||||
kit.If(kit.Format(kit.Value(value, USERNAME)), func(p string) { language = m.Cmdv(USER, p, LANGUAGE) })
|
||||
})
|
||||
kit.If(language == "", func() { language = kit.Select("", "zh-cn", strings.Contains(m.Option(ice.MSG_USERUA), "zh_CN")) })
|
||||
kit.If(language == "" && m.R != nil, func() { language = kit.Select("", kit.Split(m.R.Header.Get(html.AcceptLanguage), ",;"), 0) })
|
||||
kit.If(language == "", func() { language = ice.Info.Lang })
|
||||
@ -62,8 +65,8 @@ func SessAuth(m *ice.Message, value ice.Any, arg ...string) *ice.Message {
|
||||
USERNICK, m.Option(ice.MSG_USERNICK, kit.Format(kit.Value(value, USERNICK))),
|
||||
USERNAME, m.Option(ice.MSG_USERNAME, kit.Format(kit.Value(value, USERNAME))),
|
||||
USERROLE, m.Option(ice.MSG_USERROLE, kit.Format(kit.Value(value, USERROLE))),
|
||||
LANGUAGE, m.Option(ice.MSG_LANGUAGE, language),
|
||||
arg, logs.FileLineMeta(kit.Select(logs.FileLine(-1), m.Option("aaa.checker"))),
|
||||
LANGUAGE, m.Option(ice.MSG_LANGUAGE, language), arg,
|
||||
logs.FileLineMeta(kit.Select(logs.FileLine(-1), m.Option("aaa.checker"))),
|
||||
)
|
||||
}
|
||||
func SessLogout(m *ice.Message, arg ...string) {
|
||||
|
@ -51,9 +51,9 @@ func init() {
|
||||
}
|
||||
}},
|
||||
mdb.CREATE: {Name: "create usernick username* userrole=void,tech userzone", Hand: func(m *ice.Message, arg ...string) {
|
||||
_user_create(m, m.Option(USERNAME), m.OptionSimple(USERNICK, USERROLE, USERZONE, BACKGROUND, AVATAR, AVATAR_URL, LANGUAGE, EMAIL)...)
|
||||
_user_create(m, m.Option(USERNAME), m.OptionSimple(USERNICK, USERROLE, USERZONE, LANGUAGE, EMAIL, BACKGROUND, AVATAR)...)
|
||||
}},
|
||||
}, mdb.ImportantHashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone"))},
|
||||
}, mdb.ImportantHashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone,language"))},
|
||||
})
|
||||
}
|
||||
|
||||
@ -86,10 +86,9 @@ func UserRoot(m *ice.Message, arg ...string) *ice.Message {
|
||||
userrole := kit.Select(ROOT, arg, 2)
|
||||
username := kit.Select(ice.Info.Username, arg, 1)
|
||||
usernick := kit.Select(UserNick(m, username), arg, 0)
|
||||
background := kit.Select("usr/icons/background.jpg", UserInfo(m, username, BACKGROUND, ""))
|
||||
if len(arg) > 0 {
|
||||
ice.Info.Username = username
|
||||
m.Cmd(USER, mdb.CREATE, usernick, username, userrole, userzone, background)
|
||||
m.Cmd(USER, mdb.CREATE, usernick, username, userrole, userzone)
|
||||
}
|
||||
return SessAuth(m, kit.Dict(USERNICK, usernick, USERNAME, username, USERROLE, userrole))
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func _zone_import(m *ice.Message, prefix, chain, file string) {
|
||||
if os.IsNotExist(e) {
|
||||
return
|
||||
}
|
||||
if m.Warn(e) {
|
||||
if e != nil {
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
@ -158,7 +158,7 @@ const (
|
||||
USR_ICONS_AVATAR = "usr/icons/avatar.jpg"
|
||||
USR_ICONS_CONTEXTS = "usr/icons/contexts.png"
|
||||
USR_ICONS_ICEBERGS = "usr/icons/icebergs.jpg"
|
||||
USR_ICONS_VOLCANOS = "usr/icons/valcanos.jpg"
|
||||
USR_ICONS_VOLCANOS = "usr/icons/volcanos.jpg"
|
||||
|
||||
TYPE_ALL = "all"
|
||||
TYPE_BIN = "bin"
|
||||
|
@ -70,10 +70,7 @@ func init() {
|
||||
}
|
||||
}},
|
||||
SOCKET: {Hand: func(m *ice.Message, arg ...string) {
|
||||
parse := func(str string) int64 {
|
||||
port, _ := strconv.ParseInt(str, 16, 32)
|
||||
return port
|
||||
}
|
||||
parse := func(str string) int64 { port, _ := strconv.ParseInt(str, 16, 32); return port }
|
||||
trans := func(str string) string {
|
||||
switch str {
|
||||
case "0A":
|
||||
|
@ -27,7 +27,9 @@ func UserWeb(m Message) *url.URL {
|
||||
return kit.ParseURL(m.Option(ice.MSG_USERWEB))
|
||||
}
|
||||
func UserHost(m *ice.Message) string {
|
||||
if u := UserWeb(m); strings.Contains(u.Host, tcp.LOCALHOST) {
|
||||
if p := m.Option(ice.MSG_USERHOST); p != "" {
|
||||
return p
|
||||
} else if u := UserWeb(m); strings.Contains(u.Host, tcp.LOCALHOST) {
|
||||
return m.Option(ice.MSG_USERHOST, tcp.PublishLocalhost(m, u.Scheme+"://"+u.Host))
|
||||
} else {
|
||||
return m.Option(ice.MSG_USERHOST, u.Scheme+"://"+u.Host)
|
||||
|
@ -32,7 +32,7 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
|
||||
arg := kit.Simple(args...)
|
||||
kit.If(len(arg) == 0, func() { args = nil })
|
||||
if cmd != "" {
|
||||
if cmd != ice.RENDER_DOWNLOAD || !kit.HasPrefix(arg[0], ice.SRC_TEMPLATE, ice.USR_INTSHELL, ice.USR_VOLCANOS, ice.USR_ICONS, ice.USR_MODULES) {
|
||||
if cmd != ice.RENDER_DOWNLOAD || !kit.HasPrefix(arg[0], ice.SRC_TEMPLATE, ice.USR_INTSHELL, ice.USR_VOLCANOS) {
|
||||
if !(cmd == ice.RENDER_RESULT && len(args) == 0) {
|
||||
defer func() { m.Logs("Render", cmd, args) }()
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ func _serve_start(m *ice.Message) {
|
||||
kit.If(m.Option(aaa.USERNAME), func() { aaa.UserRoot(m, m.Option(aaa.USERNICK), m.Option(aaa.USERNAME)) })
|
||||
kit.If(m.Option(tcp.PORT) == tcp.RANDOM, func() { m.Option(tcp.PORT, m.Cmdx(tcp.PORT, aaa.RIGHT)) })
|
||||
kit.If(runtime.GOOS == cli.WINDOWS || m.Cmdx(cli.SYSTEM, "lsof", "-i", ":"+m.Option(tcp.PORT)) != "", func() {
|
||||
m.Go(func() { m.Cmd(SPIDE, ice.OPS, _serve_address(m)+"/exit", ice.Maps{CLIENT_TIMEOUT: "300ms"}) }).Sleep300ms()
|
||||
m.Go(func() { m.Cmd(SPIDE, ice.OPS, _serve_address(m)+"/exit", ice.Maps{CLIENT_TIMEOUT: "30ms"}) }).Sleep300ms()
|
||||
})
|
||||
cli.NodeInfo(m, kit.Select(ice.Info.Hostname, m.Option(tcp.NODENAME)), SERVER)
|
||||
m.Start("", m.OptionSimple(tcp.HOST, tcp.PORT)...)
|
||||
@ -178,15 +178,13 @@ func _serve_auth(m *ice.Message, key string, cmds []string, w http.ResponseWrite
|
||||
ls := kit.Simple(mdb.Cache(m, m.Option(ice.MSG_USERIP), func() ice.Any {
|
||||
if IsLocalHost(m) {
|
||||
aaa.UserRoot(m)
|
||||
return kit.Simple(m.Time(), m.OptionSplit(ice.MSG_USERNICK, ice.MSG_USERNAME, ice.MSG_USERROLE, ice.MSG_LANGUAGE))
|
||||
return kit.Simple(m.Time(), m.OptionSplit(ice.MSG_USERNICK), m.OptionSplit(ice.MSG_USERNAME), m.OptionSplit(ice.MSG_USERROLE))
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}))
|
||||
if len(ls) > 0 {
|
||||
m.Auth(aaa.USERNICK, m.Option(ice.MSG_USERNICK, ls[1]),
|
||||
aaa.USERNAME, m.Option(ice.MSG_USERNAME, ls[2]),
|
||||
aaa.USERROLE, m.Option(ice.MSG_USERROLE, ls[3]),
|
||||
aaa.LANGUAGE, m.Option(ice.MSG_LANGUAGE, ls[4]), CACHE, ls[0])
|
||||
aaa.SessAuth(m, kit.Dict(aaa.USERNICK, ls[1], aaa.USERNAME, ls[2], aaa.USERROLE, ls[3]), CACHE, ls[0])
|
||||
}
|
||||
}
|
||||
m.Cmd(COUNT, mdb.CREATE, aaa.IP, m.Option(ice.MSG_USERIP), m.Option(ice.MSG_USERUA), kit.Dict(ice.LOG_DISABLE, ice.TRUE))
|
||||
|
@ -18,9 +18,9 @@ import (
|
||||
|
||||
func _share_link(m *ice.Message, p string, arg ...ice.Any) string {
|
||||
if strings.HasPrefix(p, ice.USR_PUBLISH) {
|
||||
return tcp.PublishLocalhost(m, MergeLink(m, strings.TrimPrefix(p, ice.USR), arg...))
|
||||
return kit.MergeURL2(UserHost(m), strings.TrimPrefix(p, ice.USR), arg...)
|
||||
}
|
||||
return tcp.PublishLocalhost(m, MergeLink(m, kit.Select("", PP(SHARE, LOCAL), !strings.HasPrefix(p, nfs.PS) && !strings.HasPrefix(p, HTTP))+p, arg...))
|
||||
return kit.MergeURL2(UserHost(m), kit.Select("", PP(SHARE, LOCAL), !strings.HasPrefix(p, nfs.PS) && !strings.HasPrefix(p, HTTP))+p, arg...)
|
||||
}
|
||||
func _share_cache(m *ice.Message, arg ...string) {
|
||||
if m.Cmdy(CACHE, arg[0]); m.Length() == 0 {
|
||||
|
@ -46,6 +46,7 @@ func install(m *ice.Message, cmd, icon, index string, arg ...string) {
|
||||
if icon != "" {
|
||||
nfs.Exists(m, ice.USR_ICONS+icon, func(p string) { icon = p })
|
||||
if m.Warn(!strings.HasPrefix(icon, web.HTTP) && !nfs.Exists(m, icon)) {
|
||||
m.Info("what %s", m.FormatStack(1, 100))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ Volcanos(chat.ONIMPORT, {
|
||||
if (can.ConfWidth() > 1400) { item.width = can.base.Min(can.ConfWidth()-600, 640, 1400), item.left = (can.ConfWidth()-item.width)/2 }
|
||||
if (can.ConfHeight() > 800) { item.height = can.base.Min(can.ConfHeight()-200, 320, 800), item.top = 50 }
|
||||
if (can.user.isMobile) { item.left = 0, item.top = 25, item.height = can.ConfHeight()-125, item.width = can.ConfWidth() }
|
||||
item.height = can.base.Max(html.DESKTOP_HEIGHT, item.height), item.width = can.base.Max(html.DESKTOP_WIDTH, item.width)
|
||||
can.onappend.plugin(can, item, function(sub) { can.ondetail.select(can, sub._target)
|
||||
var index = 0; can.core.Item({
|
||||
close: {color: "#f95f57", inner: "x", onclick: function(event) { sub.onaction._close(event, sub) }},
|
||||
|
@ -25,7 +25,14 @@ func _publish_bin_list(m *ice.Message) *ice.Message {
|
||||
func _publish_list(m *ice.Message, arg ...string) *ice.Message {
|
||||
defer m.SortStrR(mdb.TIME)
|
||||
m.Option(nfs.DIR_REG, kit.Select("", arg, 0))
|
||||
return nfs.DirDeepAll(m, ice.USR_PUBLISH, nfs.PWD, nil, nfs.DIR_WEB_FIELDS)
|
||||
defer m.Table(func(value ice.Maps) {
|
||||
if p := value[nfs.PATH]; strings.Contains(p, "ice.windows.") {
|
||||
m.PushDownload(mdb.LINK, "ice.exe", p)
|
||||
} else {
|
||||
m.Push(mdb.LINK, kit.MergeURL2(web.UserHost(m), "/publish/"+p))
|
||||
}
|
||||
})
|
||||
return nfs.DirDeepAll(m, ice.USR_PUBLISH, nfs.PWD, nil)
|
||||
}
|
||||
func _publish_file(m *ice.Message, file string, arg ...string) string {
|
||||
if strings.HasSuffix(file, ice.ICE_BIN) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user