summaryrefslogtreecommitdiff
path: root/public/app/routes
diff options
context:
space:
mode:
Diffstat (limited to 'public/app/routes')
-rw-r--r--public/app/routes/backend.php44
-rw-r--r--public/app/routes/frontend.php60
-rw-r--r--public/app/routes/user.php84
3 files changed, 129 insertions, 59 deletions
diff --git a/public/app/routes/backend.php b/public/app/routes/backend.php
index 9b90cf1..700fa14 100644
--- a/public/app/routes/backend.php
+++ b/public/app/routes/backend.php
@@ -1,9 +1,41 @@
<?php
-Route::add('/admin/info', // generaly you need to hide phpinfo()
- function() { // so, remove this route on production
- // Authenticate::session(); // or require authentication
- phpinfo(); },
- 'get'
-);
+use app\controllers\Auth;
+use app\models\cms\Course_model;
+// admin lessons
+// ---
+Route::add('/admin/lessons', function () {
+ Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles
+ Render::view('admin/skeleton', [
+ 'title' => 'Διαχείριση Μαθημάτων',
+ 'action' => 'lessons',
+ ]);
+});
+
+
+// admin cateogies
+// ---
+Route::add('/admin/categories', function () {
+ Auth::allowRoles([1, 2, 3]);
+ Render::view('admin/skeleton', [
+ 'title' => 'Διαχείριση Κατηγοριών',
+ 'action' => 'categories',
+ ]);
+});
+
+
+Route::add('/admin/api/categories', function () {
+ Auth::allowRoles([1, 2, 3]);
+ $tree = proxy(
+ [\app\models\cms\Course_model::class, 'category_tree'],
+ [], CACHE_ROOT_TTL
+ );
+
+ $breadcrumbs = proxy(
+ [\app\models\cms\Course_model::class, 'breadcrumbs'],
+ [$tree], CACHE_ROOT_TTL
+ );
+ // $breadcrumbs = Course_model::breadcrumbs($tree);
+ Render::json($breadcrumbs);
+}); \ No newline at end of file
diff --git a/public/app/routes/frontend.php b/public/app/routes/frontend.php
index 56db23a..dde0fcd 100644
--- a/public/app/routes/frontend.php
+++ b/public/app/routes/frontend.php
@@ -1,14 +1,18 @@
<?php
-use app\controllers\Resolve;
-use app\controllers\Product;
use app\controllers\Auth;
use app\controllers\Classroom_user;
+use app\models\cms\Course_model;
// Home/Welcome
// ---
Route::add('/', function() { // echo 'Welcome!'; });
- Render::view('welcome');
+ Render::view('welcome', [ // cache categories (while retrieving)
+ 'categories' => proxy(
+ [\app\models\cms\Course_model::class, 'category_tree'],
+ [], CACHE_ROOT_TTL
+ )
+ ]);
// header('Location: /some/default/url', true, 302);
});
@@ -38,56 +42,6 @@ Route::notFound( function() {
// [..] order
-Route::add('/login', function() { Render::view('user/login'); });
-Route::add('/registration', function() { Render::view('user/registration'); });
-
-
-Route::add('/account/check-login', function() {
- $response = Auth::login();
- Render::json(['status' => $response]);
- },
- 'post'
-);
-
-// user sends a registration form;
-Route::add('/account/register', function() {
- $response = Auth::register();
- Render::json($response);
- },
- 'post'
-);
-
-// user requests activation
-Route::add('/account/activate', function() { Auth::activate(); } );
-
-// user profile
-Route::add('/account/profile', function() {
- $user = Auth::is_connected();
- if ($user === false) {
- Render::view('error/general',
- [
- 'title' => 'Nope!',
- 'message' => "<h2>No profile</h2>User is not connected"
- ]
- );
-
- } else {
- print_r($user);
- }
- }
-);
-
-// test connection
-// NOTE: this is only for testing purposes
-if (!PRODUCTION) {
- Route::add('/check/connection', function() { Auth::is_connected(); });
-}
-
-Route::add('/account/reset_password', function() { Auth::reset_password(); } );
-
-
-
-
// Resolve urls
// --- -- -- - - -
diff --git a/public/app/routes/user.php b/public/app/routes/user.php
new file mode 100644
index 0000000..d419a5b
--- /dev/null
+++ b/public/app/routes/user.php
@@ -0,0 +1,84 @@
+<?php
+
+use app\controllers\Auth;
+use app\controllers\Classroom_user;
+
+/** User Connection Management Routes
+ * -----------------------------------------------------------------------------
+ */
+
+// common requests (GET method)
+// --- -- -- - - -
+
+// request login ... -> sends to POST:/account/check-login
+Route::add('/login', function() { Render::view('user/login'); });
+
+// request registration ... -> sends to POST:/account/register
+Route::add('/registration', function() { Render::view('user/registration'); });
+
+// request logout
+Route::add('/logout', function() {
+ Auth::logout();
+ header('Location: /'); die();
+});
+
+// request activation
+Route::add('/account/activate', function() { Auth::activate(); } );
+
+// request password reset
+Route::add('/account/reset_password', function() { Auth::reset_password(); } );
+
+
+
+// Replies to common requests (POST method)
+// --- -- -- - - -
+
+// user sends login form
+Route::add('/account/check-login', function() {
+ $response = Auth::login();
+ Render::json(['status' => $response]);
+ },
+ 'post'
+);
+
+// user sends a registration form
+Route::add('/account/register', function() {
+ $response = Auth::register();
+ Render::json($response);
+ },
+ 'post'
+);
+
+
+// Account Management
+// --- -- -- - - -
+
+// user profile
+Route::add('/account/profile', function() {
+ $user = Auth::is_connected();
+ if ($user === false) {
+ Render::view('error/general',
+ [
+ 'title' => 'Nope!',
+ 'message' => "<h2>No profile</h2>User is not connected"
+ ]
+ );
+
+ } else {
+ print_r($user);
+ }
+ }
+);
+
+
+// temporary (on development)
+// --- -- -- - --
+// NOTE: these is only for testing purposes
+
+// test connection
+if (!PRODUCTION) {
+ Route::add('/check/connection', function() { Auth::is_connected(); });
+}
+
+
+