Navigation for Web UI finally available
This commit is contained in:
parent
a66ed5ee1e
commit
27be1626a7
|
@ -10,13 +10,14 @@ Visit [https://airhorn.solutions/](https://airhorn.solutions/).
|
|||
Since there is not yet any command to request a list of available sound files, just take a look in `audio/`.
|
||||
They are named after the scheme `command_soundname.dca` and would result in a channel command like `!command soundname` like in `!airhorn default`.
|
||||
Typing only the `!command` without an argument results in a random sound of this command's collection.
|
||||
- Comfortable web interface to trigger sounds
|
||||
- Automatically detect all `.dca` files in `audio/`
|
||||
- Optional sound descriptions via `.txt` files in `audio/` with the same name as the soundfile
|
||||
|
||||
## Installation
|
||||
Coming soon.
|
||||
## To do
|
||||
- ~~Remove hardcoded sound collections and let the bot build them himself by scanning the `audio/` folder for files.~~
|
||||
- ~~Build-in web interface to trigger sounds. ~~
|
||||
~~The idea is to be able to have a detailed listing of available sound files in a responsive interface and a simple button to trigger the sound playback in a channel.~~
|
||||
- more web interface enhancements
|
||||
|
||||
## Known issues
|
||||
- none at the moment
|
||||
|
|
|
@ -54,8 +54,9 @@
|
|||
<div id="navbar" class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="#">Home</a></li>
|
||||
<li><a href="#about">About</a></li>
|
||||
<li><a href="#contact">Contact</a></li>
|
||||
{{ range . }}
|
||||
<li><a href="#{{ . }}">{{ . }}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
|
|
|
@ -1 +1 @@
|
|||
<div class="col-sm-3 text-center"><div class="sounditem"><div data-toggle="tooltip" data-placement="top" title="{{ .Itemtext }}">{{ .Itemcommand }} {{ .Itemsoundname }}<br/>{{ .Itemshorttext }}<br/><a class="btn btn-primary" href="javascript:playSound('{{ .Itemcommand }}', '{{ .Itemsoundname }}')" role="button">Play!</a><br/></div></div></div>
|
||||
<div class="col-sm-3 text-center"><div class="sounditem"><div data-toggle="tooltip" data-placement="top" title="{{ .Itemtext }}">{{ .Itemcommand }} {{ .Itemsoundname }}<br/>{{ .Itemshorttext }}<br/><button class="btn btn-primary" onclick="javascript:playSound('{{ .Itemcommand }}', '{{ .Itemsoundname }}')" role="button" id="sounditem">Play!</button><br/></div></div></div>
|
||||
|
|
26
webserver.go
26
webserver.go
|
@ -89,22 +89,22 @@ func handlePlaySound(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
if user != nil && guild != nil && sound != nil && soundCollection != nil {
|
||||
go enqueuePlay(user, guild, soundCollection, sound)
|
||||
}
|
||||
if user != nil && guild != nil && sound == nil && soundCollection != nil {
|
||||
go enqueuePlay(user, guild, soundCollection, soundCollection.Random())
|
||||
if sound != nil {
|
||||
go enqueuePlay(user, guild, soundCollection, sound)
|
||||
} else {
|
||||
go enqueuePlay(user, guild, soundCollection, soundCollection.Random())
|
||||
}
|
||||
http.Error(w, http.StatusText(200), 200)
|
||||
} else {
|
||||
http.Error(w, http.StatusText(500), 500)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func handleMain(w http.ResponseWriter, r *http.Request) {
|
||||
session, _ := store.Get(r, "gidbig-session")
|
||||
if session.Values["discordUsername"] != nil {
|
||||
err := tmpls["internal.html"].ExecuteTemplate(w, "header", map[string]interface{}{})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
var prefixes []string
|
||||
var si []SoundItem
|
||||
for _, sc := range COLLECTIONS {
|
||||
var newSoundItemRandom SoundItem
|
||||
|
@ -115,6 +115,7 @@ func handleMain(w http.ResponseWriter, r *http.Request) {
|
|||
Itemtext: "random",
|
||||
Itemshorttext: "random",
|
||||
}
|
||||
prefixes = append(prefixes, sc.Prefix)
|
||||
si = append(si, newSoundItemRandom)
|
||||
for _, snd := range sc.Sounds {
|
||||
var newSoundItem SoundItem
|
||||
|
@ -140,6 +141,11 @@ func handleMain(w http.ResponseWriter, r *http.Request) {
|
|||
si = append(si, newSoundItem)
|
||||
}
|
||||
}
|
||||
err := tmpls["internal.html"].ExecuteTemplate(w, "header", prefixes)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
var currentPrefix string = ""
|
||||
var i int = 0
|
||||
|
|
Reference in New Issue