|
| 1 | +# build.py: generate the HTML files from text files |
| 2 | + |
| 3 | +import sys |
1 | 4 | import glob
|
| 5 | +import urllib.request |
| 6 | +from time import gmtime, strftime |
| 7 | +import os |
| 8 | + |
| 9 | +if len(sys.argv) != 2: |
| 10 | + print("Usage: python3 build.py ARG\n" |
| 11 | + "\n" |
| 12 | + "For documentation on ARG, see README.md.") |
| 13 | + exit(1) |
2 | 14 |
|
3 | 15 | PAGE_TOP = r"""
|
4 | 16 | <!DOCTYPE html>
|
|
12 | 24 | <link rel="preconnect" href="https://fonts.googleapis.com">
|
13 | 25 | <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
14 | 26 | <link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@500&display=swap" rel="stylesheet">
|
15 |
| -<link href="https://fonts.googleapis.com/css2?family=Nunito&display=swap" rel="stylesheet"> |
| 27 | +<link href="https://fonts.googleapis.com/css2?family=Nunito&display=swap" rel="stylesheet"> |
16 | 28 |
|
17 | 29 | <style type="text/css" media="screen">
|
18 | 30 | body { font-family: 'nunito', arial, sans-serif; font-size: 16px; line-height: 1.5em; margin: 2em; background-color:#fcfcfc; color: #111; }
|
|
55 | 67 |
|
56 | 68 | <h1>FLINT : <span style="color:#cc3333">Fast Library for Number Theory</span></h1>
|
57 | 69 |
|
58 |
| -<!-- <div style="text-align:center; margin-bottom:1.5em"><img style="scale:90%" src="factor200.svg"></div> --> |
59 |
| -<!-- <div style="text-align:center; margin-bottom:1.5em"><img style="scale:90%" src="factor.svg"></div> --> |
| 70 | +<!-- <div style="text-align:center; margin-bottom:1.5em"><img style="scale:90%" src="img/factor200.svg"></div> --> |
| 71 | +<!-- <div style="text-align:center; margin-bottom:1.5em"><img style="scale:90%" src="img/factor.svg"></div> --> |
60 | 72 |
|
61 | 73 |
|
62 | 74 | <div style="text-align:center; margin-bottom:1.5em; overflow:scroll">
|
63 | 75 |
|
64 | 76 | <script>
|
65 | 77 | var formulas = [
|
66 |
| - "delta.svg", |
67 |
| - "factor.svg", |
68 |
| - "factorpoly.svg", |
69 |
| - "bernoulli.svg", |
70 |
| - "zeta.svg", |
| 78 | + "img/delta.svg", |
| 79 | + "img/factor.svg", |
| 80 | + "img/factorpoly.svg", |
| 81 | + "img/bernoulli.svg", |
| 82 | + "img/zeta.svg", |
71 | 83 | ];
|
72 | 84 |
|
73 | 85 | var size = formulas.length;
|
|
101 | 113 | """
|
102 | 114 |
|
103 | 115 | PAGE_KATEX = r"""
|
104 |
| -<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous"> |
105 |
| -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script> |
106 |
| -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous" |
107 |
| - onload="renderMathInElement(document.body);"></script> |
| 116 | +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.css" integrity="sha384-7lU0muIg/i1plk7MgygDUp3/bNRA65orrBub4/OSWHECgwEsY83HaS1x3bljA/XV" crossorigin="anonymous"> |
| 117 | +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.js" integrity="sha384-RdymN7NRJ+XoyeRY4185zXaxq9QWOOx3O7beyyrRK4KQZrPlCDQQpCu95FoCGPAE" crossorigin="anonymous"></script> |
| 118 | +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/contrib/auto-render.min.js" integrity="sha384-hCXGrW6PitJEwbkoStFjeJxv+fSOOQKOPbJxSfM6G5sWZjAyWhXiTIIAmQqnlLlh" crossorigin="anonymous" |
| 119 | + onload="renderMathInElement(document.body);"></script> |
108 | 120 | <script>
|
109 | 121 | document.addEventListener("DOMContentLoaded", function() {
|
110 | 122 | renderMathInElement(document.body, {
|
|
119 | 131 |
|
120 | 132 | indent = 11
|
121 | 133 |
|
122 |
| -authors_data = open("../flint/AUTHORS").read().splitlines() |
| 134 | +urllib.request.urlretrieve("https://raw.githubusercontent.com/flintlib/flint/refs/heads/main/AUTHORS", "AUTHORS") |
| 135 | +authors_data = open("AUTHORS").read().splitlines() |
123 | 136 |
|
124 | 137 | lines = authors_data[authors_data.index("Major contributors")+2 : authors_data.index("Other contributors")]
|
125 | 138 | lines_contributors = authors_data[authors_data.index("Other contributors")+5 : authors_data.index("Other credits")]
|
|
172 | 185 | contributorlist += "</ul>"
|
173 | 186 |
|
174 | 187 | authorphoto = {
|
175 |
| - "William Hart" : "bill.jpg", |
176 |
| - "Fredrik Johansson" : "fredrik.jpg", |
177 |
| - "Albin Ahlbäck" : "albin.jpg", |
178 |
| - "Andy Novocin" : "andy.jpg", |
179 |
| - "Daniel Schultz" : "daniel.jpg", |
180 |
| - "David Harvey" : "david.jpg", |
181 |
| - "Mike Hansen" : "mike.jpg", |
182 |
| - "Pascal Molin" : "pascal.jpg", |
183 |
| - "Alex Best" : "alex.jpg", |
184 |
| - "D.H.J. Polymath" : "polymath.jpg", |
| 188 | + "William Hart" : "img/people/bill.jpg", |
| 189 | + "Fredrik Johansson" : "img/people/fredrik.jpg", |
| 190 | + "Albin Ahlbäck" : "img/people/albin.jpg", |
| 191 | + "Andy Novocin" : "img/people/andy.jpg", |
| 192 | + "Daniel Schultz" : "img/people/daniel.jpg", |
| 193 | + "David Harvey" : "img/people/david.jpg", |
| 194 | + "Mike Hansen" : "img/people/mike.jpg", |
| 195 | + "Pascal Molin" : "img/people/pascal.jpg", |
| 196 | + "Alex Best" : "img/people/alex.jpg", |
| 197 | + "D.H.J. Polymath" : "img/people/polymath.jpg", |
185 | 198 | }
|
186 | 199 |
|
187 | 200 | if 0:
|
|
195 | 208 | else:
|
196 | 209 | s += """<b>%s</b>""" % author
|
197 | 210 | if author in authorphoto:
|
198 |
| - s += """<br/><img src="people/%s" style="max-width:150px; max-height:150px" />""" % authorphoto[author] |
| 211 | + s += """<br/><img src="%s" style="max-width:150px; max-height:150px" />""" % authorphoto[author] |
199 | 212 | #if data.get("github"):
|
200 | 213 | # s += """<br/><a href="https://github.com/flintlib/flint/commits?author=%s">commits</a>""" % data.get("github")
|
201 | 214 | s += "</td><td>"
|
|
226 | 239 | authorlist += s
|
227 | 240 | authorlist += "</dl>"
|
228 | 241 |
|
229 |
| -pages = ["index", "applications", "news", "documentation", "downloads", "development", "authors", "links"] |
| 242 | +source_prefix = "src/" |
| 243 | +source_suffix = ".txt" |
| 244 | +pages = [ |
| 245 | + "index", |
| 246 | + "applications", |
| 247 | + "news", |
| 248 | + "documentation", |
| 249 | + "downloads", |
| 250 | + "development", |
| 251 | + "authors", |
| 252 | + "links" |
| 253 | +] |
230 | 254 |
|
231 | 255 | page_titles = []
|
232 | 256 | page_texts = []
|
|
237 | 261 | text = ""
|
238 | 262 | title = "Documentation"
|
239 | 263 | else:
|
240 |
| - text = open(page + ".txt", "r").read() |
| 264 | + text = open(source_prefix + page + source_suffix, "r").read() |
241 | 265 | title = text[text.find("<h2>")+4 : text.find("</h2>")]
|
242 | 266 | page_want_katex.append("%WANT_KATEX" in text)
|
243 | 267 | text = text.replace("%AUTHORLIST", authorlist)
|
|
249 | 273 |
|
250 | 274 |
|
251 | 275 |
|
252 |
| -from time import gmtime, strftime |
253 | 276 | timestamp = strftime("Last updated: %Y-%m-%d %H:%M:%S GMT", gmtime())
|
254 | 277 |
|
255 | 278 |
|
|
288 | 311 | else:
|
289 | 312 | title = " - " + title
|
290 | 313 |
|
291 |
| - fp = open(pages[i] + ".html", "w") |
| 314 | + path = sys.argv[1] |
| 315 | + fp = open(path + "/" + pages[i] + ".html", "w") |
292 | 316 | fp.write(PAGE_TOP.replace("TITLE", title).replace("MENU", menu).replace("%KATEX%", PAGE_KATEX if page_want_katex[i] else ""))
|
293 | 317 | fp.write(page_texts[i])
|
294 | 318 | fp.write(PAGE_BOTTOM.replace("TIMESTAMP", timestamp))
|
|
0 commit comments