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.

56 lines
1.5 KiB

9 years ago
  1. <?php
  2. $app->get('/', function() use($app) {
  3. $res = $app->response();
  4. ob_start();
  5. render('index', array(
  6. 'title' => 'Switchboard',
  7. 'meta' => ''
  8. ));
  9. $html = ob_get_clean();
  10. $res->body($html);
  11. });
  12. $app->get('/subscription/:hash', function($hash) use($app) {
  13. $res = $app->response();
  14. $subscription = db\get_by_col('subscriptions', 'hash', $hash);
  15. $feed = db\get_by_id('feeds', $subscription->feed_id);
  16. if(!$subscription) {
  17. $app->response()->status(404);
  18. } else {
  19. ob_start();
  20. render('subscription-status', array(
  21. 'title' => 'Switchboard',
  22. 'meta' => '',
  23. 'subscription' => $subscription,
  24. 'feed' => $feed
  25. ));
  26. $html = ob_get_clean();
  27. $res->body($html);
  28. }
  29. });
  30. $app->get('/feed/:hash', function($hash) use($app) {
  31. $res = $app->response();
  32. $feed = db\get_by_col('feeds', 'hash', $hash);
  33. $subscribers = ORM::for_table('subscriptions')->where('feed_id', $feed->id)->where('active', 1)->find_many();
  34. $num_subscribers = ORM::for_table('subscriptions')->where('feed_id', $feed->id)->where('active', 1)->count();
  35. if(!$feed) {
  36. $app->response()->status(404);
  37. } else {
  38. ob_start();
  39. render('feed-status', array(
  40. 'title' => 'Switchboard',
  41. 'meta' => '',
  42. 'feed' => $feed,
  43. 'subscribers' => $subscribers,
  44. 'num_subscribers' => $num_subscribers
  45. ));
  46. $html = ob_get_clean();
  47. $res->body($html);
  48. }
  49. });