Refactored the query generator subfunctions.
Refactored more prebuilder queries to use the OO methods. Refactored the router generator. Added more query generator OO methods. More work on Cosora.
This commit is contained in:
parent
f1c418bd13
commit
8ec0534299
|
@ -3,6 +3,7 @@ package qgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Accumulator struct {
|
type Accumulator struct {
|
||||||
|
@ -42,6 +43,7 @@ func (build *Accumulator) recordError(err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (build *Accumulator) prepare(res string, err error) *sql.Stmt {
|
func (build *Accumulator) prepare(res string, err error) *sql.Stmt {
|
||||||
|
log.Print("res: ", res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
build.recordError(err)
|
build.recordError(err)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1076,6 +1076,16 @@ func (adapter *MssqlAdapter) Insert(nlist ...string) *insertPrebuilder {
|
||||||
return &insertPrebuilder{name, "", "", "", adapter}
|
return &insertPrebuilder{name, "", "", "", adapter}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (adapter *MssqlAdapter) Update(nlist ...string) *updatePrebuilder {
|
||||||
|
name := optString(nlist, "_builder")
|
||||||
|
return &updatePrebuilder{name, "", "", "", adapter}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (adapter *MssqlAdapter) Delete(nlist ...string) *deletePrebuilder {
|
||||||
|
name := optString(nlist, "_builder")
|
||||||
|
return &deletePrebuilder{name, "", "", adapter}
|
||||||
|
}
|
||||||
|
|
||||||
func (adapter *MssqlAdapter) Write() error {
|
func (adapter *MssqlAdapter) Write() error {
|
||||||
var stmts, body string
|
var stmts, body string
|
||||||
for _, name := range adapter.BufferOrder {
|
for _, name := range adapter.BufferOrder {
|
||||||
|
|
|
@ -562,6 +562,16 @@ func (adapter *MysqlAdapter) Insert(nlist ...string) *insertPrebuilder {
|
||||||
return &insertPrebuilder{name, "", "", "", adapter}
|
return &insertPrebuilder{name, "", "", "", adapter}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (adapter *MysqlAdapter) Update(nlist ...string) *updatePrebuilder {
|
||||||
|
name := optString(nlist, "_builder")
|
||||||
|
return &updatePrebuilder{name, "", "", "", adapter}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (adapter *MysqlAdapter) Delete(nlist ...string) *deletePrebuilder {
|
||||||
|
name := optString(nlist, "_builder")
|
||||||
|
return &deletePrebuilder{name, "", "", adapter}
|
||||||
|
}
|
||||||
|
|
||||||
func (adapter *MysqlAdapter) Write() error {
|
func (adapter *MysqlAdapter) Write() error {
|
||||||
var stmts, body string
|
var stmts, body string
|
||||||
for _, name := range adapter.BufferOrder {
|
for _, name := range adapter.BufferOrder {
|
||||||
|
|
|
@ -328,6 +328,16 @@ func (adapter *PgsqlAdapter) Insert(nlist ...string) *insertPrebuilder {
|
||||||
return &insertPrebuilder{name, "", "", "", adapter}
|
return &insertPrebuilder{name, "", "", "", adapter}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (adapter *PgsqlAdapter) Update(nlist ...string) *updatePrebuilder {
|
||||||
|
name := optString(nlist, "_builder")
|
||||||
|
return &updatePrebuilder{name, "", "", "", adapter}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (adapter *PgsqlAdapter) Delete(nlist ...string) *deletePrebuilder {
|
||||||
|
name := optString(nlist, "_builder")
|
||||||
|
return &deletePrebuilder{name, "", "", adapter}
|
||||||
|
}
|
||||||
|
|
||||||
func (adapter *PgsqlAdapter) Write() error {
|
func (adapter *PgsqlAdapter) Write() error {
|
||||||
var stmts, body string
|
var stmts, body string
|
||||||
for _, name := range adapter.BufferOrder {
|
for _, name := range adapter.BufferOrder {
|
||||||
|
|
|
@ -118,6 +118,9 @@ type Adapter interface {
|
||||||
|
|
||||||
Select(name ...string) *selectPrebuilder
|
Select(name ...string) *selectPrebuilder
|
||||||
Insert(name ...string) *insertPrebuilder
|
Insert(name ...string) *insertPrebuilder
|
||||||
|
Update(name ...string) *updatePrebuilder
|
||||||
|
Delete(name ...string) *deletePrebuilder
|
||||||
|
|
||||||
Write() error
|
Write() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,46 @@ func processJoiner(joinstr string) (joiner []DBJoiner) {
|
||||||
return joiner
|
return joiner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseNumber(tmpWhere *DBWhere, segment string, i int) int {
|
||||||
|
var buffer string
|
||||||
|
for ; i < len(segment); i++ {
|
||||||
|
char := segment[i]
|
||||||
|
if '0' <= char && char <= '9' {
|
||||||
|
buffer += string(char)
|
||||||
|
} else {
|
||||||
|
i--
|
||||||
|
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{buffer, "number"})
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseColumn(tmpWhere *DBWhere, segment string, i int) int {
|
||||||
|
var buffer string
|
||||||
|
for ; i < len(segment); i++ {
|
||||||
|
char := segment[i]
|
||||||
|
if ('a' <= char && char <= 'z') || ('A' <= char && char <= 'Z') || char == '.' || char == '_' {
|
||||||
|
buffer += string(char)
|
||||||
|
} else if char == '(' {
|
||||||
|
return parseFunction(tmpWhere, segment, buffer, i)
|
||||||
|
} else {
|
||||||
|
i--
|
||||||
|
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{buffer, "column"})
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseFunction(tmpWhere *DBWhere, segment string, buffer string, i int) int {
|
||||||
|
var preI = i
|
||||||
|
i = skipFunctionCall(segment, i-1)
|
||||||
|
buffer += segment[preI:i] + string(segment[i])
|
||||||
|
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{buffer, "function"})
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
func processWhere(wherestr string) (where []DBWhere) {
|
func processWhere(wherestr string) (where []DBWhere) {
|
||||||
if wherestr == "" {
|
if wherestr == "" {
|
||||||
return where
|
return where
|
||||||
|
@ -102,20 +142,16 @@ func processWhere(wherestr string) (where []DBWhere) {
|
||||||
var buffer string
|
var buffer string
|
||||||
var optype int // 0: None, 1: Number, 2: Column, 3: Function, 4: String, 5: Operator
|
var optype int // 0: None, 1: Number, 2: Column, 3: Function, 4: String, 5: Operator
|
||||||
for _, segment := range strings.Split(wherestr, " AND ") {
|
for _, segment := range strings.Split(wherestr, " AND ") {
|
||||||
var tmpWhere DBWhere
|
var tmpWhere = &DBWhere{[]DBToken{}}
|
||||||
segment += ")"
|
segment += ")"
|
||||||
for i := 0; i < len(segment); i++ {
|
for i := 0; i < len(segment); i++ {
|
||||||
char := segment[i]
|
char := segment[i]
|
||||||
//fmt.Println("optype", optype)
|
|
||||||
switch optype {
|
switch optype {
|
||||||
case 0: // unknown
|
case 0: // unknown
|
||||||
//fmt.Println("case 0:", char, string(char))
|
|
||||||
if '0' <= char && char <= '9' {
|
if '0' <= char && char <= '9' {
|
||||||
optype = 1
|
i = parseNumber(tmpWhere, segment, i)
|
||||||
buffer = string(char)
|
|
||||||
} else if ('a' <= char && char <= 'z') || ('A' <= char && char <= 'Z') || char == '_' {
|
} else if ('a' <= char && char <= 'z') || ('A' <= char && char <= 'Z') || char == '_' {
|
||||||
optype = 2
|
i = parseColumn(tmpWhere, segment, i)
|
||||||
buffer = string(char)
|
|
||||||
} else if char == '\'' {
|
} else if char == '\'' {
|
||||||
optype = 4
|
optype = 4
|
||||||
buffer = ""
|
buffer = ""
|
||||||
|
@ -123,51 +159,13 @@ func processWhere(wherestr string) (where []DBWhere) {
|
||||||
optype = 5
|
optype = 5
|
||||||
buffer = string(char)
|
buffer = string(char)
|
||||||
} else if char == '?' {
|
} else if char == '?' {
|
||||||
//fmt.Println("Expr:","?")
|
|
||||||
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{"?", "substitute"})
|
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{"?", "substitute"})
|
||||||
}
|
}
|
||||||
case 1: // number
|
|
||||||
if '0' <= char && char <= '9' {
|
|
||||||
buffer += string(char)
|
|
||||||
} else {
|
|
||||||
optype = 0
|
|
||||||
i--
|
|
||||||
//fmt.Println("Expr:",buffer)
|
|
||||||
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{buffer, "number"})
|
|
||||||
}
|
|
||||||
case 2: // column
|
|
||||||
if ('a' <= char && char <= 'z') || ('A' <= char && char <= 'Z') || char == '.' || char == '_' {
|
|
||||||
buffer += string(char)
|
|
||||||
} else if char == '(' {
|
|
||||||
optype = 3
|
|
||||||
i--
|
|
||||||
} else {
|
|
||||||
optype = 0
|
|
||||||
i--
|
|
||||||
//fmt.Println("Expr:", buffer)
|
|
||||||
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{buffer, "column"})
|
|
||||||
}
|
|
||||||
case 3: // function
|
|
||||||
var preI = i
|
|
||||||
//fmt.Println("buffer", buffer)
|
|
||||||
//fmt.Println("len(halves)", len(halves[1]))
|
|
||||||
//fmt.Println("preI", string(halves[1][preI]))
|
|
||||||
//fmt.Println("msg prior to preI", halves[1][0:preI])
|
|
||||||
i = skipFunctionCall(segment, i-1)
|
|
||||||
//fmt.Println("i",i)
|
|
||||||
//fmt.Println("msg prior to i-1", halves[1][0:i-1])
|
|
||||||
//fmt.Println("string(i-1)", string(halves[1][i-1]))
|
|
||||||
//fmt.Println("string(i)", string(halves[1][i]))
|
|
||||||
buffer += segment[preI:i] + string(segment[i])
|
|
||||||
//fmt.Println("Expr:",buffer)
|
|
||||||
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{buffer, "function"})
|
|
||||||
optype = 0
|
|
||||||
case 4: // string
|
case 4: // string
|
||||||
if char != '\'' {
|
if char != '\'' {
|
||||||
buffer += string(char)
|
buffer += string(char)
|
||||||
} else {
|
} else {
|
||||||
optype = 0
|
optype = 0
|
||||||
//fmt.Println("Expr:",buffer)
|
|
||||||
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{buffer, "string"})
|
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{buffer, "string"})
|
||||||
}
|
}
|
||||||
case 5: // operator
|
case 5: // operator
|
||||||
|
@ -176,14 +174,13 @@ func processWhere(wherestr string) (where []DBWhere) {
|
||||||
} else {
|
} else {
|
||||||
optype = 0
|
optype = 0
|
||||||
i--
|
i--
|
||||||
//fmt.Println("Expr:",buffer)
|
|
||||||
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{buffer, "operator"})
|
tmpWhere.Expr = append(tmpWhere.Expr, DBToken{buffer, "operator"})
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
panic("Bad optype in processWhere")
|
panic("Bad optype in processWhere")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
where = append(where, tmpWhere)
|
where = append(where, *tmpWhere)
|
||||||
}
|
}
|
||||||
return where
|
return where
|
||||||
}
|
}
|
||||||
|
@ -222,13 +219,14 @@ func processSet(setstr string) (setter []DBSetter) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tmpSetter.Column = strings.TrimSpace(halves[0])
|
tmpSetter.Column = strings.TrimSpace(halves[0])
|
||||||
|
segment := halves[1] + ")"
|
||||||
|
|
||||||
halves[1] += ")"
|
|
||||||
var optype int // 0: None, 1: Number, 2: Column, 3: Function, 4: String, 5: Operator
|
var optype int // 0: None, 1: Number, 2: Column, 3: Function, 4: String, 5: Operator
|
||||||
//fmt.Println("halves[1]",halves[1])
|
//fmt.Println("segment", segment)
|
||||||
for i := 0; i < len(halves[1]); i++ {
|
for i := 0; i < len(segment); i++ {
|
||||||
char := halves[1][i]
|
char := segment[i]
|
||||||
//fmt.Println("optype",optype)
|
//fmt.Println("optype",optype)
|
||||||
|
//fmt.Println("Expr:",buffer)
|
||||||
switch optype {
|
switch optype {
|
||||||
case 0: // unknown
|
case 0: // unknown
|
||||||
if '0' <= char && char <= '9' {
|
if '0' <= char && char <= '9' {
|
||||||
|
@ -244,7 +242,6 @@ func processSet(setstr string) (setter []DBSetter) {
|
||||||
optype = 5
|
optype = 5
|
||||||
buffer = string(char)
|
buffer = string(char)
|
||||||
} else if char == '?' {
|
} else if char == '?' {
|
||||||
//fmt.Println("Expr:","?")
|
|
||||||
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{"?", "substitute"})
|
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{"?", "substitute"})
|
||||||
}
|
}
|
||||||
case 1: // number
|
case 1: // number
|
||||||
|
@ -253,7 +250,6 @@ func processSet(setstr string) (setter []DBSetter) {
|
||||||
} else {
|
} else {
|
||||||
optype = 0
|
optype = 0
|
||||||
i--
|
i--
|
||||||
//fmt.Println("Expr:",buffer)
|
|
||||||
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{buffer, "number"})
|
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{buffer, "number"})
|
||||||
}
|
}
|
||||||
case 2: // column
|
case 2: // column
|
||||||
|
@ -265,22 +261,12 @@ func processSet(setstr string) (setter []DBSetter) {
|
||||||
} else {
|
} else {
|
||||||
optype = 0
|
optype = 0
|
||||||
i--
|
i--
|
||||||
//fmt.Println("Expr:",buffer)
|
|
||||||
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{buffer, "column"})
|
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{buffer, "column"})
|
||||||
}
|
}
|
||||||
case 3: // function
|
case 3: // function
|
||||||
var preI = i
|
var preI = i
|
||||||
//fmt.Println("buffer",buffer)
|
i = skipFunctionCall(segment, i-1)
|
||||||
//fmt.Println("len(halves)",len(halves[1]))
|
buffer += segment[preI:i] + string(segment[i])
|
||||||
//fmt.Println("preI",string(halves[1][preI]))
|
|
||||||
//fmt.Println("msg prior to preI",halves[1][0:preI])
|
|
||||||
i = skipFunctionCall(halves[1], i-1)
|
|
||||||
//fmt.Println("i",i)
|
|
||||||
//fmt.Println("msg prior to i-1",halves[1][0:i-1])
|
|
||||||
//fmt.Println("string(i-1)",string(halves[1][i-1]))
|
|
||||||
//fmt.Println("string(i)",string(halves[1][i]))
|
|
||||||
buffer += halves[1][preI:i] + string(halves[1][i])
|
|
||||||
//fmt.Println("Expr:",buffer)
|
|
||||||
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{buffer, "function"})
|
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{buffer, "function"})
|
||||||
optype = 0
|
optype = 0
|
||||||
case 4: // string
|
case 4: // string
|
||||||
|
@ -288,7 +274,6 @@ func processSet(setstr string) (setter []DBSetter) {
|
||||||
buffer += string(char)
|
buffer += string(char)
|
||||||
} else {
|
} else {
|
||||||
optype = 0
|
optype = 0
|
||||||
//fmt.Println("Expr:", buffer)
|
|
||||||
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{buffer, "string"})
|
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{buffer, "string"})
|
||||||
}
|
}
|
||||||
case 5: // operator
|
case 5: // operator
|
||||||
|
@ -297,7 +282,6 @@ func processSet(setstr string) (setter []DBSetter) {
|
||||||
} else {
|
} else {
|
||||||
optype = 0
|
optype = 0
|
||||||
i--
|
i--
|
||||||
//fmt.Println("Expr:", buffer)
|
|
||||||
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{buffer, "operator"})
|
tmpSetter.Expr = append(tmpSetter.Expr, DBToken{buffer, "operator"})
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -297,19 +297,19 @@ func writeInserts(adapter qgen.Adapter) error {
|
||||||
|
|
||||||
adapter.Insert("notifyOne").Table("activity_stream_matches").Columns("watcher, asid").Fields("?,?").Parse()
|
adapter.Insert("notifyOne").Table("activity_stream_matches").Columns("watcher, asid").Fields("?,?").Parse()
|
||||||
|
|
||||||
adapter.SimpleInsert("addEmail", "emails", "email, uid, validated, token", "?,?,?,?")
|
adapter.Insert("addEmail").Table("emails").Columns("email, uid, validated, token").Fields("?,?,?,?").Parse()
|
||||||
|
|
||||||
adapter.SimpleInsert("addSubscription", "activity_subscriptions", "user, targetID, targetType, level", "?,?,?,2")
|
adapter.Insert("addSubscription").Table("activity_subscriptions").Columns("user, targetID, targetType, level").Fields("?,?,?,2").Parse()
|
||||||
|
|
||||||
adapter.SimpleInsert("addForumPermsToForum", "forums_permissions", "gid,fid,preset,permissions", "?,?,?,?")
|
adapter.Insert("addForumPermsToForum").Table("forums_permissions").Columns("gid,fid,preset,permissions").Fields("?,?,?,?").Parse()
|
||||||
|
|
||||||
adapter.SimpleInsert("addPlugin", "plugins", "uname, active, installed", "?,?,?")
|
adapter.Insert("addPlugin").Table("plugins").Columns("uname, active, installed").Fields("?,?,?").Parse()
|
||||||
|
|
||||||
adapter.SimpleInsert("addTheme", "themes", "uname, default", "?,?")
|
adapter.Insert("addTheme").Table("themes").Columns("uname, default").Fields("?,?").Parse()
|
||||||
|
|
||||||
adapter.SimpleInsert("addAttachment", "attachments", "sectionID, sectionTable, originID, originTable, uploadedBy, path", "?,?,?,?,?,?")
|
adapter.Insert("addAttachment").Table("attachments").Columns("sectionID, sectionTable, originID, originTable, uploadedBy, path").Fields("?,?,?,?,?,?").Parse()
|
||||||
|
|
||||||
adapter.SimpleInsert("createWordFilter", "word_filters", "find, replacement", "?,?")
|
adapter.Insert("createWordFilter").Table("word_filters").Columns("find, replacement").Fields("?,?").Parse()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -334,48 +334,48 @@ func writeReplaces(adapter qgen.Adapter) (err error) {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
func writeUpdates(adapter qgen.Adapter) error {
|
func writeUpdates(adapter qgen.Adapter) error {
|
||||||
adapter.SimpleUpdate("editReply", "replies", "content = ?, parsed_content = ?", "rid = ?")
|
adapter.Update("editReply").Table("replies").Set("content = ?, parsed_content = ?").Where("rid = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("editProfileReply", "users_replies", "content = ?, parsed_content = ?", "rid = ?")
|
adapter.Update("editProfileReply").Table("users_replies").Set("content = ?, parsed_content = ?").Where("rid = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("updateSetting", "settings", "content = ?", "name = ?")
|
adapter.Update("updateSetting").Table("settings").Set("content = ?").Where("name = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("updatePlugin", "plugins", "active = ?", "uname = ?")
|
adapter.Update("updatePlugin").Table("plugins").Set("active = ?").Where("uname = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("updatePluginInstall", "plugins", "installed = ?", "uname = ?")
|
adapter.Update("updatePluginInstall").Table("plugins").Set("installed = ?").Where("uname = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("updateTheme", "themes", "default = ?", "uname = ?")
|
adapter.Update("updateTheme").Table("themes").Set("default = ?").Where("uname = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("updateForum", "forums", "name = ?, desc = ?, active = ?, preset = ?", "fid = ?")
|
adapter.Update("updateForum").Table("forums").Set("name = ?, desc = ?, active = ?, preset = ?").Where("fid = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("updateUser", "users", "name = ?, email = ?, group = ?", "uid = ?")
|
adapter.Update("updateUser").Table("users").Set("name = ?, email = ?, group = ?").Where("uid = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("updateGroupPerms", "users_groups", "permissions = ?", "gid = ?")
|
adapter.Update("updateGroupPerms").Table("users_groups").Set("permissions = ?").Where("gid = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("updateGroup", "users_groups", "name = ?, tag = ?", "gid = ?")
|
adapter.Update("updateGroup").Table("users_groups").Set("name = ?, tag = ?").Where("gid = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("updateEmail", "emails", "email = ?, uid = ?, validated = ?, token = ?", "email = ?")
|
adapter.Update("updateEmail").Table("emails").Set("email = ?, uid = ?, validated = ?, token = ?").Where("email = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("verifyEmail", "emails", "validated = 1, token = ''", "email = ?") // Need to fix this: Empty string isn't working, it gets set to 1 instead x.x -- Has this been fixed?
|
adapter.Update("verifyEmail").Table("emails").Set("validated = 1, token = ''").Where("email = ?").Parse() // Need to fix this: Empty string isn't working, it gets set to 1 instead x.x -- Has this been fixed?
|
||||||
|
|
||||||
adapter.SimpleUpdate("setTempGroup", "users", "temp_group = ?", "uid = ?")
|
adapter.Update("setTempGroup").Table("users").Set("temp_group = ?").Where("uid = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("updateWordFilter", "word_filters", "find = ?, replacement = ?", "wfid = ?")
|
adapter.Update("updateWordFilter").Table("word_filters").Set("find = ?, replacement = ?").Where("wfid = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleUpdate("bumpSync", "sync", "last_update = UTC_TIMESTAMP()", "")
|
adapter.Update("bumpSync").Table("sync").Set("last_update = UTC_TIMESTAMP()").Parse()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeDeletes(adapter qgen.Adapter) error {
|
func writeDeletes(adapter qgen.Adapter) error {
|
||||||
adapter.SimpleDelete("deleteProfileReply", "users_replies", "rid = ?")
|
adapter.Delete("deleteProfileReply").Table("users_replies").Where("rid = ?").Parse()
|
||||||
|
|
||||||
//adapter.SimpleDelete("deleteForumPermsByForum", "forums_permissions", "fid = ?")
|
//adapter.Delete("deleteForumPermsByForum").Table("forums_permissions").Where("fid = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleDelete("deleteActivityStreamMatch", "activity_stream_matches", "watcher = ? AND asid = ?")
|
adapter.Delete("deleteActivityStreamMatch").Table("activity_stream_matches").Where("watcher = ? AND asid = ?").Parse()
|
||||||
//adapter.SimpleDelete("deleteActivityStreamMatchesByWatcher","activity_stream_matches","watcher = ?")
|
//adapter.Delete("deleteActivityStreamMatchesByWatcher").Table("activity_stream_matches").Where("watcher = ?").Parse()
|
||||||
|
|
||||||
adapter.SimpleDelete("deleteWordFilter", "word_filters", "wfid = ?")
|
adapter.Delete("deleteWordFilter").Table("word_filters").Where("wfid = ?").Parse()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type RouteImpl struct {
|
type RouteImpl struct {
|
||||||
Name string
|
Name string
|
||||||
Path string
|
Path string
|
||||||
Vars []string
|
Vars []string
|
||||||
MemberAction bool
|
RunBefore []Runnable
|
||||||
RunBefore []Runnable
|
|
||||||
|
|
||||||
Parent *RouteGroup
|
Parent *RouteGroup
|
||||||
}
|
}
|
||||||
|
@ -35,10 +34,17 @@ func (route *RouteImpl) LitBefore(items ...string) *RouteImpl {
|
||||||
|
|
||||||
func (route *RouteImpl) hasBefore(items ...string) bool {
|
func (route *RouteImpl) hasBefore(items ...string) bool {
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
for _, before := range route.RunBefore {
|
if route.hasBeforeItem(item) {
|
||||||
if before.Contents == item {
|
return true
|
||||||
return true
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (route *RouteImpl) hasBeforeItem(item string) bool {
|
||||||
|
for _, before := range route.RunBefore {
|
||||||
|
if before.Contents == item {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -49,15 +55,19 @@ func addRouteGroup(routeGroup *RouteGroup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func blankRoute() *RouteImpl {
|
func blankRoute() *RouteImpl {
|
||||||
return &RouteImpl{"", "", []string{}, false, []Runnable{}, nil}
|
return &RouteImpl{"", "", []string{}, []Runnable{}, nil}
|
||||||
|
}
|
||||||
|
|
||||||
|
func route(fname string, path string, args ...string) *RouteImpl {
|
||||||
|
return &RouteImpl{fname, path, args, []Runnable{}, nil}
|
||||||
}
|
}
|
||||||
|
|
||||||
func View(fname string, path string, args ...string) *RouteImpl {
|
func View(fname string, path string, args ...string) *RouteImpl {
|
||||||
return &RouteImpl{fname, path, args, false, []Runnable{}, nil}
|
return route(fname, path, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MemberView(fname string, path string, args ...string) *RouteImpl {
|
func MemberView(fname string, path string, args ...string) *RouteImpl {
|
||||||
route := &RouteImpl{fname, path, args, false, []Runnable{}, nil}
|
route := route(fname, path, args...)
|
||||||
if !route.hasBefore("SuperModOnly", "AdminOnly") {
|
if !route.hasBefore("SuperModOnly", "AdminOnly") {
|
||||||
route.Before("MemberOnly")
|
route.Before("MemberOnly")
|
||||||
}
|
}
|
||||||
|
@ -65,7 +75,7 @@ func MemberView(fname string, path string, args ...string) *RouteImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ModView(fname string, path string, args ...string) *RouteImpl {
|
func ModView(fname string, path string, args ...string) *RouteImpl {
|
||||||
route := &RouteImpl{fname, path, args, false, []Runnable{}, nil}
|
route := route(fname, path, args...)
|
||||||
if !route.hasBefore("AdminOnly") {
|
if !route.hasBefore("AdminOnly") {
|
||||||
route.Before("SuperModOnly")
|
route.Before("SuperModOnly")
|
||||||
}
|
}
|
||||||
|
@ -73,7 +83,7 @@ func ModView(fname string, path string, args ...string) *RouteImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Action(fname string, path string, args ...string) *RouteImpl {
|
func Action(fname string, path string, args ...string) *RouteImpl {
|
||||||
route := &RouteImpl{fname, path, args, true, []Runnable{}, nil}
|
route := route(fname, path, args...)
|
||||||
route.Before("NoSessionMismatch")
|
route.Before("NoSessionMismatch")
|
||||||
if !route.hasBefore("SuperModOnly", "AdminOnly") {
|
if !route.hasBefore("SuperModOnly", "AdminOnly") {
|
||||||
route.Before("MemberOnly")
|
route.Before("MemberOnly")
|
||||||
|
@ -82,13 +92,11 @@ func Action(fname string, path string, args ...string) *RouteImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
func AnonAction(fname string, path string, args ...string) *RouteImpl {
|
func AnonAction(fname string, path string, args ...string) *RouteImpl {
|
||||||
route := &RouteImpl{fname, path, args, false, []Runnable{}, nil}
|
return route(fname, path, args...).Before("ParseForm")
|
||||||
route.Before("ParseForm")
|
|
||||||
return route
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func UploadAction(fname string, path string, args ...string) *RouteImpl {
|
func UploadAction(fname string, path string, args ...string) *RouteImpl {
|
||||||
route := &RouteImpl{fname, path, args, true, []Runnable{}, nil}
|
route := route(fname, path, args...)
|
||||||
if !route.hasBefore("SuperModOnly", "AdminOnly") {
|
if !route.hasBefore("SuperModOnly", "AdminOnly") {
|
||||||
route.Before("MemberOnly")
|
route.Before("MemberOnly")
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,16 +505,18 @@ var profile_0 = []byte(`
|
||||||
<div class="rowitem"><h1>Profile</h1></div>
|
<div class="rowitem"><h1>Profile</h1></div>
|
||||||
</header>-->
|
</header>-->
|
||||||
<div id="profile_left_pane" class="rowmenu">
|
<div id="profile_left_pane" class="rowmenu">
|
||||||
<div class="rowitem avatarRow">
|
<div class="topBlock">
|
||||||
<img src="`)
|
<div class="rowitem avatarRow">
|
||||||
|
<img src="`)
|
||||||
var profile_1 = []byte(`" class="avatar" />
|
var profile_1 = []byte(`" class="avatar" />
|
||||||
</div>
|
</div>
|
||||||
<div class="rowitem nameRow">
|
<div class="rowitem nameRow">
|
||||||
<span class="profileName">`)
|
<span class="profileName">`)
|
||||||
var profile_2 = []byte(`</span>`)
|
var profile_2 = []byte(`</span>`)
|
||||||
var profile_3 = []byte(`<span class="username">`)
|
var profile_3 = []byte(`<span class="username">`)
|
||||||
var profile_4 = []byte(`</span>`)
|
var profile_4 = []byte(`</span>`)
|
||||||
var profile_5 = []byte(`
|
var profile_5 = []byte(`
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="passiveBlock">
|
<div class="passiveBlock">
|
||||||
<div class="rowitem passive">
|
<div class="rowitem passive">
|
||||||
|
|
|
@ -45,10 +45,14 @@ a {
|
||||||
padding-top: 14px;
|
padding-top: 14px;
|
||||||
display: flex;
|
display: flex;
|
||||||
/*background-color: hsl(0,0%,97%);*/
|
/*background-color: hsl(0,0%,97%);*/
|
||||||
|
padding-left: 0px;
|
||||||
|
padding-right: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main {
|
#main {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
padding-left: 8px;
|
||||||
|
padding-right: 8px;
|
||||||
}
|
}
|
||||||
.sidebar {
|
.sidebar {
|
||||||
width: 200px;
|
width: 200px;
|
||||||
|
@ -750,8 +754,19 @@ select, input, textarea {
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
.footer {
|
||||||
border: 1px solid var(--element-border-color);
|
border-top: 1px solid var(--element-border-color);
|
||||||
border-bottom: 2px solid var(--element-border-color);
|
padding: 12px;
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
margin-top: 14px;
|
||||||
|
margin-left: -8px;
|
||||||
|
margin-right: -8px;
|
||||||
|
}
|
||||||
|
.footer #poweredBy {
|
||||||
|
font-size: 17px;
|
||||||
|
}
|
||||||
|
.footer #poweredBy span {
|
||||||
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media(max-width: 670px) {
|
@media(max-width: 670px) {
|
||||||
|
|
Loading…
Reference in New Issue