diff --git a/models/playground/player.go b/models/playground/player.go new file mode 100644 index 0000000000..477e63d064 --- /dev/null +++ b/models/playground/player.go @@ -0,0 +1,19 @@ +package playground + +import ( + "context" + + "code.gitea.io/gitea/models/db" +) + +type Player struct { + ID int64 `xorm:"pk autoincr"` +} + +func createPlayer(ctx context.Context, p *Player) (err error) { + return err +} + +func init() { + db.RegisterModel(new(Player)) +} diff --git a/routers/web/playground.go b/routers/web/playground.go new file mode 100644 index 0000000000..443a06b1c3 --- /dev/null +++ b/routers/web/playground.go @@ -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" +) + +func Playground(ctx *context.Context) { + if ctx.IsSigned { + ctx.Data["UserName"] = ctx.Doer.DisplayName() + } + + ctx.Data["PageIsPlayground"] = true + ctx.HTML(http.StatusOK, tplPlayground) +} diff --git a/routers/web/web.go b/routers/web/web.go index 20d5376cfe..bea5746ff3 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -470,6 +470,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) diff --git a/templates/playground.tmpl b/templates/playground.tmpl new file mode 100644 index 0000000000..183e31d213 --- /dev/null +++ b/templates/playground.tmpl @@ -0,0 +1,7 @@ +{{template "base/head" .}} +{{if .IsSigned}} +User : {{.UserName}} +{{else}} +User : None +{{end}} +{{template "base/footer" .}}