diff --git a/bot/bot.go b/bot/bot.go index 2e665da..d49ad8b 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -147,7 +147,10 @@ func NewBot(config *config.Config, c *irc.Conn) *Bot { } http.HandleFunc("/", bot.serveRoot) - go http.ListenAndServe(":8080", nil) + if config.HttpAddr == "" { + config.HttpAddr = "127.0.0.1:1337" + } + go http.ListenAndServe(config.HttpAddr, nil) return bot } diff --git a/config.json b/config.json index 54aceff..612613d 100644 --- a/config.json +++ b/config.json @@ -12,6 +12,7 @@ "QuoteTime": 1, "LogLength": 50, "Admins": [""], + "HttpAddr": "127.0.0.1:1337", "UntappdToken": "", "UntappdFreq": 3600, diff --git a/config/config.go b/config/config.go index 43bd9f4..6d3abb9 100644 --- a/config/config.go +++ b/config/config.go @@ -19,6 +19,7 @@ type Config struct { QuoteTime int LogLength int Admins []string + HttpAddr string UntappdToken string UntappdFreq int WelcomeMsgs []string diff --git a/plugins/factoid.go b/plugins/factoid.go index 1cda8b6..47f14c1 100644 --- a/plugins/factoid.go +++ b/plugins/factoid.go @@ -470,6 +470,7 @@ func (p *FactoidPlugin) serveQuery(w http.ResponseWriter, r *http.Request) { p.Coll.Find(bson.M{"trigger": e}).All(&entries) context["Count"] = fmt.Sprintf("Found %d entries", len(entries)) context["Entries"] = entries + context["Search"] = e } else { context["Error"] = "Something's fucked." } diff --git a/plugins/webTemplates.go b/plugins/webTemplates.go index 1990c28..df08b6f 100644 --- a/plugins/webTemplates.go +++ b/plugins/webTemplates.go @@ -7,29 +7,83 @@ var factoidIndex string = ` -Factoids + Factoids + - - {{if .Error}} -
{{.Error}}
- {{end}} -
-
- + +
+ Search for a factoid + + +
- {{ $entries := .Entries }} +
+ + + {{if .Error}} + {{.Error}} + {{end}} + + {{if .Count}} + Found {{.Count}} entries. + {{end}} +
+ + {{if .Entries}} +
+ + + + + + + + + + + + {{range .Entries}} + + + + + + + {{end}} + +
TriggerFull TextAuthor# Hits
{{.Trigger}}{{.FullText}}{{.CreatedBy}}{{.AccessCount}}
+
{{end}}