summaryrefslogtreecommitdiff
path: root/web/_views
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 /web/_views
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 '')
-rw-r--r--src/web/_views/apps/error/main.php (renamed from web/_views/apps/error/main.php)2
-rw-r--r--src/web/_views/apps/home/main.php (renamed from web/_views/apps/home/main.php)2
-rw-r--r--src/web/_views/footer.php (renamed from web/_views/footer.php)4
-rw-r--r--src/web/_views/header.php (renamed from web/_views/header.php)32
-rw-r--r--src/web/_views/modal/new_post.php (renamed from web/_views/modal/new_post.php)22
-rw-r--r--src/web/_views/template/comment.php (renamed from web/_views/template/comment.php)2
-rw-r--r--src/web/_views/template/error.php (renamed from web/_views/template/error.php)0
-rw-r--r--src/web/_views/template/modal.php (renamed from web/_views/template/modal.php)0
-rw-r--r--src/web/_views/template/pfp.php (renamed from web/_views/template/pfp.php)0
-rw-r--r--src/web/_views/template/post.php (renamed from web/_views/template/post.php)31
-rw-r--r--src/web/_views/template/posts.php (renamed from web/_views/template/posts.php)2
-rw-r--r--src/web/_views/template/toast.php (renamed from web/_views/template/toast.php)11
12 files changed, 61 insertions, 47 deletions
diff --git a/web/_views/apps/error/main.php b/src/web/_views/apps/error/main.php
index 81051bd..dde39cf 100644
--- a/web/_views/apps/error/main.php
+++ b/src/web/_views/apps/error/main.php
@@ -1,6 +1,6 @@
<?php /* Copyright (c) 2024 Freya Murphy */ ?>
<?php /* vi: syntax=php */ ?>
-<div id="error">
+<div id="main-content">
<h1><?=$title?></h1>
<span><?=$msg?></span>
</div>
diff --git a/web/_views/apps/home/main.php b/src/web/_views/apps/home/main.php
index 5cfdf8c..29bf7c3 100644
--- a/web/_views/apps/home/main.php
+++ b/src/web/_views/apps/home/main.php
@@ -7,7 +7,7 @@
<?php $this->view('template/pfp', array('user' => $self))?>
<a
id="action-new-post"
- class="input btn-fake ml"
+ class="btn btn-alt btn-wide ml"
autocomplete="off"
aria-label="<?=lang('action_new_post_tip')?>"
>
diff --git a/web/_views/footer.php b/src/web/_views/footer.php
index 1266b9a..9040c3a 100644
--- a/web/_views/footer.php
+++ b/src/web/_views/footer.php
@@ -1,4 +1,8 @@
<?php /* Copyright (c) 2024 Freya Murphy */ ?>
<?php /* vi: syntax=php */ ?>
+ <footer>
+ Freya Murphy © 2023 | <a href="https://freya.cat">freya.cat</a>
+ </footer>
<body>
+
</html>
diff --git a/web/_views/header.php b/src/web/_views/header.php
index 891e27e..7c60197 100644
--- a/web/_views/header.php
+++ b/src/web/_views/header.php
@@ -2,28 +2,8 @@
<?php /* vi: syntax=php */ ?>
<?php
$self = $this->main->user();
+ $this->view('header_empty', $data);
?>
-<!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);
- }
- foreach ($css_files as $css) {
- echo $this->main->link_css($css);
- }
- ?>
- <title><?=$title?></title>
- </head>
- <body>
<header class="nav">
<div class="nav-left">
<span class="logo">xssbook</span>
@@ -31,7 +11,7 @@
<div class="nav-center" :class="{hidden: !visible}">
<a
id="action-home"
- class="header-entry btn btn-hover btn-action btn-blue"
+ class="btn"
href="/home"
title="<?=lang('action_home_tip')?>"
>
@@ -40,7 +20,7 @@
</a>
<a
id="action-people"
- class="header-entry btn btn-hover btn-action btn-blue"
+ class="btn"
href="/people"
title="<?=lang('action_people_tip')?>"
>
@@ -49,7 +29,7 @@
</a>
<a
id="action-chat"
- class="header-entry btn btn-hover btn-action btn-blue"
+ class="btn"
href="/chat"
title="<?=lang('action_chat_tip')?>"
>
@@ -70,7 +50,7 @@
'class' => 'pfp-sm ml',
)); ?>
<?php else: ?>
- <?=ilang('action_login', class: 'btn btn-action', href: '/auth/login')?>
+ <?=ilang('action_login', class: 'btn', href: '/auth/login')?>
<?php endif; ?>
</div>
<script>
@@ -80,5 +60,3 @@
});
</script>
</header>
- <div id="toast-container">
- </div>
diff --git a/web/_views/modal/new_post.php b/src/web/_views/modal/new_post.php
index 71028ad..50b9b84 100644
--- a/web/_views/modal/new_post.php
+++ b/src/web/_views/modal/new_post.php
@@ -22,7 +22,7 @@
<div class="modal-footer">
<?=ilang('action_submit',
id: 'new-post-submit',
- class: 'btn-action',
+ class: 'btn btn-wide btn-submit',
attrs: array('type' => 'submit'),
button: TRUE
)?>
@@ -32,14 +32,28 @@
$('#new-post-form').submit(function(e) {
e.preventDefault();
let content = $('#new-post-content').val();
+ let me = $(this);
+
+ const getPost = function(data) {
+ if (data) {
+ $('#post-container').prepend(data);
+ }
+ me.closest('.modal-container').remove();
+ }
+
+ const onPost = function(data) {
+ let id = data[0].id;
+ $.get({
+ url: '/_util/post/post?id=' + id,
+ success: getPost
+ });
+ }
$.ajax({
url: '/api/post',
method: 'POST',
data: JSON.stringify({ content }),
- success: function(data) {
- window.location.reload();
- },
+ success: onPost
});
});
</script>
diff --git a/web/_views/template/comment.php b/src/web/_views/template/comment.php
index 20032b2..3ff473b 100644
--- a/web/_views/template/comment.php
+++ b/src/web/_views/template/comment.php
@@ -8,7 +8,7 @@
<div class="ml col sub-card">
<div class="row">
<strong><?=$format_model->name($user)?></strong>
- <span class="dim ml"><?=$format_model->date($comment['date'])?></span>
+ <span class="dim ml"><?=$format_model->date($comment['created'])?></span>
</div>
<?=$comment['content']?>
</div>
diff --git a/web/_views/template/error.php b/src/web/_views/template/error.php
index 2e02cb1..2e02cb1 100644
--- a/web/_views/template/error.php
+++ b/src/web/_views/template/error.php
diff --git a/web/_views/template/modal.php b/src/web/_views/template/modal.php
index e3ce6fe..e3ce6fe 100644
--- a/web/_views/template/modal.php
+++ b/src/web/_views/template/modal.php
diff --git a/web/_views/template/pfp.php b/src/web/_views/template/pfp.php
index aec7318..aec7318 100644
--- a/web/_views/template/pfp.php
+++ b/src/web/_views/template/pfp.php
diff --git a/web/_views/template/post.php b/src/web/_views/template/post.php
index 0541026..83a72bf 100644
--- a/web/_views/template/post.php
+++ b/src/web/_views/template/post.php
@@ -5,7 +5,7 @@
<?php $this->view('template/pfp', array('user' => $user))?>
<div class="col ml">
<strong><?=$user['first_name'] . ' ' . $user['last_name']?></strong>
- <span class="dim"><?=$post['date']?></span>
+ <span class="dim"><?=$post['created']?></span>
</div>
</div>
<p>
@@ -13,20 +13,28 @@
</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: 'grow btn btn-hover btn-action')?>
- <?=ilang('action_comment', class: 'grow btn btn-hover btn-action action-comment',
- click: '$(\'#new-comment-' . $post['id'] . '\').focus()'
+ <?=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 else: ?>
- <hr>
<?php endif; ?>
- <div class="col comments">
+ <div class="col comments pb">
<?php
$_GET = array('id' => $post['id']);
$cdata = $this->comments();
@@ -52,16 +60,17 @@
?>
</div>
<?php if ($self): ?>
- <div class="row grow mt">
+ <div class="row pb">
<?php $this->view('template/pfp', array('user' => $user))?>
- <form class="ml action-new-comment-form">
+ <form class="ml action-new-comment-form row">
<input
type="hidden"
name="id"
value="<?=$post['id']?>"
>
<input
- class="action-new-comment input"
+ id="action-new-comment-<?=$post['id']?>"
+ class="action-new-comment btn btn-wide btn-alt"
postId="<?=$post['id']?>"
autocomplete="off"
type="text"
@@ -73,3 +82,5 @@
</div>
<?php endif; ?>
</div>
+
+
diff --git a/web/_views/template/posts.php b/src/web/_views/template/posts.php
index f57a25f..5e9156c 100644
--- a/web/_views/template/posts.php
+++ b/src/web/_views/template/posts.php
@@ -10,7 +10,7 @@
if ($loaded >= $page_size && $page_size < $total) {
ilang('action_load_posts',
id: 'action-load-posts',
- class: 'btn btn-line mb',
+ class: 'btn btn-line btn-wide mb',
attrs: array(
'loaded' => $loaded,
'pageSize' => $page_size,
diff --git a/web/_views/template/toast.php b/src/web/_views/template/toast.php
index 1f74602..ae2e7d8 100644
--- a/web/_views/template/toast.php
+++ b/src/web/_views/template/toast.php
@@ -11,9 +11,16 @@
array_push($params, $hint);
}
- $msg = lang($msg, sub: $params);
+ $lang_msg = lang($msg, FALSE, sub: $params);
+
+ if(!$lang_msg) {
+ $lang_msg = $msg;
+ } else {
+ $lang_msg = ucfirst($lang_msg);
+ }
+
?>
<div class="toast error">
- <?=ucfirst($msg)?>
+ <?=$lang_msg?>
<?=ilang('action_close', class: 'action-close-toast')?>
</div>