Starting web interface
This commit is contained in:
parent
38fd0ab7cd
commit
7d585ce02e
4
main.go
4
main.go
|
@ -13,9 +13,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"github.com/layeh/gopus"
|
"github.com/layeh/gopus"
|
||||||
"github.com/layeh/gumble/gumble"
|
"github.com/layeh/gumble/gumble"
|
||||||
|
@ -230,5 +230,7 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Webserver()
|
||||||
|
|
||||||
<-dj.keepAlive
|
<-dj.keepAlive
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,7 @@ var youtubeVideoPatterns = []string{
|
||||||
// YOUTUBE SERVICE
|
// YOUTUBE SERVICE
|
||||||
// ---------------
|
// ---------------
|
||||||
|
|
||||||
type YouTube struct {
|
type YouTube struct {}
|
||||||
}
|
|
||||||
|
|
||||||
// Name of the service
|
// Name of the service
|
||||||
func (y YouTube) ServiceName() string {
|
func (y YouTube) ServiceName() string {
|
||||||
|
|
|
@ -42,8 +42,9 @@ func (q *SongQueue) CurrentSong() Song {
|
||||||
|
|
||||||
// NextSong moves to the next Song in SongQueue. NextSong() removes the first Song in the queue.
|
// NextSong moves to the next Song in SongQueue. NextSong() removes the first Song in the queue.
|
||||||
func (q *SongQueue) NextSong() {
|
func (q *SongQueue) NextSong() {
|
||||||
|
if !isNil(q.CurrentSong().Playlist()) {
|
||||||
if s, err := q.PeekNext(); err == nil {
|
if s, err := q.PeekNext(); err == nil {
|
||||||
if !isNil(q.CurrentSong().Playlist()) && !isNil(s.Playlist()) {
|
if !isNil(s.Playlist()) {
|
||||||
if q.CurrentSong().Playlist().ID() != s.Playlist().ID() {
|
if q.CurrentSong().Playlist().ID() != s.Playlist().ID() {
|
||||||
q.CurrentSong().Playlist().DeleteSkippers()
|
q.CurrentSong().Playlist().DeleteSkippers()
|
||||||
}
|
}
|
||||||
|
@ -51,6 +52,7 @@ func (q *SongQueue) NextSong() {
|
||||||
} else {
|
} else {
|
||||||
q.CurrentSong().Playlist().DeleteSkippers()
|
q.CurrentSong().Playlist().DeleteSkippers()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
q.queue = q.queue[1:]
|
q.queue = q.queue[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
35
web.go
Normal file
35
web.go
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package mumbledj
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Page struct {
|
||||||
|
Title string
|
||||||
|
Body []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Page) save() error {
|
||||||
|
filename := p.Title + ".txt"
|
||||||
|
return ioutil.WriteFile(filename, p.Body, 0600)
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadPage(title string) (*Page, error) {
|
||||||
|
filename := title + ".txt"
|
||||||
|
body, err := ioutil.ReadFile(filename)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &Page{Title: title, Body: body}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
|
||||||
|
}
|
||||||
|
|
||||||
|
func Webserver(){
|
||||||
|
http.HandleFunc("/", handler)
|
||||||
|
http.ListenAndServe(":8080", nil)
|
||||||
|
}
|
Reference in a new issue