WIP: OpenGraph implementation

This commit is contained in:
Tagadda 2018-08-28 10:37:32 +02:00
parent 1caad26fb9
commit ec29bfe947
3 changed files with 22 additions and 0 deletions

View File

@ -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");

View File

@ -6,6 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Poll Verlaine</title>
<link rel="stylesheet" type="text/css" href="<?= $VERLAINE["app_url"] ?>/static/css/main.css" />
<?php if(isset($head)): ?>
<?= $head ?>
<?php endif; ?>
</head>
<body>
<?= $body_content ?>

6
views/opengraph.php Normal file
View File

@ -0,0 +1,6 @@
<meta property="og:site_name" content="PollVerlaine" />
<meta property="og:title" content="<?= $poll->title ?>" />
<meta property="og:type" content="website" />
<meta property="og:url" content="<?= $app_url ?>/polls/<?= $poll->id ?>" />
<meta property="og:image" content="<?= $app_url ?>/polls/<?= $poll->id ?>/results/svg" />
<meta property="og:image:type" content="image/svg+xml"/>