User registration added to menus and page tree.
This commit is contained in:
parent
ff205469cb
commit
bb315f3efb
24 changed files with 160 additions and 64 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -15,3 +15,4 @@ kanga.world/composer.json
|
||||||
kanga.world/index.php
|
kanga.world/index.php
|
||||||
kanga.world/site/config/config.php
|
kanga.world/site/config/config.php
|
||||||
kanga.world/content/home/*/
|
kanga.world/content/home/*/
|
||||||
|
kanga.world/content/1_home/*/
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
a:link:not(.dropdown-item), a:visited:not(.dropdown-item), a:hover:not(.dropdown-item), a:active:not(.dropdown-item) {
|
a:link:not(.dropdown-item):not(.nav-link),
|
||||||
|
a:visited:not(.dropdown-item):not(.nav-link),
|
||||||
|
a:hover:not(.dropdown-item):not(.nav-link),
|
||||||
|
a:active:not(.dropdown-item):not(.nav-link) {
|
||||||
color: #ff0000;
|
color: #ff0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
kanga.world/content/activated/activated.txt
Normal file
5
kanga.world/content/activated/activated.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Title: Activation Complete!
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Text: Your account is now active! Please login.
|
5
kanga.world/content/newuser/newuser.txt
Normal file
5
kanga.world/content/newuser/newuser.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Title: New User
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Text: Check your email for an activation link.
|
|
@ -1,4 +1,4 @@
|
||||||
Title: User Settings
|
Title: Profile
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -26,9 +26,8 @@ Danger: Danger Zone
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Delete_Button: Delete Account
|
Delete-button: Delete Account
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Delete_Warning: Are you sure? This action cannot be reversed!
|
Delete-warning: Are you sure? This action cannot be reversed!
|
||||||
|
|
7
kanga.world/site/blueprints/pages/activated.yml
Normal file
7
kanga.world/site/blueprints/pages/activated.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
title: Avtivated User Landing Page
|
||||||
|
preset: page
|
||||||
|
fields:
|
||||||
|
text:
|
||||||
|
label: Text
|
||||||
|
type: textarea
|
||||||
|
size: large
|
7
kanga.world/site/blueprints/pages/newuser.yml
Normal file
7
kanga.world/site/blueprints/pages/newuser.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
title: New User Landing Page
|
||||||
|
preset: page
|
||||||
|
fields:
|
||||||
|
text:
|
||||||
|
label: Text
|
||||||
|
type: textarea
|
||||||
|
size: large
|
|
@ -67,8 +67,8 @@ return [
|
||||||
if ($user = $kirby->users()->findBy('emailActivationToken', $token)) {
|
if ($user = $kirby->users()->findBy('emailActivationToken', $token)) {
|
||||||
if ($user->emailActivationToken()->toString() === Str::toType($token, 'string')) {
|
if ($user->emailActivationToken()->toString() === Str::toType($token, 'string')) {
|
||||||
$user->update(['emailActivation' => true]);
|
$user->update(['emailActivation' => true]);
|
||||||
go('user');
|
$kirby->session()->set('kpActivated', true);
|
||||||
//go('CUSTOM_SUCCESSFUL_ACTIVATION_PAGE');
|
go('/activated');
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
//go('CUSTOM_ERROR_ACTIVATION_PAGE');
|
//go('CUSTOM_ERROR_ACTIVATION_PAGE');
|
||||||
|
|
|
@ -4,8 +4,8 @@ return function ($kirby) {
|
||||||
|
|
||||||
if($kirby->user()) {
|
if($kirby->user()) {
|
||||||
go('/');
|
go('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$error = null;
|
$error = null;
|
||||||
$alert = null;
|
$alert = null;
|
||||||
|
|
||||||
|
@ -53,14 +53,14 @@ return function ($kirby) {
|
||||||
|
|
||||||
// CHECK EMAIL ACTIVATION
|
// CHECK EMAIL ACTIVATION
|
||||||
if (option('user.email.activation', false) === true) {
|
if (option('user.email.activation', false) === true) {
|
||||||
|
|
||||||
$user->update([
|
$user->update([
|
||||||
'emailActivation' => false,
|
'emailActivation' => false,
|
||||||
'emailActivationToken' => $token
|
'emailActivationToken' => $token
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$kirby->impersonate();
|
$kirby->impersonate();
|
||||||
|
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
|
||||||
|
@ -93,19 +93,18 @@ return function ($kirby) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// LOGIN USER
|
// Welcome new user.
|
||||||
if($user->login($data['password'])) {
|
$kirby->session()->set('kpNewUser', true);
|
||||||
go();
|
go('/newuser');
|
||||||
}
|
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'alert' => $alert,
|
'alert' => $alert,
|
||||||
'data' => $data ?? false
|
'data' => $data ?? false
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,23 +7,30 @@ Kirby::plugin('kangaroopunch/download-kirbytag', [
|
||||||
[
|
[
|
||||||
'pattern' => 'download/(:any)/(:any)',
|
'pattern' => 'download/(:any)/(:any)',
|
||||||
'action' => function($sourcepage, $filerequested) {
|
'action' => function($sourcepage, $filerequested) {
|
||||||
// Unmuddle the page ID that called us.
|
$file = "";
|
||||||
$slug = str_rot13(urldecode($sourcepage));
|
kirby()->impersonate('kirby');
|
||||||
$slug = str_replace('|', '/', $slug);
|
try {
|
||||||
// Get page object.
|
// Unmuddle the page ID that called us.
|
||||||
$page = kirby()->api()->page($slug);
|
$slug = str_rot13(urldecode($sourcepage));
|
||||||
// Find the current download count.
|
$slug = str_replace('|', '/', $slug);
|
||||||
$file = $page->file($filerequested);
|
// Get page object.
|
||||||
$content = $file->content();
|
$page = kirby()->api()->page($slug);
|
||||||
if ($content->has('downloads')) {
|
// Find the current download count.
|
||||||
$count = $content->get('downloads')->toInt();
|
$file = $page->file($filerequested);
|
||||||
} else {
|
$content = $file->content();
|
||||||
// Initialize counter.
|
if ($content->has('downloads')) {
|
||||||
$count = 0;
|
$count = $content->get('downloads')->toInt();
|
||||||
|
} else {
|
||||||
|
// Initialize counter.
|
||||||
|
$count = 0;
|
||||||
|
}
|
||||||
|
// Update download count.
|
||||||
|
$count++;
|
||||||
|
$file->update([ 'downloads' => $count ]);
|
||||||
|
} catch (Exception $ex){
|
||||||
|
$file = $ex->getMessage();
|
||||||
}
|
}
|
||||||
// Update download count.
|
kirby()->impersonate();
|
||||||
$count++;
|
|
||||||
$file->update([ 'downloads' => $count ]);
|
|
||||||
// Send file to user.
|
// Send file to user.
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
@ -37,39 +44,45 @@ Kirby::plugin('kangaroopunch/download-kirbytag', [
|
||||||
'desc'
|
'desc'
|
||||||
],
|
],
|
||||||
'html' => function($tag) {
|
'html' => function($tag) {
|
||||||
// Did we get a valid file?
|
try {
|
||||||
$file = $tag->file($tag->value());
|
// Did we get a valid file?
|
||||||
if (!$file === true) {
|
$file = $tag->file($tag->value());
|
||||||
return '<div class="downloadlinkerror">ERROR: Cannot locate "' . $tag->value() . '"!</div>';
|
if (!$file === true) {
|
||||||
}
|
return '<div class="downloadlinkerror">ERROR: Cannot locate "' . $tag->value() . '"!</div>';
|
||||||
// Ensure we're using the proper blueprint.
|
|
||||||
//$file->update([ 'template' => 'download' ]);
|
|
||||||
// Did they provide a description?
|
|
||||||
if (is_null($tag->desc) === true) {
|
|
||||||
// No. Does the file itself have one?
|
|
||||||
$desc = $file->content()->get('description')->value();
|
|
||||||
if (is_null($desc) || strlen($desc) == 0) {
|
|
||||||
// Nope. Use the filename.
|
|
||||||
$desc = $tag->value();
|
|
||||||
}
|
}
|
||||||
} else {
|
// Ensure we're using the proper blueprint.
|
||||||
// Yep. Use the provided description.
|
kirby()->impersonate('kirby');
|
||||||
$desc = $tag->desc;
|
$file->update([ 'template' => 'download' ]);
|
||||||
|
kirby()->impersonate();
|
||||||
|
// Did they provide a description?
|
||||||
|
if (is_null($tag->desc) === true) {
|
||||||
|
// No. Does the file itself have one?
|
||||||
|
$desc = $file->content()->get('description')->value();
|
||||||
|
if (is_null($desc) || strlen($desc) == 0) {
|
||||||
|
// Nope. Use the filename.
|
||||||
|
$desc = $tag->value();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Yep. Use the provided description.
|
||||||
|
$desc = $tag->desc;
|
||||||
|
}
|
||||||
|
// Find pretty file size.
|
||||||
|
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
||||||
|
$bytes = max($file->size(), 0);
|
||||||
|
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
||||||
|
$pow = min($pow, count($units) - 1);
|
||||||
|
$bytes /= pow(1024, $pow);
|
||||||
|
$size = round($bytes, 2) . ' ' . $units[$pow];
|
||||||
|
// Muddle up the page slug a bit to discourage direct linking to the file.
|
||||||
|
$slug = str_replace('/', '|', $tag->parent()->id());
|
||||||
|
$slug = esc(str_rot13($slug), 'url');
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
return $ex->getMessage();
|
||||||
}
|
}
|
||||||
// Find pretty file size.
|
|
||||||
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
|
||||||
$bytes = max($file->size(), 0);
|
|
||||||
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
|
||||||
$pow = min($pow, count($units) - 1);
|
|
||||||
$bytes /= pow(1024, $pow);
|
|
||||||
$size = round($bytes, 2) . ' ' . $units[$pow];
|
|
||||||
// Muddle up the page slug a bit to discourage direct linking to the file.
|
|
||||||
$slug = str_replace('/', '|', $tag->parent()->id());
|
|
||||||
$slug = esc(str_rot13($slug), 'url');
|
|
||||||
// Send the link.
|
// Send the link.
|
||||||
return '<a href="/download/' . $slug . '/' . esc($tag->value(), 'url') . '" class="downloadlink">' . $desc . ' (' . $size . ')</a>';
|
return '<a href="/download/' . $slug . '/' . esc($tag->value(), 'url') . '" class="downloadlink">' . $desc . ' (' . $size . ')</a>';
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -13,5 +13,5 @@
|
||||||
<body>
|
<body>
|
||||||
<script src="/assets/js/jquery-3.6.0.min.js"></script>
|
<script src="/assets/js/jquery-3.6.0.min.js"></script>
|
||||||
<script type="text/javascript" src="/assets/slick/slick.min.js"></script>
|
<script type="text/javascript" src="/assets/slick/slick.min.js"></script>
|
||||||
<?php snippet('menu') ?>
|
|
||||||
<div class="container mainpage">
|
<div class="container mainpage">
|
||||||
|
<?php snippet('menu') ?>
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle Navigation">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle Navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
<?php foreach($site->children()->listed() as $item): ?>
|
<?php foreach($site->children()->listed() as $item): ?>
|
||||||
<?php if ($item->hasListedChildren() && strcasecmp($item->title(), "Home")) { ?>
|
<?php if ($item->hasListedChildren() && strcasecmp($item->slug(), "home")) { ?>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"><?= $item->title() ?></a>
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"><?= $item->title() ?></a>
|
||||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
@ -23,5 +25,36 @@
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
|
||||||
|
<?php if ($kirby->user() && !$kirby->session()->get('kpNewUser')) { ?>
|
||||||
|
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<?php
|
||||||
|
if ($kirby->user()->name() && strlen($kirby->user()->name()) > 1) {
|
||||||
|
$userDropDown = esc($kirby->user()->name(), 'html');
|
||||||
|
} else {
|
||||||
|
$userDropDown = esc($kirby->user()->email(), 'html');
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"><?= $userDropDown ?></a>
|
||||||
|
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
<li><a class="dropdown-item" href="/user">Profile</a></li>
|
||||||
|
<li><a class="dropdown-item" href="/logout">Logout</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<?php } else { ?>
|
||||||
|
|
||||||
|
<li class="nav-item"><a class="nav-link" href="/login">Login</a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="/register">Register</a></li>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<p> </p>
|
||||||
|
|
12
kanga.world/site/templates/activated.php
Normal file
12
kanga.world/site/templates/activated.php
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
if ($kirby->session()->get('kpActivated') !== true) {
|
||||||
|
go('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
$kirby->session()->remove('kpActivated');
|
||||||
|
snippet('header');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?= $page->text()->kirbytext() ?>
|
||||||
|
|
||||||
|
<?php snippet('footer') ?>
|
12
kanga.world/site/templates/newuser.php
Normal file
12
kanga.world/site/templates/newuser.php
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
if ($kirby->session()->get('kpNewUser') !== true) {
|
||||||
|
go('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
$kirby->session()->remove('kpNewUser');
|
||||||
|
snippet('header');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?= $page->text()->kirbytext() ?>
|
||||||
|
|
||||||
|
<?php snippet('footer') ?>
|
Loading…
Add table
Reference in a new issue