mirror of https://github.com/velour/catbase.git
Making the web interface a bit better
This commit is contained in:
parent
edd941fe46
commit
242be51029
|
@ -147,7 +147,10 @@ func NewBot(config *config.Config, c *irc.Conn) *Bot {
|
||||||
}
|
}
|
||||||
|
|
||||||
http.HandleFunc("/", bot.serveRoot)
|
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
|
return bot
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
"QuoteTime": 1,
|
"QuoteTime": 1,
|
||||||
"LogLength": 50,
|
"LogLength": 50,
|
||||||
"Admins": ["<Admin Nick>"],
|
"Admins": ["<Admin Nick>"],
|
||||||
|
"HttpAddr": "127.0.0.1:1337",
|
||||||
|
|
||||||
"UntappdToken": "<Your Token>",
|
"UntappdToken": "<Your Token>",
|
||||||
"UntappdFreq": 3600,
|
"UntappdFreq": 3600,
|
||||||
|
|
|
@ -19,6 +19,7 @@ type Config struct {
|
||||||
QuoteTime int
|
QuoteTime int
|
||||||
LogLength int
|
LogLength int
|
||||||
Admins []string
|
Admins []string
|
||||||
|
HttpAddr string
|
||||||
UntappdToken string
|
UntappdToken string
|
||||||
UntappdFreq int
|
UntappdFreq int
|
||||||
WelcomeMsgs []string
|
WelcomeMsgs []string
|
||||||
|
|
|
@ -470,6 +470,7 @@ func (p *FactoidPlugin) serveQuery(w http.ResponseWriter, r *http.Request) {
|
||||||
p.Coll.Find(bson.M{"trigger": e}).All(&entries)
|
p.Coll.Find(bson.M{"trigger": e}).All(&entries)
|
||||||
context["Count"] = fmt.Sprintf("Found %d entries", len(entries))
|
context["Count"] = fmt.Sprintf("Found %d entries", len(entries))
|
||||||
context["Entries"] = entries
|
context["Entries"] = entries
|
||||||
|
context["Search"] = e
|
||||||
} else {
|
} else {
|
||||||
context["Error"] = "Something's fucked."
|
context["Error"] = "Something's fucked."
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,29 +7,83 @@ var factoidIndex string = `
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Factoids</title>
|
<title>Factoids</title>
|
||||||
|
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.1.0/pure-min.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
{{if .Error}}
|
|
||||||
<div id="error">{{.Error}}</div>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<form action="/factoid/req" method="POST">
|
<form action="/factoid/req" method="POST" class="pure-form">
|
||||||
<input type="text" name="entry" /> <input type="submit" value="Find" />
|
<fieldset>
|
||||||
|
<legend>Search for a factoid</legend>
|
||||||
|
<input type="text" name="entry" placeholder="trigger" value="{{.Search}}" />
|
||||||
|
<button type="submit" class="pure-button notice">Find</button>
|
||||||
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ $entries := .Entries }}
|
<div>
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
{{if .Count}}
|
.pure-button-success,
|
||||||
<div id="count">Found {{.Count}} entries.</div>
|
.pure-button-error,
|
||||||
{{end}}
|
.pure-button-warning,
|
||||||
|
.pure-button-secondary {
|
||||||
|
color: white;
|
||||||
|
border-radius: 4px;
|
||||||
|
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
{{range $entries}}
|
.pure-button-success {
|
||||||
<div class="entry">
|
background: rgb(76, 201, 71); /* this is a green */
|
||||||
{{.Trigger}} - {{.Action}}
|
}
|
||||||
</div>
|
|
||||||
|
.pure-button-error {
|
||||||
|
background: rgb(202, 60, 60); /* this is a maroon */
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-button-warning {
|
||||||
|
background: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-button-secondary {
|
||||||
|
background: rgb(95, 198, 218); /* this is a light blue */
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
{{if .Error}}
|
||||||
|
<span id="error" class="pure-button-error">{{.Error}}</span>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if .Count}}
|
||||||
|
<span id="count" class="pure-button-success">Found {{.Count}} entries.</span>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{if .Entries}}
|
||||||
|
<div style="padding-top: 1em;">
|
||||||
|
<table class="pure-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Trigger</th>
|
||||||
|
<th>Full Text</th>
|
||||||
|
<th>Author</th>
|
||||||
|
<th># Hits</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{{range .Entries}}
|
||||||
|
<tr>
|
||||||
|
<td>{{.Trigger}}</td>
|
||||||
|
<td>{{.FullText}}</td>
|
||||||
|
<td>{{.CreatedBy}}</td>
|
||||||
|
<td>{{.AccessCount}}</td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue