Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git
<?php
require_once __DIR__ . '/Page.php';

class RawPage implements Page {
  private $git;
  private $hash;

  public function __construct( $git, $hash ) {
    $this->git  = $git;
    $this->hash = $hash;
  }

  public function render() {
    $name = $_GET['name'] ?? '';
    $file = $this->git->readFile( $this->hash, $name );

    while( ob_get_level() ) {
      ob_end_clean();
    }

    $file->emitRawHeaders();
    $this->git->stream( $this->hash, function( $d ) {
      echo $d;
    }, $name );

    exit;
  }
}