docs path fix in serve
This commit is contained in:
@@ -48,7 +48,7 @@ func (c *DocsController) ServeDocs(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
docs_base_dir := c.fileService.GetPath(targetRelease.DocsFolderPath)
|
||||
docs_base_dir := targetRelease.DocsFolderPath
|
||||
|
||||
if _, err := os.Stat(docs_base_dir); os.IsNotExist(err) {
|
||||
http.Error(w, fmt.Sprintf("Documentation for '%s' version '%s' not found.", name, version), http.StatusNotFound)
|
||||
@@ -58,6 +58,13 @@ func (c *DocsController) ServeDocs(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
fs := http.StripPrefix(fmt.Sprintf("/docs/%s/%s", name, version), http.FileServer(http.Dir(docs_base_dir)))
|
||||
prefix := fmt.Sprintf("/docs/%s/%s", name, version)
|
||||
|
||||
if r.URL.Path == prefix {
|
||||
http.Redirect(w, r, prefix+"/", http.StatusMovedPermanently)
|
||||
return
|
||||
}
|
||||
|
||||
fs := http.StripPrefix(prefix, http.FileServer(http.Dir(docs_base_dir)))
|
||||
fs.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ func (r *Router) Init() *chi.Mux {
|
||||
router.Get("/download/{name}/{version}/cartridge", r.downloadController.GetCartridge)
|
||||
router.Get("/play/{name}/{version}", r.playController.Play)
|
||||
router.Get("/play/{name}/{version}/content*", r.playController.ServeContent)
|
||||
router.Get("/docs/{name}/{version}", r.docsController.ServeDocs)
|
||||
router.Get("/docs/{name}/{version}/*", r.docsController.ServeDocs)
|
||||
|
||||
fs := http.FileServer(http.Dir("assets"))
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="btn-group d-flex justify-content-center" role="group" aria-label="Game controls">
|
||||
<button id="fullscreenButton" class="btn btn-secondary btn-sm">Fullscreen</button>
|
||||
{{if .WebPlayableRelease.DocsFolderPath}}
|
||||
<a href="/docs/{{.Software.Name}}/{{.WebPlayableRelease.Version}}" class="btn btn-info btn-sm">Docs</a>
|
||||
<a href="/docs/{{.Software.Name}}/{{.WebPlayableRelease.Version}}" class="btn btn-primary btn-sm">Docs</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -89,7 +89,7 @@
|
||||
<a href="/download/{{$.Software.Name}}/{{.Version}}/cartridge"
|
||||
class="btn btn-primary btn-sm">Cartridge</a>
|
||||
{{if .DocsFolderPath}}
|
||||
<a href="/docs/{{$.Software.Name}}/{{.Version}}" class="btn btn-info btn-sm">Docs</a>
|
||||
<a href="/docs/{{$.Software.Name}}/{{.Version}}" class="btn btn-primary btn-sm">Docs</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user