From 5565d92e1e9b05f8d19d097c7a832f3e779c7aa0 Mon Sep 17 00:00:00 2001 From: tp_dhu Date: Mon, 24 Mar 2025 02:13:54 +0000 Subject: [PATCH] routing now moved to ini config --- app/config/routes.ini | 62 +++++++++++++++++++++++++++++++++++ public/index.php | 75 +------------------------------------------ 2 files changed, 63 insertions(+), 74 deletions(-) create mode 100644 app/config/routes.ini diff --git a/app/config/routes.ini b/app/config/routes.ini new file mode 100644 index 0000000..7089a31 --- /dev/null +++ b/app/config/routes.ini @@ -0,0 +1,62 @@ +[routes] + +; home +GET /=HomeController->display + +; auth +GET /login=AuthController->showLoginForm +POST /login=AuthController->login +GET /logout=AuthController->logout + +; tickets - CRUD (CREATE, READ, UPDATE, DELETE) +GET /tickets=TicketController->index +GET /ticket/@id=TicketController->view +GET /ticket/create=TicketController->createForm +POST /ticket/create=TicketController->create +GET /ticket/@id/edit=TicketController->editForm +POST /ticket/@id/update=TicketController->update +GET /ticket/@id/delete=TicketController->delete +; additional routes - comments +POST /ticket/@id/comment=CommentController->create +GET /ticket/@id/comment/@comment_id/delete=CommentController->delete +GET /ticket/@id/comments=CommentController->index +; route for linking a child to a parent +POST /ticket/@id/add-subtask=TicketController->addSubtask + +; attachments +GET /ticket/@id/attachments=AttachmentController->index +POST /ticket/@id/attachments/upload=AttachmentController->upload +GET /attachment/@id/download=AttachmentController->download +GET /attachment/@id/delete=AttachmentController->delete + +; knowledgebase +GET /kb=KBController->index +GET /kb/@id=KBController->view +GET /kb/create=KBController->createForm +POST /kb/create=KBController->create +GET /kb/@id/edit=KBController->editForm +POST /kb/@id/update=KBController->update + +; tags +GET /tags=TagController->index +GET /tag/create=TagController->createForm +POST /tag/create=TagController->create + +; parsedown preview +POST /parsedown/preview=ParsedownPreview->view + +; dashboard +GET /dashboard=DashboardController->index + +; projects +GET /projects=ProjectController->index +GET /project/@id=ProjectController->view +GET /project/create=ProjectController->createForm +POST /project/create=ProjectController->create +GET /project/@id/edit=ProjectController->editForm +POST /project/@id/update=ProjectController->update + +; additional routes - user +GET /users=UserController->index +GET /user/@id/edit=UserController->editForm +POST /user/@id/update=UserController->update \ No newline at end of file diff --git a/public/index.php b/public/index.php index 2d91ce2..614c11e 100644 --- a/public/index.php +++ b/public/index.php @@ -11,7 +11,7 @@ $htmlpurifier = \HTMLPurifier::instance(); $md = \Parsedown::instance(); $md->setSafeMode(true); -$f3->config('../app/.env.cfg'); +$f3->config('../app/config/.env.cfg'); $f3->set('DEBUG', 3); // development debug $f3->set('CACHE', FALSE); @@ -26,77 +26,4 @@ $f3->set('DB', new \DB\SQL( new \DB\SQL\Session($f3->get('DB')); $f3->set('SESSION.status', 'running'); -// Routing and Controller Setup - -// home -$f3->route('GET /', 'HomeController->display'); - -// auth -$f3->route('GET /login', 'AuthController->showLoginForm'); -$f3->route('POST /login', 'AuthController->login'); -$f3->route('GET /logout', 'AuthController->logout'); - -// Example protected route -$f3->route('GET /dashboard', function($f3){ - if(!$f3->exists('SESSION.user')){ - $f3->reroute('/login'); - } - echo 'Welcome to the dashboard' . $f3->get('SESSION.username'); - echo 'logout'; - -}); - -// tickets - CRUD (CREATE, READ, UPDATE, DELETE) -$f3->route('GET /tickets', 'TicketController->index'); // view all tickets -$f3->route('GET /ticket/@id', 'TicketController->view'); // view ticket details -$f3->route('GET /ticket/create', 'TicketController->createForm'); // show form to create -$f3->route('POST /ticket/create', 'TicketController->create'); // save -$f3->route('GET /ticket/@id/edit', 'TicketController->editForm'); // edit ticket -$f3->route('POST /ticket/@id/update', 'TicketController->update'); // -$f3->route('GET /ticket/@id/delete', 'TicketController->delete'); -// additional routes - comments -$f3->route('POST /ticket/@id/comment', 'CommentController->create'); -$f3->route('GET /ticket/@id/comment/@comment_id/delete', 'CommentController->delete'); -$f3->route('GET /ticket/@id/comments', 'CommentController->index'); -// route for linking a child to a parent -$f3->route('POST /ticket/@id/add-subtask', 'TicketController->addSubtask'); - -// attachments -$f3->route('GET /ticket/@id/attachments', 'AttachmentController->index'); -$f3->route('POST /ticket/@id/attachments/upload', 'AttachmentController->upload'); -$f3->route('GET /attachment/@id/download', 'AttachmentController->download'); -$f3->route('GET /attachment/@id/delete', 'AttachmentController->delete'); - -// knowledgebase -$f3->route('GET /kb', 'KBController->index'); -$f3->route('GET /kb/@id', 'KBController->view'); -$f3->route('GET /kb/create', 'KBController->createForm'); -$f3->route('POST /kb/create', 'KBController->create'); -$f3->route('GET /kb/@id/edit', 'KBController->editForm'); -$f3->route('POST /kb/@id/update', 'KBController->update'); // should this be update - "crud"? - -// tags -$f3->route('GET /tags', 'TagController->index'); -$f3->route('GET /tag/create', 'TagController->createForm'); -$f3->route('POST /tag/create', 'TagController->create'); - -// parsedown preview -$f3->route('POST /parsedown/preview', 'ParsedownPreview->view'); - -// dashboard -$f3->route('GET /dashboard', 'DashboardController->index'); - -// projects -$f3->route('GET /projects', 'ProjectController->index'); -$f3->route('GET /project/@id', 'ProjectController->view'); -$f3->route('GET /project/create', 'ProjectController->createForm'); -$f3->route('POST /project/create', 'ProjectController->create'); -$f3->route('GET /project/@id/edit', 'ProjectController->editForm'); -$f3->route('POST /project/@id/update', 'ProjectController->update'); - -// additional routes - user -$f3->route('GET /users', 'UserController->index'); -$f3->route('GET /user/@id/edit', 'UserController->editForm'); -$f3->route('POST /user/@id/update', 'UserController->update'); - $f3->run(); \ No newline at end of file