-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #31
- Loading branch information
Showing
215 changed files
with
2,562 additions
and
1,133 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,20 +9,36 @@ | |
- `BLOG_POST_SLUG_TITLE` : | ||
- `BLOG_POST_AUTHOR` : | ||
""" | ||
import requests | ||
|
||
from dataclasses import dataclass | ||
from typing import Optional | ||
import httpx | ||
import bs4 | ||
import time | ||
import os | ||
|
||
ROOT: str = "https://blahcat.github.io" | ||
URL: str = f"{ROOT}/feeds/all.atom.xml" | ||
ATOM_FEED_URL: str = f"{ROOT}/feeds/all.atom.xml" | ||
|
||
|
||
@dataclass | ||
class SocialMedia: | ||
twitter: Optional[str] | ||
mastodon: Optional[str] | ||
discord: Optional[str] | ||
github: Optional[str] | ||
|
||
|
||
time.sleep(10) | ||
AUTHORS = { | ||
"hugsy": SocialMedia("@_hugsy_", "@[email protected]", "@crazy.hugsy", "hugsy") | ||
} | ||
|
||
h = requests.get(URL) | ||
time.sleep(2) | ||
|
||
h = httpx.get(ATOM_FEED_URL) | ||
assert h.status_code == 200 | ||
|
||
soup = bs4.BeautifulSoup(h.text, "lxml") | ||
soup = bs4.BeautifulSoup(h.text, "xml") | ||
node = soup.find("entry") | ||
assert node is not None | ||
|
||
|
@@ -34,33 +50,29 @@ def get(x: str): | |
|
||
|
||
def strip_html(html: str): | ||
s = bs4.BeautifulSoup(html, features="html.parser") | ||
s = bs4.BeautifulSoup(html, features="xml") | ||
return s.get_text() | ||
|
||
|
||
def env(x: str): | ||
os.system(f"echo {x} >> $GITHUB_ENV") | ||
|
||
|
||
title = get("title").text | ||
authors = [x.text for x in get("author").find_all("name")] | ||
published = get("published").text | ||
url = ROOT + get("link")["href"] | ||
slug = get("link")["href"][18:-5] | ||
url = str(get("link")["href"]) | ||
slug = str(get("link")["href"].rsplit("/")[-1]) | ||
summary = strip_html(get("summary").text)[:-3] + " [...]" | ||
|
||
author_twitters = [] | ||
for author in authors: | ||
if author == "hugsy": | ||
author_twitters.append("@_hugsy_") | ||
# TODO automate this | ||
|
||
author_twitters = [ | ||
AUTHORS[n].twitter for n in authors if n in AUTHORS and AUTHORS[n].twitter | ||
] | ||
twitter_body = ( | ||
f"""New blog post: '{title}' by {' and '.join(author_twitters)} - {url}""" | ||
) | ||
twitter_body = twitter_body[:280] | ||
|
||
|
||
def env(x: str): | ||
os.system(f"echo {x} >> $GITHUB_ENV") | ||
|
||
|
||
env(f"""BLOG_POST_TITLE="{title}" """) | ||
env(f"""BLOG_POST_PUBLISHED_DATE="{published}" """) | ||
env(f"""BLOG_POST_URL={url}""") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
httpx[cli] | ||
bs4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,11 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
python-version: '3.11' | ||
architecture: 'x64' | ||
cache: 'pip' | ||
- name: Build and publish the site | ||
|
@@ -32,8 +33,6 @@ jobs: | |
source ~/.bashrc | ||
git config --global user.name "hugsy" | ||
git config --global user.email "[email protected]" | ||
git clone https://github.com/hugsy/attila.git /tmp/themes/attila | ||
pelican-themes --install /tmp/themes/attila | ||
pelican content -o output -s pelicanconf.py | ||
zola build -o output | ||
ghp-import output --no-jekyll --branch=gh-pages --message="Generated new content" | ||
git push --force origin gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ jobs: | |
steps: | ||
- name: checkout | ||
uses: actions/[email protected] | ||
with: | ||
submodules: true | ||
|
||
- name: Restore lychee cache | ||
uses: actions/[email protected] | ||
|
@@ -33,9 +35,19 @@ jobs: | |
env: | ||
GITHUB_TOKEN: ${{secrets.LYCHEE_TOKEN}} | ||
with: | ||
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' | ||
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' | ||
fail: true | ||
|
||
- name: Check anchors (setup) | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: [email protected] | ||
|
||
- name: Check anchors (setup) | ||
run: | | ||
zola check | ||
spellcheck: | ||
name: Spell Checker | ||
runs-on: ubuntu-latest | ||
|
@@ -46,7 +58,7 @@ jobs: | |
uses: actions/[email protected] | ||
|
||
- name: Spellcheck | ||
uses: rojopolis/spellcheck-github-actions@0.36.0 | ||
uses: rojopolis/spellcheck-github-actions@0.38.0 | ||
with: | ||
task_name: Markdown | ||
config_path: .github/spellcheck.yml | ||
|
@@ -55,5 +67,5 @@ jobs: | |
- if: '!cancelled()' | ||
run: | | ||
if [ -f spellcheck-output.txt ]; then | ||
python scripts/ci_spellcheck_format.py spellcheck-output.txt >> ${GITHUB_STEP_SUMMARY} | ||
python .github/scripts/ci_spellcheck_format.py spellcheck-output.txt >> ${GITHUB_STEP_SUMMARY} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,13 @@ jobs: | |
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
python-version: '3.11' | ||
architecture: 'x64' | ||
cache: 'pip' | ||
- shell: bash | ||
run: | | ||
python -m pip install -r scripts/requirements.txt | ||
python scripts/get_release_info.py | ||
python -m pip install -r .github/scripts/requirements.txt | ||
python .github/scripts/get_release_info.py | ||
- uses: nearform-actions/[email protected] | ||
with: | ||
twitter-app-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,13 +22,13 @@ jobs: | |
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
python-version: '3.11' | ||
architecture: 'x64' | ||
cache: 'pip' | ||
- shell: bash | ||
run: | | ||
python -m pip install -r scripts/requirements.txt | ||
python scripts/get_release_info.py | ||
python .github/scripts/get_release_info.py | ||
- uses: ncipollo/release-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -45,13 +45,13 @@ jobs: | |
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
python-version: '3.11' | ||
architecture: 'x64' | ||
cache: 'pip' | ||
- shell: bash | ||
run: | | ||
python -m pip install -r scripts/requirements.txt | ||
python scripts/get_release_info.py | ||
python .github/scripts/get_release_info.py | ||
- name: Create the new GitHub Discussion | ||
uses: abirismyname/[email protected] | ||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "themes/zola-clean-blog"] | ||
path = themes/zola-clean-blog | ||
url = https://github.com/dave-tucker/zola-clean-blog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"files.associations": { | ||
"themes/*/templates/*.html": "jinja-html" | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# https://www.getzola.org/documentation/getting-started/configuration/ | ||
base_url = "https://blahcat.github.io" | ||
title = "BlahCats Blog" | ||
description = "Tales of a binary encoded life..." | ||
theme = "zola-clean-blog" | ||
generate_feeds = true | ||
feed_filenames = ["atom.xml", "rss.xml"] | ||
author = "hugsy" | ||
compile_sass = true | ||
build_search_index = true | ||
minify_html = true | ||
|
||
taxonomies = [ | ||
{ name = "categories", rss = true, paginate_by = 10 }, | ||
{ name = "tags", rss = true, paginate_by = 10 }, | ||
{ name = "authors" }, | ||
] | ||
|
||
[markdown] | ||
highlight_code = true | ||
highlight_theme = "base16-ocean-dark" # https://www.getzola.org/documentation/getting-started/configuration/#syntax-highlighting | ||
render_emoji = true | ||
bottom_footnotes = true | ||
smart_punctuation = true | ||
external_links_target_blank = true | ||
external_links_no_follow = true | ||
external_links_no_referrer = true | ||
|
||
[slugify] | ||
paths = "on" | ||
taxonomies = "on" | ||
anchors = "on" | ||
paths_keep_dates = true | ||
|
||
[link_checker] | ||
internal_level = "error" | ||
external_level = "warn" | ||
|
||
[extra] | ||
clean_default_bg_cover = "/img/blog-cover.png" | ||
|
||
clean_blog_menu = [ | ||
{ url = "$BASE_URL", name = "Home" }, | ||
{ url = "$BASE_URL/series", name = "Series" }, | ||
{ url = "$BASE_URL/notes", name = "Notes" }, | ||
{ url = "$BASE_URL/about", name = "About" }, | ||
{ url = "$BASE_URL/qemu", name = "Qemu VMs" }, | ||
] | ||
|
||
clean_blog_social = [ | ||
{ icon = "fas fa-rss", url = "$BASE_URL/atom.xml" }, | ||
{ icon = "fab fa-twitter", url = "https://twitter.com/ctf_blahcat" }, | ||
{ icon = "fab fa-github", url = "https://github.com/blahcat" }, | ||
{ icon = "fab fa-youtube", url = "https://www.youtube.com/channel/UCDrgY65mRZWVoMiB5-VMqfg" }, | ||
{ icon = "fab fa-discord", url = "https://discord.gg/hSbqxxBgRX" }, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.