mirror of https://github.com/velour/catbase.git
Removing secondary URL
This commit is contained in:
parent
b5003e82b5
commit
42e17ae755
|
@ -449,20 +449,11 @@ func (p *FactoidPlugin) BotMessage(message bot.Message) bool {
|
|||
// Register any web URLs desired
|
||||
func (p *FactoidPlugin) RegisterWeb() *string {
|
||||
http.HandleFunc("/factoid/req", p.serveQuery)
|
||||
http.HandleFunc("/factoid", p.serveIndex)
|
||||
http.HandleFunc("/factoid", p.serveQuery)
|
||||
tmp := "/factoid"
|
||||
return &tmp
|
||||
}
|
||||
|
||||
// Serve up the index template
|
||||
func (p *FactoidPlugin) serveIndex(w http.ResponseWriter, r *http.Request) {
|
||||
t, err := template.New("factoidIndex").Parse(factoidIndex)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
t.Execute(w, nil)
|
||||
}
|
||||
|
||||
func (p *FactoidPlugin) serveQuery(w http.ResponseWriter, r *http.Request) {
|
||||
context := make(map[string]interface{})
|
||||
if e := r.PostFormValue("entry"); e != "" {
|
||||
|
@ -471,8 +462,6 @@ func (p *FactoidPlugin) serveQuery(w http.ResponseWriter, r *http.Request) {
|
|||
context["Count"] = fmt.Sprintf("%d", len(entries))
|
||||
context["Entries"] = entries
|
||||
context["Search"] = e
|
||||
} else {
|
||||
context["Error"] = "Something's fucked."
|
||||
}
|
||||
t, err := template.New("factoidIndex").Parse(factoidIndex)
|
||||
if err != nil {
|
||||
|
|
|
@ -11,7 +11,7 @@ var factoidIndex string = `
|
|||
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.1.0/pure-min.css">
|
||||
</head>
|
||||
<div>
|
||||
<form action="/factoid/req" method="POST" class="pure-form">
|
||||
<form action="/factoid" method="POST" class="pure-form">
|
||||
<fieldset>
|
||||
<legend>Search for a factoid</legend>
|
||||
<input type="text" name="entry" placeholder="trigger" value="{{.Search}}" />
|
||||
|
|
Loading…
Reference in New Issue