Skip to content

Commit 4e86d00

Browse files
authored
Replace Pelican with Zola (#32)
Fixes #31
1 parent a816170 commit 4e86d00

File tree

215 files changed

+2562
-1133
lines changed

Some content is hidden

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

215 files changed

+2562
-1133
lines changed

scripts/get_release_info.py renamed to .github/scripts/get_release_info.py

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,36 @@
99
- `BLOG_POST_SLUG_TITLE` :
1010
- `BLOG_POST_AUTHOR` :
1111
"""
12-
import requests
12+
13+
from dataclasses import dataclass
14+
from typing import Optional
15+
import httpx
1316
import bs4
1417
import time
1518
import os
1619

1720
ROOT: str = "https://blahcat.github.io"
18-
URL: str = f"{ROOT}/feeds/all.atom.xml"
21+
ATOM_FEED_URL: str = f"{ROOT}/feeds/all.atom.xml"
22+
23+
24+
@dataclass
25+
class SocialMedia:
26+
twitter: Optional[str]
27+
mastodon: Optional[str]
28+
discord: Optional[str]
29+
github: Optional[str]
30+
1931

20-
time.sleep(10)
32+
AUTHORS = {
33+
"hugsy": SocialMedia("@_hugsy_", "@[email protected]", "@crazy.hugsy", "hugsy")
34+
}
2135

22-
h = requests.get(URL)
36+
time.sleep(2)
37+
38+
h = httpx.get(ATOM_FEED_URL)
2339
assert h.status_code == 200
2440

25-
soup = bs4.BeautifulSoup(h.text, "lxml")
41+
soup = bs4.BeautifulSoup(h.text, "xml")
2642
node = soup.find("entry")
2743
assert node is not None
2844

@@ -34,33 +50,29 @@ def get(x: str):
3450

3551

3652
def strip_html(html: str):
37-
s = bs4.BeautifulSoup(html, features="html.parser")
53+
s = bs4.BeautifulSoup(html, features="xml")
3854
return s.get_text()
3955

4056

57+
def env(x: str):
58+
os.system(f"echo {x} >> $GITHUB_ENV")
59+
60+
4161
title = get("title").text
4262
authors = [x.text for x in get("author").find_all("name")]
4363
published = get("published").text
44-
url = ROOT + get("link")["href"]
45-
slug = get("link")["href"][18:-5]
64+
url = str(get("link")["href"])
65+
slug = str(get("link")["href"].rsplit("/")[-1])
4666
summary = strip_html(get("summary").text)[:-3] + " [...]"
4767

48-
author_twitters = []
49-
for author in authors:
50-
if author == "hugsy":
51-
author_twitters.append("@_hugsy_")
52-
# TODO automate this
53-
68+
author_twitters = [
69+
AUTHORS[n].twitter for n in authors if n in AUTHORS and AUTHORS[n].twitter
70+
]
5471
twitter_body = (
5572
f"""New blog post: '{title}' by {' and '.join(author_twitters)} - {url}"""
5673
)
5774
twitter_body = twitter_body[:280]
5875

59-
60-
def env(x: str):
61-
os.system(f"echo {x} >> $GITHUB_ENV")
62-
63-
6476
env(f"""BLOG_POST_TITLE="{title}" """)
6577
env(f"""BLOG_POST_PUBLISHED_DATE="{published}" """)
6678
env(f"""BLOG_POST_URL={url}""")

.github/scripts/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
httpx[cli]
2+
bs4

.github/spellcheck.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ matrix:
88
- .github/wordlist.txt
99
encoding: utf-8
1010
pipeline:
11+
- pyspelling.filters.context:
12+
context_visible_first: true
13+
escapes: \\[\\`~]
14+
delimiters:
15+
# Ignore anything in {{ }}
16+
- open: '(?s)(?P<open> *\{{2})'
17+
close: '^(?P=open)$'
18+
- open: '(?P<open>\}{2})'
19+
close: '(?P=open)'
20+
# Ignore frontmatter (+++ / +++)
21+
- open: '(?s)^(?P<open> *\+{3})$'
22+
close: '^(?P=open)$'
23+
- open: '(?P<open>\+{3})$'
24+
close: '(?P=open)'
1125
- pyspelling.filters.markdown:
1226
markdown_extensions:
1327
- pymdownx.superfences

.github/workflows/build.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v4
2222
with:
23+
submodules: true
2324
token: ${{ secrets.GITHUB_TOKEN }}
2425
- uses: actions/setup-python@v5
2526
with:
26-
python-version: '3.10'
27+
python-version: '3.11'
2728
architecture: 'x64'
2829
cache: 'pip'
2930
- name: Build and publish the site
@@ -32,8 +33,6 @@ jobs:
3233
source ~/.bashrc
3334
git config --global user.name "hugsy"
3435
git config --global user.email "[email protected]"
35-
git clone https://github.com/hugsy/attila.git /tmp/themes/attila
36-
pelican-themes --install /tmp/themes/attila
37-
pelican content -o output -s pelicanconf.py
36+
zola build -o output
3837
ghp-import output --no-jekyll --branch=gh-pages --message="Generated new content"
3938
git push --force origin gh-pages

.github/workflows/check.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
steps:
2121
- name: checkout
2222
uses: actions/[email protected]
23+
with:
24+
submodules: true
2325

2426
- name: Restore lychee cache
2527
uses: actions/[email protected]
@@ -33,9 +35,19 @@ jobs:
3335
env:
3436
GITHUB_TOKEN: ${{secrets.LYCHEE_TOKEN}}
3537
with:
36-
args: --exclude='^http://rawpixels.net/.*$' --exclude='^http://rawpixels.net/.*$' --exclude='^https://twitter.com/.*$' --exclude='^https://ctftime.org/.*$' --cache --max-cache-age 1w --exclude-all-private --threads 10 --timeout 30 --retry-wait-time 60 --user-agent 'Mozilla/5.0 (Windows NT x.y; rv:10.0) Gecko/20100101 Firefox/10.0' --no-progress 'content/**/*.md'
38+
args: --exclude='^file://.*$' --exclude='^http://rawpixels.net/.*$' --exclude='^http://rawpixels.net/.*$' --exclude='^https://twitter.com/.*$' --exclude='^https://ctftime.org/.*$' --cache --max-cache-age 1w --exclude-all-private --threads 10 --timeout 30 --retry-wait-time 60 --user-agent 'Mozilla/5.0 (Windows NT x.y; rv:10.0) Gecko/20100101 Firefox/10.0' --no-progress 'content/**/*.md'
3739
fail: true
3840

41+
- name: Check anchors (setup)
42+
uses: taiki-e/install-action@v2
43+
with:
44+
45+
46+
- name: Check anchors (setup)
47+
run: |
48+
zola check
49+
50+
3951
spellcheck:
4052
name: Spell Checker
4153
runs-on: ubuntu-latest
@@ -46,7 +58,7 @@ jobs:
4658
uses: actions/[email protected]
4759

4860
- name: Spellcheck
49-
uses: rojopolis/spellcheck-github-actions@0.36.0
61+
uses: rojopolis/spellcheck-github-actions@0.38.0
5062
with:
5163
task_name: Markdown
5264
config_path: .github/spellcheck.yml
@@ -55,5 +67,5 @@ jobs:
5567
- if: '!cancelled()'
5668
run: |
5769
if [ -f spellcheck-output.txt ]; then
58-
python scripts/ci_spellcheck_format.py spellcheck-output.txt >> ${GITHUB_STEP_SUMMARY}
70+
python .github/scripts/ci_spellcheck_format.py spellcheck-output.txt >> ${GITHUB_STEP_SUMMARY}
5971
fi

.github/workflows/notify.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ jobs:
2323
- uses: actions/checkout@v4
2424
- uses: actions/setup-python@v4
2525
with:
26-
python-version: '3.10'
26+
python-version: '3.11'
2727
architecture: 'x64'
2828
cache: 'pip'
2929
- shell: bash
3030
run: |
31-
python -m pip install -r scripts/requirements.txt
32-
python scripts/get_release_info.py
31+
python -m pip install -r .github/scripts/requirements.txt
32+
python .github/scripts/get_release_info.py
3333
- uses: nearform-actions/[email protected]
3434
with:
3535
twitter-app-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ jobs:
2222
- uses: actions/checkout@v4
2323
- uses: actions/setup-python@v4
2424
with:
25-
python-version: '3.10'
25+
python-version: '3.11'
2626
architecture: 'x64'
2727
cache: 'pip'
2828
- shell: bash
2929
run: |
3030
python -m pip install -r scripts/requirements.txt
31-
python scripts/get_release_info.py
31+
python .github/scripts/get_release_info.py
3232
- uses: ncipollo/release-action@v1
3333
with:
3434
token: ${{ secrets.GITHUB_TOKEN }}
@@ -45,13 +45,13 @@ jobs:
4545
- uses: actions/checkout@v4
4646
- uses: actions/setup-python@v4
4747
with:
48-
python-version: '3.10'
48+
python-version: '3.11'
4949
architecture: 'x64'
5050
cache: 'pip'
5151
- shell: bash
5252
run: |
5353
python -m pip install -r scripts/requirements.txt
54-
python scripts/get_release_info.py
54+
python .github/scripts/get_release_info.py
5555
- name: Create the new GitHub Discussion
5656
uses: abirismyname/[email protected]
5757
env:

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "themes/zola-clean-blog"]
2+
path = themes/zola-clean-blog
3+
url = https://github.com/dave-tucker/zola-clean-blog

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.associations": {
3+
"themes/*/templates/*.html": "jinja-html"
4+
},
5+
}

0 commit comments

Comments
 (0)