Skip to content

Commit

Permalink
Merge pull request #589 from cj123/track-list-fix
Browse files Browse the repository at this point in the history
ensure all track image urls are accessed with the correct slash, chec…
  • Loading branch information
cj123 authored Oct 25, 2019
2 parents 8ebd715 + e647d28 commit 276fb3c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ v1.5.2

Fixes:

* Fixes track pages for users running Server Manager on Windows
* Fixes an issue where Championships with 'Any Car Model' specified would fail to find a class for a car.
* Fixes an issue where cars with no skins might prevent a race from starting.
* Fixes an issue where Scheduled Championship Race Weekend sessions caused the calendar to error on load.
* Fixes the Race Weekend "Start after previous session" checkbox not displaying correctly.

---

v1.5.1
------

Expand Down
12 changes: 9 additions & 3 deletions content_tracks.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@ type Track struct {
MetaData TrackMetaData
}

const defaultTrackURL = "/static/img/no-preview-general.png"

func (t Track) GetImagePath() string {
if len(t.Layouts) == 0 {
return defaultTrackURL
}

for _, layout := range t.Layouts {
if layout == defaultLayoutName || layout == "" {
return filepath.Join("content", "tracks", t.Name, "ui", "preview.png")
return filepath.ToSlash(filepath.Join("content", "tracks", t.Name, "ui", "preview.png"))
}
}

return filepath.Join("content", "tracks", t.Name, "ui", t.Layouts[0], "preview.png")
return filepath.ToSlash(filepath.Join("content", "tracks", t.Name, "ui", t.Layouts[0], "preview.png"))
}

func (t *Track) LoadMetaData() error {
Expand Down Expand Up @@ -88,7 +94,7 @@ func trackLayoutURL(track, layout string) string {
_, err := os.Stat(filepath.Join(ServerInstallPath, layoutPath))

if err != nil {
return defaultSkinURL
return defaultTrackURL
}

return "/" + filepath.ToSlash(layoutPath)
Expand Down

0 comments on commit 276fb3c

Please sign in to comment.