barryserver-git
Barry Added raw file view c81ef5c (4 years, 1 month ago)diff --git a/git.php b/git.php index a73406f..b1c3415 100644 --- a/git.php +++ b/git.php @@ -41,6 +41,8 @@ $DESCRIPTION = "A BarryServer Git Browser"; /* FOOTER: Text displayed at the bottom of each page */ $FOOTER = "BarryServer Git Browser"; + +ob_start(); ?> <!DOCTYPE html> <html> @@ -150,6 +152,14 @@ $FOOTER = "BarryServer Git Browser"; .clone { font-style: italic; color: lightgray; + display: inline-block; + } + + /* Raw Link */ + .raw-link { + font-weight: bold; + float: right; + display: inline-block; } /* File Content */ @@ -209,12 +219,13 @@ $FOOTER = "BarryServer Git Browser"; $branch = explode("/", substr($path,1))[1]; echo " <span class=\"clone\">git clone "; if ($branch !== $BRANCH && $branch !== "") {echo "-b ".$branch." ";} - echo "<a href=\"git://".$_SERVER["SERVER_NAME"]."/".$repo.".git\">git://".$_SERVER["SERVER_NAME"]."/".$repo.".git</a></span><br><br>\n"; + echo "<a href=\"git://".$_SERVER["SERVER_NAME"]."/".$repo.".git\">git://".$_SERVER["SERVER_NAME"]."/".$repo.".git</a></span>\n"; $rest = implode("/",array_slice(explode("/", substr($path,1)),2)); chdir($ORIGINAL."/".$repo.".git"); if (!isset($branch)) {header("Location: ".$ROOT.$SCRIPT."/".$repo."/");} if (substr($path,-1) !== "/" && $rest === "" && $branch !== "" && isset($branch)) {header("Location: ".$ROOT.$SCRIPT."/".$repo."/".$branch."/");} if ($branch === "") { + echo "<br><br>\n"; $branches = shell_exec("git show-branch"); foreach (explode("\n",$branches) as $cbranch) { echo preg_replace("/\[(.+)\] (.+)/","<a href=\"".$ROOT.$SCRIPT."/".$repo."/$1\" class=\"branch\">$1</a>",$cbranch)."<br>"; @@ -247,6 +258,7 @@ $FOOTER = "BarryServer Git Browser"; $filestxt .= " <a href=\"".$ROOT.$SCRIPT."/".$repo."/".$branch."/".explode("\t",$name[2])[1]."\" class=\"file\">".end(explode("/",explode("\t",$name[2])[1]))."</a><br>\n"; } } + echo "<br><br>\n"; echo $folderstxt; echo $filestxt; if ($readmefile = shell_exec("git ls-tree --full-name ".$branch." ".$rest."README")) { @@ -271,6 +283,12 @@ $FOOTER = "BarryServer Git Browser"; } else { if (shell_exec("git ls-tree --full-name ".$branch." ".$rest)) { $content = shell_exec("git cat-file -p ".explode("\t",explode(" ",explode("\n",$files)[0])[2])[0]); + if (isset($_GET["raw"])) { + ob_clean(); + header("Content-type: text/plain"); + echo $content; + die(); + } echo "<pre>\n".htmlspecialchars($content)."</pre>\n"; } else { echo " <span class=\"error\">\n <b>404! File not found!</b><br>\n";