diff --git a/webroot/index.php b/webroot/index.php index 1f57a87..b86ec95 100644 --- a/webroot/index.php +++ b/webroot/index.php @@ -101,7 +101,7 @@ Flight::route("HEAD|GET /polls/@id:[a-fA-F0-9]+/results", function ($id) { if ($poll) { if (Flight::request()->type === "application/json") - Flight::json(Format::poll($poll)); //TODO Add a svg for results? + Flight::json(array_merge(Format::poll($poll), ["image" => $VERLAINE["app_url"]."/polls/{$id}/results/svg"])); else { Flight::render("svg/results", ["poll" => $poll, "colors" => $VERLAINE["chart_colors"]], "results_chart"); @@ -114,6 +114,15 @@ Flight::route("HEAD|GET /polls/@id:[a-fA-F0-9]+/results", function ($id) { Flight::notFound(); }); +Flight::route("HEAD|GET /polls/@id:[a-fA-F0-9]+/results/svg", function ($id) { + global $VERLAINE; + $poll = Poll::load_poll($id); + if ($poll) + Flight::render("svg/results", ["poll" => $poll, "colors" => $VERLAINE["chart_colors"]]); + else + Flight::notFound(); +}); + Flight::route("GET|DELETE /polls/@id:[a-fA-F0-9]+/@token:[a-fA-F0-9]+", function ($id, $token) { $poll = Poll::load_poll($id); if ($poll) @@ -138,15 +147,6 @@ Flight::route("GET|DELETE /polls/@id:[a-fA-F0-9]+/@token:[a-fA-F0-9]+", function Flight::notFound(); }); -Flight::route("HEAD|GET /polls/@id:[a-fA-F0-9]+/results/svg", function ($id) { - global $VERLAINE; - $poll = Poll::load_poll($id); - if ($poll) - Flight::render("svg/results", ["poll" => $poll, "colors" => $VERLAINE["chart_colors"]]); - else - Flight::notFound(); -}); - Flight::route("/", function () { global $VERLAINE; Flight::render("home", ["app_url" => $VERLAINE["app_url"]], "body_content");