c60118e7c4
Add Http Conn Count tracking. Move more panel phrases into the panel namespace. Use a string builder in hookgen. Use Countf() in a couple of places to eliminate boilerplate. Reduce prepared stmt boilerplate in forum store with a lambda. Reduce prepared stmt boilerplate in topic.go with a lambda. Reduce prepared stmt boilerplate in group.go with a lambda. Add TestSetCreatedAt method to *Topic. Add DateOlderThanQ method to *accDeleteBuilder and *accUpdateBuilder. Add Stmt method to *accUpdateBuilder and *AccSelectBuilder. Add AccBuilder interface. Shorten variable names. Shorten extractPerm name to ep. Add avatar_visibility setting stub. Implementation coming in a later commit. Don't set an IP for installer generated posts. Add counters_perf_tick_row hook. Add avatar_visibility phrase. Add avatar_visibility_label phrase. Rename forums_no_description to forums_no_desc. Rename panel.forums_create_description_label to panel.forums_create_desc_label. Rename panel.forums_create_description to panel.forums_create_desc. Rename panel_forum_description to panel.forum_desc. Rename panel_forum_description_placeholder to panel.forum_desc_placeholder. Add panel_debug_http_conns_label phrase. Add panel.forum_actions_head phrase. Add panel.forum_actions_create_head phrase. Add panel.forum_action_run_on_topic_creation phrase. Add panel.forum_action_run_days_after_topic_creation phrase. Add panel.forum_action_run_days_after_topic_last_reply phrase. Add panel.forum_action_action phrase. Add panel.forum_action_action_delete phrase. Add panel.forum_action_action_lock phrase. Add panel.forum_action_action_unlock phrase. Add panel.forum_action_action_move phrase. Add panel.forum_action_extra phrase. Add panel.forum_action_create_button phrase. You will need to run the patcher / updater for this commit.
70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
// +build hookgen
|
|
|
|
package main // import "github.com/Azareal/Gosora/hook_gen"
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"runtime/debug"
|
|
"strings"
|
|
|
|
h "github.com/Azareal/Gosora/cmd/common_hook_gen"
|
|
c "github.com/Azareal/Gosora/common"
|
|
_ "github.com/Azareal/Gosora/extend"
|
|
)
|
|
|
|
// TODO: Make sure all the errors in this file propagate upwards properly
|
|
func main() {
|
|
// Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
fmt.Println(r)
|
|
debug.PrintStack()
|
|
}
|
|
}()
|
|
|
|
hooks := make(map[string]int)
|
|
for _, pl := range c.Plugins {
|
|
if len(pl.Meta.Hooks) > 0 {
|
|
for _, hook := range pl.Meta.Hooks {
|
|
hooks[hook]++
|
|
}
|
|
continue
|
|
}
|
|
if pl.Init != nil {
|
|
if e := pl.Init(pl); e != nil {
|
|
log.Print("early plugin init err: ", e)
|
|
return
|
|
}
|
|
}
|
|
if pl.Hooks != nil {
|
|
log.Print("Hooks not nil for ", pl.UName)
|
|
for hook, _ := range pl.Hooks {
|
|
hooks[hook] += 1
|
|
}
|
|
}
|
|
}
|
|
log.Printf("hooks: %+v\n", hooks)
|
|
|
|
imports := []string{"net/http"}
|
|
hookVars := h.HookVars{imports, nil}
|
|
var params2sb strings.Builder
|
|
add := func(name, params, ret, htype string, multiHook, skip bool, defaultRet, pure string) {
|
|
first := true
|
|
for _, param := range strings.Split(params, ",") {
|
|
if !first {
|
|
params2sb.WriteRune(',')
|
|
}
|
|
pspl := strings.Split(strings.ReplaceAll(strings.TrimSpace(param), " ", " "), " ")
|
|
params2sb.WriteString(pspl[0])
|
|
first = false
|
|
}
|
|
hookVars.Hooks = append(hookVars.Hooks, h.Hook{name, params, params2sb.String(), ret, htype, hooks[name] > 0, multiHook, skip, defaultRet, pure})
|
|
params2sb.Reset()
|
|
}
|
|
|
|
h.AddHooks(add)
|
|
h.Write(hookVars)
|
|
log.Println("Successfully generated the hooks")
|
|
}
|