diff --git a/bot/web/index.templ b/bot/web/index.templ index a648fa8..2988811 100644 --- a/bot/web/index.templ +++ b/bot/web/index.templ @@ -9,6 +9,7 @@ templ (w *Web) Header(title string) { rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css" /> + ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -37,7 +37,7 @@ func (w *Web) Header(title string) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(w.botName()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 25, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 26, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -50,7 +50,7 @@ func (w *Web) Header(title string) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 25, Col: 44} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 26, Col: 44} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -68,7 +68,7 @@ func (w *Web) Header(title string) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(w.botName()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 27, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 28, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -192,7 +192,7 @@ func (w *Web) Nav(currentPage string) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(w.botName()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 61, Col: 62} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 62, Col: 62} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -224,7 +224,7 @@ func (w *Web) Nav(currentPage string) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(item.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 67, Col: 101} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 68, Col: 101} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -251,7 +251,7 @@ func (w *Web) Nav(currentPage string) templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(item.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 69, Col: 63} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 70, Col: 63} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -298,7 +298,7 @@ func (w *Web) showStats() templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", w.stats.MessagesRcv)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 84, Col: 56} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 85, Col: 56} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -311,7 +311,7 @@ func (w *Web) showStats() templ.Component { var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", w.stats.MessagesSent)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 88, Col: 57} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 89, Col: 57} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { @@ -324,7 +324,7 @@ func (w *Web) showStats() templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(w.stats.Uptime()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 92, Col: 34} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 93, Col: 34} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { diff --git a/plugins/emojy/emojy.go b/plugins/emojy/emojy.go index 4222518..9d6eda4 100644 --- a/plugins/emojy/emojy.go +++ b/plugins/emojy/emojy.go @@ -207,6 +207,18 @@ func InvertEmojyList(emojy map[string]string) map[string]string { return out } +func (p *EmojyPlugin) allCountsFlat(threshold int) ([]EmojyCount, error) { + emoji, err := p.allCounts(threshold) + if err != nil { + return nil, err + } + output := []EmojyCount{} + for _, v := range emoji { + output = append(output, v...) + } + return output, nil +} + func (p *EmojyPlugin) allCounts(threshold int) (map[string][]EmojyCount, error) { out := map[string][]EmojyCount{} onServerList := InvertEmojyList(p.b.GetEmojiList(true)) diff --git a/plugins/emojy/list.templ b/plugins/emojy/list.templ index eacc423..f201df0 100644 --- a/plugins/emojy/list.templ +++ b/plugins/emojy/list.templ @@ -1,25 +1,29 @@ package emojy -templ (p *EmojyPlugin) listTempl(emojy emojyMap) { +templ (p *EmojyPlugin) listTempl(emojy []EmojyCount) {

Emojy

@p.emojyNav() -
- for _, v := range emojy { - for _, c := range v { -
- { -
- { c.Emojy } -
-
- } - } +
+ for _, e := range emojy { +
+
@p.listItem(e)
+
+ }
-} \ No newline at end of file +} + +templ (p *EmojyPlugin) listItem(e EmojyCount) { +
+ { +
+ { e.Emojy } +
+
+} diff --git a/plugins/emojy/list_templ.go b/plugins/emojy/list_templ.go index 27ff61f..24b7bec 100644 --- a/plugins/emojy/list_templ.go +++ b/plugins/emojy/list_templ.go @@ -10,7 +10,7 @@ import "context" import "io" import "bytes" -func (p *EmojyPlugin) listTempl(emojy emojyMap) templ.Component { +func (p *EmojyPlugin) listTempl(emojy []EmojyCount) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) if !templ_7745c5c3_IsBuffer { @@ -31,45 +31,22 @@ func (p *EmojyPlugin) listTempl(emojy emojyMap) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - for _, v := range emojy { - for _, c := range v { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
\"")
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var2 string - templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(c.Emojy) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/emojy/list.templ`, Line: 18, Col: 29} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } + for _, e := range emojy { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = p.listItem(e).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err } } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") @@ -82,3 +59,56 @@ func (p *EmojyPlugin) listTempl(emojy emojyMap) templ.Component { return templ_7745c5c3_Err }) } + +func (p *EmojyPlugin) listItem(e EmojyCount) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var2 := templ.GetChildren(ctx) + if templ_7745c5c3_Var2 == nil { + templ_7745c5c3_Var2 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
\"")
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(e.Emojy) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `plugins/emojy/list.templ`, Line: 25, Col: 17} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} diff --git a/plugins/emojy/web.go b/plugins/emojy/web.go index c41e4f0..28077b2 100644 --- a/plugins/emojy/web.go +++ b/plugins/emojy/web.go @@ -43,7 +43,7 @@ func (p *EmojyPlugin) handleUploadForm(w http.ResponseWriter, r *http.Request) { func (p *EmojyPlugin) handleList(w http.ResponseWriter, r *http.Request) { threshold := p.c.GetInt("emojy.statthreshold", 1) - emojy, err := p.allCounts(threshold) + emojy, err := p.allCountsFlat(threshold) if err != nil { fmt.Fprintf(w, "Error: %s", err) return diff --git a/plugins/meme/meme.templ b/plugins/meme/meme.templ index 0464d55..3f95735 100644 --- a/plugins/meme/meme.templ +++ b/plugins/meme/meme.templ @@ -17,26 +17,27 @@ templ (p *MemePlugin) index(all webResps) {
-
+ +
for _, meme := range all { -
- @p.Show(meme) +
+
@p.Show(meme)
}
} templ (p *MemePlugin) Show(meme webResp) { -
+
{

{ meme.Name }

-
+        
             { meme.Config }