listing all pastes works
[phorkie.git] / www / display.php
index 5bd06bbb55ded4776a6b0fcec643243a3549649b..f806c56b807f3f46d417884176c1c49eeb49d39f 100644 (file)
@@ -1,42 +1,17 @@
 <?php
 <?php
+namespace Phorkie;
 /**
  * Display paste contents
 /**
  * Display paste contents
- *
  */
 require_once 'www-header.php';
 
  */
 require_once 'www-header.php';
 
-if (!isset($_GET['id'])) {
-    errout(400, 'Paste ID missing');
-}
-if (!is_numeric($_GET['id'])) {
-    errout(400, 'Paste ID not numeric');
-}
-$id = (int)$_GET['id'];
-$repoDir = $GLOBALS['phorkie']['cfg']['repos'] . '/' . $id;
-if (!is_dir($repoDir)) {
-    errout(404, 'Paste not found');
-}
-
-$files = glob($repoDir . '/*');
-$tplFiles = array();
-foreach ($files as $file) {
-    $tplFile = array();
-    $tplFile['filename'] = basename($file);
-    $tplFile['type'] = get_type_from_file($file);
-    //FIXME: highlight
-    $tplFile['content'] = file_get_contents($file);
-    $tplFile['raw'] = '/' . $id . '/raw/' . $tplFile['filename'];
-    $tplFiles[] = $tplFile;
-}
+$repo = new Repository();
+$repo->loadFromRequest();
 
 render(
     'display',
     array(
 
 render(
     'display',
     array(
-        'description' => file_get_contents($repoDir . '/.git/description'),
-        'files' => $tplFiles,
-        'links' => array(
-            'edit' => '/' . $id . '/edit'
-        )
+        'repo' => $repo,
     )
 );
 ?>
     )
 );
 ?>