bf851bd9fc
Added support for dyntmpl to the template system. The Account Dashboard now sort of uses dyntmpl, more work needed here. Renamed the pre_render_view_topic hook to pre_render_topic. Added the GetCurrentLangPack() function. Added the alerts_no_new_alerts phrase. Added the account_level_list phrase. Refactored the route rename logic in the patcher to cut down on the amount of boilerplate. Added more route renames to the patcher. You will need to run the patcher / updater in this commit.
46 lines
1009 B
Go
46 lines
1009 B
Go
package main
|
|
|
|
import "strings"
|
|
import "github.com/Azareal/Gosora/query_gen"
|
|
|
|
type PrimaryKeySpitter struct {
|
|
keys map[string]string
|
|
}
|
|
|
|
func NewPrimaryKeySpitter() *PrimaryKeySpitter {
|
|
return &PrimaryKeySpitter{make(map[string]string)}
|
|
}
|
|
|
|
func (spit *PrimaryKeySpitter) Hook(name string, args ...interface{}) error {
|
|
if name == "CreateTableStart" {
|
|
var found string
|
|
var table = args[0].(*qgen.DB_Install_Table)
|
|
for _, key := range table.Keys {
|
|
if key.Type == "primary" {
|
|
expl := strings.Split(key.Columns, ",")
|
|
if len(expl) > 1 {
|
|
continue
|
|
}
|
|
found = key.Columns
|
|
}
|
|
if found != "" {
|
|
table := table.Name
|
|
spit.keys[table] = found
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (spit *PrimaryKeySpitter) Write() error {
|
|
out := `// Generated by Gosora's Query Generator. DO NOT EDIT.
|
|
package main
|
|
|
|
var dbTablePrimaryKeys = map[string]string{
|
|
`
|
|
for table, key := range spit.keys {
|
|
out += "\t\"" + table + "\":\"" + key + "\",\n"
|
|
}
|
|
return writeFile("./gen_tables.go", out+"}\n")
|
|
}
|