Git Codebase - Sn0wlink IT
Git Codebase
Code:
Download ZIP
đź—€ assets
LICENSE
README.md
index.php
README.md
# Dynamic PHP Git Repository Browser Release: Version 1.0  A lightweight, zero‑dependency PHP-based Git repository viewer that dynamically lists and displays repositories, directories, files, and README.md content from a given document root. Designed for self-hosters who want a simple, fast, no‑JavaScript viewer for local or server‑side Git repositories. # Features - Works on mobile - Automatic repository discovery - Scans root directory for directories and treats each as a Git repo. - Latest commit timestamps - Uses git to show last modification date. - Directory navigation - View nested folders - “Up directory” control - Clean URL navigation with ?loc= and ?file= parameters - File viewing - Renders plain text files directly - Automatically displays images (exif_imagetype) - Provides direct download links - README.md rendering - Detects and displays README.md in any repository - Optional Parsedown Markdown renderer - Social header block - Configurable username, profile photo, websites, email, Mastodon account, and location. # Project Structure The application is fully contained in a single index.php file: - Page templating (banner, logo, content) - Repository listing - Directory and file browser - Markdown handling - Social header output # Requirements - PHP 7.4+ (works on PHP 8.x) - Git installed on the host - Web server (Apache, Nginx, Lighttpd, etc.) # Usage 1. Drop index.php into your document root. 2. Ensure subdirectories are Git repositories. 3. Open in a browser: ``` http://your-server/index.php ``` The script will automatically: - List repositories - Let you navigate into them - Display directories/files - Render README.md (optionally with Parsedown) ### Generating ZIP Archives There is a *zip_dir.sh* file in the assets folder. Place this next to the index.php file (root directory) and run. This will then take all of the repos and compress them to zip files. Once run the 'Download Zip' button will appear on the Web UI for that repo. You can also generate the zip manually making sure to call the zip file the same as the repo name. For example 'Code Repo' -> 'Code Repo.zip'. It is reccomended to run the *zip_dir.sh* file as a cronjob nightly to keep changes on the repo up to date. # Security Notes The viewer exposes file contents under the document root — use caution on shared or public servers. Ensure proper file permissions. We recommend blocking all other scripts running by adding this to your .htaccess file: --- ``` RewriteEngine On # Rewrite the root "/" request to index.php RewriteRule ^$ index.php [L] # Allowed file types RewriteCond %{REQUEST_URI} \.(png|jpe?g|gif|webp|svg|zip|txt)$ [NC] RewriteRule .* - [L] # Block everything except index.php RewriteCond %{REQUEST_URI} !^/index\.php$ RewriteRule . - [F] ``` --- **Avoid exposing private repos.** # Planned / Possible Enhancements - Dark mode # License Software provided under the [MIT Licence](https://mit-license.org/)