Code for the foss.best website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

48 lines
1.0 KiB

  1. <?php
  2. // Include composer dependencies
  3. include_once __DIR__ . '/vendor/autoload.php';
  4. include 'functions.php';
  5. // Init router
  6. $router = new AltoRouter();
  7. // Router mapping
  8. $router->map('GET', '/', function() {}, 'home');
  9. // Router matching
  10. $match = $router->match();
  11. // Template engine settings and variables
  12. $options = [
  13. 'paths' => [
  14. 'views/',
  15. ],
  16. 'enable_profiler' => false,
  17. 'profiler' => [
  18. 'time_precision' => 3,
  19. 'line_height' => 30,
  20. 'display' => true,
  21. 'log' => false,
  22. ],
  23. ];
  24. $variables = [];
  25. // Home view
  26. if ($match['name'] == 'home') {
  27. $variables['title'] = 'FOSSBest';
  28. $variables['index'] = getIndex($variables['params']);
  29. }
  30. // Render the appropriate route
  31. if(is_array($match) && is_callable($match['target'])) {
  32. switch ($match['name']) {
  33. case 'home':
  34. Phug::displayFile('index', $variables, $options);
  35. break;
  36. }
  37. } else {
  38. // No route was matched
  39. Phug::displayFile('404', $variables, $options);
  40. }