forgejo/routers/web/playground.go
2025-09-22 10:57:37 +02:00

37 lines
854 B
Go

// 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 base.TplName = "playground/playground"
tplPlaygroundReplIframe base.TplName = "playground/repl-iframe"
tplPlaygroundPyScript base.TplName = "playground/pyscript"
)
func PlaygroundReplIframe(ctx *context.Context) {
ctx.Data["PageIsPlayground"] = true
ctx.HTML(http.StatusOK, tplPlaygroundReplIframe)
}
func PlaygroundPyScript(ctx *context.Context) {
ctx.Data["PageIsPlayground"] = true
ctx.HTML(http.StatusOK, tplPlaygroundPyScript)
}
func Playground(ctx *context.Context) {
if ctx.IsSigned {
ctx.Data["UserName"] = ctx.Doer.DisplayName()
}
ctx.Data["PageIsPlayground"] = true
ctx.HTML(http.StatusOK, tplPlayground)
}