Commit 45b8f4952d

45b8f4952dfa2ad7ce01a203ecca2e64deb6e53e

parent: 37ae034013

Unsigned

cmc <hello@cleberg.net> · 2025-06-04 15:47 UTC

feat(lint): added ruff.toml to automate linting and formatting

Layout: unified · split

build.py +35 −4
@@ -1,11 +1,36 @@
11#!/usr/bin/env python3
2"""
3This script automates the process of building, testing, and deploying the website.
4It handles tasks such as:
5
6- Removing and recreating the build directory.
7- Minifying CSS assets.
8- Running the Emacs publishing script to generate site content.
9- Updating the index.html file with the latest blog posts.
10- Optionally deploying the built site to a remote server.
11- Starting a local development server for previewing changes.
12
13Usage:
14 Set the environment variable ENV to 'prod' for production builds.
15 Run the script to perform the build process accordingly.
16
17Dependencies:
18 - Python 3
19 - Emacs with the publish.el script
20 - minify tool for CSS minification
21 - rsync for deployment
22
23Author:
24 Christian Cleberg <hello@cleberg.net>
25"""
26
227import os
328import re
429import shutil
530import subprocess
631import sys
7from pathlib import Path
832from datetime import datetime
33from pathlib import Path
934
1035
1136def update_index_html(html_snippet, template_path="./.build/index.html"):
@@ -60,7 +85,9 @@ def update_index_html(html_snippet, template_path="./.build/index.html"):
6085 end_line_start = end_index
6186
6287 # Construct the new content
63 new_content = content[:insert_start] + indented_snippet + content[end_line_start:]
88 new_content = (
89 content[:insert_start] + indented_snippet + content[end_line_start:]
90 )
6491
6592 # Write back to index.html
6693 with open(template_path, "w", encoding="utf-8") as f:
@@ -161,7 +188,9 @@ def get_recent_posts_html(content_dir="./content/blog", num_posts=3):
161188 f'\t\t<time datetime="{post["date_str"]}">{post["date_str"]}</time>'
162189 )
163190 lines.append('\t\t<div class="post-content">')
164 lines.append(f'\t\t\t<a href="/blog/{post["slug"]}.html">{post["title"]}</a>')
191 lines.append(
192 f'\t\t\t<a href="/blog/{post["slug"]}.html">{post["title"]}</a>'
193 )
165194 if post["tags"]:
166195 lines.append('\t\t\t<div class="post-tags">')
167196 for tag in post["tags"]:
@@ -245,7 +274,9 @@ def start_dev_server(build_dir):
245274 os.chdir(build_dir)
246275 # This will run until interrupted (Ctrl+C)
247276 try:
248 subprocess.run([sys.executable, "-m", "http.server", "8000"], check=True)
277 subprocess.run(
278 [sys.executable, "-m", "http.server", "8000"], check=True
279 )
249280 except KeyboardInterrupt:
250281 print("\nDevelopment server stopped.")
251282 except subprocess.CalledProcessError as e:
ruff.toml added +14
@@ -0,0 +1,14 @@
1exclude = [".venv"]
2line-length = 80
3indent-width = 4
4respect-gitignore = true
5show-fixes = true
6
7[format]
8docstring-code-format = true
9docstring-code-line-length = 80
10indent-style = "space"
11quote-style = "double"
12
13[lint]
14ignore = ["PLR0912"]
\ No newline at end of file
utils/salary_visualization.py +1 −1
@@ -6,9 +6,9 @@ plotly.
66"""
77
88import locale
9from pandas import read_csv as pd_read_csv
109import pandas as pd
1110import plotly.graph_objs as go
11from pandas import read_csv as pd_read_csv
1212
1313locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
1414