|
| 1 | +# π Project Index System Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This repository features an automated project indexing system that creates a beautiful, responsive web page displaying all projects and exercises. The system automatically updates whenever new files are added! |
| 6 | + |
| 7 | +## π― Key Features |
| 8 | + |
| 9 | +- **Automatic Discovery**: Scans all directories for HTML, Python, and JavaScript files |
| 10 | +- **Beautiful UI**: Modern gradient design with card-based layout |
| 11 | +- **Live Statistics**: Shows total categories and file counts |
| 12 | +- **Responsive Design**: Works perfectly on desktop and mobile devices |
| 13 | +- **Zero Maintenance**: GitHub Actions handles everything automatically |
| 14 | +- **Future-Proof**: Works with any new projects you add |
| 15 | + |
| 16 | +## π Files |
| 17 | + |
| 18 | +### 1. `generate_index.py` |
| 19 | +Python script that scans the repository and generates `index.html`. |
| 20 | + |
| 21 | +**What it does:** |
| 22 | +- Scans all directories (except hidden ones and `node_modules`) |
| 23 | +- Collects all HTML, Python, and JavaScript files |
| 24 | +- Generates a beautiful index page with: |
| 25 | + - File names and types |
| 26 | + - File sizes |
| 27 | + - Last modification dates |
| 28 | + - Direct links to each file |
| 29 | + |
| 30 | +**Usage:** |
| 31 | +```bash |
| 32 | +python generate_index.py |
| 33 | +``` |
| 34 | + |
| 35 | +### 2. `index.html` (Generated) |
| 36 | +The main landing page for your repository. This file is auto-generated and should not be edited manually. |
| 37 | + |
| 38 | +**Features:** |
| 39 | +- Clean, modern design with purple gradient background |
| 40 | +- Card-based layout for each file |
| 41 | +- Responsive grid that adapts to screen size |
| 42 | +- Color-coded file type badges (HTML=red, Python=blue, JS=yellow) |
| 43 | +- Click any card to open that file |
| 44 | + |
| 45 | +### 3. `.github/workflows/generate-index.yml` |
| 46 | +GitHub Action workflow that automatically runs the generator. |
| 47 | + |
| 48 | +**Triggers:** |
| 49 | +- When you push HTML, Python, or JavaScript files to `main` branch |
| 50 | +- Manual trigger via GitHub Actions UI |
| 51 | + |
| 52 | +**What it does:** |
| 53 | +1. Runs `generate_index.py` |
| 54 | +2. Checks if `index.html` changed |
| 55 | +3. Automatically commits and pushes changes |
| 56 | +4. Uses `[skip ci]` to prevent infinite loops |
| 57 | + |
| 58 | +## π How to Use |
| 59 | + |
| 60 | +### View the Index |
| 61 | + |
| 62 | +Once deployed to GitHub Pages, visit: |
| 63 | +``` |
| 64 | +https://bigbrodyg.github.io/DIYJavaScript/ |
| 65 | +``` |
| 66 | + |
| 67 | +Or open `index.html` locally in your browser. |
| 68 | + |
| 69 | +### Add New Projects |
| 70 | + |
| 71 | +Simply add your files to any directory: |
| 72 | + |
| 73 | +```bash |
| 74 | +# Example: Add a new exercise |
| 75 | +mkdir my-new-project |
| 76 | +echo "console.log('Hello World!');" > my-new-project/app.js |
| 77 | + |
| 78 | +# Commit and push |
| 79 | +git add . |
| 80 | +git commit -m "Add new project" |
| 81 | +git push |
| 82 | +``` |
| 83 | + |
| 84 | +The index will automatically update within 1-2 minutes! π |
| 85 | + |
| 86 | +### Manual Generation |
| 87 | + |
| 88 | +If you want to generate the index locally: |
| 89 | + |
| 90 | +```bash |
| 91 | +python generate_index.py |
| 92 | +``` |
| 93 | + |
| 94 | +## π¨ Customization |
| 95 | + |
| 96 | +### Modify Styles |
| 97 | + |
| 98 | +Edit the `<style>` section in `generate_index.py` (in the `generate_html` function): |
| 99 | + |
| 100 | +```python |
| 101 | +# Change the gradient colors |
| 102 | +background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
| 103 | + |
| 104 | +# Change card colors |
| 105 | +background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); |
| 106 | +``` |
| 107 | + |
| 108 | +### Add File Types |
| 109 | + |
| 110 | +To include additional file types, modify the `scan_directory` function: |
| 111 | + |
| 112 | +```python |
| 113 | +if ext in ['.html', '.htm', '.py', '.js', '.mjs', '.css', '.json']: # Add more extensions |
| 114 | +``` |
| 115 | + |
| 116 | +### Exclude Directories |
| 117 | + |
| 118 | +To exclude specific directories, modify the `main` function: |
| 119 | + |
| 120 | +```python |
| 121 | +excluded_dirs = ['.git', 'node_modules', 'dist', 'build', 'venv'] |
| 122 | +if item.is_dir() and item.name not in excluded_dirs: |
| 123 | +``` |
| 124 | + |
| 125 | +## π§ Troubleshooting |
| 126 | + |
| 127 | +### Index Not Updating |
| 128 | + |
| 129 | +1. Check the Actions tab on GitHub |
| 130 | +2. Look for the "Generate Project Index" workflow |
| 131 | +3. Check for any errors in the workflow logs |
| 132 | +4. Ensure the workflow has `contents: write` permission |
| 133 | + |
| 134 | +### Manual Trigger |
| 135 | + |
| 136 | +If you need to manually trigger the workflow: |
| 137 | +1. Go to GitHub β Actions |
| 138 | +2. Select "Generate Project Index" |
| 139 | +3. Click "Run workflow" |
| 140 | + |
| 141 | +### Local Testing |
| 142 | + |
| 143 | +Test the generator locally before pushing: |
| 144 | + |
| 145 | +```bash |
| 146 | +python generate_index.py |
| 147 | +# Open index.html in your browser to preview |
| 148 | +``` |
| 149 | + |
| 150 | +## π Statistics |
| 151 | + |
| 152 | +The index automatically displays: |
| 153 | +- Total number of categories (directories with files) |
| 154 | +- Total number of indexed files |
| 155 | +- Files per category |
| 156 | +- File sizes and modification dates |
| 157 | + |
| 158 | +## π Best Practices |
| 159 | + |
| 160 | +1. **Organize by Category**: Keep related files in the same directory |
| 161 | +2. **Use Descriptive Names**: File names appear on the index |
| 162 | +3. **Add README Files**: Document your projects (not indexed, but useful) |
| 163 | +4. **Keep It Clean**: Remove or archive old/unused projects |
| 164 | + |
| 165 | +## π¦ Workflow Status |
| 166 | + |
| 167 | +Check the workflow status in the README badges or the Actions tab: |
| 168 | + |
| 169 | +[](https://github.com/bigBrodyG/DIYJavaScript/actions/workflows/generate-index.yml) |
| 170 | + |
| 171 | +## π‘ Tips |
| 172 | + |
| 173 | +- The index shows the last modification date - useful for tracking recent changes |
| 174 | +- File sizes help identify large files that might need optimization |
| 175 | +- Color-coded badges make it easy to identify file types at a glance |
| 176 | +- The responsive design works great on mobile for quick browsing |
| 177 | + |
| 178 | +## π Learning Opportunity |
| 179 | + |
| 180 | +This system demonstrates: |
| 181 | +- Python file system operations |
| 182 | +- HTML/CSS for modern web design |
| 183 | +- GitHub Actions automation |
| 184 | +- CI/CD best practices |
| 185 | +- Template generation |
| 186 | + |
| 187 | +Feel free to study the code and adapt it for your own projects! |
| 188 | + |
| 189 | +## π License |
| 190 | + |
| 191 | +Same as the main repository. |
0 commit comments