Files
mwandGitHub 887fe536d6 Fix/local development (#101)
* **Remove Python SCSS compiler and development script**

- Deleted `compile_scss.py` and `dev.sh` scripts to clean up unused SCSS compilation and local development workflow.
- Streamlining project by removing legacy Python-based tooling. Clear shift toward alternative CSS build processes in workflows.

* Migrate SCSS compilation to Python-based workflow and simplify Dockerfile

- Replaced Node.js SCSS tools with libsass and introduced `scss_watcher.py` for automated SCSS compilation during development.
- Updated Dockerfile to use Python-based dependencies and removed redundant npm configuration.
- Cleaned up `package.json`, `requirements.txt`, and outdated scripts to streamline the project.
- Enhanced development workflow with a lightweight Python-based approach.

* Replace `python -m sass` with `pysassc` for SCSS compilation in development scripts

* **Refactor and streamline MkDocs workflows, footer, and blog structure**

- Removed outdated `deploy-preview-fix.yml` and `deploy-test.yml` workflows for cleanup.
- Enhanced `deploy-preview.yml`:
  - Expanded branch triggers to include `build/**`, `test/**`, and `preview/**`.
  - Improved `site_url` logic by standardizing URL formatting.
- Updated `mkdocs.yml` navigation to use consistent `index.md` file naming.
- Simplified footer template to use relative paths for internal links (e.g., `impressum/`, `datenschutz/`).
- Adjusted `mkdocs.sh` to ensure SCSS watcher includes `overrides`.
- Deleted outdated `Sequential Thinking` blog and branch documentation for better maintenance.

* Update to Python 3.13 and streamline MkDocs workflows

- Upgraded Dockerfile base image to `python:3.13-slim-bullseye` for consistency with the latest Python version.
- Consolidated MkDocs and plugin installation steps in `deploy-preview.yml`.
- Replaced Node.js SCSS tools with Python `pysassc` for CSS build process, removing unnecessary npm steps.

* Replace `mkdocs-lightbox` with `mkdocs-glightbox` and improve CSS build step in GitHub Actions workflow

- Updated `deploy-preview.yml` to switch from `mkdocs-lightbox` to `mkdocs-glightbox` for better compatibility and features.
- Enhanced CSS build logic to create the target directory (`docs/assets/css`) if it does not exist, ensuring a smoother workflow execution.

* Streamline deploy workflows and enhance CSS build process

- Added repository-specific condition to `deploy-live.yml` for improved workflow targeting.
- Consolidated MkDocs and plugin installation steps in `deploy-live.yml` to remove redundant tasks.
- Enhanced CSS build step to ensure target directory creation (`mkdir -p docs/assets/css`) in both workflows.
2025-06-02 14:03:20 +02:00

86 lines
3.5 KiB
Python

import time
import subprocess
import os
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class ScssEventHandler(FileSystemEventHandler):
"""
Handles file system events to recompile SCSS on changes.
"""
def on_modified(self, event):
"""
Called when a file or directory is modified.
"""
if event.is_directory:
return
# Define source and destination paths relative to the WORKDIR /docs
scss_source_path = "overrides/assets/css/custom.scss"
css_dest_path = "docs/assets/css/custom.css"
# Check if the modified file is the custom.scss file we care about
# We need to be careful with event.src_path as it might be an absolute path
# or relative to where the watcher was started.
# A more robust check is to see if the event path ends with our source path.
if event.src_path.endswith(scss_source_path):
print(f"Detected change in {event.src_path}. Compiling SCSS...")
print(f"Source SCSS: {scss_source_path}")
print(f"Destination CSS: {css_dest_path}")
try:
# Execute the SCSS compilation command
result = subprocess.run([
"pysassc",
scss_source_path,
css_dest_path
], capture_output=True, text=True, check=True)
print("SCSS compilation command output:")
print("STDOUT:", result.stdout)
print("STDERR:", result.stderr)
print("SCSS compiled successfully.")
# --- NEW: Verify content of the compiled CSS file ---
if os.path.exists(css_dest_path):
with open(css_dest_path, 'r') as f:
content = f.read()
print(f"Content of {css_dest_path} (first 200 chars):\n{content[:200]}...")
else:
print(f"Error: Compiled CSS file not found at {css_dest_path}")
# --- END NEW ---
except subprocess.CalledProcessError as e:
print(f"Error compiling SCSS: {e}")
print("STDOUT:", e.stdout)
print("STDERR:", e.stderr)
except FileNotFoundError:
print("Error: 'sass' command not found. Make sure libsass is installed and in PATH.")
except Exception as e:
print(f"An unexpected error occurred during SCSS compilation: {e}")
if __name__ == "__main__":
# Define the path to watch (the directory containing custom.scss)
# This path is relative to the WORKDIR /docs inside the container
path_to_watch = os.path.join("overrides", "assets", "css")
# Ensure the path exists before starting the watcher
if not os.path.exists(path_to_watch):
print(f"Error: Directory '{path_to_watch}' not found. Please ensure the path to custom.scss is correct relative to /docs.")
exit(1)
event_handler = ScssEventHandler()
observer = Observer()
# Schedule the observer to watch the specified path without recursion
observer.schedule(event_handler, path_to_watch, recursive=False)
observer.start()
print(f"Watching for changes in {path_to_watch}...")
try:
# Keep the observer running until interrupted
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
print("SCSS watcher stopped.")
observer.join()