Social Media Disclaimer Links
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.
 
 
 

61 lines
1.6 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->map('GET', '/[i:id]', function() {}, 'disclaimer');
  10. $router->map('GET', '/b[i:id]', function() {}, 'disclaimer_beta');
  11. // Router matching
  12. $match = $router->match();
  13. // Template engine settings and variables
  14. $options = [
  15. 'paths' => [
  16. 'views/',
  17. ],
  18. 'enable_profiler' => false,
  19. 'profiler' => [
  20. 'time_precision' => 3,
  21. 'line_height' => 30,
  22. 'display' => true,
  23. 'log' => false,
  24. ],
  25. ];
  26. $variables = [];
  27. // If we are dealing with home
  28. if ($match['name'] == 'home' || $match['name'] == 'disclaimer') {
  29. $variables['title'] = 'SMDL.io';
  30. $variables['disclaimers'] = getDisclaimers($variables['params']);
  31. }
  32. // If we are dealing with a dislcaimer link
  33. if ($match['name'] == 'disclaimer_beta') {
  34. $variables['title'] = '#'.$match['params']['id'].' - SMDL.io';
  35. $variables['params']['id'] = $match['params']['id'];
  36. $variables['disclaimers'] = getDisclaimers($variables['params']);
  37. }
  38. // Render the appropriate route
  39. if(is_array($match) && is_callable($match['target'])) {
  40. switch ($match['name']) {
  41. case 'home':
  42. case 'disclaimer':
  43. Phug::displayFile('index', $variables, $options);
  44. break;
  45. case 'disclaimer_beta':
  46. Phug::displayFile('disclaimer', $variables, $options);
  47. break;
  48. }
  49. } else {
  50. // No route was matched
  51. Phug::displayFile('404', $variables, $options);
  52. }