feat: use resources, renamed knyt -> knowyt
This commit is contained in:
parent
b3b7a61167
commit
1dfbd43e22
2
Makefile
2
Makefile
@ -39,4 +39,4 @@ run-standalone:
|
||||
clean:
|
||||
rm -rf client/dist/
|
||||
rm -rf client/.nuxt/
|
||||
rm -f server/knowyt
|
||||
$(MAKE) -C server clean
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "knyt",
|
||||
"name": "knowyt",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
@ -3,10 +3,11 @@ info:
|
||||
@perl -ne 'm/^([a-zA-Z0-9\-]+):/ && print(" $$1\n");' Makefile
|
||||
|
||||
build:
|
||||
cd src/ && go build -o ../knowyt knowyt.go
|
||||
$(MAKE) generate
|
||||
go build -o knowyt src/knowyt.go
|
||||
|
||||
run:
|
||||
cd src/ && go run knowyt.go
|
||||
go run src/knowyt.go
|
||||
|
||||
run-loop:
|
||||
pexec -R -c -e TARGET \
|
||||
@ -22,3 +23,13 @@ _run-endless-loop:
|
||||
|
||||
_run-inotify-restart:
|
||||
inotifyloop --exclude 'data/.*' . curl -s http://localhost:32039/__intern__/exit
|
||||
|
||||
clean:
|
||||
rm -f knowyt
|
||||
rm -f src/resources/*-generated.go
|
||||
|
||||
generate: src/resources/dist-generated.go
|
||||
|
||||
src/resources/dist-generated.go: $(shell find ../client/dist -type f)
|
||||
src/resources/dist-generated.go: src/resources/dist-build.go
|
||||
go generate src/resources/dist-build.go
|
||||
|
@ -1,9 +1,9 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"sirlab.de/go/knyt/applicationConfig"
|
||||
"sirlab.de/go/knyt/game"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/applicationConfig"
|
||||
"sirlab.de/go/knowyt/game"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) CollectQuotes(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) ContinueGame(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) DeletePlayer(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) FinishGame(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"sirlab.de/go/knyt/applicationConfig"
|
||||
"sirlab.de/go/knowyt/applicationConfig"
|
||||
)
|
||||
|
||||
func (app *Application) GetConfig() applicationConfig.ApplicationConfig {
|
||||
|
@ -2,7 +2,7 @@ package application
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sirlab.de/go/knyt/game"
|
||||
"sirlab.de/go/knowyt/game"
|
||||
)
|
||||
|
||||
func (app Application) GetGameById(id string) (*game.Game, error) {
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) GetGameInfo(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) GetQuotes(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -2,7 +2,7 @@ package application
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app Application) GetUserById(id string) (*user.User, error) {
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"sirlab.de/go/knyt/game"
|
||||
"sirlab.de/go/knowyt/game"
|
||||
)
|
||||
|
||||
func (app *Application) loadGameState(gm *game.Game, fileName string) error {
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"sirlab.de/go/knyt/game"
|
||||
"sirlab.de/go/knowyt/game"
|
||||
)
|
||||
|
||||
func (app Application) loadGames() error {
|
||||
|
@ -3,8 +3,8 @@ package application
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"sirlab.de/go/knyt/game"
|
||||
"sirlab.de/go/knyt/quote"
|
||||
"sirlab.de/go/knowyt/game"
|
||||
"sirlab.de/go/knowyt/quote"
|
||||
)
|
||||
|
||||
func (app Application) loadQuotes(gm *game.Game, dirName string) error {
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app Application) loadUsers() error {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) RemoveQuote(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) ResetGame(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path"
|
||||
"sirlab.de/go/knyt/game"
|
||||
"sirlab.de/go/knowyt/game"
|
||||
)
|
||||
|
||||
func (app *Application) saveGameState(gm *game.Game) error {
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"net/http"
|
||||
"path"
|
||||
"sirlab.de/go/knyt/game"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/game"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) SavePlayer(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"net/http"
|
||||
"path"
|
||||
"sirlab.de/go/knyt/game"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/game"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) SaveQuote(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) SaveSelection(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) SetGameName(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) StartGame(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"sirlab.de/go/knyt/applicationConfig"
|
||||
"sirlab.de/go/knyt/game"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/applicationConfig"
|
||||
"sirlab.de/go/knowyt/game"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
@ -3,7 +3,7 @@ package application
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) SyncHandler(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -2,7 +2,7 @@ package engine
|
||||
|
||||
import (
|
||||
"github.com/imkira/go-observer"
|
||||
"sirlab.de/go/knyt/syncdata"
|
||||
"sirlab.de/go/knowyt/syncdata"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -2,7 +2,7 @@ package engine
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sirlab.de/go/knyt/syncdata"
|
||||
"sirlab.de/go/knowyt/syncdata"
|
||||
)
|
||||
|
||||
func (eng *Engine) publish(populateSyncDataCb PopulateSyncDataCb) {
|
||||
|
@ -3,7 +3,7 @@ package engine
|
||||
import (
|
||||
"github.com/imkira/go-observer"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/syncdata"
|
||||
"sirlab.de/go/knowyt/syncdata"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/syncdata"
|
||||
"sirlab.de/go/knowyt/syncdata"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"sirlab.de/go/knyt/quote"
|
||||
"sirlab.de/go/knowyt/quote"
|
||||
)
|
||||
|
||||
func (gm *Game) AddQuote(qu *quote.Quote) {
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"sirlab.de/go/knyt/engine"
|
||||
"sirlab.de/go/knyt/quote"
|
||||
"sirlab.de/go/knowyt/engine"
|
||||
"sirlab.de/go/knowyt/quote"
|
||||
)
|
||||
|
||||
func NewGameFromFile(id, fileName string) (*Game, error) {
|
||||
|
@ -2,7 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sirlab.de/go/knyt/quote"
|
||||
"sirlab.de/go/knowyt/quote"
|
||||
)
|
||||
|
||||
func (gm *Game) getQuoteById(id string) (*quote.Quote, error) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (gm *Game) GetQuotesInfoByUser(usr *user.User) *QuotesInfo {
|
||||
|
@ -2,7 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (gm *Game) EventPlayerJoins(usr *user.User) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"sirlab.de/go/knyt/syncdata"
|
||||
"sirlab.de/go/knowyt/syncdata"
|
||||
"sort"
|
||||
)
|
||||
|
||||
|
@ -2,7 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sirlab.de/go/knyt/syncdata"
|
||||
"sirlab.de/go/knowyt/syncdata"
|
||||
)
|
||||
|
||||
func (gm *Game) populateGetRoundInfo() *syncdata.RoundInfo {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"sirlab.de/go/knyt/syncdata"
|
||||
"sirlab.de/go/knowyt/syncdata"
|
||||
)
|
||||
|
||||
func (gm *Game) populateSyncDataCb(syncData *syncdata.SyncData) {
|
||||
|
@ -3,7 +3,7 @@ package game
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sirlab.de/go/knyt/quote"
|
||||
"sirlab.de/go/knowyt/quote"
|
||||
)
|
||||
|
||||
func (gm *Game) RemoveQuote(fileName, usrId, quoteId string) error {
|
||||
|
@ -2,7 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sirlab.de/go/knyt/quote"
|
||||
"sirlab.de/go/knowyt/quote"
|
||||
)
|
||||
|
||||
func (gm *Game) CreateQuote(fileName, usrId, quoteId, quoteText string) error {
|
||||
|
@ -2,7 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (gm *Game) SaveSelection(usr *user.User, selection string) {
|
||||
|
@ -3,7 +3,7 @@ package game
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"sirlab.de/go/knyt/quote"
|
||||
"sirlab.de/go/knowyt/quote"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"sirlab.de/go/knyt/engine"
|
||||
"sirlab.de/go/knyt/quote"
|
||||
"sirlab.de/go/knowyt/engine"
|
||||
"sirlab.de/go/knowyt/quote"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
module sirlab.de/go/knyt
|
||||
module sirlab.de/go/knowyt
|
||||
|
||||
go 1.16
|
||||
|
||||
|
@ -2,8 +2,8 @@ package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/application"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/application"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
type HandlerFunc func(http.ResponseWriter, *http.Request)
|
||||
|
31
server/src/handler/filehandler.go
Normal file
31
server/src/handler/filehandler.go
Normal file
@ -0,0 +1,31 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"mime"
|
||||
"net/http"
|
||||
"path"
|
||||
"sirlab.de/go/knowyt/resources"
|
||||
)
|
||||
|
||||
func FileHandler(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
uri := req.URL.String()
|
||||
if uri[len(uri)-1] == '/' {
|
||||
uri += "index.html"
|
||||
}
|
||||
uri = uri[1:]
|
||||
data, err := Resources.Asset(uri)
|
||||
if err != nil {
|
||||
fmt.Printf("%s: %v\n", uri, err)
|
||||
http.NotFoundHandler().ServeHTTP(w, req)
|
||||
return
|
||||
}
|
||||
|
||||
mimeType := mime.TypeByExtension(path.Ext(uri))
|
||||
if mimeType == "" {
|
||||
mimeType = "text/plain"
|
||||
}
|
||||
w.Header().Add("Content-Type", mimeType)
|
||||
fmt.Fprint(w, string(data))
|
||||
}
|
@ -3,12 +3,12 @@ package handler
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
func (authMux *AuthMux) createCookie() *http.Cookie {
|
||||
return &http.Cookie{
|
||||
Name: "knyt-auth",
|
||||
Name: "knowyt-auth",
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
MaxAge: -1,
|
||||
|
@ -3,7 +3,7 @@ package handler
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -25,7 +25,7 @@ func (authMux *AuthMux) accessDenied(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (authMux *AuthMux) getUserFromSession(r *http.Request) (*user.User, error) {
|
||||
authCookie, err := r.Cookie("knyt-auth")
|
||||
authCookie, err := r.Cookie("knowyt-auth")
|
||||
if err != nil {
|
||||
fmt.Printf("%v\n", err)
|
||||
return nil, fmt.Errorf("invalid cookie")
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
"sirlab.de/go/knowyt/user"
|
||||
)
|
||||
|
||||
type UserInfoJson struct {
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"sirlab.de/go/knyt/application"
|
||||
"sirlab.de/go/knyt/applicationConfig"
|
||||
"sirlab.de/go/knyt/handler"
|
||||
"sirlab.de/go/knowyt/application"
|
||||
"sirlab.de/go/knowyt/applicationConfig"
|
||||
"sirlab.de/go/knowyt/handler"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -38,8 +38,7 @@ func main() {
|
||||
mux.PrivateHandleFunc("/api/removeQuote", app.RemoveQuote)
|
||||
|
||||
// default handler
|
||||
fsHandler := http.FileServer(http.Dir("../../client/dist/"))
|
||||
mux.PublicHandle("/", fsHandler)
|
||||
http.HandleFunc("/", handler.FileHandler)
|
||||
|
||||
// start listening
|
||||
fmt.Printf("http://localhost:%d/\n", mux.Port)
|
||||
|
1
server/src/resources/.gitignore
vendored
Normal file
1
server/src/resources/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*-generated.go
|
3
server/src/resources/dist-build.go
Normal file
3
server/src/resources/dist-build.go
Normal file
@ -0,0 +1,3 @@
|
||||
package Resources
|
||||
|
||||
//go:generate go-bindata -pkg Resources -o dist-generated.go --prefix ../../../client/dist/ ../../../client/dist/ ../../../client/dist/_nuxt/ ../../../client/dist/play ../../../client/dist/admin ../../../client/dist/fonts/dosis ../../../client/dist/fonts/wendy-one
|
Loading…
Reference in New Issue
Block a user