diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..2eebfde --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +By submitting code to this project, you agree to irrevocably release it under the same license as this project. See README.md for more details. \ No newline at end of file diff --git a/controllers/controllers.php b/controllers/controllers.php index 0dfa086..fc84960 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -2,12 +2,10 @@ $app->get('/', function() use($app) { $res = $app->response(); - ob_start(); - render('index', array( + $html = render('index', array( 'title' => 'Switchboard', 'meta' => '' )); - $html = ob_get_clean(); $res->body($html); }); @@ -20,14 +18,12 @@ $app->get('/subscription/:hash', function($hash) use($app) { if(!$subscription) { $app->response()->status(404); } else { - ob_start(); - render('subscription-status', array( + $html = render('subscription-status', array( 'title' => 'Switchboard', 'meta' => '', 'subscription' => $subscription, 'feed' => $feed )); - $html = ob_get_clean(); $res->body($html); } }); @@ -42,15 +38,13 @@ $app->get('/feed/:hash', function($hash) use($app) { if(!$feed) { $app->response()->status(404); } else { - ob_start(); - render('feed-status', array( + $html = render('feed-status', array( 'title' => 'Switchboard', 'meta' => '', 'feed' => $feed, 'subscribers' => $subscribers, 'num_subscribers' => $num_subscribers )); - $html = ob_get_clean(); $res->body($html); } }); diff --git a/controllers/push.php b/controllers/push.php index 4668c4f..d8eb21c 100644 --- a/controllers/push.php +++ b/controllers/push.php @@ -49,7 +49,7 @@ $app->post('/', function() use($app) { $callback = k($params, 'hub_callback'); if(!is_valid_push_url($topic)) { - push_error($app, 'Topic URL was invalid'); + push_error($app, 'Topic URL was invalid ('.$topic.')'); } if(!is_valid_push_url($callback)) { @@ -102,6 +102,12 @@ $app->post('/', function() use($app) { // Sanity check the request params $url = k($params, 'hub_url'); + if(!$url) + $url = k($params, 'hub_topic'); + + if(!$url) { + push_error($app, 'No URL was specified. When publishing, send the topic URL in a parameter named hub.topic'); + } if(!is_valid_push_url($url)) { push_error($app, 'URL was invalid'); diff --git a/lib/helpers.php b/lib/helpers.php index 439d1ed..64ab074 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -97,7 +97,9 @@ function is_valid_push_url($url) { function render($page, $data) { global $app; - return $app->render('layout.php', array_merge($data, array('page' => $page))); + ob_start(); + $app->render('layout.php', array_merge($data, array('page' => $page))); + return ob_get_clean(); }; function partial($template, $data=array(), $debug=false) { diff --git a/scripts/run.php b/scripts/run.php index 5d30182..4a92a0c 100644 --- a/scripts/run.php +++ b/scripts/run.php @@ -1,7 +1,7 @@