summaryrefslogtreecommitdiff
path: root/src/web/_views
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/web/_views/apps/auth/login.php86
-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/header_empty.php23
-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/modal/register.php173
-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
15 files changed, 343 insertions, 47 deletions
diff --git a/src/web/_views/apps/auth/login.php b/src/web/_views/apps/auth/login.php
new file mode 100644
index 0000000..d7f326b
--- /dev/null
+++ b/src/web/_views/apps/auth/login.php
@@ -0,0 +1,86 @@
+<?php /* Copyright (c) 2024 Freya Murphy */ ?>
+<?php /* vi: syntax=php */ ?>
+<div id="main-content">
+ <div class="branding col">
+ <h1>xssbook</h1>
+ <span><?=lang('login_branding')?></span>
+ </div>
+ <div class="form card col">
+ <form id="action-login" class="col" action="">
+ <div class="rel mb">
+ <input
+ type="text"
+ name="username"
+ id="login-username"
+ placeholder=" "
+ >
+ <label for="username">
+ <?=lang('ph_username')?>
+ </label>
+ </div>
+ <div class="rel mb">
+ <input
+ type="password"
+ name="password"
+ id="login-password"
+ placeholder=" "
+ >
+ <label for="password">
+ <?=lang('ph_password')?>
+ </label>
+ </div>
+ <?=ilang('action_login',
+ class: 'btn btn-submit btn-wide',
+ button: TRUE,
+ attrs: array('type' => 'submit')
+ )?>
+ <?=ilang('action_forgot_passwd',
+ class: 'btn btn-line btn-blue btn-wide mt'
+ )?>
+ </form>
+ <hr>
+ <?=ilang('action_create_account',
+ id: 'action-register',
+ class: 'btn btn-success btn-wide',
+ button: TRUE,
+ attrs: array('type' => 'submit')
+ )?>
+ </div>
+ <script>
+
+ var onLogin = function(data) {
+ let jwt = data.token;
+
+ $.ajax({
+ url: '/auth/update',
+ method: 'POST',
+ data: JSON.stringify({
+ key: 'jwt',
+ value: jwt
+ }),
+ success: function (_) {
+ window.location = '/home';
+ }
+ })
+ };
+
+ $('#action-login').on('submit', function(e) {
+ e.preventDefault();
+ let username = $('#login-username').val();
+ let password = $('#login-password').val();
+
+ $.ajax({
+ url: '/api/rpc/login',
+ method: 'POST',
+ data: JSON.stringify({ username, password }),
+ success: onLogin
+ });
+ });
+
+ $('#action-register').on('click', function() {
+ $.get( "/modal/register", function (data) {
+ $(document.body).append(data);
+ });
+ })
+ </script>
+</div>
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/src/web/_views/header_empty.php b/src/web/_views/header_empty.php
new file mode 100644
index 0000000..75f6f17
--- /dev/null
+++ b/src/web/_views/header_empty.php
@@ -0,0 +1,23 @@
+<!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>
+ <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/src/web/_views/modal/register.php b/src/web/_views/modal/register.php
new file mode 100644
index 0000000..f4d364a
--- /dev/null
+++ b/src/web/_views/modal/register.php
@@ -0,0 +1,173 @@
+
+<?php /* Copyright (c) 2024 Freya Murphy */ ?>
+<?php /* vi: syntax=php */ ?>
+<form id="register-form">
+<div class="modal-content register-modal col">
+ <label class="static">
+ <?=lang('ph_basic_info')?>
+ </label>
+ <div class="row mt">
+ <div class="rel btn-wide">
+ <input
+ type="text"
+ name="first_name"
+ id="register-first-name"
+ placeholder=" "
+ >
+ <label for="first_name">
+ <?=lang('ph_first_name')?>
+ </label>
+ </div>
+ <div class="rel ml btn-wide">
+ <input
+ type="text"
+ name="last_name"
+ id="register-last-name"
+ placeholder=" "
+ >
+ <label for="last_name">
+ <?=lang('ph_last_name')?>
+ </label>
+ </div>
+ </div>
+ <div class="rel mt">
+ <input
+ type="text"
+ name="username"
+ id="register-username"
+ placeholder=" "
+ >
+ <label for="username">
+ <?=lang('ph_username')?>
+ </label>
+ </div>
+ <div class="rel mt">
+ <input
+ type="password"
+ name="password"
+ id="register-password"
+ placeholder=" "
+ >
+ <label for="password">
+ <?=lang('ph_password')?>
+ </label>
+ </div>
+ <div class="rel mt">
+ <input
+ type="text"
+ name="email"
+ id="register-email"
+ placeholder=" "
+ >
+ <label for="email">
+ <?=lang('ph_email')?>
+ </label>
+ </div>
+ <label for="birth_date" class="mt static">
+ <?=lang('ph_birth_date')?>
+ </label>
+ <input
+ class="mt"
+ type="date"
+ name="birth_date"
+ id="register-birth-date"
+ >
+ <label for="gender" class="mt static">
+ <?=lang('ph_gender')?>
+ </label>
+ <div class="row mt" data-type="radio" data-name="gender-wrapper">
+ <div class="rel radio mr">
+ <input
+ type="radio"
+ id="register-gender-male"
+ name="gender"
+ value="male"
+ >
+ <label
+ for="register-gender-male"
+ class="static"
+ >
+ <?=lang('ph_gender_male')?>
+ </label>
+ </div>
+ <div class="rel radio mr">
+ <input
+ type="radio"
+ id="register-gender-female"
+ name="gender"
+ value="female"
+ >
+ <label
+ for="register-gender-female"
+ class="static"
+ >
+ <?=lang('ph_gender_female')?>
+ </label>
+ </div>
+ <div class="rel radio">
+ <input
+ type="radio"
+ id="register-gender-lettuce"
+ name="gender"
+ value="lettuce"
+ >
+ <label
+ for="register-gender-lettuce"
+ class="static"
+ >
+ <?=lang('ph_gender_lettuce')?>
+ </label>
+ </div>
+ </div>
+</div>
+<div class="modal-footer">
+ <?=ilang('action_register',
+ id: 'register-submit',
+ class: 'btn btn-wide btn-success',
+ attrs: array('type' => 'submit'),
+ button: TRUE
+ )?>
+</div>
+</form>
+<script>
+ $('#register-form').submit(function(e) {
+ e.preventDefault();
+
+ const form = event.target;
+ const formFields = form.elements;
+
+ let first_name = formFields.first_name.value.trim();
+ let last_name = formFields.last_name.value.trim();
+ let username = formFields.username.value.trim();
+ let password = formFields.password.value.trim();
+ let email = formFields.email.value.trim();
+ let birth_date = formFields.birth_date.value.trim();
+ let gender = formFields.gender.value.trim();
+
+ if(birth_date === '') {
+ errorToast('toast_date_empty');
+ return;
+ }
+
+ const onSuccess = () => {
+ $.ajax({
+ url: '/api/rpc/login',
+ method: 'POST',
+ data: JSON.stringify({
+ username, password
+ }),
+ success: onLogin
+ });
+ };
+
+ $.ajax({
+ url: '/api/user',
+ method: 'POST',
+ data: JSON.stringify({
+ first_name, last_name, username, password,
+ email, birth_date, gender
+ }),
+ success: onSuccess
+ });
+ });
+</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>