start migration to bundle format
This commit is contained in:
parent
64e270a868
commit
7fe9b99535
13 changed files with 378 additions and 470 deletions
129
test_template/pages/pyscript.typ
Normal file
129
test_template/pages/pyscript.typ
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
#import "@local/template-web:0.0.1": *
|
||||
|
||||
#let summ = summary(
|
||||
base-url: "http://test.example.com",
|
||||
path: "/pycript.html",
|
||||
title: "TeTyTe",
|
||||
page-label: <pyscript-label>,
|
||||
preview-image: image(
|
||||
"/assets/platypus.png",
|
||||
alt: "A drawing of a blue-ish round-ish platypus with big eyes, holding a laptop. This platypus is quite cute, but I might be biased.",
|
||||
),
|
||||
author: "Me!",
|
||||
tags: ("test", "html/css", "typst", "pyscript"),
|
||||
description: "Demonstrate how to use pyscript to run python in the browser",
|
||||
date: datetime(year: 1942, month: 4, day: 1),
|
||||
)
|
||||
|
||||
#show: webpage.with(
|
||||
..summ.template-args,
|
||||
logo: image(
|
||||
"/assets/platypus.png",
|
||||
alt: "A drawing of a blue-ish round-ish platypus with big eyes, holding a laptop. This platypus is quite cute, but I might be biased.",
|
||||
height: 100pt,
|
||||
width: 100pt, // TODO 0.15 regression? in 0.14 setting the height was enough
|
||||
),
|
||||
header: [
|
||||
= Showcase Pyscript
|
||||
Show how to run Python in the browser
|
||||
],
|
||||
footer: context [
|
||||
|
||||
#sym.copyright #document.date.display("[year]") Histausse \
|
||||
Please don't train AI on my stuff without explicit permission
|
||||
],
|
||||
site-name: "TTT",
|
||||
icon: "/img/platypus.png", // TODO: use <ico> somehow? probably not supported in 0.15
|
||||
menu: [
|
||||
- #link(<index-page>)[Home]
|
||||
- #link(<pyscript-page>)[Demo Pyscript]
|
||||
- #link(<cards-page>)[Demo the summary card system]
|
||||
],
|
||||
// Pyscript:
|
||||
pyscript-data-list: (
|
||||
"remote-2026.3.1": pyscript-data(
|
||||
"https://pyscript.net/releases/2026.3.1/core.js",
|
||||
additionnal-head-tags: {
|
||||
html.elem("script", attrs: (src: "/mini-coi.js")) // TODO: use <mini-coi> somehow? probably not supported in 0.15
|
||||
html.elem("link", attrs: (rel: "stylesheet", href: "https://pyscript.net/releases/2026.3.1/core.css"))
|
||||
},
|
||||
)
|
||||
),
|
||||
pyscript-version: "remote-2026.3.1",
|
||||
)
|
||||
|
||||
```python-run
|
||||
n = ""
|
||||
while not n.isnumeric():
|
||||
n = input("enter a valid number: ")
|
||||
|
||||
for i in range(1, int(n) + 1):
|
||||
if i % 3 == 0 and i % 5 == 0:
|
||||
print("plopliplop")
|
||||
elif i % 3 == 0:
|
||||
print("plop")
|
||||
elif i % 5 == 0:
|
||||
print("plip")
|
||||
else:
|
||||
print(i)
|
||||
```
|
||||
```python-run
|
||||
# /// script
|
||||
# # requires-python = ">=3.11" # not supported yet
|
||||
# dependencies = [
|
||||
# "rich",
|
||||
# ]
|
||||
#
|
||||
# [tool.pyscript]
|
||||
# repl = true
|
||||
# [tool.pyscript.files]
|
||||
# "https://peps.python.org/api/peps.json" = "./peps.json"
|
||||
# ///
|
||||
|
||||
import json
|
||||
from rich.pretty import pprint
|
||||
|
||||
with open("./peps.json") as fd:
|
||||
data = json.load(fd)
|
||||
pprint([(k, v["title"]) for k, v in data.items()][:10])
|
||||
# >>> print(data["723"]["title"])
|
||||
# Inline script metadata
|
||||
```
|
||||
|
||||
```python-run
|
||||
# /// script
|
||||
# # requires-python = ">=3.11" # not supported yet
|
||||
# dependencies = [
|
||||
# "rich",
|
||||
# ]
|
||||
#
|
||||
# [tool.pyscript]
|
||||
# repl = true
|
||||
# hide-meta = true
|
||||
# [tool.pyscript.files]
|
||||
# "https://peps.python.org/api/peps.json" = "./peps.json"
|
||||
# ///
|
||||
# setting tool.pyscript.hide-meta to true will hide the `/// script` section
|
||||
import json
|
||||
from rich.pretty import pprint
|
||||
|
||||
with open("./peps.json") as fd:
|
||||
data = json.load(fd)
|
||||
pprint([(k, v["title"]) for k, v in data.items()][:10])
|
||||
# >>> print(data["723"]["title"])
|
||||
# Inline script metadata
|
||||
```
|
||||
|
||||
```python-run
|
||||
# /// script
|
||||
# dependencies = [
|
||||
# "pygame-ce",
|
||||
# "./python-packages/isn_s_cube-0.1.0-py3-none-any.whl"
|
||||
# ]
|
||||
# [tool.pyscript]
|
||||
# pygame = true
|
||||
# ///
|
||||
from isn_s_cube import wasm
|
||||
await wasm()
|
||||
```
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue