openidec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 07d8654ac2b848d5cd47e8da6ae939128a9008c4
parent 932c4886e05817a40275010313761fd4edf07e39
Author: Peter Kosyh <p.kosyh@gmail.com>
Date:   Mon,  7 Sep 2020 19:56:12 +0300

style

Diffstat:
Mii-node/lib/style.css | 2+-
Mii-node/tpl/header.tpl | 4++--
Mii-node/web.go | 23++++++++++++++++-------
Mii/msg.go | 24+++++++++++++++++++++++-
4 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/ii-node/lib/style.css b/ii-node/lib/style.css @@ -214,7 +214,7 @@ body { color: black; } #header .title .info { - font-size: smaller; + font-size: small; color: #555555; font-style: italic; font-weight: bold; diff --git a/ii-node/tpl/header.tpl b/ii-node/tpl/header.tpl @@ -6,14 +6,14 @@ <meta name="viewport" content="width=device-width; initial-scale=1.0"> <link rel="icon" href="/lib/icon.png" type="image/png"> <link rel="stylesheet" type="text/css" href="/lib/style.css"> -<title>go-ii</title> +<title>{{.Sysname}}</title> </head> <body> <div id="body"> <table id="header"> <tr> <td class="title"> - <span class="logo"><a href="/">ii-go</a></span> + <span class="logo"><a href="/">{{.Sysname}}</a></span> <span class="info">II/IDEC networks {{ with .Echo }} :: <a href="/echo/{{.}}">{{.}}</a> <span class="info">{{index $.Echolist.Info .}}</span>{{end}} </span> </td> diff --git a/ii-node/web.go b/ii-node/web.go @@ -34,6 +34,8 @@ type WebContext struct { Selected string Ref string Info string + Sysname string + Host string www *WWW } @@ -152,14 +154,19 @@ func www_avatar(ctx *WebContext, w http.ResponseWriter, r *http.Request, user st ii.Error.Printf("Avatar is too big.") return errors.New("Avatar is too big") } - img := parse_ava(ava) - if img == nil { - ii.Error.Printf("Wrong xpm format for avatar: " + user) - return errors.New("Wrong xpm format") + if ava == "" { + ii.Trace.Printf("Delete avatar for %s", ctx.User.Name) + ctx.User.Tags.Del("avatar") + } else { + img := parse_ava(ava) + if img == nil { + ii.Error.Printf("Wrong xpm format for avatar: " + user) + return errors.New("Wrong xpm format") + } + b64 := base64.URLEncoding.EncodeToString([]byte(ava)) + ii.Trace.Printf("New avatar for %s: %s", ctx.User.Name, b64) + ctx.User.Tags.Add("avatar/" + b64) } - b64 := base64.URLEncoding.EncodeToString([]byte(ava)) - ii.Trace.Printf("New avatar for %s: %s", ctx.User.Name, b64) - ctx.User.Tags.Add("avatar/" + b64) if err := ctx.www.udb.Edit(ctx.User); err != nil { ii.Error.Printf("Error saving avatar: " + user) return errors.New("Error saving avatar") @@ -731,6 +738,8 @@ func handleWWW(www *WWW, w http.ResponseWriter, r *http.Request) { var user *ii.User = &ii.User{} ctx.User = user ctx.www = www + ctx.Sysname = www.db.Name + ctx.Host = www.Host www.udb.LoadUsers() err := _handleWWW(&ctx, w, r) if err != nil { diff --git a/ii/msg.go b/ii/msg.go @@ -197,11 +197,33 @@ func (t *Tags) Add(str string) error { t.Hash = make(map[string]string) } for i := 0; i < len(tags); i += 2 { + _, ok := t.Hash[tags[i]] t.Hash[tags[i]] = tags[i+1] - t.List = append(t.List, tags[i]) + if !ok { /* new tag */ + t.List = append(t.List, tags[i]) + } } return nil } +func (t *Tags) Del(tag string) bool { + if t.Hash == nil { + return false + } + _, ok := t.Hash[tag] + if !ok { + return false + } + delete(t.Hash, tag) + for k, v := range t.List { + if v == tag { + copy(t.List[k:], t.List[k+1:]) + t.List[len(t.List) - 1] = "" + t.List = t.List[:len(t.List) - 1] + return true + } + } + return false +} func (t Tags) String() string { var text string