Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit 7cac256

Browse files
committed
Script to install a sitmap.xml in /static
* This details all of the major html pages for all books to ensure that they are properly indexed.
1 parent fbcfd41 commit 7cac256

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/make_sitemap.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
2+
import os
23

34
# /Users/bmiller/Runestone/RunestoneServer/books/csawesome/published/csawesome/MixedFreeResponse/RandomStringChooserParsonsB.html
45
# becomes /ns/books/published/
@@ -7,15 +8,17 @@ def path_to_url(p):
78
return "https://runestone.academy/ns/books/published" + parts[-1]
89

910

10-
with open("sitemap.xml", "w") as sm:
11+
home = os.environ["HOME"]
12+
13+
with open(Path(home, "Runestone/RunestoneServer/static", "sitemap.xml"), "w") as sm:
1114
sm.write(
12-
"""
13-
<?xml version="1.0" encoding="utf-8"?>
15+
"""<?xml version="1.0" encoding="utf-8"?>
1416
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
1517
<url><loc>https://runestone.academy</loc></url>
18+
<url><loc>https://runestone.academy/runestone/books/index</loc></url>
1619
"""
1720
)
18-
p = Path("/Users/bmiller/Runestone/RunestoneServer/books")
21+
p = Path(home, "Runestone/books")
1922
for i in p.rglob("*.html"):
2023
if "build" in str(i) or "knowl" in str(i):
2124
continue

0 commit comments

Comments
 (0)