Description files for audio and new webui feature for backgrounds
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
<div class="row">
|
||||||
|
{{ range . }}
|
||||||
|
<div class="col-sm-3 text-center">{{ .Itemtext }}<br/><a class="btn btn-primary" href="javascript:playSound('{{ .Itemcommand }}', '{{ .Itemsoundname }}')" role="button">Play!</a></div>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
body {
|
body {
|
||||||
padding-top: 50px;
|
padding-top: 50px;
|
||||||
}
|
}
|
||||||
.itembuffer {
|
.sounditem {
|
||||||
margin: 1px;
|
margin: 1px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
<div class="col-sm-3 text-center"><div class="itembuffer">{{ .Itemtext }}<br/><a class="btn btn-default" href="javascript:playSound('{{ .Itemcommand }}', '{{ .Itemsoundname }}')" role="button">Play!</a></div></div>
|
<div class="col-sm-3 text-center"><div class="sounditem" style="background-image: linear-gradient(rgba(255,255,255,0.8),rgba(255,255,255,0.8)), url(/static/img/{{ .Itemprefix }}.jpg); background-size: 100%;" data-toggle="tooltip" title="{{ .Itemtext }}">{{ .Itemcommand }} {{ .Itemsoundname }}<br/>{{ .Itemshorttext }}<br/><a class="btn btn-default" href="javascript:playSound('{{ .Itemcommand }}', '{{ .Itemsoundname }}')" role="button">Play!</a></div></div>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<div class="row">
|
||||||
|
{{ range . }}
|
||||||
|
<div class="col-sm-3 text-center">{{ .Itemtext }}<br/><a class="btn btn-primary" href="javascript:playSound('{{ .Itemcommand }}', '{{ .Itemsoundname }}')" role="button">Play!</a></div>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
+24
-2
@@ -1,11 +1,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
@@ -38,10 +40,13 @@ var (
|
|||||||
store *sessions.CookieStore
|
store *sessions.CookieStore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SoundItem is used to represent a sound of our COLLECTIONS for html generation
|
||||||
type SoundItem struct {
|
type SoundItem struct {
|
||||||
|
Itemprefix string
|
||||||
Itemcommand string
|
Itemcommand string
|
||||||
Itemsoundname string
|
Itemsoundname string
|
||||||
Itemtext string
|
Itemtext string
|
||||||
|
Itemshorttext string
|
||||||
}
|
}
|
||||||
|
|
||||||
// startWebServer
|
// startWebServer
|
||||||
@@ -63,6 +68,7 @@ func startWebServer(port string, ci string, cs string, redirectURL string) {
|
|||||||
r.HandleFunc("/discordCallback", handlediscordCallback)
|
r.HandleFunc("/discordCallback", handlediscordCallback)
|
||||||
r.HandleFunc("/playsound", handlePlaySound)
|
r.HandleFunc("/playsound", handlePlaySound)
|
||||||
http.Handle("/", r)
|
http.Handle("/", r)
|
||||||
|
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
|
||||||
http.ListenAndServe(":"+port, nil)
|
http.ListenAndServe(":"+port, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,11 +102,27 @@ func handleMain(w http.ResponseWriter, r *http.Request) {
|
|||||||
var si []SoundItem
|
var si []SoundItem
|
||||||
for _, sc := range COLLECTIONS {
|
for _, sc := range COLLECTIONS {
|
||||||
for _, snd := range sc.Sounds {
|
for _, snd := range sc.Sounds {
|
||||||
si = append(si, SoundItem{
|
var newSoundItem SoundItem
|
||||||
|
newSoundItem = SoundItem{
|
||||||
|
Itemprefix: sc.Prefix,
|
||||||
Itemcommand: "!" + sc.Prefix,
|
Itemcommand: "!" + sc.Prefix,
|
||||||
Itemsoundname: snd.Name,
|
Itemsoundname: snd.Name,
|
||||||
Itemtext: "!" + sc.Prefix + " " + snd.Name,
|
Itemtext: "!" + sc.Prefix + " " + snd.Name,
|
||||||
})
|
Itemshorttext: "!" + sc.Prefix + " " + snd.Name,
|
||||||
|
}
|
||||||
|
file, e := os.Open(fmt.Sprintf("audio/%v_%v.txt", sc.Prefix, snd.Name))
|
||||||
|
if e == nil {
|
||||||
|
scanner := bufio.NewScanner(file)
|
||||||
|
scanner.Scan()
|
||||||
|
text := scanner.Text()
|
||||||
|
newSoundItem.Itemtext = text
|
||||||
|
if len(text) > 20 {
|
||||||
|
text = text[0:20]
|
||||||
|
text += "..."
|
||||||
|
}
|
||||||
|
newSoundItem.Itemshorttext = text
|
||||||
|
}
|
||||||
|
si = append(si, newSoundItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user