diff options
Diffstat (limited to 'html/app/routes')
| -rw-r--r-- | html/app/routes/api.php | 81 | ||||
| -rw-r--r-- | html/app/routes/backend.php | 9 | ||||
| -rw-r--r-- | html/app/routes/frontend.php | 194 |
3 files changed, 0 insertions, 284 deletions
diff --git a/html/app/routes/api.php b/html/app/routes/api.php deleted file mode 100644 index 61e485b..0000000 --- a/html/app/routes/api.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -use app\controllers\Auth; -use app\controllers\api\Common_api; -use app\controllers\api\Doc_api; - - -/** API CALLS - * ----------------------------------------------------------------------------- - * - * these calls return json responses - */ - - -// api: tree of product-categories -Route::add('/api/tree', - function() { Doc_api::tree(); }, - 'get' -); - -// api: database documentation -Route::add('/api/doc', - function() { Doc_api::dbDoc(); }, - 'get' -); - -Route::add('/api/url/([0-9a-zA-Z-_\/]*)', - function($url) { Common_api::category_by_url($url); } -); - -// route: /api/table -Route::add('/api/([0-9a-zA-Z-_]*)', - function($table) { Common_api::table($table); }, - 'get' -); - -// route: /api/table/{id} -Route::add('/api/([0-9a-zA-Z-_]*)/([0-9]*)', - function($table, $id) { Common_api::record($table, $id); }, - 'get' -); - - - -/** XML CALLS - * ----------------------------------------------------------------------------- - * - * These calls are like `/api`, except... - * they return xml/html as part of the responses; - * - * example: { success: true, message: html } - * - * Used when an html message needs to be passed in some div - * - */ - - - - -/** TEST CALLS - * ----------------------------------------------------------------------------- - * - * direct calls to simple tests - * - */ - - -// route for testing... -// --- -Route::add('/test/([0-9a-zA-Z-_\/]*)', function($test) { - - // TODO: - // hide tests from production - - if (file_exists(TESTS_DIRECTORY . $test .'.php')) { - if (!Benchmark::exist('start')) Benchmark::add_spot('start'); - require(TESTS_DIRECTORY . $test .'.php'); - } else { echo "Test {$test} not exist"; - } die(); - -}); diff --git a/html/app/routes/backend.php b/html/app/routes/backend.php deleted file mode 100644 index 9b90cf1..0000000 --- a/html/app/routes/backend.php +++ /dev/null @@ -1,9 +0,0 @@ -<?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' -); - diff --git a/html/app/routes/frontend.php b/html/app/routes/frontend.php deleted file mode 100644 index 67f4655..0000000 --- a/html/app/routes/frontend.php +++ /dev/null @@ -1,194 +0,0 @@ -<?php - -use app\controllers\Resolve; -use app\controllers\Product; -use app\controllers\Auth; -use app\controllers\Classroom_user; - -// Home/Welcome -// --- -Route::add('/', function() { // echo 'Welcome!'; }); - Render::view('welcome'); - // header('Location: /some/default/url', true, 302); -}); - - -// Error Pages -// --- -Route::notFound( function() { - header("HTTP/1.0 404 Not Found"); - Render::view('error/404', ['message' => 'nobody knows it (but you got a secret smile;)']); -}); // 404 - - - -// Account -/////////////////////////////////////////////////////////////////////////////////////////////// - -// [ok] login -// [ok] register -// [ok] activate -// [..] ask-reset -// [..] reset -// [..] profile -// [..] edit-profile -// [..] subscriptions -// [..] payments -// [..] pay -// [..] 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() { - // check if user is activated and loged in - // then ... - }, - 'post' -); - - - -Route::add('/account/reset_password', function() { Auth::reset_password(); } ); - - - - - -// Resolve urls -// --- -- -- - - - -Route::add('/course/([0-9a-zA-Z-_]*)', - function($label) { Course::show([$label]); } -); - -Route::add('/lesson/([0-9a-f]*)/([0-9a-zA-Z-_]*)', - function($ticket, $lesson) { Lesson::show([$lesson, $ticket]); } -); - -Route::add('/media/([0-9a-f]*)/([0-9a-zA-Z-_]*)/([0-9]*)/', - function($ticket, $type, $id) { Media::serve([$type, $id, $ticket]); } -); - - -// 4-th level paths belong to products -// --- -Route::add('/about/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)', - function($a, $b, $c) { Page::show([$a, $b, $c]); } -); - - -/** URL-format Proposal: - * ----------------------------------------------------------------------------- - * - * Page (almost-static content): - * /about/{url} -# Route::add('/about/([0-9a-zA-Z-_\/]*)', function($url) { Page::fromUrl($url); }); - * - * Product: - * /{level-1}/{level-2}/{level-3}/{friendly-url}-{id} -# Route::add('/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)-([0-9]*)', -# function($category, $subcategory, $group, $label, $id) { -# Product::fromID([$$category, $subcategory, $group, $label], $id); -# } -# ); - * - * Category - * /{category}/[ {subcategory}[ /{group}]] -Route::add('/([0-9a-zA-Z-_]*)', function($a) { Category::url([$a]); }; -Route::add('/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)', function($a, $b) { Category::url([$a, $b]); }); -Route::add('/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)', function($a, $b, $c) { Category::url([$a, $b, $c]); }); - * ----------------------------------------------------------------------------- - */ - - -/* EXAMPLES (use it for brainsrtorming) - * ----------------------------------------------------------------------------- - * - // Typical Use - // --- - Route::add('/art', function() { Art::blah(); }); - Route::add('/art/db', function() { Art::fromDatabase(); }); - Route::add('/art/([0-9]*)', function($id) { Art::getInfo($id); }); - - - // Get-Post route example - // --- - Route::add('/contact-form', function() { - echo '<form method="post"><input type="text" name="test" /><input type="submit" value="send" /></form>'; - }, 'get'); - - Route::add('/contact-form', function() { - echo 'Hey! The form has been sent:<br/>'; print_r($_POST); - }, 'post'); - - - // Accept number as parameter - // --- - Route::add('/foo/([0-9]*)/bar', function($var1) { - // echo $var1.' is a number!'; - echo "{$var1} is a number!"; - }); - - - // About pages - // --- - Route::add('/about/([0-9a-zA-Z-_]*)', function($page) { - InfoPage::render('about/'.page); - }); - - - // handle a request like: /foo/123/bar/3254-lefki-zaxari-marata-1kg - // where first-numeric-part of last-uri-section (3254) is the product number - // --- - Route::add('/foo/([0-9]*)/bar/([0-9]*)-([0-9a-zA-Z-_]*)', function($num, $id, $name) { - echo $num .' is some nomber, id = '. $id .' and label = '. $name; - }); - - - // handle a request like: /zaxares-glykantika/lefki-zaxari-year-2022-45678 - // where last-numeric-part of last-uri-section (45678) is the product number - // --- - Route::add('/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)-([0-9]*)', - function($category, $subcategory, $group, $label, $id) { - Shop::product([$$category, $subcategory, $group, $label], $id); - }); - - - // last chance to resolve (some friendly url) - // --- - Route::add('/([0-9a-zA-Z-_]*)', function($a) { Resolve::uri([$a]); }); - Route::add('/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)', function($a, $b) { Resolve::uri([$a, $b]); }); - Route::add('/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)', function($a, $b, $c) { Resolve::uri([$a, $b, $c]); }); - - - // Product page - // handle a request like: /pantopoleio/zaxares/lefki-zaxari/lefki-zaxari-year-2022-45678 - // where last-numeric-part of last-uri-section (45678) is the product number - // --- - Route::add('/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)-([0-9]*)', - function($category, $subcategory, $group, $label, $id) { - Shop::product([$$category, $subcategory, $group, $label], $id); - }); -* ------------------------------------------------------------------------------ -*/ |
