Skip to content

Commit 3586139

Browse files
authored
Update PyCon.net homepage for PyCon 2024 (#64)
* First pass. A real PyScript terminal, typing code, updated copy. * Outgoing links target=_blank * Fixed character bleeding. * Firefox on mobile fixes. * Minor Pythonic update. * Check on SAB. * Minor fixes.
1 parent 91f32e1 commit 3586139

File tree

4 files changed

+155
-57
lines changed

4 files changed

+155
-57
lines changed

assets/css/main.css

+6-5
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,11 @@ a.examples-block:hover {
457457
/* ----------------------------------
458458
Terminal interface
459459
-----------------------------------*/
460-
.terminal {
460+
.old-terminal {
461461
box-shadow: 1px 1px 40px rgb(0 0 0 / 30%);
462462
margin: 0 auto;
463463
max-width: 650px;
464+
display: none;
464465
}
465466

466467
.window-buttons {
@@ -537,7 +538,7 @@ a.examples-block:hover {
537538
animation: blink 500ms linear infinite alternate;
538539
} */
539540

540-
.terminal p {
541+
.old-terminal p {
541542
font-family: 'Hack Regular', monospace;
542543
font-size: 1em;
543544
left: 10%;
@@ -548,7 +549,7 @@ a.examples-block:hover {
548549
width: 0;
549550
}
550551

551-
.terminal span {
552+
.old-terminal span {
552553
color: #fff;
553554
font-weight: bold;
554555
}
@@ -664,7 +665,7 @@ a.examples-block:hover {
664665
Mobile layout
665666
-----------------------------------*/
666667
@media all and (max-width: 700px) {
667-
.terminal p {
668+
.old-terminal p {
668669
font-size: .8rem;
669670
left: 3%;
670671
}
@@ -760,4 +761,4 @@ a.examples-block:hover {
760761
.button.twitter:hover {
761762
background-color: #FDA803;
762763
color: #1D1D22;
763-
}
764+
}

index.html

+82-52
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4+
<script src="/mini-coi.js" scope="./"></script>
45
<meta charset="utf-8">
56
<meta name="viewport" content="width=device-width, initial-scale=1">
67

7-
<title>PyScript | Run Python in your HTML</title>
8+
<title>PyScript is a platform for Python in the browser.</title>
89
<meta name="description" content="PyScript">
910
<meta name="author" content="Anaconda Inc.">
1011
<meta property="og:title" content="Pyscript.net">
1112
<meta property="og:type" content="website">
12-
<meta property="og:description" content="Run Python code in your HTML.">
13+
<meta property="og:description" content="PyScript is a platform for Python in the browser.">
1314
<meta property="og:image" content="assets/images/pyscript-preview.png">
1415

1516
<link rel="icon" href="/assets/images/favicon.ico">
@@ -31,6 +32,8 @@
3132
gtag('js', new Date());
3233
gtag('config', 'G-LKETQQ110J');
3334
</script>
35+
<link rel="stylesheet" href="https://pyscript.net/releases/2024.5.1/core.css" />
36+
<script type="module" src="https://pyscript.net/releases/2024.5.1/core.js"></script>
3437
</head>
3538

3639
<body>
@@ -40,15 +43,23 @@
4043
<header class="site-header">
4144
<div class="logo">
4245
<img src="assets/images/pyscript-sticker-black.svg">
43-
<strong class="subhead">Run Python in Your HTML</strong>
46+
<strong class="subhead">PyScript is a platform for Python in the browser.</strong>
4447
</div>
4548
</header>
4649
<!-- end header -->
4750

4851
<section class="content">
4952

5053
<!-- begin terminal window -->
51-
<div class="terminal">
54+
<div id="new-terminal">
55+
<script id="python-terminal" type="mpy" terminal worker>
56+
import code
57+
code.interact()
58+
</script>
59+
<script type="mpy" src="./main.py" async></script>
60+
</div>
61+
62+
<div class="old-terminal" id="old-terminal">
5263
<div class="menu">
5364
<div class="window-buttons close"></div>
5465
<div class="window-buttons minimize"></div>
@@ -64,8 +75,8 @@
6475
</pre>
6576

6677
<p class="line1">&lt;html&gt;<span class="cursor1">|</span></p>
67-
<p class="line2">&nbsp;&nbsp;&nbsp;&nbsp;...<span class="cursor2">|</span></p>
68-
<p class="line3">&nbsp;&nbsp;&nbsp;&nbsp;&lt;py-script&gt;<span style="color: #aaa;"> <span style="color:#FFD580;">print</span>(<span style="color:#BAE67E;">'Now you can!'</span>) </span>&lt;/py-script&gt;<span class="cursor3">|</span></p>
78+
<p class="line2">&nbsp;&nbsp;...<span class="cursor2">|</span></p>
79+
<p class="line3">&nbsp;&nbsp;&lt;script type="py"&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #aaa;"><span style="color:#FFD580;">print</span>(<span style="color:#BAE67E;">'You can!'</span>)</span><br/>&nbsp;&nbsp;&lt;/script&gt;<span class="cursor3">|</span></p>
6980
<p class="line4">&lt;/html&gt;<span class="cursor4">|</span></p>
7081

7182
<p class="line5"><span class="cursor5">|</span></p>
@@ -76,20 +87,6 @@
7687
<!-- end terminal window -->
7788

7889
<div class="dialogs">
79-
<!-- begin examples badge -->
80-
<a href="https://pyscript.com/@examples" target="_blank" rel="noreferrer noopener" class="examples-block">
81-
<div class="glyph">
82-
<svg width="16px" height="16px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="bi bi-grid">
83-
<path d="M1 2.5A1.5 1.5 0 0 1 2.5 1h3A1.5 1.5 0 0 1 7 2.5v3A1.5 1.5 0 0 1 5.5 7h-3A1.5 1.5 0 0 1 1 5.5v-3zM2.5 2a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3zm6.5.5A1.5 1.5 0 0 1 10.5 1h3A1.5 1.5 0 0 1 15 2.5v3A1.5 1.5 0 0 1 13.5 7h-3A1.5 1.5 0 0 1 9 5.5v-3zm1.5-.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3zM1 10.5A1.5 1.5 0 0 1 2.5 9h3A1.5 1.5 0 0 1 7 10.5v3A1.5 1.5 0 0 1 5.5 15h-3A1.5 1.5 0 0 1 1 13.5v-3zm1.5-.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3zm6.5.5A1.5 1.5 0 0 1 10.5 9h3a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1-1.5 1.5h-3A1.5 1.5 0 0 1 9 13.5v-3zm1.5-.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3z"/>
84-
</svg>
85-
</div>
86-
<div>
87-
<h2>Examples</h2>
88-
<p><span>Click here</span> for example projects</p>
89-
</div>
90-
</a>
91-
<!-- end examples badge -->
92-
9390
<!-- begin pyscript.com badge -->
9491
<a href="https://pyscript.com/" target="_blank" rel="noreferrer noopener" class="examples-block">
9592
<div class="glyph">
@@ -99,28 +96,44 @@ <h2>Examples</h2>
9996
</div>
10097
<div>
10198
<h2>Try it out!</h2>
102-
<p><span>PyScript.com</span> is the easiest way to try it out, for free</p>
99+
<p><span>PyScript.com</span> is free and easy.</p>
103100
</div>
104101
</a>
105102
<!-- end pyscript.com badge -->
106-
</div>
107-
108-
<!-- begin dialog content -->
109-
<div class="dialogs">
110103

111104
<!-- begin documentation dropdown -->
112-
<a href="https://pyscript.github.io/docs/latest/" target="_blank" rel="noreferrer noopener" class="dialog" tabindex="1">
105+
<a href="https://pyscript.github.io/docs/latest/" target="_blank" rel="noreferrer noopener" class="examples-block" tabindex="1">
113106
<div class="glyph">
114107
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.1.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M448 336v-288C448 21.49 426.5 0 400 0H96C42.98 0 0 42.98 0 96v320c0 53.02 42.98 96 96 96h320c17.67 0 32-14.33 32-31.1c0-11.72-6.607-21.52-16-27.1v-81.36C441.8 362.8 448 350.2 448 336zM143.1 128h192C344.8 128 352 135.2 352 144C352 152.8 344.8 160 336 160H143.1C135.2 160 128 152.8 128 144C128 135.2 135.2 128 143.1 128zM143.1 192h192C344.8 192 352 199.2 352 208C352 216.8 344.8 224 336 224H143.1C135.2 224 128 216.8 128 208C128 199.2 135.2 192 143.1 192zM384 448H96c-17.67 0-32-14.33-32-32c0-17.67 14.33-32 32-32h288V448z"/></svg>
115108
</div>
116109

117110
<div>
118111
<h2>Documentation</h2>
119-
<p>Click here for PyScript documentation</p>
112+
<p>For beginners and advanced users.</p>
120113
</div>
121114
</a>
122115
<!-- end documentation dropdown -->
123116

117+
118+
</div>
119+
120+
<!-- begin dialog content -->
121+
<div class="dialogs">
122+
<!-- begin examples badge -->
123+
<a href="https://pyscript.com/@examples" target="_blank" rel="noreferrer noopener" class="dialog">
124+
<div class="glyph">
125+
<svg width="16px" height="16px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="bi bi-grid">
126+
<path d="M1 2.5A1.5 1.5 0 0 1 2.5 1h3A1.5 1.5 0 0 1 7 2.5v3A1.5 1.5 0 0 1 5.5 7h-3A1.5 1.5 0 0 1 1 5.5v-3zM2.5 2a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3zm6.5.5A1.5 1.5 0 0 1 10.5 1h3A1.5 1.5 0 0 1 15 2.5v3A1.5 1.5 0 0 1 13.5 7h-3A1.5 1.5 0 0 1 9 5.5v-3zm1.5-.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3zM1 10.5A1.5 1.5 0 0 1 2.5 9h3A1.5 1.5 0 0 1 7 10.5v3A1.5 1.5 0 0 1 5.5 15h-3A1.5 1.5 0 0 1 1 13.5v-3zm1.5-.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3zm6.5.5A1.5 1.5 0 0 1 10.5 9h3a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1-1.5 1.5h-3A1.5 1.5 0 0 1 9 13.5v-3zm1.5-.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3z"/>
127+
</svg>
128+
</div>
129+
<div>
130+
<h2>Examples</h2>
131+
<p>See what PyScript can do.</p>
132+
</div>
133+
</a>
134+
<!-- end examples badge -->
135+
136+
124137
<!-- begin installation dropdown -->
125138
<div class="dialog dropdown" tabindex="2">
126139
<div class="glyph">
@@ -131,20 +144,14 @@ <h2>Documentation</h2>
131144

132145
<div>
133146
<h2>Install</h2>
134-
<p>Click here for instructions</p>
147+
<p>Click here for instructions.</p>
135148
</div>
136149

137150
<div class="dropdown-content">
138151
<i class="close" tabindex="2"></i>
139152
<div class="inner">
140-
<p style="font-size:1.15rem;padding-bottom: 0;">Just kidding, you don't need to install anything. &#128515; </p>
141-
142-
<p>To use PyScript you can either <a href="https://github.com/pyscript/pyscript/archive/refs/heads/main.zip">download</a> it and follow the instructions, or add the following lines to your page.</p>
143-
<code class="pre">
144-
&lt;link rel="stylesheet" href="https://pyscript.net/releases/2024.1.1/core.css" /&gt;<br>
145-
&lt;script type="module" src="https://pyscript.net/releases/2024.1.1/core.js"&gt;&lt;/script&gt;
146-
</code>
147-
<p>Click <a href="https://pyscript.github.io/docs/latest/beginning-pyscript/" target="_blank">here</a> for more info on how to use PyScript.</p>
153+
<p style="font-size:1.15rem;padding-bottom: 0;">Just kidding, you don't need to install anything. ;-) </p>
154+
<p><a href="https://docs.pyscript.net/" target="_blank">Read our docs</a> to learn how to use PyScript.</p>
148155
</div>
149156
</div>
150157
</div>
@@ -176,24 +183,36 @@ <h5>pyscript_dev</h5>
176183
<div class="readme">
177184
<h1 id="pyscript">Say Hello to PyScript</h1>
178185

179-
<p>
180-
PyScript is a framework that allows users to create rich Python applications in the browser using HTML's interface and the power of <a href="https://pyodide.org/en/stable/" target="_blank">Pyodide</a>, <a href="https://webassembly.org/" target="_blank">WASM</a>, and modern web technologies. The PyScript framework provides users at every experience level with access to an expressive, easy-to-learn programming language with countless applications.</p>
186+
<p><strong>PyScript</strong> is a platform for <a href="https://python.org" target="_blank">Python</a> in the
187+
<a href="https://en.wikipedia.org/wiki/Web_browser" target="_blank">browser</a>.</p>
181188

182-
<h2>What is PyScript? Well, here are some of the core components:</h2>
183-
<!-- new copy from Fabio -->
189+
<p>PyScript brings together two of the most vibrant technical ecosystems on the
190+
planet. If <a href="https://en.wikipedia.org/wiki/World_Wide_Web" target="_blank">the web</a> and Python
191+
had a baby, you'd get PyScript.</p>
192+
193+
<p>At the core of PyScript is a <em>philosophy of digital empowerment</em>. The web is
194+
the world's most ubiquitous computing platform, mature and familiar to billions
195+
of people. Python is one of the
196+
<a href="https://spectrum.ieee.org/the-top-programming-languages-2023" target="_blank">world's most popular programming languages</a>.</p>
197+
<p>With PyScript, <em>Python runs anywhere there's a
198+
browser (<u>which is everywhere</u>)</em>.</p>
199+
200+
<h2>PyScript is...</h2>
184201
<ul>
185-
<li><strong>Python in the browser:</strong> Enable drop-in content, external file hosting, and application hosting without the reliance on server-side configuration</li>
186-
<li><strong>Python ecosystem:</strong> Run many popular packages of Python and the scientific stack (such as numpy, pandas, scikit-learn, and more)</li>
187-
<li><strong>Python with JavaScript:</strong> Bi-directional communication between Python and Javascript objects and namespaces </li>
188-
<li><strong>Environment management:</strong> Allow users to define what packages and files to include for the page code to run</li>
189-
<li><strong>Visual application development:</strong> Use readily available curated UI components, such as buttons, containers, text boxes, and more</li>
190-
<li><strong>Flexible framework:</strong> A flexible framework that can be leveraged to create and share new pluggable and extensible components directly in Python</li>
191-
</ul>
192-
193-
<p>All that to say… PyScript is just HTML, only a bit (okay, maybe a lot) more powerful, thanks to the rich and accessible ecosystem of Python libraries. </p>
194-
195-
<p>In short, our mission is to bring programming for the 99%. </p>
196-
<!-- end copy -->
202+
<li><strong>Easy</strong>: your apps run in the browser with no complicated installation
203+
required.</li>
204+
<li><strong>Expressive</strong>: create apps with a powerful, popular and easy to learn
205+
language like Python.</li>
206+
<li><strong>Scalable</strong>: no need for expensive infrastructure ~ your code runs in
207+
your user's browser.</li>
208+
<li><strong>Shareable</strong>: applications are just a URL on the web. That's it!</li>
209+
<li><strong>Universal</strong>: your code runs anywhere a browser runs... which is
210+
<em>everywhere</em>!</li>
211+
<li><strong>Secure</strong>: PyScript runs in the world's most battle-tested computing
212+
platform, the browser!</li>
213+
<li><strong>Powerful</strong>: the best of the web and Python, together at last.</li>
214+
</ul>
215+
197216
</div>
198217
<!-- end readme content -->
199218

@@ -296,5 +315,16 @@ <h2>What is PyScript? Well, here are some of the core components:</h2>
296315
heap.load("758475466");
297316
</script>
298317
<!-- END HEAP INTEGRATION -->
318+
<script>
319+
// It's a hack.
320+
try{
321+
var sab = new SharedArrayBuffer(4);
322+
if(sab===undefined)throw new Error('not supported')
323+
}
324+
catch(e){
325+
document.getElementById("new-terminal").style.display = "none";
326+
document.getElementById("old-terminal").style.display = "block";
327+
}
328+
</script>
299329
</body>
300330
</html>

main.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Well done! You've found the source.
3+
4+
If you're at PyCon 2024, email ntollervey <at> anaconda.com
5+
and (subject to availability) you can have some PyScript
6+
swag. :-)
7+
8+
Now go build cool stuff with PyScript.
9+
"""
10+
import asyncio
11+
import random
12+
from pyscript import document
13+
14+
15+
# It's the same API as JS when using the document object!
16+
python_terminal = document.getElementById("python-terminal")
17+
18+
19+
async def type_it_in(code):
20+
"""
21+
Advanced AI to type code into the terminal. ;-)
22+
"""
23+
lines = code.split("\n")
24+
for line in lines:
25+
await asyncio.sleep(1)
26+
for char in line:
27+
wait = random.choice(
28+
[0.05, 0.07, 0.1, 0.15, 0.2, 0.3]
29+
)
30+
await asyncio.sleep(wait)
31+
python_terminal.terminal.write(char)
32+
python_terminal.process(line.strip())
33+
34+
35+
# Web scale use of advanced AI.
36+
await type_it_in(
37+
'print("Hello, from PyScript!")\r\n'
38+
'# Your turn...'
39+
)

mini-coi.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*! coi-serviceworker v0.1.7 - Guido Zuidhof and contributors, licensed under MIT */
2+
/*! mini-coi - Andrea Giammarchi and contributors, licensed under MIT */
3+
(({ document: d, navigator: { serviceWorker: s } }) => {
4+
if (d) {
5+
const { currentScript: c } = d;
6+
s.register(c.src, { scope: c.getAttribute('scope') || '.' }).then(r => {
7+
r.addEventListener('updatefound', () => location.reload());
8+
if (r.active && !s.controller) location.reload();
9+
});
10+
}
11+
else {
12+
addEventListener('install', () => skipWaiting());
13+
addEventListener('activate', e => e.waitUntil(clients.claim()));
14+
addEventListener('fetch', e => {
15+
const { request: r } = e;
16+
if (r.cache === 'only-if-cached' && r.mode !== 'same-origin') return;
17+
e.respondWith(fetch(r).then(r => {
18+
const { body, status, statusText } = r;
19+
if (!status || status > 399) return r;
20+
const h = new Headers(r.headers);
21+
h.set('Cross-Origin-Opener-Policy', 'same-origin');
22+
h.set('Cross-Origin-Embedder-Policy', 'require-corp');
23+
h.set('Cross-Origin-Resource-Policy', 'cross-origin');
24+
return new Response(body, { status, statusText, headers: h });
25+
}));
26+
});
27+
}
28+
})(self);

0 commit comments

Comments
 (0)