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.

59 lines
1.6 KiB

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