LLM Outline For GitHub Refactor
Header
- Intent Analysis: The user wants an architectural design and code-level refactoring plan to create a distinct, GitHub-backed static site generator version of their notes pipeline for non-technical users. The key requirement is complete isolation so that developing and publishing this version has zero impact on the user’s personal, offline VPS/WSL/rsync workflow.
- Premise Evaluation: The premise relies on code modularity and runtime environment detection. If environment detection is implemented incorrectly, the user risks exposing private notes to public Git histories, leaking local absolute path structures, or running deployment functions (like WSL rsync commands) inside restricted cloud runners. Complete physical isolation of data folders and the implementation of a strict configuration override pattern are required to maintain security.
Body
1. Workflow Isolation & Coexistence Strategy
To develop, test, and distribute the GitHub-based version without altering your personal, offline workflow, apply a strict separation of concerns utilizing environment detection and file overrides.
┌──────────────────────────────┐
│ Common build_site.py Core │
└──────────────┬───────────────┘
│
Is "config.local.yaml" present?
│
┌────────────────┴────────────────┐
▼ YES ▼ NO
[Personal Offline Mode] [GitHub Public Mode]
- Load absolute paths - Load relative repository paths
- Execute local WSL rsync - Output to root-relative "./dist"
- Run locally on host F:\ - Deployment handled by CI runner
Isolation Rules
- Physical Folder Separation: Do not co-locate your private vault (
F:\ipse_paideia) with the development repository of the public-facing project. Keep the public project in a completely separate root-level folder (e.g.,D:\dev\public\markdown-notes-template). - Configuration Overrides: Create a base
config.yamlcontaining relative paths for the public version. Create a separateconfig.local.yamlfor your personal offline settings containing your absolute path definitions (F:\ipse_paideia,D:\dev\personal\...). - Strict Git Ignore Rules: Add
config.local.yamlto the.gitignorefile. This guarantees that your personal absolute paths and local paths are never pushed to GitHub. - Compile-Time Feature Flags: Refactor the deployment function in
build_site.pyto run only ifconfig.local.yamlis detected and a specificdeploy_locallykey is set totrue. If absent, the script must exit silently after generating the HTML output, leaving final deployment tasks to the platform runner.
2. GitHub-Based Template Repository Structure
The distributed public version must be packaged as a clean, standardized repository template that a non-technical user can clone or duplicate.
markdown-notes-template/
├── .github/
│ └── workflows/
│ └── deploy.yml # GitHub Actions CI/CD deployment pipeline
├── src/ # Input directory for user's Markdown files
│ ├── index.md # Homepage of the notes site
│ └── navigation_menu.md # Simplified markdown navigation source
├── assets/ # Front-end design assets
│ ├── css/ # Custom overrides & Pico.css
│ └── templates/ # Pandoc HTML layout templates
├── system/ # Critical files hidden from typical user paths
│ ├── favicons/
│ ├── robots.txt
│ └── .htaccess # Kept for standard Apache compatibility if needed
├── requirements.txt # Python dependencies (e.g., PyYAML)
├── build_site.py # Path-abstracted Python compiler script
└── config.yaml # Repository-relative configuration defaults
3. Pathing & Script Refactoring Plan
The code base in build_site.py requires restructuring to transition from host-specific configurations to environment-aware pathing.
Step A: Dynamic Root Resolution
Replace absolute paths with dynamic lookups anchored to the script’s directory location:
import os
import yaml
# Determine repository root directory
REPO_ROOT = os.path.dirname(os.path.abspath(__file__))
# Determine which configuration file to load
local_config_path = os.path.join(REPO_ROOT, "config.local.yaml")
default_config_path = os.path.join(REPO_ROOT, "config.yaml")
if os.path.exists(local_config_path):
with open(local_config_path, "r") as f:
config = yaml.safe_load(f)
print("Running in Local Personal Mode.")
else:
with open(default_config_path, "r") as f:
config = yaml.safe_load(f)
print("Running in Public GitHub Mode.")
# Convert relative configuration paths to absolute paths at runtime
SRC_DIR = os.path.abspath(os.path.join(REPO_ROOT, config.get("src", "./src")))
DST_DIR = os.path.abspath(os.path.join(REPO_ROOT, config.get("dst", "./dist")))
Step B: Decouple External Systems
Isolate and wrap any shell invocations (WSL, rsync, rclone, or SSH commands) inside conditional checks:
def sync_to_server():
# Only run if explicitly authorized by local configuration override
if config.get("local_deploy_enabled", False):
print("Executing local deployment commands...")
# Invoke your existing WSL/rsync command logic here
else:
print("Skipping local deployment. Asset compilation complete.")
4. GitHub Actions CI/CD Pipeline
To remove the need for local execution, local Python configurations, Pandoc local binaries, and terminal commands for the end-user, create a GitHub Actions workflow file.
Save the following configuration inside .github/workflows/deploy.yml:
name: Deploy Markdown Site
on:
push:
branches:
- main # Runs on every push to the main branch
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build_and_deploy:
environment:
name: github-pages
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install Pandoc
uses: pandoc/actions/setup@v1
with:
version: '3.1.11' # Explicit stable version tag
- name: Run Build Script
run: python build_site.py
- name: Index Site with Pagefind
run: npx pagefind --site dist
- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
5. Implementation Roadmap for Dual Workflows
To execute this architectural shift successfully, complete the tasks in the following order:
- Clean up scripts: Refactor your local
build_site.pyfile to resolve paths dynamically relative to__file__rather than using hardcodedD:orF:strings. - Isolate settings: Extract your personal folder locations and server synchronization settings into a new
config.local.yamlfile inside your development folder. - Verify Gitignore: Add
config.local.yamlto your global or local.gitignore. - Confirm absolute offline functionality: Execute
python build_site.pyon your machine. Confirm that the script detectsconfig.local.yaml, compiles your files, and executes the local WSL rsync step correctly. - Create the public repository: Create a clean, separate folder and initialize a new git repository (
markdown-notes-template). Copy the refactoredbuild_site.pyand the baseconfig.yaml(which uses./srcand./dist) into this folder. - Add templates: Copy the
.github/workflows/deploy.ymlpipeline and standard default assets to the new public repository. - Test public execution: Run
git pushto trigger the GitHub Pages compilation. Confirm the public pipeline compiles and indexes using Pages, independent of your offline architecture.