[SLOYD] Add pyscript
This commit is contained in:
parent
7a09e9ca7e
commit
2bb6f391db
5 changed files with 23 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -472,6 +472,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)
|
||||
|
|
|
|||
1
templates/playground/footer.tmpl
Normal file
1
templates/playground/footer.tmpl
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
11
templates/playground/pyscript.tmpl
Normal file
11
templates/playground/pyscript.tmpl
Normal 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" .}}
|
||||
Loading…
Add table
Reference in a new issue