diff options
-rw-r--r-- | assets/styles.css | 14 | ||||
-rw-r--r-- | src/Handlers/NewNote.php | 14 | ||||
-rw-r--r-- | templates/macros.twig | 1 | ||||
-rw-r--r-- | templates/new_note.twig | 3 |
4 files changed, 27 insertions, 5 deletions
diff --git a/assets/styles.css b/assets/styles.css index 4421620..925985c 100644 --- a/assets/styles.css +++ b/assets/styles.css @@ -8,6 +8,8 @@ html { --fg-link-normal: #7187d7; --fg-link-active: #ff3f00; --fg-link-visited: #9f71d7; + --success-color: hsl(98.1, 63.9%, 51.2%); + --success-bgcolor: hsl(175.4, 16%, 15.9%); --col-separator: #aaa; } @@ -234,4 +236,14 @@ input:placeholder-shown { .attachments .delete { font-style: italic; text-decoration: line-through; -}
\ No newline at end of file +} + +.success { + border: 1px solid var(--success-color); + background: var(--success-bgcolor); + color: var(--success-color); + padding: 10px; + margin: 10px 0; + text-align: center; + border-radius: 2px; +} diff --git a/src/Handlers/NewNote.php b/src/Handlers/NewNote.php index 9d4286d..838c7cb 100644 --- a/src/Handlers/NewNote.php +++ b/src/Handlers/NewNote.php @@ -24,6 +24,7 @@ class NewNote implements Handler public function handle(Env $env, array $variables) { $content = self::getPostedContent(); + $templateData = []; if ($content !== null) { $note = new Note(); $note->setContent($content); @@ -34,11 +35,16 @@ class NewNote implements Handler Attachment::createFromUploads($env->db(), $env->attachmentsPath(), $note, $_FILES['attachments']); $url = $env->documentRoot() . "n/" . $note->getId(); - http_response_code(303); - header("Location: {$url}"); - echo 'Note created: <a href="' . Esc::e($url) . '">'; + if ($_POST["create_and_new"]) { + $templateData["success"] = true; + } else { + http_response_code(303); + header("Location: {$url}"); + echo 'Note created: <a href="' . Esc::e($url) . '">'; + return; + } } - echo $env->twig()->render("/new_note.twig", []); + echo $env->twig()->render("/new_note.twig", $templateData); } }
\ No newline at end of file diff --git a/templates/macros.twig b/templates/macros.twig index 2c72334..2bc163a 100644 --- a/templates/macros.twig +++ b/templates/macros.twig @@ -74,6 +74,7 @@ <form action="{{ url("new-note") }}" method="post" enctype="multipart/form-data"> {{ _self.note_form_content({}) }} <button type="submit">Create</button> + <button type="submit" name="create_and_new" value="1">Create & New</button> </form> </section> {% endmacro %}
\ No newline at end of file diff --git a/templates/new_note.twig b/templates/new_note.twig index df9a320..4655a6e 100644 --- a/templates/new_note.twig +++ b/templates/new_note.twig @@ -1,5 +1,8 @@ {% extends "skeleton.twig" %} {% import "macros.twig" as macros %} {% block body %} + {% if success %} + <div class="success">Succcessfully created new note!</div> + {% endif %} {{ macros.new_note() }} {% endblock %}
\ No newline at end of file |