1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Add ability to link back to parent site in external phame blogs

Summary: Ref T9897. Adds a Parent Site and Parent Domain field to allow external sites to link back to parent.

Test Plan: Set up ```local.blog.phacility.com```, set parent site to "Phacility" and parent domain to "local.www.phacility.com". Get new crumbs at Blog and Post levels.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9897

Differential Revision: https://secure.phabricator.com/D16150
This commit is contained in:
Chad Little 2016-06-20 12:42:53 -07:00
parent 9a2c2505a0
commit 967945e4b4
8 changed files with 128 additions and 7 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_phame.phame_blog
ADD parentDomain VARCHAR(128) NOT NULL COLLATE {$COLLATE_TEXT};

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_phame.phame_blog
ADD parentSite VARCHAR(128) NOT NULL COLLATE {$COLLATE_TEXT};

View file

@ -159,6 +159,12 @@ abstract class PhameLiveController extends PhameController {
// "Blogs" crumb into the crumbs list.
if ($is_external) {
$crumbs = new PHUICrumbsView();
// Link back to parent site
if ($blog->getParentSite() && $blog->getParentDomain()) {
$crumbs->addTextCrumb(
$blog->getParentSite(),
$blog->getExternalParentURI());
}
} else {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addTextCrumb(

View file

@ -95,8 +95,7 @@ final class PhameBlogManageController extends PhameBlogController {
Javelin::initBehavior('phabricator-tooltips');
$properties = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($blog);
->setUser($viewer);
$domain = $blog->getDomain();
if (!$domain) {
@ -105,6 +104,20 @@ final class PhameBlogManageController extends PhameBlogController {
$properties->addProperty(pht('Domain'), $domain);
$parent_site = $blog->getParentSite();
if (!$parent_site) {
$parent_site = phutil_tag('em', array(), pht('No parent site'));
}
$properties->addProperty(pht('Parent Site'), $parent_site);
$parent_domain = $blog->getParentDomain();
if (!$parent_domain) {
$parent_domain = phutil_tag('em', array(), pht('No parent domain'));
}
$properties->addProperty(pht('Parent Domain'), $parent_domain);
$feed_uri = PhabricatorEnv::getProductionURI(
$this->getApplicationURI('blog/feed/'.$blog->getID().'/'));
$properties->addProperty(
@ -133,8 +146,6 @@ final class PhameBlogManageController extends PhameBlogController {
->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)
->process();
$properties->invokeWillRenderEvent();
$description = $blog->getDescription();
if (strlen($description)) {
$description = new PHUIRemarkupView($viewer, $description);
@ -150,7 +161,7 @@ final class PhameBlogManageController extends PhameBlogController {
private function buildCurtain(PhameBlog $blog) {
$viewer = $this->getViewer();
$curtain = $this->newCurtainView($viewer);
$curtain = $this->newCurtainView($blog);
$actions = id(new PhabricatorActionListView())
->setObject($blog)

View file

@ -101,6 +101,22 @@ final class PhameBlogEditEngine
->setConduitTypeDescription(pht('New blog domain.'))
->setValue($object->getDomain())
->setTransactionType(PhameBlogTransaction::TYPE_DOMAIN),
id(new PhabricatorTextEditField())
->setKey('parentSite')
->setLabel(pht('Parent Site'))
->setDescription(pht('Blog parent site name.'))
->setConduitDescription(pht('Change the blog parent site name.'))
->setConduitTypeDescription(pht('New blog parent site name.'))
->setValue($object->getParentSite())
->setTransactionType(PhameBlogTransaction::TYPE_PARENTSITE),
id(new PhabricatorTextEditField())
->setKey('parentDomain')
->setLabel(pht('Parent Domain'))
->setDescription(pht('Blog parent domain name.'))
->setConduitDescription(pht('Change the blog parent domain.'))
->setConduitTypeDescription(pht('New blog parent domain.'))
->setValue($object->getParentDomain())
->setTransactionType(PhameBlogTransaction::TYPE_PARENTDOMAIN),
id(new PhabricatorSelectEditField())
->setKey('status')
->setLabel(pht('Status'))

View file

@ -18,6 +18,8 @@ final class PhameBlogEditor
$types[] = PhameBlogTransaction::TYPE_SUBTITLE;
$types[] = PhameBlogTransaction::TYPE_DESCRIPTION;
$types[] = PhameBlogTransaction::TYPE_DOMAIN;
$types[] = PhameBlogTransaction::TYPE_PARENTSITE;
$types[] = PhameBlogTransaction::TYPE_PARENTDOMAIN;
$types[] = PhameBlogTransaction::TYPE_STATUS;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
@ -38,6 +40,10 @@ final class PhameBlogEditor
return $object->getDescription();
case PhameBlogTransaction::TYPE_DOMAIN:
return $object->getDomain();
case PhameBlogTransaction::TYPE_PARENTSITE:
return $object->getParentSite();
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
return $object->getParentDomain();
case PhameBlogTransaction::TYPE_STATUS:
return $object->getStatus();
}
@ -52,6 +58,8 @@ final class PhameBlogEditor
case PhameBlogTransaction::TYPE_SUBTITLE:
case PhameBlogTransaction::TYPE_DESCRIPTION:
case PhameBlogTransaction::TYPE_STATUS:
case PhameBlogTransaction::TYPE_PARENTSITE:
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
return $xaction->getNewValue();
case PhameBlogTransaction::TYPE_DOMAIN:
$domain = $xaction->getNewValue();
@ -77,6 +85,10 @@ final class PhameBlogEditor
return $object->setDomain($xaction->getNewValue());
case PhameBlogTransaction::TYPE_STATUS:
return $object->setStatus($xaction->getNewValue());
case PhameBlogTransaction::TYPE_PARENTSITE:
return $object->setParentSite($xaction->getNewValue());
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
return $object->setParentDomain($xaction->getNewValue());
}
return parent::applyCustomInternalTransaction($object, $xaction);
@ -91,6 +103,8 @@ final class PhameBlogEditor
case PhameBlogTransaction::TYPE_SUBTITLE:
case PhameBlogTransaction::TYPE_DESCRIPTION:
case PhameBlogTransaction::TYPE_DOMAIN:
case PhameBlogTransaction::TYPE_PARENTSITE:
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
case PhameBlogTransaction::TYPE_STATUS:
return;
}
@ -123,6 +137,25 @@ final class PhameBlogEditor
$errors[] = $error;
}
break;
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
if (!$xactions) {
continue;
}
$parent_domain = last($xactions)->getNewValue();
if (empty($parent_domain)) {
continue;
}
try {
PhabricatorEnv::requireValidRemoteURIForLink($parent_domain);
} catch (Exception $ex) {
$error = new PhabricatorApplicationTransactionValidationError(
$type,
pht('Invalid URI'),
pht('Parent Domain must be set to a valid Remote URI.'),
nonempty(last($xactions), null));
$errors[] = $error;
}
break;
case PhameBlogTransaction::TYPE_DOMAIN:
if (!$xactions) {
continue;

View file

@ -18,6 +18,8 @@ final class PhameBlog extends PhameDAO
protected $subtitle;
protected $description;
protected $domain;
protected $parentSite;
protected $parentDomain;
protected $configData;
protected $creatorPHID;
protected $viewPolicy;
@ -44,6 +46,8 @@ final class PhameBlog extends PhameDAO
'subtitle' => 'text64',
'description' => 'text',
'domain' => 'text128?',
'parentSite' => 'text128',
'parentDomain' => 'text128',
'status' => 'text32',
'mailKey' => 'bytes20',
'profileImagePHID' => 'phid?',
@ -187,11 +191,16 @@ final class PhameBlog extends PhameDAO
}
public function getExternalLiveURI() {
$domain = $this->getDomain();
$uri = new PhutilURI('http://'.$this->getDomain().'/');
return (string)$uri;
}
public function getExternalParentURI() {
$uri = $this->getParentDomain();
PhabricatorEnv::requireValidRemoteURIForLink($uri);
return (string)$uri;
}
public function getInternalLiveURI() {
return '/phame/live/'.$this->getID().'/';
}

View file

@ -8,6 +8,8 @@ final class PhameBlogTransaction
const TYPE_DESCRIPTION = 'phame.blog.description';
const TYPE_DOMAIN = 'phame.blog.domain';
const TYPE_STATUS = 'phame.blog.status';
const TYPE_PARENTSITE = 'phame.blog.parent.site';
const TYPE_PARENTDOMAIN = 'phame.blog.parent.domain';
const MAILTAG_DETAILS = 'phame-blog-details';
const MAILTAG_SUBSCRIBERS = 'phame-blog-subscribers';
@ -65,7 +67,7 @@ final class PhameBlogTransaction
switch ($this->getTransactionType()) {
case self::TYPE_STATUS:
if ($new == PhameBlog::STATUS_ARCHIVED) {
return 'red';
return 'violet';
} else {
return 'green';
}
@ -84,6 +86,8 @@ final class PhameBlogTransaction
case self::TYPE_SUBTITLE:
case self::TYPE_DESCRIPTION:
case self::TYPE_DOMAIN:
case self::TYPE_PARENTSITE:
case self::TYPE_PARENTDOMAIN:
$tags[] = self::MAILTAG_DETAILS;
break;
default:
@ -142,6 +146,32 @@ final class PhameBlogTransaction
$this->renderHandleLink($author_phid),
$new);
break;
case self::TYPE_PARENTSITE:
if ($old === null) {
return pht(
'%s set this blog\'s parent site to "%s".',
$this->renderHandleLink($author_phid),
$new);
} else {
return pht(
'%s updated the blog\'s parent site to "%s".',
$this->renderHandleLink($author_phid),
$new);
}
break;
case self::TYPE_PARENTDOMAIN:
if ($old === null) {
return pht(
'%s set this blog\'s parent domain to "%s".',
$this->renderHandleLink($author_phid),
$new);
} else {
return pht(
'%s updated the blog\'s parent domain to "%s".',
$this->renderHandleLink($author_phid),
$new);
}
break;
case self::TYPE_STATUS:
switch ($new) {
case PhameBlog::STATUS_ACTIVE:
@ -206,6 +236,18 @@ final class PhameBlogTransaction
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
break;
case self::TYPE_PARENTSITE:
return pht(
'%s updated the parent site for %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
break;
case self::TYPE_PARENTDOMAIN:
return pht(
'%s updated the parent domain for %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
break;
case self::TYPE_STATUS:
switch ($new) {
case PhameBlog::STATUS_ACTIVE: