diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2020-02-10 22:36:13 +0100 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2020-02-10 22:36:13 +0100 |
commit | 62b0b360fa8a1a2d1fd6d89d4d227a0ef559cb8a (patch) | |
tree | 5db624a9ac4ce011c18941cbdd13da6e76492c58 /templates | |
parent | 2eb5a432d2229788ce2fdb09f36c6f4bebdea813 (diff) | |
download | micropoly-62b0b360fa8a1a2d1fd6d89d4d227a0ef559cb8a.tar.gz micropoly-62b0b360fa8a1a2d1fd6d89d4d227a0ef559cb8a.tar.bz2 micropoly-62b0b360fa8a1a2d1fd6d89d4d227a0ef559cb8a.zip |
Implement simple attachment support
It is now possible to upload and view attachments!
Attachments are saved by their content hash, therefore they are
automatically deduplicated and we can later easily add integrity checks.
Still missing:
- Deleting attachments
- Multiple file inputs (idea: when the user fills in a file input, create a
new empty file input beneath with js)
- (nice to have) Thumbnails
Diffstat (limited to 'templates')
-rw-r--r-- | templates/macros.twig | 16 | ||||
-rw-r--r-- | templates/note.twig | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/templates/macros.twig b/templates/macros.twig index dc7e721..4e1b336 100644 --- a/templates/macros.twig +++ b/templates/macros.twig @@ -37,12 +37,26 @@ <input type="text" name="tag[]" /> {% endfor %} </fieldset> + <div class="attachments-container"> + <h2>Attachments</h2> + <ul class="attachment-list"> + {% for att in note.attachments %} + <li> + <a href="{{ url("attachments/%s", att.id) }}">{{ att.fileName ? att.fileName : att.id }}</a> + </li> + {% endfor %} + </ul> + + <ul class="attachment-inputs"> + <li><input type="file" name="attachments[]"></li> + </ul> + </div> {% endmacro %} {% macro new_note() %} <section class="new-note"> <h2>New Note</h2> - <form action="{{ url("new-note") }}" method="post"> + <form action="{{ url("new-note") }}" method="post" enctype="multipart/form-data"> {{ _self.note_form_content({}) }} <button type="submit">Create</button> </form> diff --git a/templates/note.twig b/templates/note.twig index 14989aa..cb0b6d8 100644 --- a/templates/note.twig +++ b/templates/note.twig @@ -1,7 +1,7 @@ {% extends "skeleton.twig" %} {% import "macros.twig" as macros %} {% block body %} - <form action="{{ url("n/%s", note.id) }}" method="post"> + <form action="{{ url("n/%s", note.id) }}" method="post" enctype="multipart/form-data"> {{ macros.note_form_content(note) }} <button type="submit">Save</button> <button |