@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+128 -7
+2
resources/sql/autopatches/20160620.phame.blog.parentdomain.2.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phame.phame_blog 2 + ADD parentDomain VARCHAR(128) NOT NULL COLLATE {$COLLATE_TEXT};
+2
resources/sql/autopatches/20160620.phame.blog.parentsite.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phame.phame_blog 2 + ADD parentSite VARCHAR(128) NOT NULL COLLATE {$COLLATE_TEXT};
+6
src/applications/phame/controller/PhameLiveController.php
··· 159 159 // "Blogs" crumb into the crumbs list. 160 160 if ($is_external) { 161 161 $crumbs = new PHUICrumbsView(); 162 + // Link back to parent site 163 + if ($blog->getParentSite() && $blog->getParentDomain()) { 164 + $crumbs->addTextCrumb( 165 + $blog->getParentSite(), 166 + $blog->getExternalParentURI()); 167 + } 162 168 } else { 163 169 $crumbs = parent::buildApplicationCrumbs(); 164 170 $crumbs->addTextCrumb(
+16 -5
src/applications/phame/controller/blog/PhameBlogManageController.php
··· 95 95 Javelin::initBehavior('phabricator-tooltips'); 96 96 97 97 $properties = id(new PHUIPropertyListView()) 98 - ->setUser($viewer) 99 - ->setObject($blog); 98 + ->setUser($viewer); 100 99 101 100 $domain = $blog->getDomain(); 102 101 if (!$domain) { ··· 105 104 106 105 $properties->addProperty(pht('Domain'), $domain); 107 106 107 + $parent_site = $blog->getParentSite(); 108 + if (!$parent_site) { 109 + $parent_site = phutil_tag('em', array(), pht('No parent site')); 110 + } 111 + 112 + $properties->addProperty(pht('Parent Site'), $parent_site); 113 + 114 + $parent_domain = $blog->getParentDomain(); 115 + if (!$parent_domain) { 116 + $parent_domain = phutil_tag('em', array(), pht('No parent domain')); 117 + } 118 + 119 + $properties->addProperty(pht('Parent Domain'), $parent_domain); 120 + 108 121 $feed_uri = PhabricatorEnv::getProductionURI( 109 122 $this->getApplicationURI('blog/feed/'.$blog->getID().'/')); 110 123 $properties->addProperty( ··· 133 146 ->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION) 134 147 ->process(); 135 148 136 - $properties->invokeWillRenderEvent(); 137 - 138 149 $description = $blog->getDescription(); 139 150 if (strlen($description)) { 140 151 $description = new PHUIRemarkupView($viewer, $description); ··· 150 161 private function buildCurtain(PhameBlog $blog) { 151 162 $viewer = $this->getViewer(); 152 163 153 - $curtain = $this->newCurtainView($viewer); 164 + $curtain = $this->newCurtainView($blog); 154 165 155 166 $actions = id(new PhabricatorActionListView()) 156 167 ->setObject($blog)
+16
src/applications/phame/editor/PhameBlogEditEngine.php
··· 101 101 ->setConduitTypeDescription(pht('New blog domain.')) 102 102 ->setValue($object->getDomain()) 103 103 ->setTransactionType(PhameBlogTransaction::TYPE_DOMAIN), 104 + id(new PhabricatorTextEditField()) 105 + ->setKey('parentSite') 106 + ->setLabel(pht('Parent Site')) 107 + ->setDescription(pht('Blog parent site name.')) 108 + ->setConduitDescription(pht('Change the blog parent site name.')) 109 + ->setConduitTypeDescription(pht('New blog parent site name.')) 110 + ->setValue($object->getParentSite()) 111 + ->setTransactionType(PhameBlogTransaction::TYPE_PARENTSITE), 112 + id(new PhabricatorTextEditField()) 113 + ->setKey('parentDomain') 114 + ->setLabel(pht('Parent Domain')) 115 + ->setDescription(pht('Blog parent domain name.')) 116 + ->setConduitDescription(pht('Change the blog parent domain.')) 117 + ->setConduitTypeDescription(pht('New blog parent domain.')) 118 + ->setValue($object->getParentDomain()) 119 + ->setTransactionType(PhameBlogTransaction::TYPE_PARENTDOMAIN), 104 120 id(new PhabricatorSelectEditField()) 105 121 ->setKey('status') 106 122 ->setLabel(pht('Status'))
+33
src/applications/phame/editor/PhameBlogEditor.php
··· 18 18 $types[] = PhameBlogTransaction::TYPE_SUBTITLE; 19 19 $types[] = PhameBlogTransaction::TYPE_DESCRIPTION; 20 20 $types[] = PhameBlogTransaction::TYPE_DOMAIN; 21 + $types[] = PhameBlogTransaction::TYPE_PARENTSITE; 22 + $types[] = PhameBlogTransaction::TYPE_PARENTDOMAIN; 21 23 $types[] = PhameBlogTransaction::TYPE_STATUS; 22 24 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 23 25 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; ··· 38 40 return $object->getDescription(); 39 41 case PhameBlogTransaction::TYPE_DOMAIN: 40 42 return $object->getDomain(); 43 + case PhameBlogTransaction::TYPE_PARENTSITE: 44 + return $object->getParentSite(); 45 + case PhameBlogTransaction::TYPE_PARENTDOMAIN: 46 + return $object->getParentDomain(); 41 47 case PhameBlogTransaction::TYPE_STATUS: 42 48 return $object->getStatus(); 43 49 } ··· 52 58 case PhameBlogTransaction::TYPE_SUBTITLE: 53 59 case PhameBlogTransaction::TYPE_DESCRIPTION: 54 60 case PhameBlogTransaction::TYPE_STATUS: 61 + case PhameBlogTransaction::TYPE_PARENTSITE: 62 + case PhameBlogTransaction::TYPE_PARENTDOMAIN: 55 63 return $xaction->getNewValue(); 56 64 case PhameBlogTransaction::TYPE_DOMAIN: 57 65 $domain = $xaction->getNewValue(); ··· 77 85 return $object->setDomain($xaction->getNewValue()); 78 86 case PhameBlogTransaction::TYPE_STATUS: 79 87 return $object->setStatus($xaction->getNewValue()); 88 + case PhameBlogTransaction::TYPE_PARENTSITE: 89 + return $object->setParentSite($xaction->getNewValue()); 90 + case PhameBlogTransaction::TYPE_PARENTDOMAIN: 91 + return $object->setParentDomain($xaction->getNewValue()); 80 92 } 81 93 82 94 return parent::applyCustomInternalTransaction($object, $xaction); ··· 91 103 case PhameBlogTransaction::TYPE_SUBTITLE: 92 104 case PhameBlogTransaction::TYPE_DESCRIPTION: 93 105 case PhameBlogTransaction::TYPE_DOMAIN: 106 + case PhameBlogTransaction::TYPE_PARENTSITE: 107 + case PhameBlogTransaction::TYPE_PARENTDOMAIN: 94 108 case PhameBlogTransaction::TYPE_STATUS: 95 109 return; 96 110 } ··· 120 134 nonempty(last($xactions), null)); 121 135 122 136 $error->setIsMissingFieldError(true); 137 + $errors[] = $error; 138 + } 139 + break; 140 + case PhameBlogTransaction::TYPE_PARENTDOMAIN: 141 + if (!$xactions) { 142 + continue; 143 + } 144 + $parent_domain = last($xactions)->getNewValue(); 145 + if (empty($parent_domain)) { 146 + continue; 147 + } 148 + try { 149 + PhabricatorEnv::requireValidRemoteURIForLink($parent_domain); 150 + } catch (Exception $ex) { 151 + $error = new PhabricatorApplicationTransactionValidationError( 152 + $type, 153 + pht('Invalid URI'), 154 + pht('Parent Domain must be set to a valid Remote URI.'), 155 + nonempty(last($xactions), null)); 123 156 $errors[] = $error; 124 157 } 125 158 break;
+10 -1
src/applications/phame/storage/PhameBlog.php
··· 18 18 protected $subtitle; 19 19 protected $description; 20 20 protected $domain; 21 + protected $parentSite; 22 + protected $parentDomain; 21 23 protected $configData; 22 24 protected $creatorPHID; 23 25 protected $viewPolicy; ··· 44 46 'subtitle' => 'text64', 45 47 'description' => 'text', 46 48 'domain' => 'text128?', 49 + 'parentSite' => 'text128', 50 + 'parentDomain' => 'text128', 47 51 'status' => 'text32', 48 52 'mailKey' => 'bytes20', 49 53 'profileImagePHID' => 'phid?', ··· 187 191 } 188 192 189 193 public function getExternalLiveURI() { 190 - $domain = $this->getDomain(); 191 194 $uri = new PhutilURI('http://'.$this->getDomain().'/'); 195 + return (string)$uri; 196 + } 197 + 198 + public function getExternalParentURI() { 199 + $uri = $this->getParentDomain(); 200 + PhabricatorEnv::requireValidRemoteURIForLink($uri); 192 201 return (string)$uri; 193 202 } 194 203
+43 -1
src/applications/phame/storage/PhameBlogTransaction.php
··· 8 8 const TYPE_DESCRIPTION = 'phame.blog.description'; 9 9 const TYPE_DOMAIN = 'phame.blog.domain'; 10 10 const TYPE_STATUS = 'phame.blog.status'; 11 + const TYPE_PARENTSITE = 'phame.blog.parent.site'; 12 + const TYPE_PARENTDOMAIN = 'phame.blog.parent.domain'; 11 13 12 14 const MAILTAG_DETAILS = 'phame-blog-details'; 13 15 const MAILTAG_SUBSCRIBERS = 'phame-blog-subscribers'; ··· 65 67 switch ($this->getTransactionType()) { 66 68 case self::TYPE_STATUS: 67 69 if ($new == PhameBlog::STATUS_ARCHIVED) { 68 - return 'red'; 70 + return 'violet'; 69 71 } else { 70 72 return 'green'; 71 73 } ··· 84 86 case self::TYPE_SUBTITLE: 85 87 case self::TYPE_DESCRIPTION: 86 88 case self::TYPE_DOMAIN: 89 + case self::TYPE_PARENTSITE: 90 + case self::TYPE_PARENTDOMAIN: 87 91 $tags[] = self::MAILTAG_DETAILS; 88 92 break; 89 93 default: ··· 142 146 $this->renderHandleLink($author_phid), 143 147 $new); 144 148 break; 149 + case self::TYPE_PARENTSITE: 150 + if ($old === null) { 151 + return pht( 152 + '%s set this blog\'s parent site to "%s".', 153 + $this->renderHandleLink($author_phid), 154 + $new); 155 + } else { 156 + return pht( 157 + '%s updated the blog\'s parent site to "%s".', 158 + $this->renderHandleLink($author_phid), 159 + $new); 160 + } 161 + break; 162 + case self::TYPE_PARENTDOMAIN: 163 + if ($old === null) { 164 + return pht( 165 + '%s set this blog\'s parent domain to "%s".', 166 + $this->renderHandleLink($author_phid), 167 + $new); 168 + } else { 169 + return pht( 170 + '%s updated the blog\'s parent domain to "%s".', 171 + $this->renderHandleLink($author_phid), 172 + $new); 173 + } 174 + break; 145 175 case self::TYPE_STATUS: 146 176 switch ($new) { 147 177 case PhameBlog::STATUS_ACTIVE: ··· 203 233 case self::TYPE_DOMAIN: 204 234 return pht( 205 235 '%s updated the domain for %s.', 236 + $this->renderHandleLink($author_phid), 237 + $this->renderHandleLink($object_phid)); 238 + break; 239 + case self::TYPE_PARENTSITE: 240 + return pht( 241 + '%s updated the parent site for %s.', 242 + $this->renderHandleLink($author_phid), 243 + $this->renderHandleLink($object_phid)); 244 + break; 245 + case self::TYPE_PARENTDOMAIN: 246 + return pht( 247 + '%s updated the parent domain for %s.', 206 248 $this->renderHandleLink($author_phid), 207 249 $this->renderHandleLink($object_phid)); 208 250 break;