From 9c27c7ab604e6d57eb973fccea7ccec56fe92742 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 21 Dec 2012 11:29:31 -0800 Subject: [PATCH] tweak phame blog template a bit for better Facebook integration Summary: this makes it more sensical when you hit "share" from a bookmarklet or cut and paste a link into FB, basically by having post-specific data when sharing a post. Test Plan: looked at generated HTML on my test blog Reviewers: epriestley Reviewed By: epriestley CC: chad, aran, Korvin Differential Revision: https://secure.phabricator.com/D4266 --- .../phame/skins/PhameBasicBlogSkin.php | 24 +++++++++++++++++++ .../skins/PhameBasicTemplateBlogSkin.php | 10 ++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/applications/phame/skins/PhameBasicBlogSkin.php b/src/applications/phame/skins/PhameBasicBlogSkin.php index 420a52ae85..38f1dd9b30 100644 --- a/src/applications/phame/skins/PhameBasicBlogSkin.php +++ b/src/applications/phame/skins/PhameBasicBlogSkin.php @@ -9,6 +9,24 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin { private $pager; private $title; + private $description; + private $oGType; + + protected function setOGType($og_type) { + $this->oGType = $og_type; + return $this; + } + protected function getOGType() { + return $this->oGType; + } + + protected function setDescription($description) { + $this->description = $description; + return $this; + } + protected function getDescription() { + return $this->description; + } protected function setTitle($title) { $this->title = $title; @@ -192,7 +210,10 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin { $matches = null; $path = $request->getPath(); + // default to the blog-wide values $this->setTitle($this->getBlog()->getName()); + $this->setDescription($this->getBlog()->getDescription()); + $this->setOGType('website'); if (preg_match('@^/post/(?P.*)$@', $path, $matches)) { $post = id(new PhamePostQuery()) ->setViewer($user) @@ -201,7 +222,10 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin { ->executeOne(); if ($post) { + $description = $post->getMarkupText(PhamePost::MARKUP_FIELD_SUMMARY); $this->setTitle($post->getTitle()); + $this->setDescription($description); + $this->setOGType('article'); $view = head($this->buildPostViews(array($post))); return $this->renderPostDetail($view); } diff --git a/src/applications/phame/skins/PhameBasicTemplateBlogSkin.php b/src/applications/phame/skins/PhameBasicTemplateBlogSkin.php index 23f94f71d0..02034d423c 100644 --- a/src/applications/phame/skins/PhameBasicTemplateBlogSkin.php +++ b/src/applications/phame/skins/PhameBasicTemplateBlogSkin.php @@ -80,10 +80,12 @@ final class PhameBasicTemplateBlogSkin extends PhameBasicBlogSkin { private function getDefaultScope() { return array( - 'skin' => $this, - 'blog' => $this->getBlog(), - 'uri' => $this->getURI(''), - 'title' => $this->getTitle(), + 'skin' => $this, + 'blog' => $this->getBlog(), + 'uri' => $this->getURI(''), + 'title' => $this->getTitle(), + 'description' => $this->getDescription(), + 'og_type' => $this->getOGType(), ); }