pupupu

simple static CMS for crappy servers
git clone https://git.ce9e.org/pupupu.git

commit
994da5670fcc81b7353a574480cb4326b5371315
parent
6f2858d98c40517d1d333f37b3a7f669e45034b2
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2018-10-19 09:37
Fix target links

Diffstat

M index.php 14 +++++++++++---
M templates/page.html 2 +-

2 files changed, 12 insertions, 4 deletions


diff --git a/index.php b/index.php

@@ -77,10 +77,11 @@ function getBreadcrumbs($path)
   77    77 
   78    78 class Pupupu
   79    79 {
   80    -1     public function __construct($srcDir, $targetDir)
   -1    80     public function __construct($srcDir, $targetDir, $targetUrl)
   81    81     {
   82    82         $this->srcDir = $srcDir;
   83    83         $this->targetDir = $targetDir;
   -1    84         $this->targetUrl = $targetUrl;
   84    85 
   85    86         $loader = new Twig_Loader_Filesystem($srcDir . '/_templates');
   86    87         $this->twig = new Twig_Environment($loader);
@@ -170,6 +171,11 @@ class Pupupu
  170   171         return $subpages;
  171   172     }
  172   173 
   -1   174     public function getUrl($path)
   -1   175     {
   -1   176         return $this->targetUrl . $path . '/';
   -1   177     }
   -1   178 
  173   179     public function upload($file)
  174   180     {
  175   181         $p = $this->targetDir . '/files/' . $file['name'];
@@ -181,9 +187,10 @@ class Pupupu
  181   187     {
  182   188         $uploads = array();
  183   189         $p = $this->targetDir . '/files';
   -1   190         $u = $this->targetUrl . '/files';
  184   191         foreach (scandir($p) as $name) {
  185   192             if (is_file("$p/$name")) {
  186    -1                 $uploads[$name] = "/files/$name";
   -1   193                 $uploads[$name] = "$u/$name";
  187   194             }
  188   195         }
  189   196         return $uploads;
@@ -293,6 +300,7 @@ function pageView($pupupu, $twig)
  293   300                 'md' => $pupupu->get($path, 'md'),
  294   301                 'subpages' => $pupupu->getSubpages($path),
  295   302                 'path' => $path,
   -1   303                 'url' => $pupupu->getUrl($path),
  296   304                 'pathIsFile' => pathIsFile($path),
  297   305                 'breadcrumbs' => getBreadcrumbs($path),
  298   306             ));
@@ -314,7 +322,7 @@ function pageView($pupupu, $twig)
  314   322     }
  315   323 }
  316   324 
  317    -1 $pupupu = new Pupupu('..', '..');
   -1   325 $pupupu = new Pupupu('..', '..', '..');
  318   326 
  319   327 if (isset($_SERVER['REQUEST_METHOD'])) {
  320   328     ensureTrailingSlash();

diff --git a/templates/page.html b/templates/page.html

@@ -32,6 +32,6 @@
   32    32 
   33    33         <input type="submit" value="Save">
   34    34         <input type="submit" class="button--danger" name="delete" value="Delete">
   35    -1         <a href="{{ path }}/" target="_blank" class="button">View</a>
   -1    35         <a href="{{ url }}" target="_blank" class="button">View</a>
   36    36     </form>
   37    37 {% endblock %}