Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Query Generator Library
|
|
|
|
* WIP Under Construction
|
|
|
|
* Copyright Azareal 2017 - 2018
|
|
|
|
*
|
|
|
|
*/
|
2017-06-13 07:12:58 +00:00
|
|
|
package qgen
|
2017-06-12 09:03:14 +00:00
|
|
|
|
|
|
|
//import "fmt"
|
2017-10-16 07:32:58 +00:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
)
|
2017-06-12 09:03:14 +00:00
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func processColumns(colstr string) (columns []DB_Column) {
|
2017-06-12 09:03:14 +00:00
|
|
|
if colstr == "" {
|
|
|
|
return columns
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
colstr = strings.Replace(colstr, " as ", " AS ", -1)
|
|
|
|
for _, segment := range strings.Split(colstr, ",") {
|
2017-06-12 09:03:14 +00:00
|
|
|
var outcol DB_Column
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
dotHalves := strings.Split(strings.TrimSpace(segment), ".")
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-06-12 09:03:14 +00:00
|
|
|
var halves []string
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
if len(dotHalves) == 2 {
|
|
|
|
outcol.Table = dotHalves[0]
|
|
|
|
halves = strings.Split(dotHalves[1], " AS ")
|
2017-06-12 09:03:14 +00:00
|
|
|
} else {
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
halves = strings.Split(dotHalves[0], " AS ")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-06-12 09:03:14 +00:00
|
|
|
halves[0] = strings.TrimSpace(halves[0])
|
|
|
|
if len(halves) == 2 {
|
|
|
|
outcol.Alias = strings.TrimSpace(halves[1])
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
if halves[0][len(halves[0])-1] == ')' {
|
2017-06-12 09:03:14 +00:00
|
|
|
outcol.Type = "function"
|
2017-06-19 08:06:54 +00:00
|
|
|
} else if halves[0] == "?" {
|
|
|
|
outcol.Type = "substitute"
|
2017-06-12 09:03:14 +00:00
|
|
|
} else {
|
|
|
|
outcol.Type = "column"
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-06-12 09:03:14 +00:00
|
|
|
outcol.Left = halves[0]
|
2017-09-03 04:50:31 +00:00
|
|
|
columns = append(columns, outcol)
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
return columns
|
|
|
|
}
|
|
|
|
|
2017-10-16 07:32:58 +00:00
|
|
|
// TODO: Allow order by statements without a direction
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func processOrderby(orderstr string) (order []DB_Order) {
|
2017-06-12 09:03:14 +00:00
|
|
|
if orderstr == "" {
|
|
|
|
return order
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
for _, segment := range strings.Split(orderstr, ",") {
|
2017-06-12 09:03:14 +00:00
|
|
|
var outorder DB_Order
|
2017-09-03 04:50:31 +00:00
|
|
|
halves := strings.Split(strings.TrimSpace(segment), " ")
|
2017-06-12 09:03:14 +00:00
|
|
|
if len(halves) != 2 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
outorder.Column = halves[0]
|
|
|
|
outorder.Order = strings.ToLower(halves[1])
|
2017-09-03 04:50:31 +00:00
|
|
|
order = append(order, outorder)
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
return order
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func processJoiner(joinstr string) (joiner []DB_Joiner) {
|
2017-06-12 09:03:14 +00:00
|
|
|
if joinstr == "" {
|
|
|
|
return joiner
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
joinstr = strings.Replace(joinstr, " on ", " ON ", -1)
|
|
|
|
joinstr = strings.Replace(joinstr, " and ", " AND ", -1)
|
|
|
|
for _, segment := range strings.Split(joinstr, " AND ") {
|
2017-06-12 09:03:14 +00:00
|
|
|
var outjoin DB_Joiner
|
|
|
|
var parseOffset int
|
|
|
|
var left, right string
|
2017-09-03 04:50:31 +00:00
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
left, parseOffset = getIdentifier(segment, parseOffset)
|
|
|
|
outjoin.Operator, parseOffset = getOperator(segment, parseOffset+1)
|
|
|
|
right, parseOffset = getIdentifier(segment, parseOffset+1)
|
2017-09-03 04:50:31 +00:00
|
|
|
|
|
|
|
left_column := strings.Split(left, ".")
|
|
|
|
right_column := strings.Split(right, ".")
|
2017-06-12 09:03:14 +00:00
|
|
|
outjoin.LeftTable = strings.TrimSpace(left_column[0])
|
|
|
|
outjoin.RightTable = strings.TrimSpace(right_column[0])
|
|
|
|
outjoin.LeftColumn = strings.TrimSpace(left_column[1])
|
|
|
|
outjoin.RightColumn = strings.TrimSpace(right_column[1])
|
2017-09-03 04:50:31 +00:00
|
|
|
|
|
|
|
joiner = append(joiner, outjoin)
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
return joiner
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func processWhere(wherestr string) (where []DB_Where) {
|
2017-06-12 09:03:14 +00:00
|
|
|
if wherestr == "" {
|
|
|
|
return where
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
wherestr = strings.Replace(wherestr, " and ", " AND ", -1)
|
|
|
|
|
2017-06-19 08:06:54 +00:00
|
|
|
var buffer string
|
|
|
|
var optype int // 0: None, 1: Number, 2: Column, 3: Function, 4: String, 5: Operator
|
2017-09-03 04:50:31 +00:00
|
|
|
for _, segment := range strings.Split(wherestr, " AND ") {
|
2017-06-19 08:06:54 +00:00
|
|
|
var tmp_where DB_Where
|
|
|
|
segment += ")"
|
|
|
|
for i := 0; i < len(segment); i++ {
|
|
|
|
char := segment[i]
|
|
|
|
//fmt.Println("optype",optype)
|
2017-09-03 04:50:31 +00:00
|
|
|
switch optype {
|
2017-06-19 08:06:54 +00:00
|
|
|
case 0: // unknown
|
|
|
|
//fmt.Println("case 0:",char,string(char))
|
2017-09-03 04:50:31 +00:00
|
|
|
if '0' <= char && char <= '9' {
|
2017-06-19 08:06:54 +00:00
|
|
|
optype = 1
|
|
|
|
buffer = string(char)
|
|
|
|
} else if ('a' <= char && char <= 'z') || ('A' <= char && char <= 'Z') || char == '_' {
|
|
|
|
optype = 2
|
|
|
|
buffer = string(char)
|
|
|
|
} else if char == '\'' {
|
|
|
|
optype = 4
|
|
|
|
buffer = ""
|
|
|
|
} else if _is_op_byte(char) {
|
|
|
|
optype = 5
|
|
|
|
buffer = string(char)
|
|
|
|
} else if char == '?' {
|
|
|
|
//fmt.Println("Expr:","?")
|
2017-09-03 04:50:31 +00:00
|
|
|
tmp_where.Expr = append(tmp_where.Expr, DB_Token{"?", "substitute"})
|
2017-06-19 08:06:54 +00:00
|
|
|
}
|
|
|
|
case 1: // number
|
2017-09-03 04:50:31 +00:00
|
|
|
if '0' <= char && char <= '9' {
|
2017-06-19 08:06:54 +00:00
|
|
|
buffer += string(char)
|
|
|
|
} else {
|
|
|
|
optype = 0
|
|
|
|
i--
|
|
|
|
//fmt.Println("Expr:",buffer)
|
2017-09-03 04:50:31 +00:00
|
|
|
tmp_where.Expr = append(tmp_where.Expr, DB_Token{buffer, "number"})
|
2017-06-19 08:06:54 +00:00
|
|
|
}
|
|
|
|
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)
|
2017-09-03 04:50:31 +00:00
|
|
|
tmp_where.Expr = append(tmp_where.Expr, DB_Token{buffer, "column"})
|
2017-06-19 08:06:54 +00:00
|
|
|
}
|
|
|
|
case 3: // function
|
2017-09-03 04:50:31 +00:00
|
|
|
var preI = i
|
2017-06-19 08:06:54 +00:00
|
|
|
//fmt.Println("buffer",buffer)
|
|
|
|
//fmt.Println("len(halves)",len(halves[1]))
|
2017-09-03 04:50:31 +00:00
|
|
|
//fmt.Println("preI",string(halves[1][preI]))
|
|
|
|
//fmt.Println("msg prior to preI",halves[1][0:preI])
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
i = skipFunctionCall(segment, i-1)
|
2017-06-19 08:06:54 +00:00
|
|
|
//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]))
|
2017-09-03 04:50:31 +00:00
|
|
|
buffer += segment[preI:i] + string(segment[i])
|
2017-06-19 08:06:54 +00:00
|
|
|
//fmt.Println("Expr:",buffer)
|
2017-09-03 04:50:31 +00:00
|
|
|
tmp_where.Expr = append(tmp_where.Expr, DB_Token{buffer, "function"})
|
2017-06-19 08:06:54 +00:00
|
|
|
optype = 0
|
|
|
|
case 4: // string
|
|
|
|
if char != '\'' {
|
|
|
|
buffer += string(char)
|
|
|
|
} else {
|
|
|
|
optype = 0
|
|
|
|
//fmt.Println("Expr:",buffer)
|
2017-09-03 04:50:31 +00:00
|
|
|
tmp_where.Expr = append(tmp_where.Expr, DB_Token{buffer, "string"})
|
2017-06-19 08:06:54 +00:00
|
|
|
}
|
|
|
|
case 5: // operator
|
|
|
|
if _is_op_byte(char) {
|
|
|
|
buffer += string(char)
|
|
|
|
} else {
|
|
|
|
optype = 0
|
|
|
|
i--
|
|
|
|
//fmt.Println("Expr:",buffer)
|
2017-09-03 04:50:31 +00:00
|
|
|
tmp_where.Expr = append(tmp_where.Expr, DB_Token{buffer, "operator"})
|
2017-06-19 08:06:54 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
panic("Bad optype in _process_where")
|
|
|
|
}
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
where = append(where, tmp_where)
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
return where
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func processSet(setstr string) (setter []DB_Setter) {
|
2017-06-12 09:03:14 +00:00
|
|
|
if setstr == "" {
|
|
|
|
return setter
|
|
|
|
}
|
|
|
|
//fmt.Println("setstr",setstr)
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-06-12 09:03:14 +00:00
|
|
|
// First pass, splitting the string by commas while ignoring the innards of functions
|
|
|
|
var setset []string
|
|
|
|
var buffer string
|
2017-09-03 04:50:31 +00:00
|
|
|
var lastItem int
|
2017-06-12 09:03:14 +00:00
|
|
|
setstr += ","
|
2017-09-03 04:50:31 +00:00
|
|
|
for i := 0; i < len(setstr); i++ {
|
2017-06-12 09:03:14 +00:00
|
|
|
if setstr[i] == '(' {
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
i = skipFunctionCall(setstr, i-1)
|
2017-09-03 04:50:31 +00:00
|
|
|
setset = append(setset, setstr[lastItem:i+1])
|
2017-06-12 09:03:14 +00:00
|
|
|
buffer = ""
|
2017-09-03 04:50:31 +00:00
|
|
|
lastItem = i + 2
|
2017-06-12 09:03:14 +00:00
|
|
|
} else if setstr[i] == ',' && buffer != "" {
|
2017-09-03 04:50:31 +00:00
|
|
|
setset = append(setset, buffer)
|
2017-06-12 09:03:14 +00:00
|
|
|
buffer = ""
|
2017-09-03 04:50:31 +00:00
|
|
|
lastItem = i + 1
|
2017-06-12 09:03:14 +00:00
|
|
|
} else if (setstr[i] > 32) && setstr[i] != ',' && setstr[i] != ')' {
|
|
|
|
buffer += string(setstr[i])
|
|
|
|
}
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-06-12 09:03:14 +00:00
|
|
|
// Second pass. Break this setitem into manageable chunks
|
|
|
|
buffer = ""
|
|
|
|
for _, setitem := range setset {
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
var tmpSetter DB_Setter
|
2017-09-03 04:50:31 +00:00
|
|
|
halves := strings.Split(setitem, "=")
|
2017-06-12 09:03:14 +00:00
|
|
|
if len(halves) != 2 {
|
|
|
|
continue
|
|
|
|
}
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
tmpSetter.Column = strings.TrimSpace(halves[0])
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-06-12 09:03:14 +00:00
|
|
|
halves[1] += ")"
|
|
|
|
var optype int // 0: None, 1: Number, 2: Column, 3: Function, 4: String, 5: Operator
|
|
|
|
//fmt.Println("halves[1]",halves[1])
|
|
|
|
for i := 0; i < len(halves[1]); i++ {
|
|
|
|
char := halves[1][i]
|
|
|
|
//fmt.Println("optype",optype)
|
2017-09-03 04:50:31 +00:00
|
|
|
switch optype {
|
2017-06-12 09:03:14 +00:00
|
|
|
case 0: // unknown
|
2017-09-03 04:50:31 +00:00
|
|
|
if '0' <= char && char <= '9' {
|
2017-06-12 09:03:14 +00:00
|
|
|
optype = 1
|
|
|
|
buffer = string(char)
|
2017-06-19 08:06:54 +00:00
|
|
|
} else if ('a' <= char && char <= 'z') || ('A' <= char && char <= 'Z') || char == '_' {
|
2017-06-12 09:03:14 +00:00
|
|
|
optype = 2
|
|
|
|
buffer = string(char)
|
|
|
|
} else if char == '\'' {
|
|
|
|
optype = 4
|
2017-06-19 08:06:54 +00:00
|
|
|
buffer = ""
|
2017-06-12 09:03:14 +00:00
|
|
|
} else if _is_op_byte(char) {
|
|
|
|
optype = 5
|
|
|
|
buffer = string(char)
|
|
|
|
} else if char == '?' {
|
|
|
|
//fmt.Println("Expr:","?")
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
tmpSetter.Expr = append(tmpSetter.Expr, DB_Token{"?", "substitute"})
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
case 1: // number
|
2017-09-03 04:50:31 +00:00
|
|
|
if '0' <= char && char <= '9' {
|
2017-06-12 09:03:14 +00:00
|
|
|
buffer += string(char)
|
|
|
|
} else {
|
|
|
|
optype = 0
|
|
|
|
i--
|
|
|
|
//fmt.Println("Expr:",buffer)
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
tmpSetter.Expr = append(tmpSetter.Expr, DB_Token{buffer, "number"})
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
case 2: // column
|
2017-06-19 08:06:54 +00:00
|
|
|
if ('a' <= char && char <= 'z') || ('A' <= char && char <= 'Z') || char == '_' {
|
2017-06-12 09:03:14 +00:00
|
|
|
buffer += string(char)
|
|
|
|
} else if char == '(' {
|
|
|
|
optype = 3
|
|
|
|
i--
|
|
|
|
} else {
|
|
|
|
optype = 0
|
|
|
|
i--
|
|
|
|
//fmt.Println("Expr:",buffer)
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
tmpSetter.Expr = append(tmpSetter.Expr, DB_Token{buffer, "column"})
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
case 3: // function
|
2017-09-03 04:50:31 +00:00
|
|
|
var preI = i
|
2017-06-12 09:03:14 +00:00
|
|
|
//fmt.Println("buffer",buffer)
|
|
|
|
//fmt.Println("len(halves)",len(halves[1]))
|
2017-09-03 04:50:31 +00:00
|
|
|
//fmt.Println("preI",string(halves[1][preI]))
|
|
|
|
//fmt.Println("msg prior to preI",halves[1][0:preI])
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
i = skipFunctionCall(halves[1], i-1)
|
2017-06-12 09:03:14 +00:00
|
|
|
//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]))
|
2017-09-03 04:50:31 +00:00
|
|
|
buffer += halves[1][preI:i] + string(halves[1][i])
|
2017-06-12 09:03:14 +00:00
|
|
|
//fmt.Println("Expr:",buffer)
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
tmpSetter.Expr = append(tmpSetter.Expr, DB_Token{buffer, "function"})
|
2017-06-12 09:03:14 +00:00
|
|
|
optype = 0
|
|
|
|
case 4: // string
|
|
|
|
if char != '\'' {
|
|
|
|
buffer += string(char)
|
|
|
|
} else {
|
|
|
|
optype = 0
|
|
|
|
//fmt.Println("Expr:",buffer)
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
tmpSetter.Expr = append(tmpSetter.Expr, DB_Token{buffer, "string"})
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
case 5: // operator
|
|
|
|
if _is_op_byte(char) {
|
|
|
|
buffer += string(char)
|
|
|
|
} else {
|
|
|
|
optype = 0
|
|
|
|
i--
|
|
|
|
//fmt.Println("Expr:",buffer)
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
tmpSetter.Expr = append(tmpSetter.Expr, DB_Token{buffer, "operator"})
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
2017-06-19 08:06:54 +00:00
|
|
|
default:
|
|
|
|
panic("Bad optype in _process_set")
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
}
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
setter = append(setter, tmpSetter)
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|
|
|
|
//fmt.Println("setter",setter)
|
|
|
|
return setter
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func processLimit(limitstr string) (limiter DB_Limit) {
|
2017-09-03 04:50:31 +00:00
|
|
|
halves := strings.Split(limitstr, ",")
|
2017-06-15 11:40:35 +00:00
|
|
|
if len(halves) == 2 {
|
|
|
|
limiter.Offset = halves[0]
|
|
|
|
limiter.MaxCount = halves[1]
|
|
|
|
} else {
|
|
|
|
limiter.MaxCount = halves[0]
|
|
|
|
}
|
|
|
|
return limiter
|
|
|
|
}
|
|
|
|
|
2017-06-12 09:03:14 +00:00
|
|
|
func _is_op_byte(char byte) bool {
|
|
|
|
return char == '<' || char == '>' || char == '=' || char == '!' || char == '*' || char == '%' || char == '+' || char == '-' || char == '/'
|
|
|
|
}
|
|
|
|
|
2017-06-19 08:06:54 +00:00
|
|
|
func _is_op_rune(char rune) bool {
|
|
|
|
return char == '<' || char == '>' || char == '=' || char == '!' || char == '*' || char == '%' || char == '+' || char == '-' || char == '/'
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func processFields(fieldstr string) (fields []DB_Field) {
|
2017-06-12 09:03:14 +00:00
|
|
|
if fieldstr == "" {
|
|
|
|
return fields
|
|
|
|
}
|
|
|
|
var buffer string
|
2017-09-03 04:50:31 +00:00
|
|
|
var lastItem int
|
2017-06-12 09:03:14 +00:00
|
|
|
fieldstr += ","
|
2017-09-03 04:50:31 +00:00
|
|
|
for i := 0; i < len(fieldstr); i++ {
|
2017-06-12 09:03:14 +00:00
|
|
|
if fieldstr[i] == '(' {
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
i = skipFunctionCall(fieldstr, i-1)
|
|
|
|
fields = append(fields, DB_Field{Name: fieldstr[lastItem : i+1], Type: getIdentifierType(fieldstr[lastItem : i+1])})
|
2017-06-12 09:03:14 +00:00
|
|
|
buffer = ""
|
2017-09-03 04:50:31 +00:00
|
|
|
lastItem = i + 2
|
2017-06-12 09:03:14 +00:00
|
|
|
} else if fieldstr[i] == ',' && buffer != "" {
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
fields = append(fields, DB_Field{Name: buffer, Type: getIdentifierType(buffer)})
|
2017-06-12 09:03:14 +00:00
|
|
|
buffer = ""
|
2017-09-03 04:50:31 +00:00
|
|
|
lastItem = i + 1
|
2017-06-12 09:03:14 +00:00
|
|
|
} else if (fieldstr[i] > 32) && fieldstr[i] != ',' && fieldstr[i] != ')' {
|
|
|
|
buffer += string(fieldstr[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fields
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func getIdentifierType(identifier string) string {
|
2017-06-12 09:03:14 +00:00
|
|
|
if ('a' <= identifier[0] && identifier[0] <= 'z') || ('A' <= identifier[0] && identifier[0] <= 'Z') {
|
2017-09-03 04:50:31 +00:00
|
|
|
if identifier[len(identifier)-1] == ')' {
|
2017-06-12 09:03:14 +00:00
|
|
|
return "function"
|
|
|
|
}
|
|
|
|
return "column"
|
|
|
|
}
|
|
|
|
if identifier[0] == '\'' || identifier[0] == '"' {
|
|
|
|
return "string"
|
|
|
|
}
|
|
|
|
return "literal"
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func getIdentifier(segment string, startOffset int) (out string, i int) {
|
2017-06-12 09:03:14 +00:00
|
|
|
segment = strings.TrimSpace(segment)
|
|
|
|
segment += " " // Avoid overflow bugs with slicing
|
|
|
|
for i = startOffset; i < len(segment); i++ {
|
|
|
|
if segment[i] == '(' {
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
i = skipFunctionCall(segment, i)
|
2017-06-12 09:03:14 +00:00
|
|
|
return strings.TrimSpace(segment[startOffset:i]), (i - 1)
|
|
|
|
}
|
|
|
|
if (segment[i] == ' ' || _is_op_byte(segment[i])) && i != startOffset {
|
|
|
|
return strings.TrimSpace(segment[startOffset:i]), (i - 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return strings.TrimSpace(segment[startOffset:]), (i - 1)
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func getOperator(segment string, startOffset int) (out string, i int) {
|
2017-06-12 09:03:14 +00:00
|
|
|
segment = strings.TrimSpace(segment)
|
|
|
|
segment += " " // Avoid overflow bugs with slicing
|
|
|
|
for i = startOffset; i < len(segment); i++ {
|
|
|
|
if !_is_op_byte(segment[i]) && i != startOffset {
|
|
|
|
return strings.TrimSpace(segment[startOffset:i]), (i - 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return strings.TrimSpace(segment[startOffset:]), (i - 1)
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
func skipFunctionCall(data string, index int) int {
|
2017-09-03 04:50:31 +00:00
|
|
|
var braceCount int
|
|
|
|
for ; index < len(data); index++ {
|
2017-06-12 09:03:14 +00:00
|
|
|
char := data[index]
|
|
|
|
if char == '(' {
|
2017-09-03 04:50:31 +00:00
|
|
|
braceCount++
|
2017-06-12 09:03:14 +00:00
|
|
|
} else if char == ')' {
|
2017-09-03 04:50:31 +00:00
|
|
|
braceCount--
|
|
|
|
if braceCount == 0 {
|
2017-06-12 09:03:14 +00:00
|
|
|
return index
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return index
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func writeFile(name string, content string) (err error) {
|
2017-06-12 09:03:14 +00:00
|
|
|
f, err := os.Create(name)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err = f.WriteString(content)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
err = f.Sync()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return f.Close()
|
2017-06-12 09:03:14 +00:00
|
|
|
}
|