summaryrefslogtreecommitdiff
path: root/src/web/_views
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
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')
-rw-r--r--src/web/_views/_modal/about.php (renamed from src/web/_views/modal/about.php)0
-rw-r--r--src/web/_views/_modal/new_post.php (renamed from src/web/_views/modal/new_post.php)25
-rw-r--r--src/web/_views/_modal/register.php (renamed from src/web/_views/modal/register.php)2
-rw-r--r--src/web/_views/_template/comment.php (renamed from src/web/_views/template/comment.php)7
-rw-r--r--src/web/_views/_template/error.php (renamed from src/web/_views/template/error.php)0
-rw-r--r--src/web/_views/_template/modal.php (renamed from src/web/_views/template/modal.php)2
-rw-r--r--src/web/_views/_template/post.php (renamed from src/web/_views/template/post.php)13
-rw-r--r--src/web/_views/_template/posts.php (renamed from src/web/_views/template/posts.php)11
-rw-r--r--src/web/_views/_template/toast.php (renamed from src/web/_views/template/toast.php)18
-rw-r--r--src/web/_views/apps/people/people.php7
-rw-r--r--src/web/_views/auth/main.php (renamed from src/web/_views/apps/auth/login.php)6
-rw-r--r--src/web/_views/error/main.php (renamed from src/web/_views/apps/error/main.php)0
-rw-r--r--src/web/_views/head.php15
-rw-r--r--src/web/_views/header.php38
-rw-r--r--src/web/_views/home/main.php (renamed from src/web/_views/apps/home/main.php)8
-rw-r--r--src/web/_views/people/card.php (renamed from src/web/_views/apps/people/card.php)2
-rw-r--r--src/web/_views/people/footer.php (renamed from src/web/_views/apps/people/footer.php)0
-rw-r--r--src/web/_views/people/header.php (renamed from src/web/_views/apps/people/header.php)0
-rw-r--r--src/web/_views/people/main.php (renamed from src/web/_views/apps/people/main.php)12
-rw-r--r--src/web/_views/people/people.php5
-rw-r--r--src/web/_views/profile/main.php (renamed from src/web/_views/apps/profile/main.php)28
-rw-r--r--src/web/_views/settings/main.php (renamed from src/web/_views/apps/settings/main.php)7
22 files changed, 89 insertions, 117 deletions
diff --git a/src/web/_views/modal/about.php b/src/web/_views/_modal/about.php
index 4bc7a4f..4bc7a4f 100644
--- a/src/web/_views/modal/about.php
+++ b/src/web/_views/_modal/about.php
diff --git a/src/web/_views/modal/new_post.php b/src/web/_views/_modal/new_post.php
index 66e6561..aff19a5 100644
--- a/src/web/_views/modal/new_post.php
+++ b/src/web/_views/_modal/new_post.php
@@ -1,31 +1,28 @@
<?php /* Copyright (c) 2024 Freya Murphy */ ?>
<?php /* vi: syntax=php */ ?>
-<?php
- $user = $this->main->user();
-?>
<form id="new-post-form">
<div class="modal-content new-post-modal">
<div class="row">
- <?=pfp($user)?>
+ <?=pfp($session)?>
<div class="col ml">
- <strong><?=$user['first_name'] . ' ' . $user['last_name']?></strong>
- <span class="subtext"><?=ucfirst(lang('now'))?></span>
+ <strong><?=$session['first_name'] . ' ' . $session['last_name']?></strong>
+ <span class="subtext"><?=ucfirst(lang('now'))?></span>
</div>
</div>
<textarea
type="text"
name="content"
id="new-post-content"
- placeholder="<?=ucfirst(lang('action_new_post_text', sub: [$user['first_name']]))?>"
+ placeholder="<?=ucfirst(lang('action_new_post_text', sub: [$session['first_name']]))?>"
></textarea>
</div>
<div class="modal-footer">
- <?=ilang('action_submit',
- id: 'new-post-submit',
- class: 'btn btn-submit btn-alt grow',
- attrs: array('type' => 'submit'),
- button: TRUE
- )?>
+ <?=ilang('action_submit',
+ id: 'new-post-submit',
+ class: 'btn btn-submit btn-alt grow',
+ attrs: array('type' => 'submit'),
+ type: 'button',
+ )?>
</div>
</form>
<script>
@@ -44,7 +41,7 @@
const onPost = function(data) {
let id = data[0].id;
$.get({
- url: '/_util/post/post?id=' + id,
+ url: '/_post/post?id=' + id,
success: getPost
});
}
diff --git a/src/web/_views/modal/register.php b/src/web/_views/_modal/register.php
index 5c76fe9..2126d0d 100644
--- a/src/web/_views/modal/register.php
+++ b/src/web/_views/_modal/register.php
@@ -125,7 +125,7 @@
id: 'register-submit',
class: 'btn btn-submit btn-alt grow',
attrs: array('type' => 'submit'),
- button: TRUE
+ type: 'button',
)?>
</div>
</form>
diff --git a/src/web/_views/template/comment.php b/src/web/_views/_template/comment.php
index ceac588..b947ff6 100644
--- a/src/web/_views/template/comment.php
+++ b/src/web/_views/_template/comment.php
@@ -1,14 +1,11 @@
<?php /* Copyright (c) 2024 Freya Murphy */ ?>
<?php /* vi: syntax=php */ ?>
-<?php
- $format_model = $this->load->model('format');
-?>
<div class="comment row mt">
<?=pfp($user)?>
<div class="ml col sub-card">
<div class="row">
- <strong><?=$format_model->name($user)?></strong>
- <span class="subtext ml"><?=$this->main->date($comment['created'])?></span>
+ <strong><?=$this->format_name($user)?></strong>
+ <span class="subtext ml"><?=$this->format_date($comment['created'])?></span>
</div>
<?=$comment['content']?>
</div>
diff --git a/src/web/_views/template/error.php b/src/web/_views/_template/error.php
index 2e02cb1..2e02cb1 100644
--- a/src/web/_views/template/error.php
+++ b/src/web/_views/_template/error.php
diff --git a/src/web/_views/template/modal.php b/src/web/_views/_template/modal.php
index 2a041a7..8e4545d 100644
--- a/src/web/_views/template/modal.php
+++ b/src/web/_views/_template/modal.php
@@ -9,6 +9,6 @@
class: 'btn btn-action modal-close',
)?>
</div>
- <?php $this->view('modal/' . $content) ?>
+ <?php $this->view('_modal/' . $content, $data) ?>
</div>
</div>
diff --git a/src/web/_views/template/post.php b/src/web/_views/_template/post.php
index 48f8bb6..f7f5de2 100644
--- a/src/web/_views/template/post.php
+++ b/src/web/_views/_template/post.php
@@ -5,14 +5,13 @@
<?=pfp($user)?>
<div class="col ml">
<strong><?=$user['first_name'] . ' ' . $user['last_name']?></strong>
- <span class="subtext"><?=$this->main->date($post['created'])?></span>
+ <span class="subtext"><?=$this->format_date($post['created'])?></span>
</div>
</div>
<p>
<?=$post['content']?>
</p>
<?php
- $self = $this->main->user();
$liked = $post['like_id'] ? 'btn-primary' : '';
$post_attrs = array(
'postId' => $post['id']
@@ -22,7 +21,7 @@
}
?>
<span class="likes subtext"><span class="count"><?=$post['like_count']?></span><?=' ' . ucfirst(lang('likes'))?></span>
-<?php if ($self): ?>
+<?php if ($session): ?>
<hr>
<div class="row">
<?=ilang('action_like',
@@ -30,7 +29,7 @@
attrs: $post_attrs
)?>
<?=ilang('action_comment', class: 'btn grow action-comment',
- click: '$(\'#action-new-comment-' . $post['id'] . '\').focus()'
+ onclick: '$(\'#action-new-comment-' . $post['id'] . '\').focus()'
)?>
</div>
<hr>
@@ -46,7 +45,7 @@
$total = $post['comment_count'];
if ($loaded >= $page_size && $page_size < $total) {
- ilang('action_load_comments',
+ echo ilang('action_load_comments',
class: 'action-load-comments btn btn-blend mt',
attrs: array(
'postId' => $post['id'],
@@ -60,9 +59,9 @@
?>
</div>
-<?php if ($self): ?>
+<?php if ($session): ?>
<div class="row pb">
- <?=pfp($self)?>
+ <?=pfp($session)?>
<form class="ml action-new-comment-form row">
<input
type="hidden"
diff --git a/src/web/_views/template/posts.php b/src/web/_views/_template/posts.php
index ed79688..4202e67 100644
--- a/src/web/_views/template/posts.php
+++ b/src/web/_views/_template/posts.php
@@ -7,9 +7,16 @@
$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) {
- ilang('action_load_posts',
+ echo ilang('action_load_posts',
id: 'action-load-posts',
class: 'btn btn-blend grow mb mt',
attrs: array(
diff --git a/src/web/_views/template/toast.php b/src/web/_views/_template/toast.php
index 0a6a82f..902955c 100644
--- a/src/web/_views/template/toast.php
+++ b/src/web/_views/_template/toast.php
@@ -3,21 +3,17 @@
<?php
$params = array();
- if ($detail) {
- array_push($params, lang('api_column_' . $detail));
- }
+ if ($detail)
+ $params[] = lang('api_column_' . $detail);
- if ($hint) {
- array_push($params, $hint);
- }
+ if ($hint)
+ $params[] = $hint;
- $lang_msg = lang($msg, FALSE, sub: $params);
-
- if(!$lang_msg) {
+ $lang_msg = lang($msg, '', sub: $params);
+ if(!$lang_msg)
$lang_msg = $msg;
- } else {
+ else
$lang_msg = ucfirst($lang_msg);
- }
?>
<div class="toast <?=$type?>">
diff --git a/src/web/_views/apps/people/people.php b/src/web/_views/apps/people/people.php
deleted file mode 100644
index 5fc0d17..0000000
--- a/src/web/_views/apps/people/people.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php /* Copyright (c) 2024 Freya Murphy */ ?>
-<?php /* vi: syntax=php */ ?>
-<?php
- foreach($users as $user) {
- $this->view('apps/people/card', array('user' => $user));
- }
-?>
diff --git a/src/web/_views/apps/auth/login.php b/src/web/_views/auth/main.php
index ac4cd02..9604770 100644
--- a/src/web/_views/apps/auth/login.php
+++ b/src/web/_views/auth/main.php
@@ -32,7 +32,7 @@
</div>
<?=ilang('action_login',
class: 'btn btn-primary btn-alt grow',
- button: TRUE,
+ type: 'button',
attrs: array('type' => 'submit')
)?>
<?/*=ilang('action_forgot_passwd',
@@ -43,7 +43,7 @@
<?=ilang('action_create_account',
id: 'action-register',
class: 'btn btn-success btn-alt grow',
- button: TRUE,
+ type: 'button',
attrs: array('type' => 'submit')
)?>
</div>
@@ -79,7 +79,7 @@
});
$('#action-register').on('click', function() {
- $.get( "/modal/register", function (data) {
+ $.get( "/_modal/register", function (data) {
$(document.body).append(data);
});
})
diff --git a/src/web/_views/apps/error/main.php b/src/web/_views/error/main.php
index bcc6f90..bcc6f90 100644
--- a/src/web/_views/apps/error/main.php
+++ b/src/web/_views/error/main.php
diff --git a/src/web/_views/head.php b/src/web/_views/head.php
index cca43a1..809ab36 100644
--- a/src/web/_views/head.php
+++ b/src/web/_views/head.php
@@ -4,23 +4,14 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
- <?php if ($this->main->session): ?>
- var jwtStr = <?=json_encode($this->main->session['jwt'])?>;
+ <?php if ($session): ?>
+ var jwtStr = <?=json_encode($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);
- }
- ?>
+ <?=CRIMSON_META($this)?>
<title><?=$title?></title>
- <!-- haa haa hee hee hoo hoo -->
- <script src="https://unpkg.com/@ruffle-rs/ruffle"></script>
</head>
<body>
<div id="toast-container">
diff --git a/src/web/_views/header.php b/src/web/_views/header.php
index 7315afb..4ba15ed 100644
--- a/src/web/_views/header.php
+++ b/src/web/_views/header.php
@@ -1,7 +1,6 @@
<?php /* Copyright (c) 2024 Freya Murphy */ ?>
<?php /* vim: syntax=php */ ?>
<?php
- $self = $this->main->user();
$this->view('head', $data);
?>
<header id="header">
@@ -11,41 +10,29 @@
<div class="center" :class="{hidden: !visible}">
<a
id="action-home"
- class="btn <?=$this->main->info['app'] == 'home' ? 'btn-primary btn-border' : ''?>"
+ class="btn <?=ROUTER->req['app'] == 'home' ? 'btn-primary btn-border' : ''?>"
href="/home"
- title="<?=ucfirst(lang('action_home_tip'))?>"
- >
+ title="<?=ucfirst(lang('action_home_tip'))?>">
<i class="mi mi-lg">home</i>
<span><?=ucfirst(lang('action_home_text'))?></span>
</a>
<a
id="action-people"
- class="btn <?=$this->main->info['app'] == 'people' ? 'btn-primary btn-border' : ''?>"
+ class="btn <?=ROUTER->req['app'] == 'people' ? 'btn-primary btn-border' : ''?>"
href="/people"
- title="<?=ucfirst(lang('action_people_tip'))?>"
- >
+ title="<?=ucfirst(lang('action_people_tip'))?>">
<i class="mi mi-lg">people</i>
<span><?=ucfirst(lang('action_people_text'))?></span>
</a>
- <!--a
- id="action-chat"
- class="btn <?=$this->main->info['app'] == 'chat' ? 'btn-primary btn-border' : ''?>"
- href="/chat"
- title="<?=lang('action_chat_tip')?>"
- >
- <i class="mi mi-lg">chat</i>
- <span><?=lang('action_chat_text')?></span>
- </a-->
</div>
<div class="right">
<button
id="action-hamburger"
title="<?=ucfirst(lang('action_hamburger_tip'))?>"
- class="btn mr"
- >
+ class="btn mr">
<i class="mi mi-lg">menu</i>
</button>
- <?php if($self): ?>
+ <?php if($session): ?>
<script>
var userMenu = null;
@@ -53,13 +40,13 @@
userMenu.toggleClass('hidden');
}
</script>
- <?=pfp($self, FALSE, 'toggleUserMenu()')?>
+ <?=pfp($session, FALSE, 'toggleUserMenu()')?>
<div class="card col hidden" id="user-menu">
<span class="user-menu-header row mr">
- <?=pfp($self, FALSE)?>
+ <?=pfp($session, FALSE)?>
<span class="col">
- <strong><?=$this->format_model->name($self)?></strong>
- <span class="subtext"><?=$self['username']?></span>
+ <strong><?=$this->format_name($session)?></strong>
+ <span class="subtext"><?=$session['username']?></span>
</span>
</span>
<hr>
@@ -67,13 +54,12 @@
'action_profile',
id: 'action-profile',
class: 'btn',
- href: '/profile?id=' . $self['id']
+ href: '/profile?id=' . $session['id']
)?>
<?=ilang(
'action_xssbook_about',
id: 'action-xssbook-about',
class: 'btn',
- click: 'viewAbout'
)?>
<?=ilang(
'action_settings',
@@ -94,7 +80,7 @@
</div>
<script>
$('#action-xssbook-about').on('click', function() {
- $.get( "/modal/about", function (data) {
+ $.get( "/_modal/about", function (data) {
$(document.body).append(data);
});
})
diff --git a/src/web/_views/apps/home/main.php b/src/web/_views/home/main.php
index 864034a..c9373d2 100644
--- a/src/web/_views/apps/home/main.php
+++ b/src/web/_views/home/main.php
@@ -1,22 +1,22 @@
<?php /* Copyright (c) 2024 Freya Murphy */ ?>
<?php /* vi: syntax=php */ ?>
<main id="main">
-<?php if ($self): ?>
+<?php if ($session): ?>
<div id="new-post" class="card">
<div class="row grow">
- <?=pfp($self)?>
+ <?=pfp($session)?>
<a
id="action-new-post"
class="btn btn-alt grow ml"
autocomplete="off"
aria-label="<?=ucfirst(lang('action_new_post_tip'))?>"
>
- <?=ucfirst(lang('action_new_post_text', sub: [$self['first_name']]))?>
+ <?=ucfirst(lang('action_new_post_text', sub: [$session['first_name']]))?>
</a>
</div>
<script>
$('#action-new-post').on('click', function() {
- $.get( "/modal/new_post", function (data) {
+ $.get( "/_modal/new_post", function (data) {
$(document.body).append(data);
});
})
diff --git a/src/web/_views/apps/people/card.php b/src/web/_views/people/card.php
index 93b1350..7e040ba 100644
--- a/src/web/_views/apps/people/card.php
+++ b/src/web/_views/people/card.php
@@ -7,7 +7,7 @@
<div class="col">
<?=pfp($user, FALSE)?>
<div class="col ml">
- <span class="name"><?=$this->format_model->name($user)?></span>
+ <span class="name"><?=$this->format_name($user)?></span>
<span class="subtext"><?=$user['username']?></span>
</div>
</div>
diff --git a/src/web/_views/apps/people/footer.php b/src/web/_views/people/footer.php
index f18e031..f18e031 100644
--- a/src/web/_views/apps/people/footer.php
+++ b/src/web/_views/people/footer.php
diff --git a/src/web/_views/apps/people/header.php b/src/web/_views/people/header.php
index b1099ec..b1099ec 100644
--- a/src/web/_views/apps/people/header.php
+++ b/src/web/_views/people/header.php
diff --git a/src/web/_views/apps/people/main.php b/src/web/_views/people/main.php
index ec84ab9..c602b2c 100644
--- a/src/web/_views/apps/people/main.php
+++ b/src/web/_views/people/main.php
@@ -1,18 +1,22 @@
<?php /* Copyright (c) 2024 Freya Murphy */ ?>
-<?php /* vi: syntax=php */ ?>
<div id="people-container" class="col">
-<?php
- $pdata = $this->people();
-?>
+ <?php $pdata = $this->people(); ?>
</div>
<?php
+
$loaded = count($pdata['users']);
$page_size = $pdata['page_size'];
$total = $pdata['count'];
$max = $pdata['max_id'];
$filter_uid = $pdata['filter_uid'];
$filer_type = $pdata['filter_type'];
+
?>
+<?php if ($loaded == 0): ?>
+ <div id="no-people" class="card">
+ <?=lang('no_people_found')?>
+ </div>
+<?php endif; ?>
<?php if ($loaded >= $page_size && $page_size < $total): ?>
<?=ilang('action_load_users',
id: 'action-load-users',
diff --git a/src/web/_views/people/people.php b/src/web/_views/people/people.php
new file mode 100644
index 0000000..8726f1d
--- /dev/null
+++ b/src/web/_views/people/people.php
@@ -0,0 +1,5 @@
+<?php /* Copyright (c) 2024 Freya Murphy */
+foreach($users as $user) {
+ $this->view('people/card', array('user' => $user));
+}
+?>
diff --git a/src/web/_views/apps/profile/main.php b/src/web/_views/profile/main.php
index b2ad496..3e7129c 100644
--- a/src/web/_views/apps/profile/main.php
+++ b/src/web/_views/profile/main.php
@@ -11,47 +11,47 @@
<div class="col content grow">
<div class="row grow">
<div class="col mb">
- <strong class="name"><?=$this->format_model->name($user)?></strong>
+ <strong class="name"><?=$this->format_name($user)?></strong>
<span class="subtext"><?=$user['follower_count'] . ' ' . ucfirst(lang('followers'))?></span>
</div>
<?php if (
- $this->main->session &&
- (!isset($self) || $self['id'] != $user['id'])
+ $session &&
+ ($session['id'] != $user['id'])
): ?>
<div class="follow">
<?=ilang(
'action_follow',
id: 'action-follow-follow',
class: 'btn btn-alt',
+ sub: [$user['first_name']],
style: (!$following && !$followed) ? '' : 'display: none',
- sub: [$user['first_name']]
)?>
<?=ilang(
'action_follow_back',
id: 'action-follow-follow-back',
class: 'btn btn-alt',
+ sub: [$user['first_name']],
style: (!$following && $followed) ? '' : 'display: none',
- sub: [$user['first_name']]
)?>
<?=ilang(
'action_following',
id: 'action-follow-following',
class: 'btn btn-alt btn-primary',
+ sub: [$user['first_name']],
style: ($following && !$followed) ? '' : 'display: none',
- sub: [$user['first_name']]
)?>
<?=ilang(
'action_friends',
id: 'action-follow-friends',
class: 'btn btn-alt btn-primary',
+ sub: [$user['first_name']],
style: ($following && $followed) ? '' : 'display: none',
- sub: [$user['first_name']]
)?>
</div>
<script>
let following = <?=json_encode($following)?>;
+ let followingId = <?=json_encode($following_id)?>;
let followed = <?=json_encode($followed)?>;
- let followId = <?=json_encode($follow_id)?>;
let followee_id = <?=json_encode($user['id'])?>;
let btns = {};
@@ -84,15 +84,15 @@
}
const onPostFollow = (data) => {
- followId = data[0].id;
+ followingId = data[0].id;
following = true;
updateFollow();
}
const onClickFollow = () => {
- if (followId) {
+ if (followingId) {
$.ajax({
- url: '/api/follow?id=eq.' + followId,
+ url: '/api/follow?id=eq.' + followingId,
method: 'PATCH',
data: JSON.stringify({ followee_id, value: !following }),
success: onPatchFollow
@@ -181,7 +181,7 @@
</tr>
<tr>
<td><strong><?=ucfirst(lang('about_general_birth_date'))?></strong></td>
- <td><?=$this->main->date($user['birth_date'])?></td>
+ <td><?=$this->format_date($user['birth_date'])?></td>
</tr>
</table>
<h1><?=ucfirst(lang('about_stats'))?></h1>
@@ -204,11 +204,11 @@
</tr>
<tr>
<td><strong><?=ucfirst(lang('about_stats_joined'))?></strong></td>
- <td><?=$this->main->date($user['created'])?></td>
+ <td><?=$this->format_date($user['created'])?></td>
</tr>
<tr>
<td><strong><?=ucfirst(lang('about_stats_seen'))?></strong></td>
- <td><?=$this->main->date($user['seen'])?></td>
+ <td><?=$this->format_date($user['seen'])?></td>
</tr>
</table>
</div>
diff --git a/src/web/_views/apps/settings/main.php b/src/web/_views/settings/main.php
index 2033acc..4401fe1 100644
--- a/src/web/_views/apps/settings/main.php
+++ b/src/web/_views/settings/main.php
@@ -1,9 +1,6 @@
-<?php /* Copyright (c) 2024 Freya Murphy */ ?>
-<?php /* vi: syntax=php */ ?>
+<?php /* Copyright (c) 2024 Freya Murphy */
-<?php
-
-$user = $this->main->user();
+$user = $session;
function __create_form($user, $col) {
$ph = ucfirst(lang('ph_' . $col));