From ec29bfe9472e267cba752a948eb7be240d461dfa Mon Sep 17 00:00:00 2001 From: Tagadda <36127788+Tagadda@users.noreply.github.com> Date: Tue, 28 Aug 2018 10:37:32 +0200 Subject: [PATCH] WIP: OpenGraph implementation --- index.php | 13 +++++++++++++ views/layout.php | 3 +++ views/opengraph.php | 6 ++++++ 3 files changed, 22 insertions(+) create mode 100644 views/opengraph.php diff --git a/index.php b/index.php index 858c989..c101606 100644 --- a/index.php +++ b/index.php @@ -36,6 +36,7 @@ Flight::route("GET /polls/@id:[a-fA-F0-9]+", function ($id) { else { Flight::render("poll", ["app_url" => $VERLAINE["app_url"], "poll" => $poll], "body_content"); + Flight::render("opengraph", ["poll" => $poll, "app_url" => $VERLAINE["app_url"]], "head"); Flight::render("layout"); } } @@ -104,6 +105,7 @@ Flight::route("GET /polls/@id:[a-fA-F0-9]+/results", function ($id) { { Flight::render("svg/results", ["poll" => $poll, "colors" => $VERLAINE["chart_colors"]], "results_chart"); Flight::render("results", ["poll" => $poll, "chart_colors" => $VERLAINE["chart_colors"]], "body_content"); + Flight::render("opengraph", ["poll" => $poll, "app_url" => $VERLAINE["app_url"]], "head"); Flight::render("layout"); } } @@ -135,6 +137,17 @@ Flight::route("GET|DELETE /polls/@id:[a-fA-F0-9]+/@token:[a-fA-F0-9]+", function Flight::notFound(); }); +Flight::route("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"); diff --git a/views/layout.php b/views/layout.php index 4408a06..26d097a 100644 --- a/views/layout.php +++ b/views/layout.php @@ -6,6 +6,9 @@ Poll Verlaine /static/css/main.css" /> + + + diff --git a/views/opengraph.php b/views/opengraph.php new file mode 100644 index 0000000..469c4f6 --- /dev/null +++ b/views/opengraph.php @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file