Skip to content

Commit 475ef98

Browse files
authored
Merge pull request #15 from FEniCS/mscroggs/web-style
Make index.html look like the website
2 parents 75d3c6e + d7fe0fa commit 475ef98

File tree

8 files changed

+99
-457
lines changed

8 files changed

+99
-457
lines changed

Diff for: .github/workflows/homepage.yml

-22
This file was deleted.

Diff for: .github/workflows/jekyll.yml

+55
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,67 @@ on:
88

99
jobs:
1010
build:
11+
if: github.ref != 'refs/heads/main'
1112
runs-on: ubuntu-latest
1213

1314
steps:
1415
- uses: actions/checkout@v4
16+
17+
# Make index.html
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: 3.11
22+
- name: Generate index.html
23+
run: |
24+
sudo apt update
25+
sudo apt install -y ruby-bundler ruby-dev
26+
python3 -m pip install -r requirements.txt
27+
python3 make_index.py
28+
29+
- name: Build the site in the jekyll/builder container
30+
run: |
31+
docker run \
32+
-v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \
33+
jekyll/builder:latest /bin/bash -c "chmod 777 /srv/jekyll && jekyll build --future"
34+
35+
build-and-deploy:
36+
if: github.ref == 'refs/heads/main'
37+
runs-on: ubuntu-latest
38+
39+
permissions:
40+
contents: read
41+
pages: write
42+
id-token: write
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
# Make index.html
48+
- name: Set up Python
49+
uses: actions/setup-python@v4
50+
with:
51+
python-version: 3.11
52+
- name: Generate index.html
53+
run: |
54+
sudo apt update
55+
sudo apt install -y ruby-bundler ruby-dev
56+
python3 -m pip install -r requirements.txt
57+
python3 make_index.py
58+
1559
- name: Build the site in the jekyll/builder container
1660
run: |
1761
docker run \
1862
-v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \
1963
jekyll/builder:latest /bin/bash -c "chmod 777 /srv/jekyll && jekyll build --future"
64+
65+
# Deploy to GitHub Pages
66+
- name: Setup Pages
67+
uses: actions/configure-pages@v3
68+
- name: Upload artifact
69+
uses: actions/upload-pages-artifact@v1
70+
with:
71+
path: '_site'
72+
- name: Deploy to GitHub Pages
73+
id: deployment
74+
uses: actions/deploy-pages@v1

Diff for: .gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
index.html
2+
*.pyc
3+
_web/
4+
Gemfile.lock
5+
_site/

Diff for: README.md

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
---
2-
pagetitle: FEniCSx Project Documentation
3-
header-includes: <link rel="shortcut icon" type="image/x-icon" href="https://fenicsproject.org/favicon.ico"/>
4-
---
5-
6-
# FEniCSx Project Documentation
7-
8-
<img style="display: block; margin: 0 auto; width: 70px;" src="https://fenicsproject.org/pub/graphics/fenics_logo.svg" alt="FEniCS project logo">
9-
101
## Latest release
112

123
#### DOLFINx

Diff for: index.html

-98
This file was deleted.

Diff for: make_index.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
3+
from markdown import markdown
4+
5+
6+
def system(command):
7+
assert os.system(command) == 0
8+
9+
10+
_path = os.path.dirname(os.path.realpath(__file__))
11+
web_path = os.path.join(_path, "_web")
12+
13+
if os.path.isdir(web_path):
14+
system(f"rm -r {web_path}")
15+
system(f"git clone http://github.com/FEniCS/web {web_path}")
16+
17+
with open(os.path.join(web_path, "template.md"), "w") as f:
18+
f.write("---\n")
19+
f.write("title: \"FEniCSx Documentation\"\n")
20+
f.write("---\n")
21+
f.write("\n")
22+
f.write("!!CONTENT!!\n")
23+
24+
system(f"cd {web_path} && bundle install && bundle exec jekyll build")
25+
26+
with open(os.path.join(web_path, "_site/template.html")) as f:
27+
template = f.read()
28+
29+
template = template.replace("<p>!!", "!!")
30+
template = template.replace("!!</p>", "!!")
31+
template = template.replace("=\"/", "=\"https://fenicsproject.org/")
32+
template = template.replace("(/assets", "(https://fenicsproject.org/assets")
33+
34+
with open("README.md") as f:
35+
readme = f.read()
36+
37+
with open("index.html", "w") as f:
38+
f.write(template.replace("!!CONTENT!!", markdown(readme)))

0 commit comments

Comments
 (0)