mirror of https://github.com/dirtbags/moth.git
go fmt
This commit is contained in:
parent
8771cf9d4f
commit
8af56b515d
|
@ -106,7 +106,7 @@ func (ctx *Instance) answerHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
pointstr := req.FormValue("points")
|
pointstr := req.FormValue("points")
|
||||||
answer := req.FormValue("answer")
|
answer := req.FormValue("answer")
|
||||||
|
|
||||||
if ! ctx.ValidTeamId(teamId) {
|
if !ctx.ValidTeamId(teamId) {
|
||||||
respond(
|
respond(
|
||||||
w, req, JSendFail,
|
w, req, JSendFail,
|
||||||
"Invalid team ID",
|
"Invalid team ID",
|
||||||
|
@ -251,7 +251,7 @@ func (ctx *Instance) staticHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *Instance) manifestHandler(w http.ResponseWriter, req *http.Request) {
|
func (ctx *Instance) manifestHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
if (! ctx.Runtime.export_manifest) {
|
if !ctx.Runtime.export_manifest {
|
||||||
http.Error(w, "Endpoint disabled", http.StatusForbidden)
|
http.Error(w, "Endpoint disabled", http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ func (ctx *Instance) manifestHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.Method == http.MethodHead) {
|
if req.Method == http.MethodHead {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -273,13 +273,13 @@ func (ctx *Instance) manifestHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
// Pack up the theme files
|
// Pack up the theme files
|
||||||
theme_root_re := regexp.MustCompile(fmt.Sprintf("^%s/", ctx.ThemeDir))
|
theme_root_re := regexp.MustCompile(fmt.Sprintf("^%s/", ctx.ThemeDir))
|
||||||
filepath.Walk(ctx.ThemeDir, func (path string, info os.FileInfo, err error) error {
|
filepath.Walk(ctx.ThemeDir, func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! info.IsDir() { // Only package up files
|
if !info.IsDir() { // Only package up files
|
||||||
localized_path := theme_root_re.ReplaceAllLiteralString( path, "")
|
localized_path := theme_root_re.ReplaceAllLiteralString(path, "")
|
||||||
manifest = append(manifest, localized_path)
|
manifest = append(manifest, localized_path)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -291,9 +291,9 @@ func (ctx *Instance) manifestHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
for _, file := range category.zf.File {
|
for _, file := range category.zf.File {
|
||||||
parts := strings.Split(file.Name, "/")
|
parts := strings.Split(file.Name, "/")
|
||||||
|
|
||||||
if (parts[0] == "content") { // Only pick up content files, not thing like map.txt
|
if parts[0] == "content" { // Only pick up content files, not thing like map.txt
|
||||||
for _, puzzlemap := range category.puzzlemap { // Figure out which puzzles are currently unlocked
|
for _, puzzlemap := range category.puzzlemap { // Figure out which puzzles are currently unlocked
|
||||||
if (puzzlemap.Path == parts[1] && puzzlemap.Points <= ctx.MaxPointsUnlocked[category_name]) {
|
if puzzlemap.Path == parts[1] && puzzlemap.Points <= ctx.MaxPointsUnlocked[category_name] {
|
||||||
|
|
||||||
manifest = append(manifest, path.Join("content", category_name, path.Join(parts[1:]...)))
|
manifest = append(manifest, path.Join("content", category_name, path.Join(parts[1:]...)))
|
||||||
break
|
break
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func (pm *PuzzleMap) MarshalJSON() ([]byte, error) {
|
func (pm *PuzzleMap) MarshalJSON() ([]byte, error) {
|
||||||
if pm == nil {
|
if pm == nil {
|
||||||
return []byte("null"), nil
|
return []byte("null"), nil
|
||||||
|
@ -35,7 +34,6 @@ func (ctx *Instance) generatePuzzleList() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ret := map[string][]PuzzleMap{}
|
ret := map[string][]PuzzleMap{}
|
||||||
for catName, mb := range ctx.categories {
|
for catName, mb := range ctx.categories {
|
||||||
filtered_puzzlemap := make([]PuzzleMap, 0, 30)
|
filtered_puzzlemap := make([]PuzzleMap, 0, 30)
|
||||||
|
@ -273,11 +271,11 @@ func (ctx *Instance) isEnabled() bool {
|
||||||
func (ctx *Instance) UpdateConfig() {
|
func (ctx *Instance) UpdateConfig() {
|
||||||
// Handle export manifest
|
// Handle export manifest
|
||||||
if _, err := os.Stat(ctx.StatePath("export_manifest")); err == nil {
|
if _, err := os.Stat(ctx.StatePath("export_manifest")); err == nil {
|
||||||
if (! ctx.Runtime.export_manifest) {
|
if !ctx.Runtime.export_manifest {
|
||||||
log.Print("Enabling manifest export")
|
log.Print("Enabling manifest export")
|
||||||
ctx.Runtime.export_manifest = true
|
ctx.Runtime.export_manifest = true
|
||||||
}
|
}
|
||||||
} else if (ctx.Runtime.export_manifest) {
|
} else if ctx.Runtime.export_manifest {
|
||||||
log.Print("Disabling manifest export")
|
log.Print("Disabling manifest export")
|
||||||
ctx.Runtime.export_manifest = false
|
ctx.Runtime.export_manifest = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ type PuzzleMap struct {
|
||||||
Path string
|
Path string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type Mothball struct {
|
type Mothball struct {
|
||||||
zf *zip.ReadCloser
|
zf *zip.ReadCloser
|
||||||
filename string
|
filename string
|
||||||
|
@ -188,7 +187,6 @@ func (m *Mothball) Refresh() error {
|
||||||
m.puzzlemap = pm
|
m.puzzlemap = pm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue