diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2025-07-23 20:41:02 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2025-07-23 20:41:02 +0200 |
commit | 226faf34b0ec4e70d87c8fd8fca43955d1e92dda (patch) | |
tree | 775a772d7f839c37532dbe73ac29ab937804a80b | |
parent | 0eccccfab33bbad8d5731700c1ed959debe98bbd (diff) |
-rw-r--r-- | index.php | 74 |
1 files changed, 70 insertions, 4 deletions
@@ -270,6 +270,9 @@ function template_root(string $content, array $meta = []): string word-break: break-word; } } + td { + padding: 0.25rem 0.5rem; + } </style> </head> <body><?php echo $content; ?></body> @@ -280,6 +283,25 @@ function template_root(string $content, array $meta = []): string } +function template_project(string $project_path, string $content): string +{ + $project_path = trim($project_path, "/"); + + ob_start(); + + ?> + <nav><ul> + <li><a href="/<?php echo uri_encode($project_path); ?>">root</a></li> + <li><a href="/<?php echo uri_encode($project_path); ?>/tree">tree</a></li> + <li><a href="/<?php echo uri_encode($project_path); ?>/log">log</a></li> + </ul></nav> + <main><?php echo $content; ?></main> + <?php + + return template_root(ob_get_clean()); +} + + /** * build breadcrumbs */ @@ -383,6 +405,8 @@ if ($url["path"] == "/") { </tbody> </table> <?php + + echo template_root(ob_get_clean()); } @@ -430,6 +454,8 @@ elseif (preg_match("#(.*)/tree/?(.*)#", $url["path"], $matches)) { </tbody> </table> <?php + + echo template_project($project, ob_get_clean()); } @@ -467,14 +493,54 @@ elseif (preg_match("#(.*)/blob/?(.*)#", $url["path"], $matches)) { <?php endif; ?> </div> <?php + + echo template_project($project, ob_get_clean()); +} + + +// Route: /$project/log +elseif (str_ends_with($url["path"], "/log")) { + $project = substr($url["path"], 0, -4); + $log = parse_log($projects_path . $project); + + ?> + <table border> + <thead> + <tr> + <th>Commit</th> + <th>Author</th> + <th>Date</th> + <th>Message</th> + </tr> + </thead> + <tbody> + <?php + + foreach ($log as $entry) { + ?> + <tr> + <td><?php echo $entry["commit"]; ?></td> + <td><?php echo $entry["author"]; ?></td> + <td><?php echo $entry["date"]; ?></td> + <td><?php echo $entry["message"]; ?></td> + </tr> + <?php + } + + ?> + </tbody> + </table> + <?php + + echo template_project($project, ob_get_clean()); } +// assume project base path else { $path = $projects_path . $url["path"]; var_dump(parse_log($path)); -} - -// display -echo template_root(ob_get_clean()); + + echo template_project($url["path"], ob_get_clean()); +} |