diff options
Diffstat (limited to 'web/views')
-rw-r--r-- | web/views/apps/error/main.php | 6 | ||||
-rw-r--r-- | web/views/apps/home/main.php | 30 | ||||
-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 | 12 | ||||
-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, 110 insertions, 5 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/views/apps/home/main.php b/web/views/apps/home/main.php new file mode 100644 index 0000000..b1c1efc --- /dev/null +++ b/web/views/apps/home/main.php @@ -0,0 +1,30 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ ?> +<?php /* vi: syntax=php */ ?> +<div id="main-content"> +<?php if ($self): ?> + <div id="new-post" class="card"> + <div class="row grow"> + <?php $this->view('template/pfp', array('user' => $self))?> + <a + id="action-new-post" + class="input btn-fake ml" + autocomplete="off" + aria-label="<?=lang('action_new_post_tip')?>" + > + <?=lang('action_new_post_text', sub: [$self['first_name']])?> + </a> + </div> + <script> + $('#action-new-post').on('click', function() { + $.get( "/modal/new_post", function (data) { + $(document.body).append(data); + }); + }) + </script> + </div> +<?php endif; ?> + <div id="post-container"> + <?=$this->posts()?> + </div> + <?=ilang('action_load_posts', id: 'action-load-posts', class: 'btn btn-line')?> +</div> 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/views/template/error.php b/web/views/template/error.php new file mode 100644 index 0000000..2e02cb1 --- /dev/null +++ b/web/views/template/error.php @@ -0,0 +1,12 @@ +<!DOCTYPE html> +<html> + <head> + <title><?=$code . ' - ' . $msg?></title> + </head> + <body> + <center> + <h1><?=$code . ' ' . $msg?></h1> + </center> + <hr> + </body> +</html> 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> |