Skip to content

Commit 364e387

Browse files
committed
Handle ?q=package_name on home page. Correct GH location.
1 parent 90eaaa4 commit 364e387

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

help/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ <h2 id="more-help">Where can I get more help?</h2>
141141

142142
<footer class="site-footer">
143143
<div class="container footer-inner">
144-
<p>Maintained by the PyScript community · <a href="https://github.com/pyscript/pyscript-packages" target="_blank">GitHub</a></p>
144+
<p>Maintained by the PyScript community · <a href="https://github.com/pyscript/packages" target="_blank">GitHub</a></p>
145145
</div>
146146
</footer>
147147
</body>

home.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,28 @@
44
It fetches the top 100 PyPI packages and displays them with their
55
PyScript support status.
66
"""
7+
import js
78
from pyscript import fetch
89
from pyscript.web import page, a
910

11+
def get_package_name():
12+
"""
13+
Extract the package name from the query string.
14+
15+
Package names are case insensitive, so we convert to lowercase.
16+
"""
17+
query_string = js.window.location.search
18+
url_params = js.URLSearchParams.new(query_string)
19+
package_name = url_params.get("q")
20+
if package_name:
21+
return package_name.strip().lower()
22+
return None
23+
24+
package_name = get_package_name()
25+
26+
if package_name:
27+
js.window.location.replace(f"./package?package={package_name}")
28+
1029
top100 = await fetch("./api/top_100_pypi_packages.json").json()
1130

1231
target = page["#top100"]

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ <h2 class="section-title">📊 Popular Python Packages</h2>
8080

8181
<footer class="site-footer">
8282
<div class="container footer-inner">
83-
<p>Maintained by the PyScript community · <a href="https://github.com/pyscript/pyscript-packages" target="_blank">GitHub</a></p>
83+
<p>Maintained by the PyScript community · <a href="https://github.com/pyscript/packages" target="_blank">GitHub</a></p>
8484
</div>
8585
</footer>
8686

package/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
<footer class="site-footer">
4545
<div class="container footer-inner">
46-
<p>Maintained by the PyScript community · <a href="https://github.com/pyscript/pyscript-packages" target="_blank">GitHub</a></p>
46+
<p>Maintained by the PyScript community · <a href="https://github.com/pyscript/packages" target="_blank">GitHub</a></p>
4747
</div>
4848
</footer>
4949
</body>

0 commit comments

Comments
 (0)