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/site/config/config.php
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
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->emailActivationToken()->toString() === Str::toType($token, 'string')) {
|
||||
$user->update(['emailActivation' => true]);
|
||||
go('user');
|
||||
//go('CUSTOM_SUCCESSFUL_ACTIVATION_PAGE');
|
||||
$kirby->session()->set('kpActivated', true);
|
||||
go('/activated');
|
||||
} else {
|
||||
return false;
|
||||
//go('CUSTOM_ERROR_ACTIVATION_PAGE');
|
||||
|
|
|
@ -93,10 +93,9 @@ return function ($kirby) {
|
|||
]);
|
||||
}
|
||||
|
||||
// LOGIN USER
|
||||
if($user->login($data['password'])) {
|
||||
go();
|
||||
}
|
||||
// Welcome new user.
|
||||
$kirby->session()->set('kpNewUser', true);
|
||||
go('/newuser');
|
||||
|
||||
$data = [];
|
||||
}
|
||||
|
|
|
@ -7,23 +7,30 @@ Kirby::plugin('kangaroopunch/download-kirbytag', [
|
|||
[
|
||||
'pattern' => 'download/(:any)/(:any)',
|
||||
'action' => function($sourcepage, $filerequested) {
|
||||
// Unmuddle the page ID that called us.
|
||||
$slug = str_rot13(urldecode($sourcepage));
|
||||
$slug = str_replace('|', '/', $slug);
|
||||
// Get page object.
|
||||
$page = kirby()->api()->page($slug);
|
||||
// Find the current download count.
|
||||
$file = $page->file($filerequested);
|
||||
$content = $file->content();
|
||||
if ($content->has('downloads')) {
|
||||
$count = $content->get('downloads')->toInt();
|
||||
} else {
|
||||
// Initialize counter.
|
||||
$count = 0;
|
||||
$file = "";
|
||||
kirby()->impersonate('kirby');
|
||||
try {
|
||||
// Unmuddle the page ID that called us.
|
||||
$slug = str_rot13(urldecode($sourcepage));
|
||||
$slug = str_replace('|', '/', $slug);
|
||||
// Get page object.
|
||||
$page = kirby()->api()->page($slug);
|
||||
// Find the current download count.
|
||||
$file = $page->file($filerequested);
|
||||
$content = $file->content();
|
||||
if ($content->has('downloads')) {
|
||||
$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.
|
||||
$count++;
|
||||
$file->update([ 'downloads' => $count ]);
|
||||
kirby()->impersonate();
|
||||
// Send file to user.
|
||||
return $file;
|
||||
}
|
||||
|
@ -37,35 +44,41 @@ Kirby::plugin('kangaroopunch/download-kirbytag', [
|
|||
'desc'
|
||||
],
|
||||
'html' => function($tag) {
|
||||
// Did we get a valid file?
|
||||
$file = $tag->file($tag->value());
|
||||
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();
|
||||
try {
|
||||
// Did we get a valid file?
|
||||
$file = $tag->file($tag->value());
|
||||
if (!$file === true) {
|
||||
return '<div class="downloadlinkerror">ERROR: Cannot locate "' . $tag->value() . '"!</div>';
|
||||
}
|
||||
} else {
|
||||
// Yep. Use the provided description.
|
||||
$desc = $tag->desc;
|
||||
// Ensure we're using the proper blueprint.
|
||||
kirby()->impersonate('kirby');
|
||||
$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.
|
||||
return '<a href="/download/' . $slug . '/' . esc($tag->value(), 'url') . '" class="downloadlink">' . $desc . ' (' . $size . ')</a>';
|
||||
}
|
||||
|
|
|
@ -13,5 +13,5 @@
|
|||
<body>
|
||||
<script src="/assets/js/jquery-3.6.0.min.js"></script>
|
||||
<script type="text/javascript" src="/assets/slick/slick.min.js"></script>
|
||||
<?php snippet('menu') ?>
|
||||
<div class="container mainpage">
|
||||
<?php snippet('menu') ?>
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<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">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<?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">
|
||||
<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">
|
||||
|
@ -23,5 +25,36 @@
|
|||
<?php endforeach ?>
|
||||
</ul>
|
||||
</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>
|
||||
</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