redirect paste url with ending slash on apache
[phorkie.git] / www / edit.php
index 4de3d47cb93b4310d6529b2ba80083a9f2d8aed2..33b22c2afe09031f3fc264c466ac49ef2eeee8ff 100644 (file)
@@ -9,15 +9,26 @@ require_once 'www-header.php';
 $repo = new Repository();
 $repo->loadFromRequest();
 
+$file = null;
+if (isset($_GET['file'])) {
+    $file = $repo->getFileByName($_GET['file']);
+}
+
 $repopo = new Repository_Post($repo);
 if ($repopo->process($_POST, $_SESSION)) {
-    redirect($repo->getLink('display'));
+    $anchor = '';
+    if ($file !== null) {
+        $anchor = '#' . $file->getAnchorName();
+    }
+    redirect($repo->getLink('display', null, true) . $anchor);
 }
 
 render(
     'edit',
     array(
         'repo' => $repo,
+        'singlefile' => $file,
+        'dh'   => new \Date_HumanDiff(),
         'htmlhelper' => new HtmlHelper(),
     )
 );