[SLOYD] Add pyscript

This commit is contained in:
Milovann Yanatchkov 2024-04-15 20:19:44 +02:00
parent 4f89496b37
commit 740eef6b4c
6 changed files with 27 additions and 0 deletions

View file

@ -116,6 +116,10 @@ FORGEJO_VERSION_API ?= ${FORGEJO_VERSION}
show-version-api:
@echo ${FORGEJO_VERSION_API}
RELEASE_VERSION = 1.22
MAKE_VERSION = 1.22
FORGEJO_VERSION = 1.22
LDFLAGS := $(LDFLAGS) -X "main.ReleaseVersion=$(RELEASE_VERSION)" -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(FORGEJO_VERSION)" -X "main.Tags=$(TAGS)" -X "main.ForgejoVersion=$(FORGEJO_VERSION_API)"
LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64

View file

@ -13,6 +13,7 @@ import (
const (
tplPlayground base.TplName = "playground/playground"
tplPlaygroundReplIframe base.TplName = "playground/repl-iframe"
tplPlaygroundPyScript base.TplName = "playground/pyscript"
)
func PlaygroundReplIframe(ctx *context.Context) {
@ -20,6 +21,12 @@ func PlaygroundReplIframe(ctx *context.Context) {
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()

View file

@ -433,6 +433,7 @@ func registerRoutes(m *web.Route) {
m.Get("/", Home)
m.Get("/playground", Playground)
m.Get("/playground/repl-iframe", PlaygroundReplIframe)
m.Get("/playground/pyscript", PlaygroundPyScript)
m.Get("/sitemap.xml", sitemapEnabled, ignExploreSignIn, HomeSitemap)
m.Group("/.well-known", func() {
m.Get("/openid-configuration", auth.OIDCWellKnown)

View file

@ -0,0 +1 @@

View file

@ -7,6 +7,9 @@
<a class="{{if .IsRepoFlagsPage}}active {{end}}item" href="{{AppSubUrl}}/playground/repl-iframe">
{{svg "octicon-terminal"}} Repl
</a>
<a class="{{if .IsRepoFlagsPage}}active {{end}}item" href="{{AppSubUrl}}/playground/pyscript">
{{svg "octicon-paper-airplane"}} PyScript
</a>
</div>
</overflow-menu>

View file

@ -0,0 +1,11 @@
{{template "base/head" .}}
{{template "playground/header" .}}
<input type="text" id="english" placeholder="Type English here..." />
<button py-click="translate_english">Translate</button>
<div id="output"></div>
<script type="py" src="{{AssetUrlPrefix}}/pyscript/main.py" config="{{AssetUrlPrefix}}/pyscript/pyscript.json"></script>
{{template "base/footer" .}}