routing now moved to ini config

This commit is contained in:
tp_dhu 2025-03-24 02:13:54 +00:00
parent 6abea313a4
commit 5565d92e1e
2 changed files with 63 additions and 74 deletions

62
app/config/routes.ini Normal file
View File

@ -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

View File

@ -11,7 +11,7 @@ $htmlpurifier = \HTMLPurifier::instance();
$md = \Parsedown::instance(); $md = \Parsedown::instance();
$md->setSafeMode(true); $md->setSafeMode(true);
$f3->config('../app/.env.cfg'); $f3->config('../app/config/.env.cfg');
$f3->set('DEBUG', 3); // development debug $f3->set('DEBUG', 3); // development debug
$f3->set('CACHE', FALSE); $f3->set('CACHE', FALSE);
@ -26,77 +26,4 @@ $f3->set('DB', new \DB\SQL(
new \DB\SQL\Session($f3->get('DB')); new \DB\SQL\Session($f3->get('DB'));
$f3->set('SESSION.status', 'running'); $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 '<a href="/logout">logout</a>';
});
// 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(); $f3->run();