xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
<root> / inc / mime.inc.php (c1765b5e26eb1f3628aa680f357e8a08fdb86e64) (1,317B) (mode 100644) [raw]
<?php

/*
 * Sets a content type based on extention
 */
function rg_content_type_by_ext($f)
{
	$b = 'application/octet-stream';

	$r = strrpos($f, '.');
	if ($r === FALSE)
		return $b;

	$e = substr($f, $r + 1);

	if (strcasecmp($e, 'apng') == 0)
		return 'text/png';

	if (strcasecmp($e, 'txt') == 0)
		return 'text/plain';

	if (strcasecmp($e, 'html') == 0)
		return 'text/html';

	if (strcasecmp($e, 'xls') == 0)
		return 'application/vnd.ms-excel';

	if (strcasecmp($e, 'doc') == 0)
		return 'application/msword';

	if (strcasecmp($e, 'ods') == 0)
		return 'application/vnd.oasis.opendocument.spreadsheet';

	if (strcasecmp($e, 'odt') == 0)
		return 'application/vnd.oasis.opendocument.text';

	if (strcasecmp($e, 'gz') == 0)
		return 'application/gzip';

	if (strcasecmp($e, 'pdf') == 0)
		return 'application/pdf';

	if (strcasecmp($e, 'zip') == 0)
		return 'application/zip';

	if (strcasecmp($e, 'xml') == 0)
		return 'application/xml';

	if (strcasecmp($e, 'json') == 0)
		return 'application/json';

	if (strcasecmp($e, 'whl') == 0)
		return 'application/zip';

	if (strcasecmp($e, 'png') == 0)
		return 'image/png';

	if (strcasecmp($e, 'jpg') == 0)
		return 'image/jpeg';
	if (strcasecmp($e, 'jpeg') == 0)
		return 'image/jpeg';

	if (strcasecmp($e, 'svg') == 0)
		return 'image/svg+xml';

	return $b;
}

Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master