routes.pm 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package Theme;
  2. use strict;
  3. use warnings;
  4. no warnings 'experimental';
  5. use feature qw{signatures};
  6. use File::Basename qw{basename};
  7. use lib 'lib';
  8. use Trog::Routes::HTML;
  9. our $default_title = 'Houston Perl Mongers';
  10. our %routes = (
  11. '/about.html' => {
  12. method => 'GET',
  13. callback => sub {Trog::Routes::HTML::redirect_permanent('/about') },
  14. },
  15. '/meetings.html' => {
  16. method => 'GET',
  17. callback => \&Trog::Routes::HTML::posts,
  18. data => { tag => ['meetings'] },
  19. },
  20. '/announce_meeting.html' => {
  21. method => 'GET',
  22. callback => \&Trog::Routes::HTML::posts,
  23. data => { tag => ['meetings'], limit => 1 },
  24. },
  25. '/sponsors.html' => {
  26. method => 'GET',
  27. callback => \&sponsors,
  28. },
  29. '/faqs.html' => {
  30. method => 'GET',
  31. callback => \&faq,
  32. },
  33. '/projects/index.html' => {
  34. method => 'GET',
  35. callback => \&Trog::Routes::HTML::posts,
  36. data => { tag => ['project'] },
  37. },
  38. '/mostrecent.html' => {
  39. method => 'GET',
  40. callback => \&Trog::Routes::HTML::posts,
  41. data => { tag => ['presentations'], limit => 1 },
  42. },
  43. '/talks/index.html' => {
  44. method => 'GET',
  45. callback => \&Trog::Routes::HTML::posts,
  46. data => { tag => ['presentations'] },
  47. },
  48. '/styles/houston.css' => {
  49. method => 'GET',
  50. callback => sub {Trog::Routes::HTML::redirect_permanent('/themes/houston.pm/styles/houston.css') },
  51. },
  52. );
  53. my $processor = Text::Xslate->new(
  54. path => 'www/themes/houston.pm/templates',
  55. );
  56. my %paths = (
  57. '/meetings.html' => 'Past & Upcoming Meetings',
  58. '/announce_meeting.html' => 'Latest Meeting',
  59. );
  60. sub path_to_tile ($path) {
  61. return $paths{$path} ? $paths{$path} : $path;
  62. }
  63. sub sponsors ($args, $render_cb) {
  64. my $out = $processor->render('sponsors.tx');
  65. return Trog::Routes::HTML::index($args,$render_cb, $out);
  66. }
  67. sub faq ($args, $render_cb) {
  68. my $out = $processor->render('faq.tx');
  69. return Trog::Routes::HTML::index($args,$render_cb, $out);
  70. }
  71. 1;