diff --git a/reset-site.sh b/reset-site.sh index 77b508a..d25ff7b 100644 --- a/reset-site.sh +++ b/reset-site.sh @@ -1,288 +1,358 @@ #!/bin/bash -# filepath: /home/bunker-mobile-lab/changemaker.lite.love.island/reset-site.sh -echo "๐ Resetting Changemaker Lite site to baseline..." +# Reset MkDocs site to baseline while preserving custom code +# Usage: ./reset-site.sh -# Define the mkdocs directory -MKDOCS_DIR="/home/bunker-mobile-lab/changemaker.lite.love.island/mkdocs" +set -e # Exit on error + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +MKDOCS_DIR="$SCRIPT_DIR/mkdocs" DOCS_DIR="$MKDOCS_DIR/docs" +TEMP_DIR="/tmp/mkdocs-reset-$$" -# Check if mkdocs directory exists -if [ ! -d "$MKDOCS_DIR" ]; then - echo "โ MkDocs directory not found: $MKDOCS_DIR" - exit 1 -fi +echo "๐ Resetting MkDocs site to baseline..." -cd "$MKDOCS_DIR" || exit 1 +# Create temp directory for backups +mkdir -p "$TEMP_DIR" -echo "๐ Current directory: $(pwd)" - -# Create backup directory with timestamp -BACKUP_DIR="../backup-$(date +%Y%m%d_%H%M%S)" -echo "๐พ Creating backup at: $BACKUP_DIR" -mkdir -p "$BACKUP_DIR" - -# Backup entire docs directory first -cp -r docs "$BACKUP_DIR/" 2>/dev/null || echo "โ ๏ธ Warning: Could not backup docs directory" - -# List of files and directories to preserve -PRESERVE_FILES=( - # Configuration files - "mkdocs.yml" - "docs/index.md" - - # Blog directory and index - "docs/blog" - "docs/blog/index.md" - - # Stylesheets - "docs/stylesheets/extra.css" - - # Template overrides - "docs/overrides/main.html" - - # JavaScript files - "docs/javascripts/gitea-widget.js" - "docs/javascripts/github-widget.js" - "docs/javascripts/home.js" - - # Hooks - "docs/hooks/repo_widget_hook.py" - - # Assets that might exist - "docs/assets" -) - -echo "๐ Preserving essential files..." - -# Create temporary directory for preserved files -TEMP_PRESERVE_DIR="/tmp/mkdocs-preserve-$$" -mkdir -p "$TEMP_PRESERVE_DIR" - -# Copy preserved files to temp directory -for file in "${PRESERVE_FILES[@]}"; do - if [ -e "$file" ]; then - # Create directory structure in temp - dirname_path=$(dirname "$file") - mkdir -p "$TEMP_PRESERVE_DIR/$dirname_path" - - # Copy file or directory - cp -r "$file" "$TEMP_PRESERVE_DIR/$file" 2>/dev/null - echo "โ Preserved: $file" - else - echo "โ ๏ธ Not found (will be created): $file" +# Backup custom directories if they exist +echo "๐ฆ Backing up custom directories..." +for dir in hooks assets javascripts overrides stylesheets blog; do + if [ -d "$DOCS_DIR/$dir" ]; then + echo " - Backing up $dir/" + cp -r "$DOCS_DIR/$dir" "$TEMP_DIR/" fi done -echo "๐๏ธ Cleaning docs directory..." +# Backup mkdocs.yml +cp "$MKDOCS_DIR/mkdocs.yml" "$TEMP_DIR/mkdocs.yml.bak" -# Remove everything from docs except .gitkeep if it exists -find docs/ -mindepth 1 -name ".gitkeep" -prune -o -type f -exec rm -f {} \; 2>/dev/null -find docs/ -mindepth 1 -name ".gitkeep" -prune -o -type d -exec rm -rf {} \; 2>/dev/null +# Clear docs directory +echo "๐งน Clearing docs directory..." +rm -rf "$DOCS_DIR"/* +rm -rf "$DOCS_DIR"/.* 2>/dev/null || true -echo "๐ Recreating directory structure..." +# Create baseline MkDocs Material structure +echo "๐ Creating baseline content structure..." +mkdir -p "$DOCS_DIR" -# Recreate basic directory structure -mkdir -p docs/{stylesheets,javascripts,overrides,hooks,assets,blog/posts} +# Create index.md +cat > "$DOCS_DIR/index.md" << 'EOF' +# Welcome to Your MkDocs Site -echo "โป๏ธ Restoring preserved files..." - -# Restore preserved files -for file in "${PRESERVE_FILES[@]}"; do - if [ -e "$TEMP_PRESERVE_DIR/$file" ]; then - # Create parent directory if needed - dirname_path=$(dirname "$file") - mkdir -p "$dirname_path" - - # Restore file or directory - cp -r "$TEMP_PRESERVE_DIR/$file" "$file" - echo "โ Restored: $file" - fi -done - -# Clean up temp directory -rm -rf "$TEMP_PRESERVE_DIR" - -echo "๐ Ensuring required files exist..." - -# Ensure blog index exists -if [ ! -f "docs/blog/index.md" ]; then - echo "Creating docs/blog/index.md..." - cat > docs/blog/index.md << 'EOF' - - -EOF -fi - -# Ensure main index exists with baseline content if missing -if [ ! -f "docs/index.md" ]; then - echo "Creating baseline docs/index.md..." - cat > docs/index.md << 'EOF' ---- -template: home.html -hide: - - navigation - - toc ---- - -# Welcome to Changemaker Lite - -Stop feeding your secrets to corporations. Own your political infrastructure. - -## Quick Start - -Get up and running in minutes: - -```bash -# Clone the repository -git clone https://gitea.bnkops.com/admin/changemaker.lite -cd changemaker.lite - -# Configure environment -./config.sh - -# Start all services -docker compose up -d -``` - -## Services - -Changemaker Lite includes essential services for documentation, development, and automation. +This site has been reset to baseline configuration. ## Getting Started -1. **Setup**: Run `./config.sh` to configure your environment -2. **Launch**: Start services with `docker compose up -d` -3. **Dashboard**: Access the Homepage at [http://localhost:3010](http://localhost:3010) +- Edit `docs/index.md` to change this page +- Add new pages in the `docs/` directory +- Configure navigation in `mkdocs.yml` +- Customize the theme in `docs/overrides/` +## Features Preserved + +Your custom code has been preserved in: + +- `hooks/` - Custom build hooks +- `assets/` - Images and static files +- `javascripts/` - Custom JavaScript +- `overrides/` - Theme overrides +- `stylesheets/` - Custom CSS +- `blog/` - Blog content + +## Next Steps + +1. Start adding your content +2. Configure the navigation +3. Customize the appearance +4. Deploy your site + +--- + +*Built with MkDocs Material* EOF -fi -# Ensure mkdocs.yml has baseline content if missing -if [ ! -f "mkdocs.yml" ]; then - echo "Creating baseline mkdocs.yml..." - cat > mkdocs.yml << 'EOF' -site_name: Changemaker Lite -site_description: Build Power. Not Rent It. Own your digital infrastructure. -site_url: https://cmlite.org -site_author: Bunker Operations -docs_dir: docs -site_dir: site +# Create a simple getting-started.md +cat > "$DOCS_DIR/getting-started.md" << 'EOF' +# Getting Started -# Repository -repo_url: https://gitea.bnkops.com/admin/changemaker.lite -repo_name: changemaker.lite -edit_uri: "" +Welcome to your fresh MkDocs Material site! -# Theme -theme: - name: material - custom_dir: docs/overrides - palette: - - scheme: slate - primary: deep purple - accent: amber - toggle: - icon: material/weather-night - name: Switch to light mode - - scheme: default - primary: deep purple - accent: amber - toggle: - icon: material/weather-sunny - name: Switch to dark mode - font: - text: Inter - code: JetBrains Mono - features: - - navigation.instant - - navigation.tracking - - navigation.tabs - - navigation.sections - - navigation.expand - - navigation.top - - search.highlight - - search.share - - search.suggest - - content.code.copy +## Adding Content -# Plugins -plugins: - - search - - blog: - blog_dir: blog - post_date_format: medium - archive_name: Archive - categories_name: Categories +Create new markdown files in the `docs/` directory: -# Extra CSS and JS -extra_css: - - stylesheets/extra.css +```bash +docs/ +โโโ index.md # Homepage +โโโ getting-started.md # This page +โโโ page1.md # Your content +โโโ page2.md # More content +``` -extra_javascript: - - javascripts/home.js - - javascripts/github-widget.js - - javascripts/gitea-widget.js +## Configuring Navigation -hooks: - - docs/hooks/repo_widget_hook.py +Edit `mkdocs.yml` to add navigation: -# Navigation +```yaml nav: - Home: index.md - - Blog: - - blog/index.md + - Getting Started: getting-started.md + - Your Section: + - Page 1: page1.md + - Page 2: page2.md +``` -# Copyright -copyright: > - Copyright © 2024 The Bunker Operations +## Using the Blog + +The blog plugin is already configured. Add posts in `docs/blog/posts/`: + +```markdown +--- +date: 2024-01-01 +categories: + - News +--- + +# Your Blog Post Title + +Post content here... +``` + +## Customization + +- Theme overrides: `docs/overrides/` +- Custom CSS: `docs/stylesheets/` +- Custom JS: `docs/javascripts/` EOF -fi -echo "๐งน Cleaning up build artifacts..." - -# Remove build directory if it exists -if [ -d "site" ]; then - rm -rf site - echo "โ Removed build directory" -fi - -# Remove any cache directories -find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null -find . -name "*.pyc" -type f -delete 2>/dev/null - -echo "๐ Verifying reset..." - -# Check that essential files exist -essential_check=true -check_files=("docs/index.md" "mkdocs.yml" "docs/blog/index.md" "docs/stylesheets/extra.css") - -for file in "${check_files[@]}"; do - if [ -f "$file" ]; then - echo "โ $file exists" +# Restore custom directories +echo "โป๏ธ Restoring custom directories..." +for dir in hooks assets javascripts overrides stylesheets blog; do + if [ -d "$TEMP_DIR/$dir" ]; then + echo " - Restoring $dir/" + cp -r "$TEMP_DIR/$dir" "$DOCS_DIR/" else - echo "โ $file missing" - essential_check=false + # Create empty directories if they didn't exist + mkdir -p "$DOCS_DIR/$dir" fi done -if [ "$essential_check" = true ]; then - echo "" - echo "๐ Site reset complete!" - echo "๐ Summary:" - echo " โข Preserved essential configuration and assets" - echo " โข Maintained blog directory and posts" - echo " โข Kept custom stylesheets and JavaScript" - echo " โข Backup created at: $BACKUP_DIR" - echo "" - echo "๐ Next steps:" - echo " โข Run 'mkdocs serve' to start development server" - echo " โข Run 'mkdocs build' to generate static site" +# Create simplified home.html +echo "๐ Creating simplified home template..." +cat > "$DOCS_DIR/overrides/home.html" << 'EOF' +{% extends "main.html" %} + +{% block extrahead %} +{{ super() }} + +{% endblock %} + +{% block content %} +
+ Your MkDocs Material site is ready for customization. +
+ + +Create pages with Markdown
+Make it your own
+Share with the world
+