reste.sh updatae

This commit is contained in:
admin 2025-07-06 15:57:59 -06:00
parent ac01d925ca
commit c4ea51995e

View File

@ -1,288 +1,358 @@
#!/bin/bash #!/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 set -e # Exit on error
MKDOCS_DIR="/home/bunker-mobile-lab/changemaker.lite.love.island/mkdocs"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MKDOCS_DIR="$SCRIPT_DIR/mkdocs"
DOCS_DIR="$MKDOCS_DIR/docs" DOCS_DIR="$MKDOCS_DIR/docs"
TEMP_DIR="/tmp/mkdocs-reset-$$"
# Check if mkdocs directory exists echo "🔄 Resetting MkDocs site to baseline..."
if [ ! -d "$MKDOCS_DIR" ]; then
echo "❌ MkDocs directory not found: $MKDOCS_DIR"
exit 1
fi
cd "$MKDOCS_DIR" || exit 1 # Create temp directory for backups
mkdir -p "$TEMP_DIR"
echo "📂 Current directory: $(pwd)" # Backup custom directories if they exist
echo "📦 Backing up custom directories..."
# Create backup directory with timestamp for dir in hooks assets javascripts overrides stylesheets blog; do
BACKUP_DIR="../backup-$(date +%Y%m%d_%H%M%S)" if [ -d "$DOCS_DIR/$dir" ]; then
echo "💾 Creating backup at: $BACKUP_DIR" echo " - Backing up $dir/"
mkdir -p "$BACKUP_DIR" cp -r "$DOCS_DIR/$dir" "$TEMP_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"
fi fi
done 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 # Clear docs directory
find docs/ -mindepth 1 -name ".gitkeep" -prune -o -type f -exec rm -f {} \; 2>/dev/null echo "🧹 Clearing docs directory..."
find docs/ -mindepth 1 -name ".gitkeep" -prune -o -type d -exec rm -rf {} \; 2>/dev/null 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 # Create index.md
mkdir -p docs/{stylesheets,javascripts,overrides,hooks,assets,blog/posts} cat > "$DOCS_DIR/index.md" << 'EOF'
# Welcome to Your MkDocs Site
echo "♻️ Restoring preserved files..." This site has been reset to baseline configuration.
# 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'
<!-- filepath: /home/bunker-mobile-lab/changemaker.lite.love.island/mkdocs/docs/blog/index.md -->
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.
## Getting Started ## Getting Started
1. **Setup**: Run `./config.sh` to configure your environment - Edit `docs/index.md` to change this page
2. **Launch**: Start services with `docker compose up -d` - Add new pages in the `docs/` directory
3. **Dashboard**: Access the Homepage at [http://localhost:3010](http://localhost:3010) - 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 EOF
fi
# Ensure mkdocs.yml has baseline content if missing # Create a simple getting-started.md
if [ ! -f "mkdocs.yml" ]; then cat > "$DOCS_DIR/getting-started.md" << 'EOF'
echo "Creating baseline mkdocs.yml..." # Getting Started
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
# Repository Welcome to your fresh MkDocs Material site!
repo_url: https://gitea.bnkops.com/admin/changemaker.lite
repo_name: changemaker.lite
edit_uri: ""
# Theme ## Adding Content
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
# Plugins Create new markdown files in the `docs/` directory:
plugins:
- search
- blog:
blog_dir: blog
post_date_format: medium
archive_name: Archive
categories_name: Categories
# Extra CSS and JS ```bash
extra_css: docs/
- stylesheets/extra.css ├── index.md # Homepage
├── getting-started.md # This page
├── page1.md # Your content
└── page2.md # More content
```
extra_javascript: ## Configuring Navigation
- javascripts/home.js
- javascripts/github-widget.js
- javascripts/gitea-widget.js
hooks: Edit `mkdocs.yml` to add navigation:
- docs/hooks/repo_widget_hook.py
# Navigation ```yaml
nav: nav:
- Home: index.md - Home: index.md
- Blog: - Getting Started: getting-started.md
- blog/index.md - Your Section:
- Page 1: page1.md
- Page 2: page2.md
```
# Copyright ## Using the Blog
copyright: >
Copyright &copy; 2024 The Bunker Operations 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 EOF
fi
echo "🧹 Cleaning up build artifacts..." # Restore custom directories
echo "♻️ Restoring custom directories..."
# Remove build directory if it exists for dir in hooks assets javascripts overrides stylesheets blog; do
if [ -d "site" ]; then if [ -d "$TEMP_DIR/$dir" ]; then
rm -rf site echo " - Restoring $dir/"
echo "✅ Removed build directory" cp -r "$TEMP_DIR/$dir" "$DOCS_DIR/"
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"
else else
echo "$file missing" # Create empty directories if they didn't exist
essential_check=false mkdir -p "$DOCS_DIR/$dir"
fi fi
done done
if [ "$essential_check" = true ]; then # Create simplified home.html
echo "" echo "🏠 Creating simplified home template..."
echo "🎉 Site reset complete!" cat > "$DOCS_DIR/overrides/home.html" << 'EOF'
echo "📋 Summary:" {% extends "main.html" %}
echo " • Preserved essential configuration and assets"
echo " • Maintained blog directory and posts" {% block extrahead %}
echo " • Kept custom stylesheets and JavaScript" {{ super() }}
echo " • Backup created at: $BACKUP_DIR" <link rel="stylesheet" href="{{ 'stylesheets/home.css' | url }}">
echo "" {% endblock %}
echo "🚀 Next steps:"
echo " • Run 'mkdocs serve' to start development server" {% block content %}
echo " • Run 'mkdocs build' to generate static site" <div class="home-container">
<div class="home-hero">
{% if config.theme.logo %}
<img src="{{ config.theme.logo | url }}" alt="Logo" class="home-logo">
{% endif %}
<h1 class="home-title">Let's get started!</h1>
<p class="home-subtitle">
Your MkDocs Material site is ready for customization.
</p>
<div class="home-actions">
<a href="{{ 'getting-started/' | url }}" class="home-button home-button-primary">
Get Started
</a>
<a href="https://squidfunk.github.io/mkdocs-material/" class="home-button home-button-secondary">
Documentation
</a>
</div>
</div>
<div class="home-features">
<div class="feature-card">
<div class="feature-icon">📝</div>
<h3>Write Content</h3>
<p>Create pages with Markdown</p>
</div>
<div class="feature-card">
<div class="feature-icon">🎨</div>
<h3>Customize Theme</h3>
<p>Make it your own</p>
</div>
<div class="feature-card">
<div class="feature-icon">🚀</div>
<h3>Deploy</h3>
<p>Share with the world</p>
</div>
</div>
</div>
{% endblock %}
EOF
# Create simplified home.css
echo "🎨 Creating simplified home styles..."
cat > "$DOCS_DIR/stylesheets/home.css" << 'EOF'
/* Simple home page styles */
.home-container {
max-width: 1200px;
margin: 0 auto;
padding: 2rem;
}
.home-hero {
text-align: center;
padding: 4rem 0;
}
.home-logo {
width: 120px;
height: 120px;
margin-bottom: 2rem;
}
.home-title {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem 0;
color: var(--md-primary-fg-color);
}
.home-subtitle {
font-size: 1.25rem;
color: var(--md-default-fg-color--light);
margin: 0 0 2rem 0;
}
.home-actions {
display: flex;
gap: 1rem;
justify-content: center;
flex-wrap: wrap;
}
.home-button {
display: inline-block;
padding: 0.75rem 2rem;
border-radius: 0.25rem;
text-decoration: none;
font-weight: 500;
transition: all 0.2s;
}
.home-button-primary {
background: var(--md-primary-fg-color);
color: var(--md-primary-bg-color);
}
.home-button-primary:hover {
background: var(--md-primary-fg-color--dark);
transform: translateY(-2px);
}
.home-button-secondary {
border: 2px solid var(--md-primary-fg-color);
color: var(--md-primary-fg-color);
}
.home-button-secondary:hover {
background: var(--md-primary-fg-color);
color: var(--md-primary-bg-color);
}
.home-features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2rem;
margin-top: 4rem;
}
.feature-card {
text-align: center;
padding: 2rem;
border-radius: 0.5rem;
background: var(--md-code-bg-color);
}
.feature-icon {
font-size: 3rem;
margin-bottom: 1rem;
}
.feature-card h3 {
margin: 0 0 0.5rem 0;
color: var(--md-default-fg-color);
}
.feature-card p {
margin: 0;
color: var(--md-default-fg-color--light);
}
/* Dark mode support */
[data-md-color-scheme="slate"] .home-logo {
filter: brightness(0.9);
}
[data-md-color-scheme="slate"] .feature-card {
background: var(--md-default-fg-color--lightest);
}
/* Mobile responsive */
@media (max-width: 768px) {
.home-title {
font-size: 2rem;
}
.home-subtitle {
font-size: 1rem;
}
.home-actions {
flex-direction: column;
align-items: center;
}
.home-button {
width: 100%;
max-width: 300px;
text-align: center;
}
}
EOF
# Update mkdocs.yml - remove nav section
echo "📋 Updating mkdocs.yml (removing nav)..."
# Use sed to remove nav section (everything from "nav:" to the next top-level key)
sed -i '/^nav:/,/^[a-zA-Z]/{ /^nav:/d; /^[a-zA-Z]/!d; }' "$MKDOCS_DIR/mkdocs.yml"
# Also ensure the logo path is correct
if [ -f "$DOCS_DIR/assets/logo.png" ]; then
echo "✅ Logo found at assets/logo.png"
else else
echo "" echo "⚠️ No logo found at assets/logo.png - you may want to add one"
echo "⚠️ Reset completed with warnings - some essential files are missing"
echo "💾 Backup available at: $BACKUP_DIR"
fi fi
# Clean up temp directory
rm -rf "$TEMP_DIR"
echo "✅ Reset complete!"
echo "" echo ""
echo "✨ Reset complete!" echo "Next steps:"
echo "1. Add your content to $DOCS_DIR"
echo "2. Configure navigation in mkdocs.yml"
echo "3. Customize the home page in overrides/home.html"
echo "4. Run 'mkdocs serve' to preview"
echo ""
echo "Your custom code has been preserved in:"
echo " - hooks/"
echo " - assets/"
echo " - javascripts/"
echo " - overrides/"
echo " - stylesheets/"
echo " - blog/"