summaryrefslogtreecommitdiff
path: root/src/web/_views/_template
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-12-23 11:13:27 -0500
committerFreya Murphy <freya@freyacat.org>2024-12-23 11:13:27 -0500
commit5a2ba9c2e7605bb788bc406184547d22c6436867 (patch)
treecbd988d534e8a8593a31d70571222443f80da0b3 /src/web/_views/_template
parentfix about modal (diff)
downloadxssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.gz
xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.bz2
xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.zip
v2.1.0, refactor w/ crimson
Diffstat (limited to 'src/web/_views/_template')
-rw-r--r--src/web/_views/_template/comment.php12
-rw-r--r--src/web/_views/_template/error.php12
-rw-r--r--src/web/_views/_template/modal.php14
-rw-r--r--src/web/_views/_template/post.php86
-rw-r--r--src/web/_views/_template/posts.php32
-rw-r--r--src/web/_views/_template/toast.php22
6 files changed, 178 insertions, 0 deletions
diff --git a/src/web/_views/_template/comment.php b/src/web/_views/_template/comment.php
new file mode 100644
index 0000000..b947ff6
--- /dev/null
+++ b/src/web/_views/_template/comment.php
@@ -0,0 +1,12 @@
+<?php /* Copyright (c) 2024 Freya Murphy */ ?>
+<?php /* vi: syntax=php */ ?>
+<div class="comment row mt">
+ <?=pfp($user)?>
+ <div class="ml col sub-card">
+ <div class="row">
+ <strong><?=$this->format_name($user)?></strong>
+ <span class="subtext ml"><?=$this->format_date($comment['created'])?></span>
+ </div>
+ <?=$comment['content']?>
+ </div>
+</div>
diff --git a/src/web/_views/_template/error.php b/src/web/_views/_template/error.php
new file mode 100644
index 0000000..2e02cb1
--- /dev/null
+++ b/src/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/src/web/_views/_template/modal.php b/src/web/_views/_template/modal.php
new file mode 100644
index 0000000..8e4545d
--- /dev/null
+++ b/src/web/_views/_template/modal.php
@@ -0,0 +1,14 @@
+<?php /* Copyright (c) 2024 Freya Murphy */ ?>
+<?php /* vi: syntax=php */ ?>
+<div class="modal-container">
+ <div class="modal">
+ <div class="modal-header row">
+ <span class="modal-title"><?=$title?></span>
+ <?=ilang(
+ 'action_modal_close',
+ class: 'btn btn-action modal-close',
+ )?>
+ </div>
+ <?php $this->view('_modal/' . $content, $data) ?>
+ </div>
+</div>
diff --git a/src/web/_views/_template/post.php b/src/web/_views/_template/post.php
new file mode 100644
index 0000000..f7f5de2
--- /dev/null
+++ b/src/web/_views/_template/post.php
@@ -0,0 +1,86 @@
+<?php /* Copyright (c) 2024 Freya Murphy */ ?>
+<?php /* vi: syntax=php */ ?>
+<div class="post card">
+ <div class="row">
+ <?=pfp($user)?>
+ <div class="col ml">
+ <strong><?=$user['first_name'] . ' ' . $user['last_name']?></strong>
+ <span class="subtext"><?=$this->format_date($post['created'])?></span>
+ </div>
+ </div>
+ <p>
+ <?=$post['content']?>
+ </p>
+<?php
+ $liked = $post['like_id'] ? 'btn-primary' : '';
+ $post_attrs = array(
+ 'postId' => $post['id']
+ );
+ if ($post['like_id'] !== NULL) {
+ $post_attrs['likeId'] = $post['like_id'];
+ }
+?>
+ <span class="likes subtext"><span class="count"><?=$post['like_count']?></span><?=' ' . ucfirst(lang('likes'))?></span>
+<?php if ($session): ?>
+ <hr>
+ <div class="row">
+ <?=ilang('action_like',
+ class: 'btn grow action-like ' . $liked,
+ attrs: $post_attrs
+ )?>
+ <?=ilang('action_comment', class: 'btn grow action-comment',
+ onclick: '$(\'#action-new-comment-' . $post['id'] . '\').focus()'
+ )?>
+ </div>
+ <hr>
+<?php endif; ?>
+ <div class="col comments pb">
+ <?php
+ $_GET = array('id' => $post['id']);
+ $cdata = $this->comments();
+
+ $loaded = $cdata['loaded'];
+ $max = $cdata['max'];
+ $page_size = $cdata['page_size'];
+ $total = $post['comment_count'];
+
+ if ($loaded >= $page_size && $page_size < $total) {
+ echo ilang('action_load_comments',
+ class: 'action-load-comments btn btn-blend mt',
+ attrs: array(
+ 'postId' => $post['id'],
+ 'loaded' => $loaded,
+ 'pageSize' => $page_size,
+ 'commentCount' => $total,
+ 'commentMax' => $max,
+ )
+ );
+ }
+
+ ?>
+ </div>
+<?php if ($session): ?>
+ <div class="row pb">
+ <?=pfp($session)?>
+ <form class="ml action-new-comment-form row">
+ <input
+ type="hidden"
+ name="id"
+ value="<?=$post['id']?>"
+ >
+ <input
+ id="action-new-comment-<?=$post['id']?>"
+ class="action-new-comment btn grow btn-alt"
+ postId="<?=$post['id']?>"
+ autocomplete="off"
+ type="text"
+ name="text"
+ placeholder="<?=ucfirst(lang('action_new_comment_text'))?>"
+ aria-label="<?=ucfirst(lang('action_new_comment_tip'))?>"
+ >
+ </form>
+ </div>
+<?php endif; ?>
+</div>
+
+
diff --git a/src/web/_views/_template/posts.php b/src/web/_views/_template/posts.php
new file mode 100644
index 0000000..4202e67
--- /dev/null
+++ b/src/web/_views/_template/posts.php
@@ -0,0 +1,32 @@
+<div id="post-container">
+<?php
+ $pdata = $this->posts();
+
+ $loaded = $pdata['loaded'];
+ $page_size = $pdata['page_size'];
+ $total = $pdata['total'];
+ $max = $pdata['max'];
+ $filterUid = $pdata['filter_uid'];
+?>
+<?php if ($loaded == 0): ?>
+ <div id="no-posts" class="card">
+ <span class="no-posts-title mb"><?=lang('no_posts_found')?></span>
+ <span><?=random_value(explode("\n", lang('no_posts_found_ext')))?></span>
+ </div>
+<?php endif; ?>
+<?php
+ if ($loaded >= $page_size && $page_size < $total) {
+ echo ilang('action_load_posts',
+ id: 'action-load-posts',
+ class: 'btn btn-blend grow mb mt',
+ attrs: array(
+ 'loaded' => $loaded,
+ 'pageSize' => $page_size,
+ 'postCount' => $total,
+ 'postMax' => $max,
+ 'userId' => $filterUid ? json_encode($filterUid) : ''
+ )
+ );
+ }
+?>
+</div>
diff --git a/src/web/_views/_template/toast.php b/src/web/_views/_template/toast.php
new file mode 100644
index 0000000..902955c
--- /dev/null
+++ b/src/web/_views/_template/toast.php
@@ -0,0 +1,22 @@
+<?php /* Copyright (c) 2024 Freya Murphy */ ?>
+<?php /* vi: syntax=php */ ?>
+<?php
+ $params = array();
+
+ if ($detail)
+ $params[] = lang('api_column_' . $detail);
+
+ if ($hint)
+ $params[] = $hint;
+
+ $lang_msg = lang($msg, '', sub: $params);
+ if(!$lang_msg)
+ $lang_msg = $msg;
+ else
+ $lang_msg = ucfirst($lang_msg);
+
+?>
+<div class="toast <?=$type?>">
+ <?=$lang_msg?>
+ <?=ilang('action_close', class: 'action-close-toast')?>
+</div>