Skip to content

Make index.html look like the website #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .github/workflows/homepage.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/jekyll.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,67 @@ on:

jobs:
build:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# Make index.html
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Generate index.html
run: |
sudo apt update
sudo apt install -y ruby-bundler ruby-dev
python3 -m pip install -r requirements.txt
python3 make_index.py

- name: Build the site in the jekyll/builder container
run: |
docker run \
-v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \
jekyll/builder:latest /bin/bash -c "chmod 777 /srv/jekyll && jekyll build --future"

build-and-deploy:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

permissions:
contents: read
pages: write
id-token: write

steps:
- uses: actions/checkout@v4

# Make index.html
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Generate index.html
run: |
sudo apt update
sudo apt install -y ruby-bundler ruby-dev
python3 -m pip install -r requirements.txt
python3 make_index.py

- name: Build the site in the jekyll/builder container
run: |
docker run \
-v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \
jekyll/builder:latest /bin/bash -c "chmod 777 /srv/jekyll && jekyll build --future"

# Deploy to GitHub Pages
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: '_site'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
index.html
*.pyc
_web/
Gemfile.lock
_site/
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
---
pagetitle: FEniCSx Project Documentation
header-includes: <link rel="shortcut icon" type="image/x-icon" href="https://fenicsproject.org/favicon.ico"/>
---

# FEniCSx Project Documentation

<img style="display: block; margin: 0 auto; width: 70px;" src="https://fenicsproject.org/pub/graphics/fenics_logo.svg" alt="FEniCS project logo">

## Latest release

#### DOLFINx
Expand Down
98 changes: 0 additions & 98 deletions index.html

This file was deleted.

38 changes: 38 additions & 0 deletions make_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os

from markdown import markdown


def system(command):
assert os.system(command) == 0


_path = os.path.dirname(os.path.realpath(__file__))
web_path = os.path.join(_path, "_web")

if os.path.isdir(web_path):
system(f"rm -r {web_path}")
system(f"git clone http://github.com/FEniCS/web {web_path}")

with open(os.path.join(web_path, "template.md"), "w") as f:
f.write("---\n")
f.write("title: \"FEniCSx Documentation\"\n")
f.write("---\n")
f.write("\n")
f.write("!!CONTENT!!\n")

system(f"cd {web_path} && bundle install && bundle exec jekyll build")

with open(os.path.join(web_path, "_site/template.html")) as f:
template = f.read()

template = template.replace("<p>!!", "!!")
template = template.replace("!!</p>", "!!")
template = template.replace("=\"/", "=\"https://fenicsproject.org/")
template = template.replace("(/assets", "(https://fenicsproject.org/assets")

with open("README.md") as f:
readme = f.read()

with open("index.html", "w") as f:
f.write(template.replace("!!CONTENT!!", markdown(readme)))
Loading