diff options
author | Freya Murphy <freya@freyacat.org> | 2024-03-30 12:14:42 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-03-30 12:14:42 -0400 |
commit | 1f04b83be337cc91a3fabcf4e574e2306f3d2eaa (patch) | |
tree | 74d7d65a7047e60d1877384e3c7b0d70c7b0e49a /web/views | |
parent | start database (user and post), and initial barebones home page (diff) | |
download | xssbook2-1f04b83be337cc91a3fabcf4e574e2306f3d2eaa.tar.gz xssbook2-1f04b83be337cc91a3fabcf4e574e2306f3d2eaa.tar.bz2 xssbook2-1f04b83be337cc91a3fabcf4e574e2306f3d2eaa.zip |
refactor
Diffstat (limited to '')
-rw-r--r-- | web/views/apps/error/main.php | 6 | ||||
-rw-r--r-- | web/views/apps/home/main.php (renamed from web/routes/home/views/main.php) | 5 | ||||
-rw-r--r-- | web/views/footer.php | 2 | ||||
-rw-r--r-- | web/views/header.php | 14 | ||||
-rw-r--r-- | web/views/modal/new_post.php (renamed from web/views/modal/new-post.php) | 24 | ||||
-rw-r--r-- | web/views/template/comment.php | 2 | ||||
-rw-r--r-- | web/views/template/error.php (renamed from web/core/error.php) | 0 | ||||
-rw-r--r-- | web/views/template/modal.php | 2 | ||||
-rw-r--r-- | web/views/template/pfp.php | 2 | ||||
-rw-r--r-- | web/views/template/post.php | 2 | ||||
-rw-r--r-- | web/views/template/toast.php | 19 |
11 files changed, 71 insertions, 7 deletions
diff --git a/web/views/apps/error/main.php b/web/views/apps/error/main.php new file mode 100644 index 0000000..81051bd --- /dev/null +++ b/web/views/apps/error/main.php @@ -0,0 +1,6 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> +<div id="error"> + <h1><?=$title?></h1> + <span><?=$msg?></span> +</div> diff --git a/web/routes/home/views/main.php b/web/views/apps/home/main.php index bf0087b..b1c1efc 100644 --- a/web/routes/home/views/main.php +++ b/web/views/apps/home/main.php @@ -1,4 +1,5 @@ -<?php // vi: syntax=php ?> +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> <div id="main-content"> <?php if ($self): ?> <div id="new-post" class="card"> @@ -15,7 +16,7 @@ </div> <script> $('#action-new-post').on('click', function() { - $.get( "/home/new_post_modal", function (data) { + $.get( "/modal/new_post", function (data) { $(document.body).append(data); }); }) diff --git a/web/views/footer.php b/web/views/footer.php index 6cbe21b..1266b9a 100644 --- a/web/views/footer.php +++ b/web/views/footer.php @@ -1,2 +1,4 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> <body> </html> diff --git a/web/views/header.php b/web/views/header.php index 183f4f4..891e27e 100644 --- a/web/views/header.php +++ b/web/views/header.php @@ -1,10 +1,18 @@ -<?php // vi: syntax=php ?> +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> <?php $self = $this->main->user(); ?> <!DOCTYPE html> <html> <head> + <script> + <?php if ($this->main->session): ?> + var jwtStr = <?=json_encode($this->main->session['jwt'])?>; + <?php else: ?> + var jwtStr = null; + <?php endif; ?> + </script> <?php foreach ($js_files as $js) { echo $this->main->link_js($js); @@ -71,4 +79,6 @@ menu.toggleClass('visible'); }); </script> - </header> + </header> + <div id="toast-container"> + </div> diff --git a/web/views/modal/new-post.php b/web/views/modal/new_post.php index 7215862..82243fb 100644 --- a/web/views/modal/new-post.php +++ b/web/views/modal/new_post.php @@ -1,7 +1,9 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> <?php $user = $this->main->user(); ?> -<form> +<form id="new-post-form"> <div class="modal-content new-post-modal"> <div class="row"> <?php $this->view('template/pfp', array('user' => $user))?> @@ -12,8 +14,8 @@ </div> <textarea type="text" - name="text" - id="text" + name="content" + id="new-post-content" placeholder="<?=lang('action_new_post_text', sub: [$user['first_name']])?>" ></textarea> </div> @@ -26,3 +28,19 @@ )?> </div> </form> +<script> + $('#new-post-form').submit(function(e) { + e.preventDefault(); + let content = $('#new-post-content').val(); + + $.ajax({ + url: '/api/post', + method: 'POST', + data: JSON.stringify({ content }), + success: function(data) { + window.location.reload(); + }, + error: errorToast + }); + }); +</script> diff --git a/web/views/template/comment.php b/web/views/template/comment.php index ef7a081..943f232 100644 --- a/web/views/template/comment.php +++ b/web/views/template/comment.php @@ -1,3 +1,5 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> <div class="comment row mt"> <?php $this->view('template/pfp', array('user' => $user))?> <div class="ml col sub-card"> diff --git a/web/core/error.php b/web/views/template/error.php index 2e02cb1..2e02cb1 100644 --- a/web/core/error.php +++ b/web/views/template/error.php diff --git a/web/views/template/modal.php b/web/views/template/modal.php index 4f47400..e3ce6fe 100644 --- a/web/views/template/modal.php +++ b/web/views/template/modal.php @@ -1,3 +1,5 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> <div class="modal-container"> <div class="modal"> <div class="modal-header row"> diff --git a/web/views/template/pfp.php b/web/views/template/pfp.php index 842fc92..aec7318 100644 --- a/web/views/template/pfp.php +++ b/web/views/template/pfp.php @@ -1,3 +1,5 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> <?php $class = isset($class) ? $class : ''; ?> diff --git a/web/views/template/post.php b/web/views/template/post.php index d9c7c92..40a3c1d 100644 --- a/web/views/template/post.php +++ b/web/views/template/post.php @@ -1,3 +1,5 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> <div class="post card"> <div class="row"> <?php $this->view('template/pfp', array('user' => $user))?> diff --git a/web/views/template/toast.php b/web/views/template/toast.php new file mode 100644 index 0000000..1f74602 --- /dev/null +++ b/web/views/template/toast.php @@ -0,0 +1,19 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> +<?php + $params = array(); + + if ($detail) { + array_push($params, lang('api_column_' . $detail)); + } + + if ($hint) { + array_push($params, $hint); + } + + $msg = lang($msg, sub: $params); +?> +<div class="toast error"> + <?=ucfirst($msg)?> + <?=ilang('action_close', class: 'action-close-toast')?> +</div> |