pupupu

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

commit
314c0ea486e97725e2600aa711ef0d8f282bff63
parent
d7773bd95e370d231ae18d533d7283502a3a6ac3
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2018-10-19 11:05
extend upload view

Diffstat

M index.php 10 ++++++++--
M static/main.scss 5 +++++
M templates/uploads.html 22 ++++++++++++++++------

3 files changed, 29 insertions, 8 deletions


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

@@ -189,8 +189,14 @@ class Pupupu
  189   189         $p = $this->targetDir . '/files' . $path;
  190   190         $u = $this->targetUrl . '/files' . $path;
  191   191         foreach (scandir($p) as $name) {
  192    -1             if (is_file("$p/$name")) {
  193    -1                 $uploads[$name] = "$u/$name";
   -1   192             if ($name !== '.' && $name !== '..') {
   -1   193                 $uploads[] = array(
   -1   194                     'name' => $name,
   -1   195                     'path' => "$path/$name",
   -1   196                     'url' => "$u/$name",
   -1   197                     'is_file' => is_file("$p/$name"),
   -1   198                     'is_image' => getimagesize("$p/$name"),
   -1   199                 );
  194   200             }
  195   201         }
  196   202         return $uploads;

diff --git a/static/main.scss b/static/main.scss

@@ -70,4 +70,9 @@ header form {
   70    70 	.file-list__main {
   71    71 		flex: 1 1 auto;
   72    72 	}
   -1    73 
   -1    74 	.file-list__icon {
   -1    75 		width: 1em;
   -1    76 		margin-right: $padding;
   -1    77 	}
   73    78 }

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

@@ -2,13 +2,23 @@
    2     2 
    3     3 {% block main %}
    4     4     <ul class="file-list">
    5    -1         {% for name, url in files %}
   -1     5         {% for file in files %}
    6     6             <li>
    7    -1                 <a href="{{ url }}" target="_blank" class="file-list__main">{{ name }}</a>
    8    -1                 <form method="post">
    9    -1                     <input type="hidden" name="name" value="{{ name }}">
   10    -1                     <button class="button--danger button--small" name="delete">Delete</button>
   11    -1                 </form>
   -1     7                 {% if file.is_file %}
   -1     8                     {% if file.is_image %}
   -1     9                         <img src="{{ file.url }}" class="file-list__icon" alt="image">
   -1    10                     {% else %}
   -1    11                         <img src="static/file.png" class="file-list__icon" alt="file">
   -1    12                     {% endif %}
   -1    13                     <a href="{{ file.url }}" target="_blank" class="file-list__main">{{ file.name }}</a>
   -1    14                     <form method="post">
   -1    15                         <input type="hidden" name="name" value="{{ file.name }}">
   -1    16                         <button class="button--danger button--small" name="delete">Delete</button>
   -1    17                     </form>
   -1    18                 {% else %}
   -1    19                     <img src="static/folder.png" class="file-list__icon" alt="folder">
   -1    20                     <a href="?path=_uploads{{ file.path }}" class="file-list__main">{{ file.name }}/</a>
   -1    21                 {% endif %}
   12    22             </li>
   13    23         {% endfor %}
   14    24         <li>