Update to latest commit from Parziphal

This commit is contained in:
Yuki K 2016-09-13 18:32:30 -04:00
parent a37ad9a625
commit bb9d01f924
2 changed files with 19 additions and 15 deletions

View File

@ -99,20 +99,21 @@ class CommentController extends ApplicationController
$query = Comment::order('id desc'); $query = Comment::order('id desc');
$search_query = explode(' ', $this->params()->query); $search_query = explode(' ', $this->params()->query);
$search_terms = array(); $search_terms = array();
$user_search = false;
foreach ($search_query as $s) { foreach ($search_query as $s) {
if (!$s) { if (!$s) {
continue; continue;
} }
if (strpos($s, 'user:') === 0 && strlen($s) > 5) { if (!$user_search && strpos($s, 'user:') === 0 && strlen($s) > 5) {
list($search_type, $param) = explode(':', $s); list($search_type, $param) = explode(':', $s);
if ($user = User::where(['name' => $param])->first()) { if ($user = User::where(['name' => $param])->first()) {
$query->where('user_id = ?', $user->id); $query->where('user_id = ?', $user->id);
} else { $user_search = true;
$query->where('false');
} }
continue; continue;
} }
@ -121,8 +122,7 @@ class CommentController extends ApplicationController
if ($search_terms) { if ($search_terms) {
$query->where('body LIKE ?', '%' . implode('%', $search_terms) . '%'); $query->where('body LIKE ?', '%' . implode('%', $search_terms) . '%');
} else { } elseif (!$user_search) {
# MI: this query makes no sense, it will return nothing.
$query->where('false'); $query->where('false');
} }

View File

@ -3,8 +3,12 @@
<?= $this->tag('meta', array('property' => 'og:title', 'content' => $this->html_title())) ?> <?= $this->tag('meta', array('property' => 'og:title', 'content' => $this->html_title())) ?>
<?= $this->tag('meta', array('property' => 'og:type', 'content' => 'article')) ?> <?= $this->tag('meta', array('property' => 'og:type', 'content' => 'article')) ?>
<?= $this->tag('meta', array('property' => 'og:url', 'content' => $this->urlFor(array('post#show', 'id' => $this->post->id, 'only_path' => false)))) ?> <?= $this->tag('meta', array('property' => 'og:url', 'content' => $this->urlFor(array('post#show', 'id' => $this->post->id, 'only_path' => false)))) ?>
<?= $this->tag('meta', array('property' => 'og:image', 'content' => $this->post->sample_url())) ?>
<?= $this->tag('meta', array('property' => 'og:site_name', 'content' => CONFIG()->app_name)) ?> <?= $this->tag('meta', array('property' => 'og:site_name', 'content' => CONFIG()->app_name)) ?>
<?= $this->tag('meta', array('property' => 'og:description', 'content' => $this->post->tags())) ?> <?= $this->tag('meta', array('property' => 'og:description', 'content' => $this->post->tags())) ?>
<?php # Reddit Thumbnail ?> <?php # Reddit Thumbnail ?>
<?= $this->tag('link', array('rel' => 'image_src', 'href' => $this->post->sample_url())) ?> <?php
if (CONFIG()->can_see_post(current_user(), $this->post)) {
echo $this->tag('link', array('rel' => 'image_src', 'href' => $this->post->sample_url()));
echo $this->tag('meta', array('property' => 'og:image', 'content' => $this->post->sample_url()));
}
?>