summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php27
1 files changed, 13 insertions, 14 deletions
diff --git a/index.php b/index.php
index bb2418f..fb64f51 100644
--- a/index.php
+++ b/index.php
@@ -45,11 +45,11 @@ $cache_parse_log = [];
*/
function parse_log(string $path): array {
global $cache_parse_log;
-
+
if (isset($cache_parse_log[$path])) {
return $cache_parse_log[$path];
}
-
+
$proxy = md5(strval(microtime(true)));
$process = proc_open(
"git -C \"{$path}\" log " . "--pretty=format:'{%n {$proxy}commit{$proxy}: {$proxy}%H{$proxy},%n {$proxy}author{$proxy}: {$proxy}%aN <%aE>{$proxy},%n {$proxy}date{$proxy}: {$proxy}%ad{$proxy},%n {$proxy}message{$proxy}: {$proxy}%s{$proxy}%n},'",
@@ -254,7 +254,7 @@ function template_root(string $content, array $meta = []): string
$meta = array_replace_recursive([
"title" => "phpgit - single file git web frontend",
], $meta);
-
+
ob_start();
?>
@@ -291,7 +291,7 @@ function template_root(string $content, array $meta = []): string
function template_project(string $project_path, string $content): string
{
$project_path = trim($project_path, "/");
-
+
ob_start();
?>
@@ -302,7 +302,7 @@ function template_project(string $project_path, string $content): string
</ul></nav>
<main><?php echo $content; ?></main>
<?php
-
+
return template_root(ob_get_clean());
}
@@ -356,9 +356,9 @@ if ($url["path"] == "/") {
} else {
$a_date = date_create()->setTimestamp(0);
}
-
+
$b_log = parse_log($b);
-
+
if (file_exists(".git/info/web/last-modified")) {
$b_date = new DateTime(file_get_contents(".git/info/web/last-modified"));
} else if (count($b_log) > 0) {
@@ -366,7 +366,7 @@ if ($url["path"] == "/") {
} else {
$b_date = date_create()->setTimestamp(0);
}
-
+
return $b_date <=> $a_date;
});
@@ -400,7 +400,7 @@ if ($url["path"] == "/") {
if (count($log) > 0) {
$date = new DateTime($log[0]["date"]);
- echo "<td>" . $date->format("Y-m-d") . "</td>";
+ echo "<td>" . $date->format("Y-m-d") . "</td>";
}
?></tr><?php
@@ -437,11 +437,11 @@ elseif (preg_match("#(.*)/tree/?(.*)#", $url["path"], $matches)) {
</thead>
<tbody>
<?php
-
+
foreach ($tree as $file) {
$current_file_path = empty($file_path) ? "" : $file_path . "/";
$basename = basename($file["path"]);
-
+
?><tr><?php
?><td><?php echo $file["mode"]; ?></td><?php
@@ -451,7 +451,7 @@ elseif (preg_match("#(.*)/tree/?(.*)#", $url["path"], $matches)) {
else:
?><td><a href="<?php echo uri_encode("/$project/tree/$current_file_path$basename"); ?>"><?php echo $basename; ?></a><td><?php
endif;
-
+
?></tr><?php
}
@@ -468,7 +468,7 @@ elseif (preg_match("#(.*)/tree/?(.*)#", $url["path"], $matches)) {
elseif (preg_match("#(.*)/blob/?(.*)#", $url["path"], $matches)) {
$project = urldecode(ltrim($matches[1], "/"));
$file_path = urldecode(rtrim($matches[2], "/"));
-
+
// show breadcrumbs
echo breadcrumbs("/$project/tree", "/$project/tree/$file_path");
@@ -546,6 +546,5 @@ else {
$path = $projects_path . $url["path"];
var_dump(parse_log($path));
-
echo template_project($url["path"], ob_get_clean());
}