File upload and persistence extension
- index.html extended with form input - pasta.html and pastalist.html show link to /file/{pasta.id}/{filename} path - files are saved in pasta_data folder - all data is now stored in pasta_data/database.json - changed pastalist.html date format to exclude year - added custom 404 error handler
This commit is contained in:
parent
c98aad7256
commit
36fa6598a8
9 changed files with 371 additions and 223 deletions
10
templates/error.html
Normal file
10
templates/error.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{% include "header.html" %}
|
||||
<br>
|
||||
<h2>404</h2>
|
||||
<b>Not Found</b>
|
||||
<br>
|
||||
<br>
|
||||
<a href="/" > Go Home</a>
|
||||
<br>
|
||||
<br>
|
||||
{% include "footer.html" %}
|
|
@ -1,8 +1,8 @@
|
|||
{% include "header.html" %}
|
||||
<form action="create" method="POST">
|
||||
<form action="upload" method="POST" enctype="multipart/form-data">
|
||||
<br>
|
||||
<label for="expiration">Expiration</label><br>
|
||||
<select name="expiration" id="expiration">
|
||||
<select style="width: 100%;" name="expiration" id="expiration">
|
||||
<optgroup label="Expire">
|
||||
<option value="1min">1 minute</option>
|
||||
<option value="10min">10 minutes</option>
|
||||
|
@ -17,7 +17,11 @@
|
|||
<br>
|
||||
<textarea style="width: 100%; min-height: 100px" name="content" autofocus></textarea>
|
||||
<br>
|
||||
<input style="width: 100px; background-color: limegreen"; type="submit" value="Save"/>
|
||||
<label>File attachment</label>
|
||||
<br>
|
||||
<input style="width: 100%;" type="file" id="file" name="file">
|
||||
<br>
|
||||
<input style="width: 120px; background-color: limegreen" ; type="submit" value="Save"/>
|
||||
<br>
|
||||
</form>
|
||||
{% include "footer.html" %}
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
{% include "header.html" %}
|
||||
<a href="/raw/{{pasta.idAsAnimals()}}">Raw Pasta</a>
|
||||
<a style="margin-right: 0.5rem" href="/raw/{{pasta.id_as_animals()}}">Raw Text Content</a>
|
||||
{% if pasta.file != "no-file" %}
|
||||
<a style="margin-right: 0.5rem; margin-left: 0.5rem" href="/file/{{pasta.id_as_animals()}}/{{pasta.file}}">Attached file '{{pasta.file}}'</a>
|
||||
{%- endif %}
|
||||
<a style="margin-right: 0.5rem; margin-left: 0.5rem" href="/remove/{{pasta.id_as_animals()}}">Remove</a>
|
||||
<pre><code>{{pasta}}</code></pre>
|
||||
|
||||
{% include "footer.html" %}
|
||||
|
|
|
@ -2,94 +2,99 @@
|
|||
|
||||
|
||||
{% if pastas.is_empty() %}
|
||||
<br>
|
||||
<p>
|
||||
No pastas yet. 😔 Create one <a href="/">here</a>.
|
||||
No pastas yet. 😔 Create one <a href="/">here</a>.
|
||||
</p>
|
||||
<br>
|
||||
{%- else %}
|
||||
<br>
|
||||
<table style="width: 100%">
|
||||
<thead>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4">Pastas</th>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Key
|
||||
</th>
|
||||
<th>
|
||||
Created
|
||||
</th>
|
||||
<th>
|
||||
Expiration
|
||||
</th>
|
||||
<th>
|
||||
<th>
|
||||
Key
|
||||
</th>
|
||||
<th>
|
||||
Created
|
||||
</th>
|
||||
<th>
|
||||
Expiration
|
||||
</th>
|
||||
<th>
|
||||
|
||||
</th>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for pasta in pastas %}
|
||||
{% if pasta.pasta_type == "text" %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/pasta/{{pasta.idAsAnimals()}}">{{pasta.idAsAnimals()}}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{pasta.createdAsString()}}
|
||||
</td>
|
||||
<td>
|
||||
{{pasta.expirationAsString()}}
|
||||
</td>
|
||||
<td>
|
||||
<a style="margin-right:1rem" href="/raw/{{pasta.idAsAnimals()}}">Raw</a>
|
||||
<a href="/remove/{{pasta.idAsAnimals()}}">Remove</a>
|
||||
</td>
|
||||
</tr>
|
||||
{%- endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4">URL Redirects</th>
|
||||
</tr>
|
||||
<tr >
|
||||
<th>
|
||||
Key
|
||||
</th>
|
||||
<th>
|
||||
Created
|
||||
</th>
|
||||
<th>
|
||||
Expiration
|
||||
</th>
|
||||
<th>
|
||||
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for pasta in pastas %}
|
||||
{% if pasta.pasta_type == "url" %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/url/{{pasta.idAsAnimals()}}">{{pasta.idAsAnimals()}}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{pasta.createdAsString()}}
|
||||
</td>
|
||||
<td>
|
||||
{{pasta.expirationAsString()}}
|
||||
</td>
|
||||
<td>
|
||||
<a style="margin-right:1rem" href="/raw/{{pasta.idAsAnimals()}}">Raw</a>
|
||||
<a href="/remove/{{pasta.idAsAnimals()}}">Remove</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% if pasta.pasta_type == "text" %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/pasta/{{pasta.id_as_animals()}}">{{pasta.id_as_animals()}}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{pasta.created_as_string()}}
|
||||
</td>
|
||||
<td>
|
||||
{{pasta.expiration_as_string()}}
|
||||
</td>
|
||||
<td>
|
||||
<a style="margin-right:1rem" href="/raw/{{pasta.id_as_animals()}}">Raw</a>
|
||||
{% if pasta.file != "no-file" %}
|
||||
<a style="margin-right:1rem" href="/file/{{pasta.id_as_animals()}}/{{pasta.file}}">File</a>
|
||||
{%- endif %}
|
||||
<a href="/remove/{{pasta.id_as_animals()}}">Remove</a>
|
||||
</td>
|
||||
</tr>
|
||||
{%- endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4">URL Redirects</th>
|
||||
</tr>
|
||||
<tr >
|
||||
<th>
|
||||
Key
|
||||
</th>
|
||||
<th>
|
||||
Created
|
||||
</th>
|
||||
<th>
|
||||
Expiration
|
||||
</th>
|
||||
<th>
|
||||
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for pasta in pastas %}
|
||||
{% if pasta.pasta_type == "url" %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/url/{{pasta.id_as_animals()}}">{{pasta.id_as_animals()}}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{pasta.created_as_string()}}
|
||||
</td>
|
||||
<td>
|
||||
{{pasta.expiration_as_string()}}
|
||||
</td>
|
||||
<td>
|
||||
<a style="margin-right:1rem" href="/raw/{{pasta.id_as_animals()}}">Raw</a>
|
||||
<a href="/remove/{{pasta.id_as_animals()}}">Remove</a>
|
||||
</td>
|
||||
</tr>
|
||||
{%- endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
{%- endif %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue