Added support for OpenGraph
- Linking to index and individual posts produces thumbs on sites like Facebook - Thumbnails theoretically support custom sizes
This commit is contained in:
parent
a5d0a3f9ef
commit
17bd7a7572
4 changed files with 23 additions and 11 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 5008621b75431073ca8dd6537a112c9f95436e54
|
Subproject commit 59f80280ba23420b891d7a9a6ee05bbb30b64b0c
|
|
@ -41,6 +41,7 @@ class IndexController
|
||||||
$this->context->featuredPost = $featuredPost;
|
$this->context->featuredPost = $featuredPost;
|
||||||
$this->context->featuredPostUser = $featuredPostUser;
|
$this->context->featuredPostUser = $featuredPostUser;
|
||||||
$this->context->featuredPostDate = $featuredPostDate;
|
$this->context->featuredPostDate = $featuredPostDate;
|
||||||
|
$this->context->pageThumb = \Chibi\UrlHelper::route('post', 'thumb', ['name' => $featuredPost->name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -733,6 +733,7 @@ class PostController
|
||||||
|
|
||||||
$flagged = in_array(TextHelper::reprPost($post), SessionHelper::get('flagged', []));
|
$flagged = in_array(TextHelper::reprPost($post), SessionHelper::get('flagged', []));
|
||||||
|
|
||||||
|
$this->context->pageThumb = \Chibi\UrlHelper::route('post', 'thumb', ['name' => $post->name]);
|
||||||
$this->context->stylesheets []= 'post-view.css';
|
$this->context->stylesheets []= 'post-view.css';
|
||||||
$this->context->stylesheets []= 'comment-small.css';
|
$this->context->stylesheets []= 'comment-small.css';
|
||||||
$this->context->scripts []= 'post-view.js';
|
$this->context->scripts []= 'post-view.js';
|
||||||
|
@ -752,13 +753,18 @@ class PostController
|
||||||
* Action that renders the thumbnail of the requested file and sends it to user.
|
* Action that renders the thumbnail of the requested file and sends it to user.
|
||||||
* @route /post/{name}/thumb
|
* @route /post/{name}/thumb
|
||||||
*/
|
*/
|
||||||
public function thumbAction($name)
|
public function thumbAction($name, $width = null, $height = null)
|
||||||
{
|
{
|
||||||
|
$dstWidth = $width === null ? $this->config->browsing->thumbWidth : $width;
|
||||||
|
$dstHeight = $height === null ? $this->config->browsing->thumbHeight : $height;
|
||||||
|
$dstWidth = min(1000, max(1, $dstWidth));
|
||||||
|
$dstHeight = min(1000, max(1, $dstHeight));
|
||||||
|
|
||||||
$this->context->layoutName = 'layout-file';
|
$this->context->layoutName = 'layout-file';
|
||||||
|
|
||||||
$path = $this->config->main->thumbsPath . DS . $name . '.custom';
|
$path = $this->config->main->thumbsPath . DS . $name . '.custom';
|
||||||
if (!file_exists($path))
|
if (!file_exists($path))
|
||||||
$path = $this->config->main->thumbsPath . DS . $name . '.default';
|
$path = $this->config->main->thumbsPath . DS . $name . '-' . $dstWidth . 'x' . $dstHeight . '.default';
|
||||||
if (!file_exists($path))
|
if (!file_exists($path))
|
||||||
{
|
{
|
||||||
$post = Model_Post::locate($name);
|
$post = Model_Post::locate($name);
|
||||||
|
@ -766,8 +772,6 @@ class PostController
|
||||||
PrivilegesHelper::confirmWithException(Privilege::ListPosts);
|
PrivilegesHelper::confirmWithException(Privilege::ListPosts);
|
||||||
PrivilegesHelper::confirmWithException(Privilege::ListPosts, PostSafety::toString($post->safety));
|
PrivilegesHelper::confirmWithException(Privilege::ListPosts, PostSafety::toString($post->safety));
|
||||||
$srcPath = $this->config->main->filesPath . DS . $post->name;
|
$srcPath = $this->config->main->filesPath . DS . $post->name;
|
||||||
$dstWidth = $this->config->browsing->thumbWidth;
|
|
||||||
$dstHeight = $this->config->browsing->thumbHeight;
|
|
||||||
|
|
||||||
if ($post->type == PostType::Youtube)
|
if ($post->type == PostType::Youtube)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,18 +2,25 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<?php if (isset($this->context->subTitle)): ?>
|
<?php
|
||||||
<title><?php printf('%s – %s', $this->context->title, $this->context->subTitle) ?></title>
|
$title = isset($this->context->subTitle)
|
||||||
<?php else: ?>
|
? sprintf('%s – %s', $this->context->title, $this->context->subTitle)
|
||||||
<title><?php echo $this->context->title ?></title>
|
: $this->context->title
|
||||||
<?php endif ?>
|
?>
|
||||||
|
<title><?php echo $title ?></title>
|
||||||
<?php foreach (array_unique($this->context->stylesheets) as $name): ?>
|
<?php foreach (array_unique($this->context->stylesheets) as $name): ?>
|
||||||
<link rel="stylesheet" type="text/css" href="<?php echo \Chibi\UrlHelper::absoluteUrl('/media/css/' . $name) ?>"/>
|
<link rel="stylesheet" type="text/css" href="<?php echo \Chibi\UrlHelper::absoluteUrl('/media/css/' . $name) ?>"/>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
<?php foreach (array_unique($this->context->scripts) as $name): ?>
|
<?php foreach (array_unique($this->context->scripts) as $name): ?>
|
||||||
<script type="text/javascript" src="<?php echo \Chibi\UrlHelper::absoluteUrl('/media/js/' . $name) ?>"></script>
|
<script type="text/javascript" src="<?php echo \Chibi\UrlHelper::absoluteUrl('/media/js/' . $name) ?>"></script>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"/>
|
||||||
|
|
||||||
|
<meta property="og:title" content="<?php echo $title ?>"/>
|
||||||
|
<meta property="og:url" content="<?php echo \Chibi\UrlHelper::currentUrl() ?>"/>
|
||||||
|
<?php if (!empty($this->context->pageThumb)): ?>
|
||||||
|
<meta property="og:image" content="<?php echo $this->context->pageThumb ?>"/>
|
||||||
|
<?php endif ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Reference in a new issue