Cosora shouldn't warp on large screens now. Control Panel looks a little off over a thousand now, this is going to be fixed in the following commit.

Added the poll column to the replies table.
Renamed *Reply.SetBody() to *Reply.SetPost()
Moved routeAccountEditCritical into /routes/account.go
This commit is contained in:
Azareal 2018-01-23 10:48:44 +00:00
parent a7fec11170
commit 1959741c00
12 changed files with 92 additions and 32 deletions

View File

@ -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)
}

28
common/thumbnailer.go Normal file
View File

@ -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 {
}
*/

View File

@ -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 {

View File

@ -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 {

View File

@ -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"},

View File

@ -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"),

29
routes/account.go Normal file
View File

@ -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
}

View File

@ -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 {

View File

@ -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])
);

View File

@ -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;

View File

@ -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`)
);

View File

@ -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;