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.

50 lines
1.3 KiB

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