diff --git a/common/reply.go b/common/reply.go index 55229c65..9c96f8b3 100644 --- a/common/reply.go +++ b/common/reply.go @@ -76,7 +76,7 @@ func init() { replyStmts = ReplyStmts{ isLiked: acc.Select("likes").Columns("targetItem").Where("sentBy = ? and targetItem = ? and targetType = 'replies'").Prepare(), createLike: acc.Insert("likes").Columns("weight, targetItem, targetType, sentBy").Fields("?,?,?,?").Prepare(), - edit: acc.Update("replies").Set("content = ?, parsed_content = ?").Where("rid = ?").Prepare(), + edit: acc.Update("replies").Set("content = ?, parsed_content = ?, poll = ?").Where("rid = ?").Prepare(), delete: acc.Delete("replies").Where("rid = ?").Prepare(), addLikesToReply: acc.Update("replies").Set("likeCount = likeCount + ?").Where("rid = ?").Prepare(), removeRepliesFromTopic: acc.Update("topics").Set("postCount = postCount - ?").Where("tid = ?").Prepare(), @@ -120,17 +120,21 @@ func (reply *Reply) Delete() error { return err } -func (reply *Reply) SetBody(content string) error { +func (reply *Reply) SetPost(content string) error { topic, err := reply.Topic() if err != nil { return err } content = PreparseMessage(html.UnescapeString(content)) parsedContent := ParseMessage(content, topic.ParentID, "forums") - _, err = replyStmts.edit.Exec(content, parsedContent, reply.ID) + _, err = replyStmts.edit.Exec(content, parsedContent, 0, reply.ID) return err } +func (reply *Reply) SetPoll(content string) error { + return nil +} + func (reply *Reply) Topic() (*Topic, error) { return Topics.Get(reply.ParentID) } diff --git a/common/thumbnailer.go b/common/thumbnailer.go new file mode 100644 index 00000000..1f9081fb --- /dev/null +++ b/common/thumbnailer.go @@ -0,0 +1,28 @@ +package common + +var Thumbnailer ThumbnailerInt + +type ThumbnailerInt interface { +} + +type RezThumbnailer struct { +} + +func (thumb *RezThumbnailer) Resize(path string, width int) error { + // TODO: Sniff the aspect ratio of the image and calculate the dest height accordingly, bug make sure it isn't excessively high + return nil +} + +func (thumb *RezThumbnailer) resize(path string, width int, height int) error { + return nil +} + +/* +type LilliputThumbnailer struct { + +} + +type ResizeThumbnailer struct { + +} +*/ diff --git a/gen_router.go b/gen_router.go index f889e4f9..6bf39bbe 100644 --- a/gen_router.go +++ b/gen_router.go @@ -70,7 +70,7 @@ var RouteMap = map[string]interface{}{ "routePanelLogsMod": routePanelLogsMod, "routePanelDebug": routePanelDebug, "routePanelDashboard": routePanelDashboard, - "routeAccountEditCritical": routeAccountEditCritical, + "routes.AccountEditCritical": routes.AccountEditCritical, "routeAccountEditCriticalSubmit": routeAccountEditCriticalSubmit, "routeAccountEditAvatar": routeAccountEditAvatar, "routeAccountEditAvatarSubmit": routeAccountEditAvatarSubmit, @@ -165,7 +165,7 @@ var routeMapEnum = map[string]int{ "routePanelLogsMod": 51, "routePanelDebug": 52, "routePanelDashboard": 53, - "routeAccountEditCritical": 54, + "routes.AccountEditCritical": 54, "routeAccountEditCriticalSubmit": 55, "routeAccountEditAvatar": 56, "routeAccountEditAvatarSubmit": 57, @@ -258,7 +258,7 @@ var reverseRouteMapEnum = map[int]string{ 51: "routePanelLogsMod", 52: "routePanelDebug", 53: "routePanelDashboard", - 54: "routeAccountEditCritical", + 54: "routes.AccountEditCritical", 55: "routeAccountEditCriticalSubmit", 56: "routeAccountEditAvatar", 57: "routeAccountEditAvatarSubmit", @@ -966,7 +966,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { } common.RouteViewCounter.Bump(54) - err = routeAccountEditCritical(w,req,user) + err = routes.AccountEditCritical(w,req,user) case "/user/edit/critical/submit/": err = common.NoSessionMismatch(w,req,user) if err != nil { diff --git a/member_routes.go b/member_routes.go index 285c1b9e..8b1f8271 100644 --- a/member_routes.go +++ b/member_routes.go @@ -394,25 +394,6 @@ func routeReportSubmit(w http.ResponseWriter, r *http.Request, user common.User, return nil } -func routeAccountEditCritical(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, ferr := common.UserCheck(w, r, &user) - if ferr != nil { - return ferr - } - - pi := common.Page{"Edit Password", user, headerVars, tList, nil} - if common.PreRenderHooks["pre_render_account_own_edit_critical"] != nil { - if common.RunPreRenderHook("pre_render_account_own_edit_critical", w, r, &user, &pi) { - return nil - } - } - err := common.Templates.ExecuteTemplate(w, "account_own_edit.html", pi) - if err != nil { - return common.InternalError(err, w, r) - } - return nil -} - func routeAccountEditCriticalSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { headerVars, ferr := common.UserCheck(w, r, &user) if ferr != nil { diff --git a/query_gen/tables.go b/query_gen/tables.go index 487f0511..de308434 100644 --- a/query_gen/tables.go +++ b/query_gen/tables.go @@ -171,8 +171,8 @@ func createTables(adapter qgen.Adapter) error { qgen.Install.CreateTable("replies", "utf8mb4", "utf8mb4_general_ci", []qgen.DBTableColumn{ - qgen.DBTableColumn{"rid", "int", 0, false, true, ""}, - qgen.DBTableColumn{"tid", "int", 0, false, false, ""}, + qgen.DBTableColumn{"rid", "int", 0, false, true, ""}, // TODO: Rename to replyID? + qgen.DBTableColumn{"tid", "int", 0, false, false, ""}, // TODO: Rename to topicID? qgen.DBTableColumn{"content", "text", 0, false, false, ""}, qgen.DBTableColumn{"parsed_content", "text", 0, false, false, ""}, qgen.DBTableColumn{"createdAt", "createdAt", 0, false, false, ""}, @@ -184,6 +184,7 @@ func createTables(adapter qgen.Adapter) error { qgen.DBTableColumn{"likeCount", "int", 0, false, false, "0"}, qgen.DBTableColumn{"words", "int", 0, false, false, "1"}, // ? - replies has a default of 1 and topics has 0? why? qgen.DBTableColumn{"actionType", "varchar", 20, false, false, "''"}, + qgen.DBTableColumn{"poll", "boolean", 0, false, false, "0"}, }, []qgen.DBTableKey{ qgen.DBTableKey{"rid", "primary"}, diff --git a/router_gen/routes.go b/router_gen/routes.go index 4dbde9da..a0723778 100644 --- a/router_gen/routes.go +++ b/router_gen/routes.go @@ -39,7 +39,7 @@ func buildUserRoutes() { userGroup := newRouteGroup("/user/") userGroup.Routes( View("routeProfile", "/user/").LitBefore("req.URL.Path += extraData"), - MemberView("routeAccountEditCritical", "/user/edit/critical/"), + MemberView("routes.AccountEditCritical", "/user/edit/critical/"), Action("routeAccountEditCriticalSubmit", "/user/edit/critical/submit/"), // TODO: Full test this MemberView("routeAccountEditAvatar", "/user/edit/avatar/"), UploadAction("routeAccountEditAvatarSubmit", "/user/edit/avatar/submit/").MaxSizeVar("common.Config.MaxRequestSize"), diff --git a/routes/account.go b/routes/account.go new file mode 100644 index 00000000..ad65ca64 --- /dev/null +++ b/routes/account.go @@ -0,0 +1,29 @@ +package routes + +import ( + "net/http" + + "../common" +) + +// A blank list to fill out that parameter in Page for routes which don't use it +var tList []interface{} + +func AccountEditCritical(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { + headerVars, ferr := common.UserCheck(w, r, &user) + if ferr != nil { + return ferr + } + + pi := common.Page{"Edit Password", user, headerVars, tList, nil} + if common.PreRenderHooks["pre_render_account_own_edit_critical"] != nil { + if common.RunPreRenderHook("pre_render_account_own_edit_critical", w, r, &user, &pi) { + return nil + } + } + err := common.Templates.ExecuteTemplate(w, "account_own_edit.html", pi) + if err != nil { + return common.InternalError(err, w, r) + } + return nil +} diff --git a/routes/reply.go b/routes/reply.go index 30c05627..3f048952 100644 --- a/routes/reply.go +++ b/routes/reply.go @@ -41,7 +41,7 @@ func ReplyEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, s return common.NoPermissionsJSQ(w, r, user, isJs) } - err = reply.SetBody(r.PostFormValue("edit_item")) + err = reply.SetPost(r.PostFormValue("edit_item")) if err == sql.ErrNoRows { return common.PreErrorJSQ("The parent topic doesn't exist.", w, r, isJs) } else if err != nil { diff --git a/schema/mssql/query_replies.sql b/schema/mssql/query_replies.sql index be3f6c8d..484c549f 100644 --- a/schema/mssql/query_replies.sql +++ b/schema/mssql/query_replies.sql @@ -12,5 +12,6 @@ CREATE TABLE [replies] ( [likeCount] int DEFAULT 0 not null, [words] int DEFAULT 1 not null, [actionType] nvarchar (20) DEFAULT '' not null, + [poll] bit DEFAULT 0 not null, primary key([rid]) ); \ No newline at end of file diff --git a/schema/mysql/query_replies.sql b/schema/mysql/query_replies.sql index 83ece34b..5e16708d 100644 --- a/schema/mysql/query_replies.sql +++ b/schema/mysql/query_replies.sql @@ -12,5 +12,6 @@ CREATE TABLE `replies` ( `likeCount` int DEFAULT 0 not null, `words` int DEFAULT 1 not null, `actionType` varchar(20) DEFAULT '' not null, + `poll` boolean DEFAULT 0 not null, primary key(`rid`) ) CHARSET=utf8mb4 COLLATE utf8mb4_general_ci; \ No newline at end of file diff --git a/schema/pgsql/query_replies.sql b/schema/pgsql/query_replies.sql index cba5c316..a127a868 100644 --- a/schema/pgsql/query_replies.sql +++ b/schema/pgsql/query_replies.sql @@ -12,5 +12,6 @@ CREATE TABLE `replies` ( `likeCount` int DEFAULT 0 not null, `words` int DEFAULT 1 not null, `actionType` varchar (20) DEFAULT '' not null, + `poll` boolean DEFAULT 0 not null, primary key(`rid`) ); \ No newline at end of file diff --git a/themes/cosora/public/main.css b/themes/cosora/public/main.css index 06f507f1..2f74db7b 100644 --- a/themes/cosora/public/main.css +++ b/themes/cosora/public/main.css @@ -42,12 +42,12 @@ a { color: var(--primary-link-color); } -body, #back { +body, #main { background-color: var(--tinted-background-color); } #back { padding: 8px; - padding-top: 14px; + padding-top: 0px; display: flex; padding-left: 0px; padding-right: 0px; @@ -59,6 +59,7 @@ body, #back { #main { width: 100%; + padding-top: 14px; padding-left: 8px; padding-right: 8px; } @@ -1327,6 +1328,19 @@ textarea { content: "\f27b"; } +@media(min-width: 1000px) { + #main { + max-width: 1000px; + margin-left: auto; + margin-right: auto; + border-left: 1px solid hsl(20,0%,95%); + border-right: 1px solid hsl(20,0%,95%); + } + #back { + background-color: hsl(0,0%,95%); + } +} + @media(min-width: 721px) { .hide_on_big { display: none;