From 1189967f2b78a186260648e1b73f5968547b2fc1 Mon Sep 17 00:00:00 2001 From: Azareal Date: Sun, 27 Oct 2019 09:11:09 +1000 Subject: [PATCH] Add a missing instruction to the installation guide. Add the /tmp/ folder, currently unused. Shorten some things. --- .gitignore | 1 + common/conversations.go | 3 +-- common/files.go | 8 ++++---- common/ip_search.go | 12 ++++++------ docs/installation.md | 4 ++++ extend/adventure/lib/adventure.go | 2 +- routes/panel/logs.go | 14 ++++++-------- routes/panel/themes.go | 3 --- templates/panel_backups.html | 4 +--- tmp/filler.txt | 1 + 10 files changed, 25 insertions(+), 27 deletions(-) create mode 100644 tmp/filler.txt diff --git a/.gitignore b/.gitignore index 5d8f92ce..bae7c55c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ tmp/* +!tmp/filler.txt tmp2/* cert_test/* tmp.txt diff --git a/common/conversations.go b/common/conversations.go index 18e9a4ce..3c2ac3e6 100644 --- a/common/conversations.go +++ b/common/conversations.go @@ -262,8 +262,7 @@ func (s *DefaultConversationStore) GetUserExtra(uid int, offset int) (cos []*Con idmap[cid] = append(idmap[cid],uid) puidmap[uid] = struct{}{} } - err = rows.Err() - if err != nil { + if err = rows.Err(); err != nil { return nil, err } //log.Println("3") diff --git a/common/files.go b/common/files.go index 4774f8ba..4e1e87e1 100644 --- a/common/files.go +++ b/common/files.go @@ -59,7 +59,7 @@ func (list SFileList) JSTmplInit() error { tmplName := strings.TrimSuffix(path, ".jgo") shortName := strings.TrimPrefix(tmplName, "template_") - var replace = func(data []byte, replaceThis string, withThis string) []byte { + replace := func(data []byte, replaceThis string, withThis string) []byte { return bytes.Replace(data, []byte(replaceThis), []byte(withThis), -1) } @@ -94,7 +94,7 @@ func (list SFileList) JSTmplInit() error { fmt.Println("new endBrace: ", endBrace) fmt.Println("data: ", string(data)) - /*var showPos = func(data []byte, index int) (out string) { + /*showPos := func(data []byte, index int) (out string) { out = "[" for j, char := range data { if index == j { @@ -107,9 +107,9 @@ func (list SFileList) JSTmplInit() error { }*/ // ? Can we just use a regex? I'm thinking of going more efficient, or just outright rolling wasm, this is a temp hack in a place where performance doesn't particularly matter - var each = func(phrase string, handle func(index int)) { + each := func(phrase string, handle func(index int)) { //fmt.Println("find each '" + phrase + "'") - var index = endBrace + index := endBrace if index < 0 { panic("index under zero: " + strconv.Itoa(index)) } diff --git a/common/ip_search.go b/common/ip_search.go index 4bb7d0ec..460367ef 100644 --- a/common/ip_search.go +++ b/common/ip_search.go @@ -3,7 +3,7 @@ package common import ( "database/sql" - "github.com/Azareal/Gosora/query_gen" + qgen "github.com/Azareal/Gosora/query_gen" ) var IPSearch IPSearcher @@ -30,7 +30,7 @@ func NewDefaultIPSearcher() (*DefaultIPSearcher, error) { }, acc.FirstError() } -func (searcher *DefaultIPSearcher) Lookup(ip string) (uids []int, err error) { +func (s *DefaultIPSearcher) Lookup(ip string) (uids []int, err error) { var uid int reqUserList := make(map[int]bool) runQuery := func(stmt *sql.Stmt) error { @@ -50,19 +50,19 @@ func (searcher *DefaultIPSearcher) Lookup(ip string) (uids []int, err error) { return rows.Err() } - err = runQuery(searcher.searchUsers) + err = runQuery(s.searchUsers) if err != nil { return uids, err } - err = runQuery(searcher.searchTopics) + err = runQuery(s.searchTopics) if err != nil { return uids, err } - err = runQuery(searcher.searchReplies) + err = runQuery(s.searchReplies) if err != nil { return uids, err } - err = runQuery(searcher.searchUsersReplies) + err = runQuery(s.searchUsersReplies) if err != nil { return uids, err } diff --git a/docs/installation.md b/docs/installation.md index 6e741503..6ca50afc 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -70,8 +70,12 @@ Type in a strong password for the `gosora` user, please oh please... Don't use " `chmod 2775 logs` +`chmod 2775 attachs` + `chmod 2775 uploads` +`chmod 2775 tmp` + `chmod 755 ./install-linux` `./install-linux` diff --git a/extend/adventure/lib/adventure.go b/extend/adventure/lib/adventure.go index 1a284f28..6193766b 100644 --- a/extend/adventure/lib/adventure.go +++ b/extend/adventure/lib/adventure.go @@ -10,6 +10,6 @@ type Adventure struct { } // TODO: Should we add a table interface? -func (adventure *Adventure) GetTable() string { +func (a *Adventure) GetTable() string { return "adventure" } diff --git a/routes/panel/logs.go b/routes/panel/logs.go index 91a2db7f..7b241cbd 100644 --- a/routes/panel/logs.go +++ b/routes/panel/logs.go @@ -34,7 +34,7 @@ func LogsRegs(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError pageList := c.Paginate(page, lastPage, 5) pi := c.PanelRegLogsPage{basePage, llist, c.Paginator{pageList, page, lastPage}} - return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage,"","","panel_reglogs", pi}) + return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage, "", "", "panel_reglogs", pi}) } // TODO: Log errors when something really screwy is going on? @@ -60,7 +60,7 @@ func topicElementTypeAction(action string, elementType string, elementID int, ac var tbit string aarr := strings.Split(action, "-") switch aarr[0] { - case "lock","unlock","stick","unstick": + case "lock", "unlock", "stick", "unstick": tbit = aarr[0] case "move": if len(aarr) == 2 { @@ -107,10 +107,9 @@ func LogsMod(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { return ferr } - logCount := c.ModLogs.Count() page, _ := strconv.Atoi(r.FormValue("page")) perPage := 12 - offset, page, lastPage := c.PageOffset(logCount, page, perPage) + offset, page, lastPage := c.PageOffset(c.ModLogs.Count(), page, perPage) logs, err := c.ModLogs.GetOffset(offset, perPage) if err != nil { @@ -125,7 +124,7 @@ func LogsMod(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { pageList := c.Paginate(page, lastPage, 5) pi := c.PanelLogsPage{basePage, llist, c.Paginator{pageList, page, lastPage}} - return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage,"","","panel_modlogs", pi}) + return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage, "", "", "panel_modlogs", pi}) } func LogsAdmin(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { @@ -134,10 +133,9 @@ func LogsAdmin(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError return ferr } - logCount := c.ModLogs.Count() page, _ := strconv.Atoi(r.FormValue("page")) perPage := 12 - offset, page, lastPage := c.PageOffset(logCount, page, perPage) + offset, page, lastPage := c.PageOffset(c.ModLogs.Count(), page, perPage) logs, err := c.AdminLogs.GetOffset(offset, perPage) if err != nil { @@ -152,5 +150,5 @@ func LogsAdmin(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError pageList := c.Paginate(page, lastPage, 5) pi := c.PanelLogsPage{basePage, llist, c.Paginator{pageList, page, lastPage}} - return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage,"","","panel_adminlogs", pi}) + return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage, "", "", "panel_adminlogs", pi}) } diff --git a/routes/panel/themes.go b/routes/panel/themes.go index de1a2327..4026d270 100644 --- a/routes/panel/themes.go +++ b/routes/panel/themes.go @@ -104,7 +104,6 @@ func ThemesMenusEdit(w http.ResponseWriter, r *http.Request, user c.User, smid s if err != nil { return c.LocalError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, user) } - menuHold, err := c.Menus.Get(mid) if err == sql.ErrNoRows { return c.NotFound(w, r, basePage.Header) @@ -149,7 +148,6 @@ func ThemesMenuItemEdit(w http.ResponseWriter, r *http.Request, user c.User, sit if err != nil { return c.LocalError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, user) } - menuItem, err := c.Menus.ItemStore().Get(itemID) if err == sql.ErrNoRows { return c.NotFound(w, r, basePage.Header) @@ -434,7 +432,6 @@ func ThemesWidgetsEditSubmit(w http.ResponseWriter, r *http.Request, user c.User // ThemesWidgetsCreateSubmit is an action which is triggered when someone sends a create request for a widget func ThemesWidgetsCreateSubmit(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { - //fmt.Println("in ThemesWidgetsCreateSubmit") js := r.PostFormValue("js") == "1" _, ferr := c.SimplePanelUserCheck(w, r, &user) if ferr != nil { diff --git a/templates/panel_backups.html b/templates/panel_backups.html index 07011881..ea557114 100644 --- a/templates/panel_backups.html +++ b/templates/panel_backups.html @@ -9,7 +9,5 @@ {{lang "panel_backups_download"}} - {{else}} -
{{lang "panel_backups_no_backups"}}
- {{end}} + {{else}}
{{lang "panel_backups_no_backups"}}
{{end}} \ No newline at end of file diff --git a/tmp/filler.txt b/tmp/filler.txt new file mode 100644 index 00000000..20e14b1e --- /dev/null +++ b/tmp/filler.txt @@ -0,0 +1 @@ +This file is here so that Git will include this folder in the repository. \ No newline at end of file