OG на странице точки

This commit is contained in:
Krivchikov Dmitry 2014-11-16 13:44:15 +03:00
parent b4e186f958
commit f8272672d6
5 changed files with 32 additions and 9 deletions

View File

@ -31,4 +31,17 @@ class Helper
return $string; return $string;
} }
public static function buildOG($point)
{
$og = array();
$og['title'] = $point->name . ' [wikipoints.ru]';
$og['description'] = mb_substr($point->description, 0, 200).'...';
$og['site_name'] = 'WikiPoints: Лучшие выходные - это выходные в путешествии!';
$og['type'] = 'article';
$og['url'] = 'http://wikipoints.ru/?point=' . $point->id;
$og['image'] = $point->getImg();
return $og;
}
} }

View File

@ -64,7 +64,6 @@ class IndexController extends Controller
App::setConfig('title', $res['pointsCount'] . ' или даже больше поводов не сидеть дома'); App::setConfig('title', $res['pointsCount'] . ' или даже больше поводов не сидеть дома');
self::addVar('pointsCount', $res['pointsCount']); self::addVar('pointsCount', $res['pointsCount']);
$og = array();
if (isset($_GET['point']) && $_GET['point'] && is_numeric($_GET['point'])) if (isset($_GET['point']) && $_GET['point'] && is_numeric($_GET['point']))
{ {
$id = (int) $_GET['point']; $id = (int) $_GET['point'];
@ -75,14 +74,10 @@ class IndexController extends Controller
$point->descriptionHtml .= ' Посмотреть на карте: http://wikipoints.ru/?point=' . $id; $point->descriptionHtml .= ' Посмотреть на карте: http://wikipoints.ru/?point=' . $id;
$point->descriptionHtml .= ' #wikipoints'; $point->descriptionHtml .= ' #wikipoints';
$og['title'] = $point->name . ' [wikipoints.ru]'; $og = Helper::buildOG($point);
$og['description'] = $point->descriptionHtml;
$og['site_name'] = 'WikiPoints - ' . $res['pointsCount'] . ' или даже больше поводов не сидеть дома';
$og['type'] = 'article';
$og['url'] = 'http://wikipoints.ru/?point=' . $id;
$og['image'] = $point->getImg();
} else if (isset($_GET['point']) && $_GET['point'] && strtolower($_GET['point']) == 'random') } else if (isset($_GET['point']) && $_GET['point'] && strtolower($_GET['point']) == 'random')
{ {
$og = array();
$og['title'] = 'Случайная точка на wikipoints.ru'; $og['title'] = 'Случайная точка на wikipoints.ru';
$og['description'] = 'Загляните сюда: http://vk.com/wikipoints Случайная точка на карте - лучший способ узнать что-то новое!'; $og['description'] = 'Загляните сюда: http://vk.com/wikipoints Случайная точка на карте - лучший способ узнать что-то новое!';
$og['site_name'] = 'WikiPoints - ' . $res['pointsCount'] . ' или даже больше поводов не сидеть дома'; $og['site_name'] = 'WikiPoints - ' . $res['pointsCount'] . ' или даже больше поводов не сидеть дома';

View File

@ -90,6 +90,7 @@ class PageController extends Controller
'photos' => $point->photos, 'photos' => $point->photos,
'countInFavs' => Favorite::model()->countInFavs($pointId), 'countInFavs' => Favorite::model()->countInFavs($pointId),
'countLikes' => Like::model()->countLikes($pointId), 'countLikes' => Like::model()->countLikes($pointId),
'og' => Helper::buildOG($point),
)); ));
} else } else
{ {

View File

@ -7,7 +7,7 @@
<div class="glyphicon glyphicon-globe _t boxButtonLayers" onclick="openBox('Layers')" title="Слои карты"></div> <div class="glyphicon glyphicon-globe _t boxButtonLayers" onclick="openBox('Layers')" title="Слои карты"></div>
<div class="glyphicon glyphicon-filter _c boxButtonFilter" title="Фильтры и поиск" onclick="openBox('Filter')"></div> <div class="glyphicon glyphicon-filter _c boxButtonFilter" title="Фильтры и поиск" onclick="openBox('Filter')"></div>
<div class="glyphicon glyphicon-flag _b" title="Я на карте" onclick="showMeOnTheMap()"></div> <div class="glyphicon glyphicon-screenshot _b" title="Я на карте" onclick="showMeOnTheMap()"></div>
<div class="glyphicon glyphicon-list boxButtonRoute" title="Маршрут" onclick="openBox('Route')"></div> <div class="glyphicon glyphicon-list boxButtonRoute" title="Маршрут" onclick="openBox('Route')"></div>

View File

@ -1,5 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html xmlns="http://www.w3.org/1999/xhtml"
lang="ru"
prefix="og: http://ogp.me/ns#"
xmlns:fb="http://ogp.me/ns/fb#"
xmlns:og="http://ogp.me/ns#">
<head> <head>
<title><?= App::getConfig('title') ?></title> <title><?= App::getConfig('title') ?></title>
@ -22,6 +26,16 @@
<?php endforeach; ?> <?php endforeach; ?>
</script> </script>
<?php endif; ?> <?php endif; ?>
<?php if ($data['og']): ?>
<meta property="og:title" content="<?= $data['og']['title'] ?>" />
<meta property="og:description" content="<?= $data['og']['description'] ?>" />
<meta property="og:site_name" content="<?= $data['og']['site_name'] ?>" />
<meta property="og:type" content="<?= $data['og']['type'] ?>" />
<meta property="og:url" content="<?= $data['og']['url'] ?>" />
<meta property="og:image" content="<?= $data['og']['image'] ?>" />
<?php endif; ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:400&subset=Cyrillic"> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:400&subset=Cyrillic">