summaryrefslogtreecommitdiff
path: root/src/web/_views/template
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-04-01 11:09:25 -0400
committerFreya Murphy <freya@freyacat.org>2024-04-01 11:09:25 -0400
commit3a82baec9d793edf81ac2b151b0f4d4159641375 (patch)
treef9d50c296b078ac48c2a2391c172c3ccf37edb3f /src/web/_views/template
parentrefactor asset dir, refactor oberver in lib (diff)
downloadxssbook2-3a82baec9d793edf81ac2b151b0f4d4159641375.tar.gz
xssbook2-3a82baec9d793edf81ac2b151b0f4d4159641375.tar.bz2
xssbook2-3a82baec9d793edf81ac2b151b0f4d4159641375.zip
login and register, liking on homepage
Diffstat (limited to 'src/web/_views/template')
-rw-r--r--src/web/_views/template/comment.php15
-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/pfp.php8
-rw-r--r--src/web/_views/template/post.php86
-rw-r--r--src/web/_views/template/posts.php23
-rw-r--r--src/web/_views/template/toast.php26
7 files changed, 184 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..3ff473b
--- /dev/null
+++ b/src/web/_views/template/comment.php
@@ -0,0 +1,15 @@
+<?php /* Copyright (c) 2024 Freya Murphy */ ?>
+<?php /* vi: syntax=php */ ?>
+<?php
+ $format_model = $this->load->model('format');
+?>
+<div class="comment row mt">
+ <?php $this->view('template/pfp', array('user' => $user))?>
+ <div class="ml col sub-card">
+ <div class="row">
+ <strong><?=$format_model->name($user)?></strong>
+ <span class="dim ml"><?=$format_model->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..e3ce6fe
--- /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">
+ <?=$title?>
+ <?=ilang(
+ 'action_modal_close',
+ class: 'float-right btn btn-action modal-close',
+ )?>
+ </div>
+ <?php $this->view('modal/' . $content) ?>
+ </div>
+</div>
diff --git a/src/web/_views/template/pfp.php b/src/web/_views/template/pfp.php
new file mode 100644
index 0000000..aec7318
--- /dev/null
+++ b/src/web/_views/template/pfp.php
@@ -0,0 +1,8 @@
+<?php /* Copyright (c) 2024 Freya Murphy */ ?>
+<?php /* vi: syntax=php */ ?>
+<?php
+ $class = isset($class) ? $class : '';
+?>
+<a class="image-loading pfp <?=$class?>" href="/profile?id=<?=$user['id']?>">
+ <img src="/api/rpc/avatar?user_id=<?=$user['id']?>" />
+</a>
diff --git a/src/web/_views/template/post.php b/src/web/_views/template/post.php
new file mode 100644
index 0000000..83a72bf
--- /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">
+ <?php $this->view('template/pfp', array('user' => $user))?>
+ <div class="col ml">
+ <strong><?=$user['first_name'] . ' ' . $user['last_name']?></strong>
+ <span class="dim"><?=$post['created']?></span>
+ </div>
+ </div>
+ <p>
+ <?=$post['content']?>
+ </p>
+<?php
+ $self = $this->main->user();
+ $liked = $post['like_id'] ? 'btn-blue' : '';
+ $post_attrs = array(
+ 'postId' => $post['id']
+ );
+ if ($post['like_id'] !== NULL) {
+ $post_attrs['likeId'] = $post['like_id'];
+ }
+?>
+<?php if ($self): ?>
+ <hr>
+ <div class="row">
+ <?=ilang('action_like',
+ class: 'btn btn-wide action-like ' . $liked,
+ attrs: $post_attrs
+ )?>
+ <?=ilang('action_comment', class: 'btn btn-wide action-comment',
+ click: '$(\'#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) {
+ ilang('action_load_comments',
+ class: 'action-load-comments btn btn-line mt',
+ attrs: array(
+ 'postId' => $post['id'],
+ 'loaded' => $loaded,
+ 'pageSize' => $page_size,
+ 'commentCount' => $total,
+ 'commentMax' => $max,
+ )
+ );
+ }
+
+ ?>
+ </div>
+<?php if ($self): ?>
+ <div class="row pb">
+ <?php $this->view('template/pfp', array('user' => $user))?>
+ <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 btn-wide btn-alt"
+ postId="<?=$post['id']?>"
+ autocomplete="off"
+ type="text"
+ name="text"
+ placeholder="<?=lang('action_new_comment_text')?>"
+ aria-label="<?=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..5e9156c
--- /dev/null
+++ b/src/web/_views/template/posts.php
@@ -0,0 +1,23 @@
+<div id="post-container">
+<?php
+ $pdata = $this->posts();
+
+ $loaded = $pdata['loaded'];
+ $page_size = $pdata['page_size'];
+ $total = $pdata['total'];
+ $max = $pdata['max'];
+
+ if ($loaded >= $page_size && $page_size < $total) {
+ ilang('action_load_posts',
+ id: 'action-load-posts',
+ class: 'btn btn-line btn-wide mb',
+ attrs: array(
+ 'loaded' => $loaded,
+ 'pageSize' => $page_size,
+ 'postCount' => $total,
+ 'postMax' => $max,
+ )
+ );
+ }
+?>
+</div>
diff --git a/src/web/_views/template/toast.php b/src/web/_views/template/toast.php
new file mode 100644
index 0000000..ae2e7d8
--- /dev/null
+++ b/src/web/_views/template/toast.php
@@ -0,0 +1,26 @@
+<?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);
+ }
+
+ $lang_msg = lang($msg, FALSE, sub: $params);
+
+ if(!$lang_msg) {
+ $lang_msg = $msg;
+ } else {
+ $lang_msg = ucfirst($lang_msg);
+ }
+
+?>
+<div class="toast error">
+ <?=$lang_msg?>
+ <?=ilang('action_close', class: 'action-close-toast')?>
+</div>