From 46397875585d03efcefc062d1aa9353ccdbebdde Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Tue, 17 Jan 2017 17:09:10 +0100 Subject: [PATCH 01/17] Preparing development for new version. --- gwu/doc.go | 2 +- version-history/changes-v1.2.2.txt | 2 +- version-history/changes-v1.3.0.txt | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 version-history/changes-v1.3.0.txt diff --git a/gwu/doc.go b/gwu/doc.go index 2d2c50b..f31d72f 100644 --- a/gwu/doc.go +++ b/gwu/doc.go @@ -396,7 +396,7 @@ package gwu // Gowut version information. const ( - GowutVersion = "v1.2.2" // Gowut version: "v"major.minor.maintenance[-dev] + GowutVersion = "v1.3.0-dev" // Gowut version: "v"major.minor.maintenance[-dev] GowutReleaseDate = "2017-01-17 CET" // Gowut release date GowutRelDateLayout = "2006-01-02 MST" // Gowut release date layout (for time.Parse()) ) diff --git a/version-history/changes-v1.2.2.txt b/version-history/changes-v1.2.2.txt index 94621b3..13e31db 100644 --- a/version-history/changes-v1.2.2.txt +++ b/version-history/changes-v1.2.2.txt @@ -4,7 +4,7 @@ Changes and new features in v1.2.2: -Moved the Showcase of Features live demo to: http://iczapp.com:3434/gowut-demo/show --Added -addr and -autoOpen flags to the Showcase of Features demo. +-Added -appName, -addr and -autoOpen flags to the Showcase of Features demo. -Added a missing check if a Server logger is set before using it. diff --git a/version-history/changes-v1.3.0.txt b/version-history/changes-v1.3.0.txt new file mode 100644 index 0000000..82dd18b --- /dev/null +++ b/version-history/changes-v1.3.0.txt @@ -0,0 +1,3 @@ + +Changes and new features in v1.3.0: +----------------------------------- From 9ad99d88f90872fb60a123eb30b9241b43d7c14b Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Thu, 19 Jan 2017 02:53:39 +0100 Subject: [PATCH 02/17] Removed unnecessary loop from showcase demo. --- _examples/showcase/showcase.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/_examples/showcase/showcase.go b/_examples/showcase/showcase.go index f080e60..b72ea7d 100644 --- a/_examples/showcase/showcase.go +++ b/_examples/showcase/showcase.go @@ -22,9 +22,6 @@ package main import ( "flag" - "fmt" - "log" - "os" "github.com/icza/gowut/_examples/showcase/showcasecore" ) @@ -38,20 +35,5 @@ var ( func main() { flag.Parse() - // Allow app control from command line (in co-operation with the starter script): - log.Println("Type 'r' to restart, 'e' to exit.") - go func() { - var cmd string - for { - fmt.Scanf("%s", &cmd) - switch cmd { - case "r": // restart - os.Exit(1) - case "e": // exit - os.Exit(0) - } - } - }() - showcasecore.StartServer(*appName, *addr, *autoOpen) } From 80526e5599d48d1ac06cf41512a7731575bad396 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Fri, 17 Feb 2017 10:42:57 +0100 Subject: [PATCH 03/17] Taken care of gometalinter warnings. Updated travis to test with Go 1.8. --- .travis.yml | 2 +- _examples/simple/simple_demo.go | 1 + gwu/session.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 55de9b8..febacf4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: go go: - - 1.7 + - 1.8 - master diff --git a/_examples/simple/simple_demo.go b/_examples/simple/simple_demo.go index fb17954..9ad95df 100644 --- a/_examples/simple/simple_demo.go +++ b/_examples/simple/simple_demo.go @@ -19,6 +19,7 @@ package main import ( "fmt" + "github.com/icza/gowut/gwu" ) diff --git a/gwu/session.go b/gwu/session.go index 50bd17f..0606422 100644 --- a/gwu/session.go +++ b/gwu/session.go @@ -159,7 +159,7 @@ func (s *sessionImpl) Private() bool { func (s *sessionImpl) AddWin(w Window) error { if len(w.Name()) == 0 { - return errors.New("Window name cannot be empty string!") + return errors.New("Window name cannot be empty string") } if _, exists := s.windows[w.Name()]; exists { return errors.New("A window with the same name has already been added: " + w.Name()) From afde613b847084445fe97b421f9c3bb304c7cc1a Mon Sep 17 00:00:00 2001 From: Martyn Weber Date: Thu, 8 Jun 2017 17:26:12 +0100 Subject: [PATCH 04/17] Added member function SetContent([]string) to ListBox so the contents of the listbox can be amended once setup --- gwu/listbox.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gwu/listbox.go b/gwu/listbox.go index 63dd7b6..588f6c7 100644 --- a/gwu/listbox.go +++ b/gwu/listbox.go @@ -77,6 +77,9 @@ type ListBox interface { // ClearSelected deselects all values. ClearSelected() + + // SetContent(content []string) + SetContent(content []string) } // ListBox implementation. @@ -102,6 +105,11 @@ func NewListBox(values []string) ListBox { return c } +func (c *listBoxImpl)SetContent(newvalues [] string) { + c.values=newvalues + c.selected=make([]bool,len(newvalues)) +} + func (c *listBoxImpl) Multi() bool { return c.multi } From f7f07d3bd2d3595629d4ab1ba96495329e8b0b76 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Wed, 28 Jun 2017 16:26:05 +0200 Subject: [PATCH 05/17] Renamed SetContent() to SetValues(). Also added a matching Values(). --- gwu/listbox.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gwu/listbox.go b/gwu/listbox.go index 588f6c7..51da319 100644 --- a/gwu/listbox.go +++ b/gwu/listbox.go @@ -36,6 +36,12 @@ type ListBox interface { // ListBox can be enabled/disabled. HasEnabled + // Values returns the values. + Values() []string + + // SetValues sets the values. Also clears the selection. + SetValues(values []string) + // Multi tells if multiple selections are allowed. Multi() bool @@ -77,9 +83,6 @@ type ListBox interface { // ClearSelected deselects all values. ClearSelected() - - // SetContent(content []string) - SetContent(content []string) } // ListBox implementation. @@ -105,9 +108,13 @@ func NewListBox(values []string) ListBox { return c } -func (c *listBoxImpl)SetContent(newvalues [] string) { - c.values=newvalues - c.selected=make([]bool,len(newvalues)) +func (c *listBoxImpl) Values() []string { + return c.values +} + +func (c *listBoxImpl) SetValues(values []string) { + c.values = values + c.selected = make([]bool, len(values)) } func (c *listBoxImpl) Multi() bool { From 5e87800568eddcd9e251f42190eab0974eed6fab Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Mon, 25 Sep 2017 14:57:55 +0200 Subject: [PATCH 06/17] Fixed a number of data race issues at server session handling. --- gwu/server.go | 19 +++++++++++++++---- gwu/session.go | 5 +++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/gwu/server.go b/gwu/server.go index ac81671..e1f018f 100644 --- a/gwu/server.go +++ b/gwu/server.go @@ -27,6 +27,7 @@ import ( "path" "strconv" "strings" + "sync" "time" ) @@ -221,6 +222,8 @@ type serverImpl struct { headers http.Header // Extra headers that will be added to all responses. rootHeads []string // Additional head HTML texts of the window list page (app root) appRootHandlerFunc AppRootHandlerFunc // App root handler function + + sessMux sync.RWMutex // Mutex to protect state related to session handling } // NewServer creates a new GUI server in HTTP mode. @@ -296,7 +299,9 @@ func (s *serverImpl) AddSessCreatorName(name, text string) { } func (s *serverImpl) AddSHandler(handler SessionHandler) { + s.sessMux.Lock() s.sessionHandlers = append(s.sessionHandlers, handler) + s.sessMux.Unlock() } // newSession creates a new (private) Session. @@ -315,6 +320,7 @@ func (s *serverImpl) newSession(e *eventImpl) Session { e.shared.session = sess } // Store new session + s.sessMux.Lock() s.sessions[sess.ID()] = sess if s.logger != nil { @@ -327,6 +333,7 @@ func (s *serverImpl) newSession(e *eventImpl) Session { for _, handler := range s.sessionHandlers { handler.Created(sess) } + s.sessMux.Unlock() return sess } @@ -337,7 +344,9 @@ func (s *serverImpl) newSession(e *eventImpl) Session { // After this method Event.Session() will return the shared public session. func (s *serverImpl) removeSess(e *eventImpl) { if e.shared.session.Private() { + s.sessMux.Lock() s.removeSess2(e.shared.session) + s.sessMux.Unlock() e.shared.session = &s.sessionImpl } } @@ -345,6 +354,7 @@ func (s *serverImpl) removeSess(e *eventImpl) { // removeSess2 removes (invalidates) the specified session. // Only private sessions can be removed, calling this with the // public session is a no-op. +// serverImpl.mux must be locked when this is called. func (s *serverImpl) removeSess2(sess Session) { if sess.Private() { if s.logger != nil { @@ -387,12 +397,13 @@ func (s *serverImpl) sessCleaner() { for { now := time.Now() - // TODO synchronization? + s.sessMux.Lock() for _, sess := range s.sessions { if now.Sub(sess.Accessed()) > sess.Timeout() { s.removeSess2(sess) } } + s.sessMux.Unlock() time.Sleep(sleep) } @@ -552,7 +563,9 @@ func (s *serverImpl) serveHTTP(w http.ResponseWriter, r *http.Request) { var sess Session c, err := r.Cookie(gwuSessidCookie) if err == nil { + s.sessMux.RLock() sess = s.sessions[c.Value] + s.sessMux.RUnlock() } if sess == nil { sess = &s.sessionImpl @@ -582,11 +595,9 @@ func (s *serverImpl) serveHTTP(w http.ResponseWriter, r *http.Request) { } if len(parts) >= 1 && parts[0] == pathSessCheck { - // Session check. Must not call sess.acess() + // Session check. Must not call sess.access() w.Header().Set("Content-Type", "text/plain; charset=utf-8") - sess.rwMutex().RLock() remaining := sess.Timeout() - time.Now().Sub(sess.Accessed()) - sess.rwMutex().RUnlock() fmt.Fprintf(w, "%f", remaining.Seconds()) return } diff --git a/gwu/session.go b/gwu/session.go index 0606422..4a03fe6 100644 --- a/gwu/session.go +++ b/gwu/session.go @@ -214,6 +214,8 @@ func (s *sessionImpl) Created() time.Time { } func (s *sessionImpl) Accessed() time.Time { + s.rwMutexF.RLock() + defer s.rwMutexF.RUnlock() return s.accessed } @@ -227,9 +229,8 @@ func (s *sessionImpl) SetTimeout(timeout time.Duration) { func (s *sessionImpl) access() { s.rwMutexF.Lock() - defer s.rwMutexF.Unlock() - s.accessed = time.Now() + s.rwMutexF.Unlock() } func (s *sessionImpl) clearNew() { From 5ef481dca0fdcbd17875ad5c9297f0caf117e808 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Mon, 25 Sep 2017 22:26:04 +0200 Subject: [PATCH 07/17] Created Procfile for Heroku. --- Procfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 Procfile diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..3bea131 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: go run _examples/showcase/showcase.go From 19fd9abf775db612b6195a5833d5c952169f0e87 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Mon, 25 Sep 2017 22:29:57 +0200 Subject: [PATCH 08/17] Created app.json to define go build pack. --- app.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 app.json diff --git a/app.json b/app.json new file mode 100644 index 0000000..69e3443 --- /dev/null +++ b/app.json @@ -0,0 +1,7 @@ +{ + "buildpacks": [ + { + "url": "heroku/go" + } + ] +} From 885bb285e031ae13931d5bf53c996c3baa6a4327 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Mon, 25 Sep 2017 22:34:13 +0200 Subject: [PATCH 09/17] Improved app.json. --- app.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app.json b/app.json index 69e3443..722533f 100644 --- a/app.json +++ b/app.json @@ -1,7 +1,8 @@ { + "name": "Gowut Showcase of Features Demo app", "buildpacks": [ - { - "url": "heroku/go" - } - ] + { + "url": "heroku/go" + } + ] } From de5ae1c786fd8e5fdef7ecf0f5c1679fc7e8bb39 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Tue, 26 Sep 2017 10:13:32 +0200 Subject: [PATCH 10/17] Added vendor for heroku. Adjusted Procfile. --- Procfile | 2 +- vendor/vendor.json | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 vendor/vendor.json diff --git a/Procfile b/Procfile index 3bea131..5542792 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: go run _examples/showcase/showcase.go +web: showcase -autoOpen=false diff --git a/vendor/vendor.json b/vendor/vendor.json new file mode 100644 index 0000000..4315fee --- /dev/null +++ b/vendor/vendor.json @@ -0,0 +1,7 @@ +{ + "rootPath": "github.com/icza/gowut", + "heroku": { + "install": "./_examples/showcase", + "sync": false + } +} From 3bd1a90df49e74e91c48c3ddcf13c007f5e990c3 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Tue, 26 Sep 2017 10:16:32 +0200 Subject: [PATCH 11/17] Changed heroku install package. --- vendor/vendor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/vendor.json b/vendor/vendor.json index 4315fee..2d8a41c 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1,7 +1,7 @@ { "rootPath": "github.com/icza/gowut", "heroku": { - "install": "./_examples/showcase", + "install": "./_examples/showcase/...", "sync": false } } From dd6d5e3f8cd6ed3ab2e4050203b87891dd6d9670 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Tue, 26 Sep 2017 10:18:44 +0200 Subject: [PATCH 12/17] Changed heroku.install value to be an array. --- vendor/vendor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/vendor.json b/vendor/vendor.json index 2d8a41c..728207f 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1,7 +1,7 @@ { "rootPath": "github.com/icza/gowut", "heroku": { - "install": "./_examples/showcase/...", + "install": ["./_examples/showcase"], "sync": false } } From f7cfa437f50c62c3aa3f1147a09101ccdb16c49d Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Tue, 26 Sep 2017 10:21:06 +0200 Subject: [PATCH 13/17] Changed Procfile to use . --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index 5542792..fe12dfb 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: showcase -autoOpen=false +web: showcase -autoOpen=false -addr=":$PORT" From 2e1178be246eefad68659bb2d8b592b0982e9824 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Tue, 26 Sep 2017 10:27:30 +0200 Subject: [PATCH 14/17] Removed app.json, changed window name to empty. --- Procfile | 2 +- app.json | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 app.json diff --git a/Procfile b/Procfile index fe12dfb..7ae44c0 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: showcase -autoOpen=false -addr=":$PORT" +web: showcase -autoOpen=false -addr=":$PORT" -appName="" diff --git a/app.json b/app.json deleted file mode 100644 index 722533f..0000000 --- a/app.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "Gowut Showcase of Features Demo app", - "buildpacks": [ - { - "url": "heroku/go" - } - ] -} From 277e647de627216b19cf5068b78e2de1ff1cc000 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Tue, 26 Sep 2017 10:35:36 +0200 Subject: [PATCH 15/17] Edited version history, replaced live demo URLs. --- README.md | 2 +- gwu/doc.go | 2 +- version-history/changes-v1.3.0.txt | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9387bc8..189e3a3 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ This one auto-opens itself in your default browser. go run _examples/showcase/showcase.go -The Showcase of Features is also available live: http://iczapp.com:3434/gowut-demo/show +The Showcase of Features is also available live: https://gowut-demo.herokuapp.com/show **2. A single window example.** diff --git a/gwu/doc.go b/gwu/doc.go index f31d72f..01db79a 100644 --- a/gwu/doc.go +++ b/gwu/doc.go @@ -388,7 +388,7 @@ Source code: https://github.com/icza/gowut Discussion forum: https://groups.google.com/d/forum/gowebuitoolkit -Live demo: http://iczapp.com:3434/gowut-demo/show +Live demo: https://gowut-demo.herokuapp.com/show */ diff --git a/version-history/changes-v1.3.0.txt b/version-history/changes-v1.3.0.txt index 82dd18b..2814122 100644 --- a/version-history/changes-v1.3.0.txt +++ b/version-history/changes-v1.3.0.txt @@ -1,3 +1,10 @@ Changes and new features in v1.3.0: ----------------------------------- + +-Added ListBox.Values() and ListBox.SetValues() methods to read / change items +of a ListBox. + +-Fixed a number of data race issues at server session handling. + +-Moved the Showcase of Features live demo to: https://gowut-demo.herokuapp.com/show From 28b57a4209583ce20dbfa41bccfc1ef2348bc624 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Tue, 26 Sep 2017 10:41:27 +0200 Subject: [PATCH 16/17] Removed dev from version, preparation for v1.3.0 release. --- gwu/doc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gwu/doc.go b/gwu/doc.go index 01db79a..c76a889 100644 --- a/gwu/doc.go +++ b/gwu/doc.go @@ -396,7 +396,7 @@ package gwu // Gowut version information. const ( - GowutVersion = "v1.3.0-dev" // Gowut version: "v"major.minor.maintenance[-dev] + GowutVersion = "v1.3.0" // Gowut version: "v"major.minor.maintenance[-dev] GowutReleaseDate = "2017-01-17 CET" // Gowut release date GowutRelDateLayout = "2006-01-02 MST" // Gowut release date layout (for time.Parse()) ) From 5ca51537bb5f47d1c24847fb55c4fbc3a07a4244 Mon Sep 17 00:00:00 2001 From: Andras Belicza Date: Tue, 26 Sep 2017 10:42:33 +0200 Subject: [PATCH 17/17] Added Go 1.9 to travis. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index febacf4..4073a64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,5 @@ language: go go: - 1.8 + - 1.9 - master