From 5073c783646c0e95d80654a4d604d440b6708f42 Mon Sep 17 00:00:00 2001 From: Azareal Date: Mon, 8 Jun 2020 21:31:45 +1000 Subject: [PATCH] text attachments for cosora and shadow reduce bytes and boilerplate --- routes/panel/users.go | 62 +++++++++++----------- routes/poll.go | 2 +- templates/panel_analytics_agent_views.html | 4 +- templates/panel_analytics_agents.html | 8 +-- templates/panel_analytics_forum_views.html | 4 +- templates/panel_analytics_forums.html | 8 +-- templates/panel_analytics_lang_views.html | 4 +- templates/panel_analytics_langs.html | 8 +-- themes/cosora/public/main.css | 7 +++ themes/shadow/public/main.css | 6 +++ 10 files changed, 63 insertions(+), 50 deletions(-) diff --git a/routes/panel/users.go b/routes/panel/users.go index 0fef1a7c..c14e26bc 100644 --- a/routes/panel/users.go +++ b/routes/panel/users.go @@ -8,8 +8,8 @@ import ( c "github.com/Azareal/Gosora/common" ) -func Users(w http.ResponseWriter, r *http.Request, user *c.User) c.RouteError { - basePage, ferr := buildBasePage(w, r, user, "users", "users") +func Users(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { + basePage, ferr := buildBasePage(w, r, u, "users", "users") if ferr != nil { return ferr } @@ -27,27 +27,27 @@ func Users(w http.ResponseWriter, r *http.Request, user *c.User) c.RouteError { return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage, "", "", "panel_users", &pi}) } -func UsersEdit(w http.ResponseWriter, r *http.Request, user *c.User, suid string) c.RouteError { - basePage, ferr := buildBasePage(w, r, user, "edit_user", "users") +func UsersEdit(w http.ResponseWriter, r *http.Request, u *c.User, suid string) c.RouteError { + basePage, ferr := buildBasePage(w, r, u, "edit_user", "users") if ferr != nil { return ferr } - if !user.Perms.EditUser { - return c.NoPermissions(w, r, user) + if !u.Perms.EditUser { + return c.NoPermissions(w, r, u) } uid, err := strconv.Atoi(suid) if err != nil { - return c.LocalError("The provided UserID is not a valid number.", w, r, user) + return c.LocalError("The provided UserID is not a valid number.", w, r, u) } targetUser, err := c.Users.Get(uid) if err == sql.ErrNoRows { - return c.LocalError("The user you're trying to edit doesn't exist.", w, r, user) + return c.LocalError("The user you're trying to edit doesn't exist.", w, r, u) } else if err != nil { return c.InternalError(err, w, r) } - if targetUser.IsAdmin && !user.IsAdmin { - return c.LocalError("Only administrators can edit the account of an administrator.", w, r, user) + if targetUser.IsAdmin && !u.IsAdmin { + return c.LocalError("Only administrators can edit the account of an administrator.", w, r, u) } // ? - Should we stop admins from deleting all the groups? Maybe, protect the group they're currently using? @@ -58,10 +58,10 @@ func UsersEdit(w http.ResponseWriter, r *http.Request, user *c.User, suid string var groupList []*c.Group for _, group := range groups { - if !user.Perms.EditUserGroupAdmin && group.IsAdmin { + if !u.Perms.EditUserGroupAdmin && group.IsAdmin { continue } - if !user.Perms.EditUserGroupSuperMod && group.IsMod { + if !u.Perms.EditUserGroupSuperMod && group.IsMod { continue } groupList = append(groupList, group) @@ -183,31 +183,31 @@ func UsersEditSubmit(w http.ResponseWriter, r *http.Request, user *c.User, suid return nil } -func UsersAvatarSubmit(w http.ResponseWriter, r *http.Request, user *c.User, suid string) c.RouteError { - _, ferr := c.SimplePanelUserCheck(w, r, user) +func UsersAvatarSubmit(w http.ResponseWriter, r *http.Request, u *c.User, suid string) c.RouteError { + _, ferr := c.SimplePanelUserCheck(w, r, u) if ferr != nil { return ferr } // TODO: Check the UploadAvatars permission too? - if !user.Perms.EditUser { - return c.NoPermissions(w, r, user) + if !u.Perms.EditUser { + return c.NoPermissions(w, r, u) } uid, err := strconv.Atoi(suid) if err != nil { - return c.LocalError("The provided UserID is not a valid number.", w, r, user) + return c.LocalError("The provided UserID is not a valid number.", w, r, u) } targetUser, err := c.Users.Get(uid) if err == sql.ErrNoRows { - return c.LocalError("The user you're trying to edit doesn't exist.", w, r, user) + return c.LocalError("The user you're trying to edit doesn't exist.", w, r, u) } else if err != nil { return c.InternalError(err, w, r) } - if targetUser.IsAdmin && !user.IsAdmin { - return c.LocalError("Only administrators can edit the account of other administrators.", w, r, user) + if targetUser.IsAdmin && !u.IsAdmin { + return c.LocalError("Only administrators can edit the account of other administrators.", w, r, u) } - ext, ferr := c.UploadAvatar(w, r, user, targetUser.ID) + ext, ferr := c.UploadAvatar(w, r, u, targetUser.ID) if ferr != nil { return ferr } @@ -221,7 +221,7 @@ func UsersAvatarSubmit(w http.ResponseWriter, r *http.Request, user *c.User, sui return c.InternalError(err, w, r) } - err = c.AdminLogs.Create("edit", targetUser.ID, "user", user.GetIP(), user.ID) + err = c.AdminLogs.Create("edit", targetUser.ID, "user", u.GetIP(), u.ID) if err != nil { return c.InternalError(err, w, r) } @@ -234,34 +234,34 @@ func UsersAvatarSubmit(w http.ResponseWriter, r *http.Request, user *c.User, sui return nil } -func UsersAvatarRemoveSubmit(w http.ResponseWriter, r *http.Request, user *c.User, suid string) c.RouteError { - _, ferr := c.SimplePanelUserCheck(w, r, user) +func UsersAvatarRemoveSubmit(w http.ResponseWriter, r *http.Request, u *c.User, suid string) c.RouteError { + _, ferr := c.SimplePanelUserCheck(w, r, u) if ferr != nil { return ferr } - if !user.Perms.EditUser { - return c.NoPermissions(w, r, user) + if !u.Perms.EditUser { + return c.NoPermissions(w, r, u) } uid, err := strconv.Atoi(suid) if err != nil { - return c.LocalError("The provided UserID is not a valid number.", w, r, user) + return c.LocalError("The provided UserID is not a valid number.", w, r, u) } targetUser, err := c.Users.Get(uid) if err == sql.ErrNoRows { - return c.LocalError("The user you're trying to edit doesn't exist.", w, r, user) + return c.LocalError("The user you're trying to edit doesn't exist.", w, r, u) } else if err != nil { return c.InternalError(err, w, r) } - if targetUser.IsAdmin && !user.IsAdmin { - return c.LocalError("Only administrators can edit the account of other administrators.", w, r, user) + if targetUser.IsAdmin && !u.IsAdmin { + return c.LocalError("Only administrators can edit the account of other administrators.", w, r, u) } ferr = c.ChangeAvatar("", w, r, targetUser) if ferr != nil { return ferr } - err = c.AdminLogs.Create("edit", targetUser.ID, "user", user.GetIP(), user.ID) + err = c.AdminLogs.Create("edit", targetUser.ID, "user", u.GetIP(), u.ID) if err != nil { return c.InternalError(err, w, r) } diff --git a/routes/poll.go b/routes/poll.go index 7e919b07..1950c5ba 100644 --- a/routes/poll.go +++ b/routes/poll.go @@ -86,8 +86,8 @@ func PollResults(w http.ResponseWriter, r *http.Request, user *c.User, sPollID s defer rows.Close() optionList := "" + var votes int for rows.Next() { - var votes int err := rows.Scan(&votes) if err != nil { return c.InternalError(err, w, r) diff --git a/templates/panel_analytics_agent_views.html b/templates/panel_analytics_agent_views.html index 585f97b0..1fc84a05 100644 --- a/templates/panel_analytics_agent_views.html +++ b/templates/panel_analytics_agent_views.html @@ -4,8 +4,8 @@ {{template "panel_analytics_time_range.html" . }} -
-
+
+
{{template "panel_analytics_script.html" . }} \ No newline at end of file diff --git a/templates/panel_analytics_agents.html b/templates/panel_analytics_agents.html index 52644e73..e5192a2c 100644 --- a/templates/panel_analytics_agents.html +++ b/templates/panel_analytics_agents.html @@ -4,14 +4,14 @@ {{template "panel_analytics_time_range.html" . }}
-
-
+
+
-
+
{{range .ItemList}}
- {{.FriendlyAgent}} + {{.FriendlyAgent}} {{.Count}}{{lang "panel_stats_views_suffix"}}
{{else}}
{{lang "panel_stats_user_agents_no_user_agents"}}
{{end}} diff --git a/templates/panel_analytics_forum_views.html b/templates/panel_analytics_forum_views.html index e347549d..d28f42c7 100644 --- a/templates/panel_analytics_forum_views.html +++ b/templates/panel_analytics_forum_views.html @@ -4,8 +4,8 @@ {{template "panel_analytics_time_range.html" . }}
-
-
+
+
{{template "panel_analytics_script.html" . }} \ No newline at end of file diff --git a/templates/panel_analytics_forums.html b/templates/panel_analytics_forums.html index 7ae1f00e..cd0f3354 100644 --- a/templates/panel_analytics_forums.html +++ b/templates/panel_analytics_forums.html @@ -4,14 +4,14 @@ {{template "panel_analytics_time_range.html" . }}
-
-
+
+
-
+
{{range .ItemList}}
- {{.FriendlyAgent}} + {{.FriendlyAgent}} {{.Count}}{{lang "panel_stats_views_suffix"}}
{{else}}
{{lang "panel_stats_forums_no_forums"}}
{{end}} diff --git a/templates/panel_analytics_lang_views.html b/templates/panel_analytics_lang_views.html index b3457e35..98f27336 100644 --- a/templates/panel_analytics_lang_views.html +++ b/templates/panel_analytics_lang_views.html @@ -4,8 +4,8 @@ {{template "panel_analytics_time_range.html" . }}
-
-
+
+
{{template "panel_analytics_script.html" . }} \ No newline at end of file diff --git a/templates/panel_analytics_langs.html b/templates/panel_analytics_langs.html index 09ff0990..4c5db37f 100644 --- a/templates/panel_analytics_langs.html +++ b/templates/panel_analytics_langs.html @@ -4,14 +4,14 @@ {{template "panel_analytics_time_range.html" . }}
-
-
+
+
-
+
{{range .ItemList}}
- {{.FriendlyAgent}} + {{.FriendlyAgent}} {{.Count}}{{lang "panel_stats_views_suffix"}}
{{else}}
{{lang "panel_stats_languages_no_languages"}}
{{end}} diff --git a/themes/cosora/public/main.css b/themes/cosora/public/main.css index 072184c8..7d643ca3 100644 --- a/themes/cosora/public/main.css +++ b/themes/cosora/public/main.css @@ -1266,6 +1266,13 @@ red { .hide_spoil img { content: " "; } +.attach_box { + background-color: #5a5555; + background-color: #EFEEEE; + border-radius: 3px; + padding: 16px; + white-space: nowrap; +} #ip_search_container .rowlist:not(.has_items) { display: block; diff --git a/themes/shadow/public/main.css b/themes/shadow/public/main.css index 627ab842..8344a64c 100644 --- a/themes/shadow/public/main.css +++ b/themes/shadow/public/main.css @@ -377,6 +377,12 @@ red { .hide_spoil img { content: " "; } +.attach_box { + background-color: #5a5555; + background-color: rgb(71,71,76); + border-radius: 3px; + padding: 16px; +} .formrow.real_first_child, .formrow:first-child { margin-top: 8px;