[FORDJ] Add Playground
This commit is contained in:
parent
8d168cb945
commit
d350e61ef7
4 changed files with 34 additions and 0 deletions
25
routers/web/playground.go
Normal file
25
routers/web/playground.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2024 Milovann Yanatchkov
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/services/context"
|
||||
)
|
||||
|
||||
const (
|
||||
// tplPlayground home page template
|
||||
tplPlayground base.TplName = "playground/playground"
|
||||
)
|
||||
|
||||
func Playground(ctx *context.Context) {
|
||||
if ctx.IsSigned {
|
||||
ctx.Data["UserName"] = ctx.Doer.DisplayName()
|
||||
}
|
||||
|
||||
ctx.Data["PageIsPlayground"] = true
|
||||
ctx.HTML(http.StatusOK, tplPlayground)
|
||||
}
|
||||
|
|
@ -444,6 +444,7 @@ func registerRoutes(m *web.Route) {
|
|||
// Especially some AJAX requests, we can reduce middleware number to improve performance.
|
||||
|
||||
m.Get("/", Home)
|
||||
m.Get("/playground", Playground)
|
||||
m.Get("/sitemap.xml", sitemapEnabled, ignExploreSignIn, HomeSitemap)
|
||||
m.Group("/.well-known", func() {
|
||||
m.Get("/openid-configuration", auth.OIDCWellKnown)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
{{end}}
|
||||
{{end}}
|
||||
<a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/repos">{{ctx.Locale.Tr "explore"}}</a>
|
||||
<a class="item{{if .PageIsPlayground}} active{{end}}" href="{{AppSubUrl}}/playground">Playground</a>
|
||||
{{else if .IsLandingPageOrganizations}}
|
||||
<a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/organizations">{{ctx.Locale.Tr "explore"}}</a>
|
||||
{{else}}
|
||||
|
|
|
|||
7
templates/playground/playground.tmpl
Normal file
7
templates/playground/playground.tmpl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{{template "base/head" .}}
|
||||
{{if .IsSigned}}
|
||||
User : {{.UserName}}
|
||||
{{else}}
|
||||
User : None
|
||||
{{end}}
|
||||
{{template "base/footer" .}}
|
||||
Loading…
Add table
Reference in a new issue