BarryServer : Git

All the code for all my projects
// BarryServer : Git / barryserver-git / blob / f3862a9d5b60134c642a8c741d0365162ae6cce7 / README

// Related

barryserver-git

root Initial commit eb472a8 (4 years, 4 months ago)
# Simple Web-based Git Browser
This project is a simple, configurable, light weight, web-based git browser for any git repositories hosted on a webserver.

This is the same script that is used to run this site.



It has support for:
 - README files (with simple markdown)
 - Unicode icons
 - Simple navigation
 - Repositories, Branches, Folders, and Files



It is easy to implement, and is very customisable as the script produces class based HTML pages, so CSS is easy to modify.

NOTE: This software has not been tested fully, and is only tested to work on the conditions of my webserver, some other conditions may require tinkering.


## Installation
To install the script requires a little configuration of your web-server. I will use nginx as an example.

Copy "git.php" into a folder in your webserver's directory (e.g. "/var/www/html/files/", or "/var/www/html/" if you don't have anything else there).



If you are happy to access the script by URLs like "example.com/git.php/project/branch/test.txt", you can stop here. If you do not want this, you can access it through a URL like "example.com/git/project/branch/text.txt" if you placed the scripts in a folder ("/var/www/html/git/"), or by a URL like "example.com/project/branch/test.txt" if you placed the scripts in the webserver's root directory.

To configure one of these options, you must modify your webserver's config. In nginx you would just add:
```
location / {
	rewrite ^(.*)$ /git.php$1 last;
}
```
if the script was in the root directory, or:
```
location /git {
	rewrite ^/git(.*)$ /git.php$1 last;
}
```
if the script was in a folder named "/git/" that was in the root directory of the webserver.


The following must be present in both configurations:
```
location /path/to/git.php {
	include snippets/fastcgi-php.conf;
	fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
```
(modify "/path/to/git.php" suitably)




While this example is for nginx it can easily be adapted for any webserver. All that really matters is that any request gets routed through "git.php" as though it were a folder.

## Setup
To configure the script to your liking you may want to edit the script. At the start of "git.php" is all of the important variables, and must be edited to account for your setup. Just after the configuration variables, "git.php" contains the CSS style sheet, so you may want to edit this to re-theme the script.

### Configuration Variables
`$TITLE` is the title of the webpage, displayed as the name of the tab, and the header text at the top of each page.

`$ROOT` is the name of the folder you placed the script in. Leave it blank for the root directory. This variable should always be preceded by a "/" unless blank.

`$SCRIPT` is the name of the script. Set it to the "git.php" if you didn't configure your webserver in the installation section. Set it to whatever you configured your webserver to use otherwise. Leave it blank if the script is in the root of your webserer. Unless blank, this should be preceded by a "/".

`$ORIGINAL` is the name of the folder that contains your repositories. It should always start with a "/" unless blank. Leave it blank if the repositories are in the same folder as the script.

`$BRANCH` is the name of the default branch (if in doubt, leave as 'master').

`$DESCRIPTION` is the description of the site, displayed on the first page.

`$FOOTER` is the text that is displayed at the bottom of each page.


### CSS
Just after the start of the document is a block of CSS in a <style> tag. Any of this can be freely modified without affecting the performance of the script. You don't even have to leave the blocks that are there, you can completely reconfigure it or even delete it.