Skip to content

Commit f25b843

Browse files
committed
Overhaul of FLINT website system
1 parent fc61013 commit f25b843

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1691
-81
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
people/*.jpg
2-
*.html
3-
temp/*
1+
AUTHORS
2+
src/downloads.txt

HISTORY

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
1.0.0 2007-12-02
2+
1.0.1 2007-12-07
3+
1.0.2 2007-12-10
4+
1.0.3 2007-12-16
5+
1.0.4 2008-01-04
6+
1.0.5 2008-01-05
7+
1.0.6 2008-01-17
8+
1.0.7 2008-01-22
9+
1.0.8 2008-02-15
10+
1.0.9 2008-03-11
11+
1.0.10 2008-06-16
12+
1.0.11 2008-07-09
13+
1.0.12 2008-07-11
14+
1.0.13 2008-07-13
15+
1.0.14 2008-09-23
16+
1.0.15 2008-10-15
17+
1.0.16 2008-10-22
18+
1.0.17 2008-11-30
19+
1.0.18 2008-12-05
20+
1.0.19 2008-12-12
21+
1.0.20 2008-12-13
22+
1.0.21 2008-12-25
23+
1.1.0 2008-12-21
24+
1.1.1 2009-02-11
25+
1.1.2 2009-03-09
26+
1.1.3 2008-03-09
27+
1.2.0 2009-03-10
28+
1.2.1 2009-03-14
29+
1.2.2 2009-03-20
30+
1.2.3 2009-03-31
31+
1.2.4 2009-04-04
32+
1.2.5 2009-04-18
33+
1.3.0 2009-06-09
34+
1.4.0 2009-07-06
35+
1.5.0 2009-09-22
36+
1.5.1 XXXX-XX-XX
37+
1.5.2 2010-04-08
38+
1.6.0 2010-12-24
39+
2.0.0 2011-01-16
40+
2.1.0 2011-03-09
41+
2.2.0 2011-06-04
42+
2.3.0 2012-11-09
43+
2.4.0 2013-11-19
44+
2.4.1 2013-11-20
45+
2.4.2 2014-03-11
46+
2.4.3 2014-04-01
47+
2.4.4 2014-07-17
48+
2.4.5 2015-02-17
49+
2.5.0 2015-08-03
50+
2.5.1 2015-08-05
51+
2.5.2 2015-08-07
52+
2.6.0 2020-06-05
53+
2.6.1 2020-07-23
54+
2.6.2 2020-07-31
55+
2.6.3 2020-08-12
56+
2.7.0 2020-12-18
57+
2.7.1 2021-01-18
58+
2.8.0 2021-07-22
59+
2.8.1 2021-10-01
60+
2.8.2 2021-10-15
61+
2.8.3 2021-11-03
62+
2.8.4 2021-11-17
63+
2.8.5 2022-04-25
64+
2.9.0 2022-06-24
65+
3.0.0 2023-10-20
66+
3.0.1 2023-11-10
67+
3.1.0 2024-02-27
68+
3.1.1 2024-03-07
69+
3.1.2 2024-03-18
70+
3.1.3 2024-04-25
71+
3.1.3-p1 2024-05-24

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Build system
2+
3+
We generate `src/downloads.txt` that is being used to generate
4+
`${DEST}/downloads.html`. To generate the source file, run
5+
```
6+
$ python3 downloads.py ${PATH_TO_DEST}
7+
```
8+
where `${PATH_TO_DEST}/download` is the path to the directory that contains all
9+
PDF-files and compressed releases (probably `~/apps/flintlib_org/`).
10+
11+
Following this, generate all HTML pages via
12+
```
13+
$ python3 build.py ${PATH_TO_DEST}
14+
```
15+
which outputs all HTML files to `${PATH_TO_DEST}` (probably
16+
`~/apps/flintlib_org/`).
17+
18+
19+
20+
# Source file structure
21+
22+
In the source directory:
23+
24+
- `./`: Building scripts are located in the top directory.
25+
- `src/`: Text files that are to be used to generated to HTML files.
26+
27+
28+
29+
# Output file system
30+
31+
The following directories in the output directory `${PATH_TO_DEST}` needs to be
32+
populated already:
33+
34+
- `img/`: Images for website, such as figures and picture of authors.
35+
- `download/`: PDF documentation along with releases (`.tar.gz` and `.zip`)
36+
files.

build.py

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1+
# build.py: generate the HTML files from text files
2+
3+
import sys
14
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)
214

315
PAGE_TOP = r"""
416
<!DOCTYPE html>
@@ -12,7 +24,7 @@
1224
<link rel="preconnect" href="https://fonts.googleapis.com">
1325
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
1426
<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">
1628
1729
<style type="text/css" media="screen">
1830
body { font-family: 'nunito', arial, sans-serif; font-size: 16px; line-height: 1.5em; margin: 2em; background-color:#fcfcfc; color: #111; }
@@ -55,19 +67,19 @@
5567
5668
<h1>FLINT : <span style="color:#cc3333">Fast Library for Number Theory</span></h1>
5769
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> -->
6072
6173
6274
<div style="text-align:center; margin-bottom:1.5em; overflow:scroll">
6375
6476
<script>
6577
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",
7183
];
7284
7385
var size = formulas.length;
@@ -101,10 +113,10 @@
101113
"""
102114

103115
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>
108120
<script>
109121
document.addEventListener("DOMContentLoaded", function() {
110122
renderMathInElement(document.body, {
@@ -119,7 +131,8 @@
119131

120132
indent = 11
121133

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()
123136

124137
lines = authors_data[authors_data.index("Major contributors")+2 : authors_data.index("Other contributors")]
125138
lines_contributors = authors_data[authors_data.index("Other contributors")+5 : authors_data.index("Other credits")]
@@ -172,16 +185,16 @@
172185
contributorlist += "</ul>"
173186

174187
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",
185198
}
186199

187200
if 0:
@@ -195,7 +208,7 @@
195208
else:
196209
s += """<b>%s</b>""" % author
197210
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]
199212
#if data.get("github"):
200213
# s += """<br/><a href="https://github.com/flintlib/flint/commits?author=%s">commits</a>""" % data.get("github")
201214
s += "</td><td>"
@@ -226,7 +239,18 @@
226239
authorlist += s
227240
authorlist += "</dl>"
228241

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+
]
230254

231255
page_titles = []
232256
page_texts = []
@@ -237,7 +261,7 @@
237261
text = ""
238262
title = "Documentation"
239263
else:
240-
text = open(page + ".txt", "r").read()
264+
text = open(source_prefix + page + source_suffix, "r").read()
241265
title = text[text.find("<h2>")+4 : text.find("</h2>")]
242266
page_want_katex.append("%WANT_KATEX" in text)
243267
text = text.replace("%AUTHORLIST", authorlist)
@@ -249,7 +273,6 @@
249273

250274

251275

252-
from time import gmtime, strftime
253276
timestamp = strftime("Last updated: %Y-%m-%d %H:%M:%S GMT", gmtime())
254277

255278

@@ -288,7 +311,8 @@
288311
else:
289312
title = " - " + title
290313

291-
fp = open(pages[i] + ".html", "w")
314+
path = sys.argv[1]
315+
fp = open(path + "/" + pages[i] + ".html", "w")
292316
fp.write(PAGE_TOP.replace("TITLE", title).replace("MENU", menu).replace("%KATEX%", PAGE_KATEX if page_want_katex[i] else ""))
293317
fp.write(page_texts[i])
294318
fp.write(PAGE_BOTTOM.replace("TIMESTAMP", timestamp))

downloads.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# downloads.py: generate downloads.txt
2+
3+
import sys
4+
import glob
5+
import re
6+
from itertools import groupby
7+
8+
if len(sys.argv) != 2:
9+
print("Usage: python3 downloads.py ARG\n"
10+
"\n"
11+
"For documentation on ARG, see README.md.")
12+
exit(1)
13+
14+
path = sys.argv[1]
15+
output = "src/downloads.txt"
16+
17+
page_top = r"""<h2>Downloads</h2>
18+
19+
<p>For a list of changes in each release, see the <a href="https://www.flintlib.org/doc/history.html">history</a> section of the documentation.</p>
20+
"""
21+
22+
files = glob.glob(path + '/download/flint-*')
23+
24+
# Only keep files that are on the form MAJOR.MINOR.PATCH and that is not alpha,
25+
# beta or devel.
26+
pattern = re.compile(r".*/flint-(\d+)\.(\d+)\.(\d+)\.(.*)")
27+
files = [fp for fp in files if pattern.match(fp)]
28+
29+
def sort_key(file):
30+
match = pattern.match(file)
31+
if match:
32+
return (int(match.group(1)), int(match.group(2)), int(match.group(3)), match.group(4))
33+
return (float('inf'), float('inf'), float('inf'), float('inf'))
34+
35+
files.sort()
36+
files.sort(key=sort_key)
37+
38+
# Find out how long PATH is
39+
pathdownlen = 0
40+
pathlen = 0
41+
pathmatch = re.match(r"(.*/download/)", files[0])
42+
if pathmatch:
43+
pathdownlen = len(pathmatch.group(1))
44+
pathlen = pathdownlen - len("download/")
45+
else:
46+
print("Could not match PATH. Exiting...")
47+
exit(1)
48+
49+
# Extract triplets and sort the files by triplets
50+
parsed_files = []
51+
for item in files:
52+
match = pattern.match(item)
53+
if match:
54+
parsed_files.append((match.group(1, 2, 3), item))
55+
56+
# Read HISTORY
57+
with open('HISTORY', 'r') as file:
58+
history_lines = file.read()
59+
60+
# NOTE: We do not capture 3.1.3-p1.
61+
history = []
62+
pattern = re.compile(r"(\d+)\.(\d+).(\d+)\s+(\d{4}-\d{2}-\d{2})")
63+
for line in history_lines.splitlines():
64+
match = pattern.match(line)
65+
if match:
66+
history.append(((match.group(1), match.group(2), match.group(3)), match.group(4)))
67+
68+
# Group by triplets and perform actions
69+
ver = "1"
70+
page = "</ul>\n"
71+
for triplet, group in groupby(parsed_files, key=lambda x: x[0]):
72+
group_strings = [item[1] for item in group]
73+
74+
# Print previous series header to page if needed if triplet[0] != ver:
75+
if triplet[0] != ver:
76+
tmp = "</ul>\n\n<h3>FLINT " + ver + ".x series</h3>\n\n<ul>\n"
77+
page = tmp + page
78+
ver = triplet[0]
79+
80+
# Start of new item
81+
this_item = "<li>"
82+
83+
# Find date
84+
found_date = False
85+
for htriplet, hdate in history:
86+
if htriplet == triplet:
87+
this_item += hdate + ": "
88+
found_date = True
89+
if not found_date:
90+
this_item += "XXXX-XX-XX: "
91+
92+
# We want the PDF to come last.
93+
if group_strings[0].endswith(".pdf"):
94+
group_strings = group_strings[1:] + group_strings[:1]
95+
96+
for ix, string in enumerate(group_strings):
97+
if ix != 0:
98+
this_item += ", "
99+
100+
if string.endswith(".tar.gz") or string.endswith(".zip"):
101+
this_item += f"""<a href="{string[pathlen:]}"><b>{string[pathdownlen:]}</b></a>"""
102+
elif string.endswith(".pdf"):
103+
this_item += f"""documentation: <a href="{string[pathlen:]}"><b>{string[pathdownlen:]}</b></a>"""
104+
else:
105+
print("error")
106+
exit(1)
107+
108+
# End of item
109+
this_item += "</li>\n"
110+
111+
page = this_item + page
112+
113+
114+
tmp = "\n<h3>FLINT " + ver + ".x series</h3>\n\n<ul>\n"
115+
page = tmp + page
116+
117+
final = page_top + page
118+
with open(output, "w") as file:
119+
file.write(final)

0 commit comments

Comments
 (0)