From b3402aae372bf260b73a2b74ef62355ea29f355b Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Wed, 10 Feb 2016 09:13:21 -0500 Subject: [PATCH] Renaming Former-commit-id: ab33ec4b9e7bae76ca4cc595b5f592ce270e82da [formerly ce5634e48d51105387d3e26507b7defc9054a28b] [formerly d84debd3176eb769221034f5e01aadc0ab70fc42 [formerly 16d0c680556a27c0d54f851ed43c7a1bae4aecd9 [formerly 6a6b53ca0a6dee28c2f38737c0b75b8bb41029d1]]] Former-commit-id: baf9031e3fc929802c670c7352d6ba5b104dfeee [formerly 6c3b7c7c0e666e8fac5890e569db8a7ca9929b05] Former-commit-id: 50d2a8dc179e0f705a21f03283cefcf0ad82f2f0 Former-commit-id: 3669e8809b64772c2d41b5beb992d05bf86f687f --- db.go | 24 ++++++++++++------------ main.go | 16 ++++++++-------- routes.go | 6 +++--- templates/index.tmpl | 2 +- utils.go | 6 +++--- websockets.go | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/db.go b/db.go index aae6bb0..604303e 100644 --- a/db.go +++ b/db.go @@ -33,8 +33,8 @@ func Close() { db.Close() } -// CowyoData is data for storing in DB -type CowyoData struct { +// WikiData is data for storing in DB +type WikiData struct { Title string CurrentText string Diffs []string @@ -58,7 +58,7 @@ func hasPassword(title string) (bool, error) { if val == nil { return nil } - var p CowyoData + var p WikiData err = p.decode(val) if err != nil { return err @@ -71,7 +71,7 @@ func hasPassword(title string) (bool, error) { return nil }) if err != nil { - fmt.Printf("Could not get CowyoData: %s", err) + fmt.Printf("Could not get WikiData: %s", err) return false, err } return hasPassword, nil @@ -96,7 +96,7 @@ func getCurrentText(title string, version int) (string, []versionsInfo, bool) { if val == nil { return nil } - var p CowyoData + var p WikiData err = p.decode(val) if err != nil { return err @@ -111,12 +111,12 @@ func getCurrentText(title string, version int) (string, []versionsInfo, bool) { return nil }) if err != nil { - fmt.Printf("Could not get CowyoData: %s", err) + fmt.Printf("Could not get WikiData: %s", err) } return currentText, vi, isCurrent } -func (p *CowyoData) load(title string) error { +func (p *WikiData) load(title string) error { title = strings.ToLower(title) if !open { return fmt.Errorf("db must be opened before loading!") @@ -144,13 +144,13 @@ func (p *CowyoData) load(title string) error { return nil }) if err != nil { - fmt.Printf("Could not get CowyoData: %s", err) + fmt.Printf("Could not get WikiData: %s", err) return err } return nil } -func (p *CowyoData) save(newText string) error { +func (p *WikiData) save(newText string) error { if !open { return fmt.Errorf("db must be opened before saving") } @@ -168,7 +168,7 @@ func (p *CowyoData) save(newText string) error { p.Diffs = append(p.Diffs, delta) enc, err := p.encode() if err != nil { - return fmt.Errorf("could not encode CowyoData: %s", err) + return fmt.Errorf("could not encode WikiData: %s", err) } err = bucket.Put([]byte(p.Title), enc) return err @@ -176,7 +176,7 @@ func (p *CowyoData) save(newText string) error { return err } -func (p *CowyoData) encode() ([]byte, error) { +func (p *WikiData) encode() ([]byte, error) { enc, err := json.Marshal(p) if err != nil { return nil, err @@ -184,7 +184,7 @@ func (p *CowyoData) encode() ([]byte, error) { return enc, nil } -func (p *CowyoData) decode(data []byte) error { +func (p *WikiData) decode(data []byte) error { err := json.Unmarshal(data, &p) if err != nil { return err diff --git a/main.go b/main.go index 3b7332f..c1c34b1 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,7 @@ import ( ) // AllowedIPs is a white/black list of -// IP addresses allowed to access cowyo +// IP addresses allowed to access awwkoala var AllowedIPs = map[string]bool{ "192.168.1.13": true, "192.168.1.12": true, @@ -39,13 +39,13 @@ func main() { flag.StringVar(&RuntimeArgs.ServerCRT, "crt", "", "location of ssl crt") flag.StringVar(&RuntimeArgs.ServerKey, "key", "", "location of ssl key") flag.CommandLine.Usage = func() { - fmt.Println(`cowyo: a websocket notepad + fmt.Println(`awwkoala: a websocket notepad run this to start the server and then visit localhost at the port you specify (see parameters). -Example: 'cowyo localhost' -Example: 'cowyo -p :8080 localhost' -Example: 'cowyo -db /var/lib/cowyo/db.bolt localhost' -Example: 'cowyo -p :8080 -crt ssl/server.crt -key ssl/server.key localhost' +Example: 'awwkoala localhost' +Example: 'awwkoala -p :8080 localhost' +Example: 'awwkoala -db /var/lib/awwkoala/db.bolt localhost' +Example: 'awwkoala -p :8080 -crt ssl/server.crt -key ssl/server.key localhost' Options:`) flag.CommandLine.PrintDefaults() } @@ -59,10 +59,10 @@ Options:`) defer Close() // Default page - p := CowyoData{"about", about_page, []string{}, []string{}} + p := WikiData{"about", about_page, []string{}, []string{}} p.save(about_page) - var q CowyoData + var q WikiData q.load("SpikySeaSlug2") fmt.Println(getImportantVersions(q)) diff --git a/routes.go b/routes.go index bc93953..0faa96b 100644 --- a/routes.go +++ b/routes.go @@ -165,7 +165,7 @@ func renderList(c *gin.Context, title string) { if strings.ToLower(title) == "about" { //}&& strings.Contains(AllowedIPs, c.ClientIP()) != true { c.Redirect(302, "/about/view") } - var p CowyoData + var p WikiData err := p.load(strings.ToLower(title)) if err != nil { panic(err) @@ -183,7 +183,7 @@ func deleteListItem(c *gin.Context) { lineNum, err := strconv.Atoi(c.DefaultQuery("lineNum", "None")) title := c.Query("title") // shortcut for c.Request.URL.Query().Get("lastname") if err == nil { - var p CowyoData + var p WikiData err := p.load(strings.ToLower(title)) if err != nil { panic(err) @@ -225,7 +225,7 @@ func listEverything() string { b := tx.Bucket([]byte("datas")) c := b.Cursor() for k, v := c.First(); k != nil; k, v = c.Next() { - var p CowyoData + var p WikiData p.load(string(k)) if len(p.CurrentText) > 1 { contentSize := strconv.Itoa(len(p.CurrentText)) diff --git a/templates/index.tmpl b/templates/index.tmpl index 9a97272..3786195 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -55,7 +55,7 @@ - Cowyo + Wiki