Skip to content

Commit

Permalink
Merge pull request #10 from albinahlback/overhaul
Browse files Browse the repository at this point in the history
Clean up FLINT webpage and automate deployment
  • Loading branch information
albinahlback authored Jan 13, 2025
2 parents fc61013 + 5200da1 commit 6b4f6ad
Show file tree
Hide file tree
Showing 55 changed files with 1,716 additions and 81 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Workflow to deploy to website

name: Deploy

on:
push:
branches:
- master

jobs:
deploy:
name: Push documentation to website
if: github.repository == 'flintlib/flintwebpage'
runs-on: ubuntu-latest
steps:
- name: "Setup SSH key"
uses: shimataro/ssh-key-action@v2.7.0
with:
key: ${{ secrets.SSH_KEY }}
name: id_ed25519
known_hosts: ${{ secrets.KNOWN_HOSTS }}

- name: "Deploy"
run: |
ssh -t wbhart@opal6.opalstack.com 'cd ~/flintwebpage && git checkout master && git pull && python3 downloads.py ~/apps/flintlib_org && python3 build.py ~/apps/flintlib_org && cp -r img/ ~/apps/flintlib_org'
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
people/*.jpg
*.html
temp/*
AUTHORS
src/downloads.txt
71 changes: 71 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
1.0.0 2007-12-02
1.0.1 2007-12-07
1.0.2 2007-12-10
1.0.3 2007-12-16
1.0.4 2008-01-04
1.0.5 2008-01-05
1.0.6 2008-01-17
1.0.7 2008-01-22
1.0.8 2008-02-15
1.0.9 2008-03-11
1.0.10 2008-06-16
1.0.11 2008-07-09
1.0.12 2008-07-11
1.0.13 2008-07-13
1.0.14 2008-09-23
1.0.15 2008-10-15
1.0.16 2008-10-22
1.0.17 2008-11-30
1.0.18 2008-12-05
1.0.19 2008-12-12
1.0.20 2008-12-13
1.0.21 2008-12-25
1.1.0 2008-12-21
1.1.1 2009-02-11
1.1.2 2009-03-09
1.1.3 2008-03-09
1.2.0 2009-03-10
1.2.1 2009-03-14
1.2.2 2009-03-20
1.2.3 2009-03-31
1.2.4 2009-04-04
1.2.5 2009-04-18
1.3.0 2009-06-09
1.4.0 2009-07-06
1.5.0 2009-09-22
1.5.1 XXXX-XX-XX
1.5.2 2010-04-08
1.6.0 2010-12-24
2.0.0 2011-01-16
2.1.0 2011-03-09
2.2.0 2011-06-04
2.3.0 2012-11-09
2.4.0 2013-11-19
2.4.1 2013-11-20
2.4.2 2014-03-11
2.4.3 2014-04-01
2.4.4 2014-07-17
2.4.5 2015-02-17
2.5.0 2015-08-03
2.5.1 2015-08-05
2.5.2 2015-08-07
2.6.0 2020-06-05
2.6.1 2020-07-23
2.6.2 2020-07-31
2.6.3 2020-08-12
2.7.0 2020-12-18
2.7.1 2021-01-18
2.8.0 2021-07-22
2.8.1 2021-10-01
2.8.2 2021-10-15
2.8.3 2021-11-03
2.8.4 2021-11-17
2.8.5 2022-04-25
2.9.0 2022-06-24
3.0.0 2023-10-20
3.0.1 2023-11-10
3.1.0 2024-02-27
3.1.1 2024-03-07
3.1.2 2024-03-18
3.1.3 2024-04-25
3.1.3-p1 2024-05-24
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Build system

We generate `src/downloads.txt` that is being used to generate
`${DEST}/downloads.html`. To generate the source file, run
```
$ python3 downloads.py ${PATH_TO_DEST}
```
where `${PATH_TO_DEST}/download` is the path to the directory that contains all
PDF-files and compressed releases (probably `~/apps/flintlib_org/`).

Following this, generate all HTML pages via
```
$ python3 build.py ${PATH_TO_DEST}
```
which outputs all HTML files to `${PATH_TO_DEST}` (probably
`~/apps/flintlib_org/`).



# Source file structure

In the source directory:

- `./`: Building scripts are located in the top directory.
- `src/`: Text files that are to be used to generated to HTML files.



# Output file system

The following directories in the output directory `${PATH_TO_DEST}` needs to be
populated already:

- `img/`: Images for website, such as figures and picture of authors.
- `download/`: PDF documentation along with releases (`.tar.gz` and `.zip`)
files.
80 changes: 52 additions & 28 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# build.py: generate the HTML files from text files

import sys
import glob
import urllib.request
from time import gmtime, strftime
import os

if len(sys.argv) != 2:
print("Usage: python3 build.py ARG\n"
"\n"
"For documentation on ARG, see README.md.")
exit(1)

PAGE_TOP = r"""
<!DOCTYPE html>
Expand All @@ -12,7 +24,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Nunito&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Nunito&display=swap" rel="stylesheet">
<style type="text/css" media="screen">
body { font-family: 'nunito', arial, sans-serif; font-size: 16px; line-height: 1.5em; margin: 2em; background-color:#fcfcfc; color: #111; }
Expand Down Expand Up @@ -55,19 +67,19 @@
<h1>FLINT : <span style="color:#cc3333">Fast Library for Number Theory</span></h1>
<!-- <div style="text-align:center; margin-bottom:1.5em"><img style="scale:90%" src="factor200.svg"></div> -->
<!-- <div style="text-align:center; margin-bottom:1.5em"><img style="scale:90%" src="factor.svg"></div> -->
<!-- <div style="text-align:center; margin-bottom:1.5em"><img style="scale:90%" src="img/factor200.svg"></div> -->
<!-- <div style="text-align:center; margin-bottom:1.5em"><img style="scale:90%" src="img/factor.svg"></div> -->
<div style="text-align:center; margin-bottom:1.5em; overflow:scroll">
<script>
var formulas = [
"delta.svg",
"factor.svg",
"factorpoly.svg",
"bernoulli.svg",
"zeta.svg",
"img/delta.svg",
"img/factor.svg",
"img/factorpoly.svg",
"img/bernoulli.svg",
"img/zeta.svg",
];
var size = formulas.length;
Expand Down Expand Up @@ -101,10 +113,10 @@
"""

PAGE_KATEX = r"""
<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">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
<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">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.js" integrity="sha384-RdymN7NRJ+XoyeRY4185zXaxq9QWOOx3O7beyyrRK4KQZrPlCDQQpCu95FoCGPAE" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/contrib/auto-render.min.js" integrity="sha384-hCXGrW6PitJEwbkoStFjeJxv+fSOOQKOPbJxSfM6G5sWZjAyWhXiTIIAmQqnlLlh" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body, {
Expand All @@ -119,7 +131,8 @@

indent = 11

authors_data = open("../flint/AUTHORS").read().splitlines()
urllib.request.urlretrieve("https://raw.githubusercontent.com/flintlib/flint/refs/heads/main/AUTHORS", "AUTHORS")
authors_data = open("AUTHORS").read().splitlines()

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

authorphoto = {
"William Hart" : "bill.jpg",
"Fredrik Johansson" : "fredrik.jpg",
"Albin Ahlbäck" : "albin.jpg",
"Andy Novocin" : "andy.jpg",
"Daniel Schultz" : "daniel.jpg",
"David Harvey" : "david.jpg",
"Mike Hansen" : "mike.jpg",
"Pascal Molin" : "pascal.jpg",
"Alex Best" : "alex.jpg",
"D.H.J. Polymath" : "polymath.jpg",
"William Hart" : "img/people/bill.jpg",
"Fredrik Johansson" : "img/people/fredrik.jpg",
"Albin Ahlbäck" : "img/people/albin.jpg",
"Andy Novocin" : "img/people/andy.jpg",
"Daniel Schultz" : "img/people/daniel.jpg",
"David Harvey" : "img/people/david.jpg",
"Mike Hansen" : "img/people/mike.jpg",
"Pascal Molin" : "img/people/pascal.jpg",
"Alex Best" : "img/people/alex.jpg",
"D.H.J. Polymath" : "img/people/polymath.jpg",
}

if 0:
Expand All @@ -195,7 +208,7 @@
else:
s += """<b>%s</b>""" % author
if author in authorphoto:
s += """<br/><img src="people/%s" style="max-width:150px; max-height:150px" />""" % authorphoto[author]
s += """<br/><img src="%s" style="max-width:150px; max-height:150px" />""" % authorphoto[author]
#if data.get("github"):
# s += """<br/><a href="https://github.com/flintlib/flint/commits?author=%s">commits</a>""" % data.get("github")
s += "</td><td>"
Expand Down Expand Up @@ -226,7 +239,18 @@
authorlist += s
authorlist += "</dl>"

pages = ["index", "applications", "news", "documentation", "downloads", "development", "authors", "links"]
source_prefix = "src/"
source_suffix = ".txt"
pages = [
"index",
"applications",
"news",
"documentation",
"downloads",
"development",
"authors",
"links"
]

page_titles = []
page_texts = []
Expand All @@ -237,7 +261,7 @@
text = ""
title = "Documentation"
else:
text = open(page + ".txt", "r").read()
text = open(source_prefix + page + source_suffix, "r").read()
title = text[text.find("<h2>")+4 : text.find("</h2>")]
page_want_katex.append("%WANT_KATEX" in text)
text = text.replace("%AUTHORLIST", authorlist)
Expand All @@ -249,7 +273,6 @@



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


Expand Down Expand Up @@ -288,7 +311,8 @@
else:
title = " - " + title

fp = open(pages[i] + ".html", "w")
path = sys.argv[1]
fp = open(path + "/" + pages[i] + ".html", "w")
fp.write(PAGE_TOP.replace("TITLE", title).replace("MENU", menu).replace("%KATEX%", PAGE_KATEX if page_want_katex[i] else ""))
fp.write(page_texts[i])
fp.write(PAGE_BOTTOM.replace("TIMESTAMP", timestamp))
Expand Down
Loading

0 comments on commit 6b4f6ad

Please sign in to comment.