@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 basic support for OpenGraph header tags for public installs

Summary: Ref T13018. This is easy to get working roughly, at least, and seems reasonable.

Test Plan: Viewed page source, saw tags. Custom header logo still worked. Pretty hard to debug against a local install since Disqus / debugger tools can't hit it, but I'll see what it looks like in production and tweak it if I got anything horribly wrong.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13018

Differential Revision: https://secure.phabricator.com/D18780

+84 -29
+33
src/applications/config/custom/PhabricatorCustomLogoConfigType.php
··· 13 13 return idx($logo, 'wordmarkText'); 14 14 } 15 15 16 + public static function getLogoURI(PhabricatorUser $viewer) { 17 + $logo_uri = null; 18 + 19 + $custom_header = self::getLogoImagePHID(); 20 + if ($custom_header) { 21 + $cache = PhabricatorCaches::getImmutableCache(); 22 + $cache_key_logo = 'ui.custom-header.logo-phid.v3.'.$custom_header; 23 + $logo_uri = $cache->getKey($cache_key_logo); 24 + 25 + if (!$logo_uri) { 26 + // NOTE: If the file policy has been changed to be restrictive, we'll 27 + // miss here and just show the default logo. The cache will fill later 28 + // when someone who can see the file loads the page. This might be a 29 + // little spooky, see T11982. 30 + $files = id(new PhabricatorFileQuery()) 31 + ->setViewer($viewer) 32 + ->withPHIDs(array($custom_header)) 33 + ->execute(); 34 + $file = head($files); 35 + if ($file) { 36 + $logo_uri = $file->getViewURI(); 37 + $cache->setKey($cache_key_logo, $logo_uri); 38 + } 39 + } 40 + } 41 + 42 + if (!$logo_uri) { 43 + $logo_uri = celerity_get_resource_uri('/rsrc/image/logo/light-eye.png'); 44 + } 45 + 46 + return $logo_uri; 47 + } 48 + 16 49 public function validateOption(PhabricatorConfigOption $option, $value) { 17 50 if (!is_array($value)) { 18 51 throw new Exception(
+44 -2
src/view/page/PhabricatorStandardPageView.php
··· 426 426 } 427 427 428 428 return hsprintf( 429 - '%s%s%s', 429 + '%s%s%s%s', 430 430 parent::getHead(), 431 431 $font_css, 432 - $response->renderSingleResource('javelin-magical-init', 'phabricator')); 432 + $response->renderSingleResource('javelin-magical-init', 'phabricator'), 433 + $this->newOpenGraphTags()); 433 434 } 434 435 435 436 public function setGlyph($glyph) { ··· 909 910 } 910 911 911 912 return $response; 913 + } 914 + 915 + private function newOpenGraphTags() { 916 + // If we don't allow public access, there's no point in emitting OpenGraph 917 + // tags because external systems can't fetch pages. 918 + if (!PhabricatorEnv::getEnvConfig('policy.allow-public')) { 919 + return array(); 920 + } 921 + 922 + $viewer = $this->getViewer(); 923 + 924 + $properties = array( 925 + array( 926 + 'og:title', 927 + $this->getTitle(), 928 + ), 929 + array( 930 + 'og:type', 931 + 'website', 932 + ), 933 + array( 934 + 'og:url', 935 + PhabricatorEnv::getProductionURI($this->getRequest()->getRequestURI()), 936 + ), 937 + array( 938 + 'og:image', 939 + PhabricatorCustomLogoConfigType::getLogoURI($viewer), 940 + ), 941 + ); 942 + 943 + $tags = array(); 944 + foreach ($properties as $property) { 945 + $tags[] = phutil_tag( 946 + 'meta', 947 + array( 948 + 'property' => $property[0], 949 + 'content' => $property[1], 950 + )); 951 + } 952 + 953 + return $tags; 912 954 } 913 955 914 956 }
+7 -27
src/view/page/menu/PhabricatorMainMenuView.php
··· 262 262 } 263 263 264 264 private function renderPhabricatorLogo() { 265 - $custom_header = PhabricatorCustomLogoConfigType::getLogoImagePHID(); 266 - 267 265 $logo_style = array(); 268 - if ($custom_header) { 269 - $cache = PhabricatorCaches::getImmutableCache(); 270 - $cache_key_logo = 'ui.custom-header.logo-phid.v3.'.$custom_header; 271 266 272 - $logo_uri = $cache->getKey($cache_key_logo); 273 - if (!$logo_uri) { 274 - // NOTE: If the file policy has been changed to be restrictive, we'll 275 - // miss here and just show the default logo. The cache will fill later 276 - // when someone who can see the file loads the page. This might be a 277 - // little spooky, see T11982. 278 - $files = id(new PhabricatorFileQuery()) 279 - ->setViewer($this->getViewer()) 280 - ->withPHIDs(array($custom_header)) 281 - ->execute(); 282 - $file = head($files); 283 - if ($file) { 284 - $logo_uri = $file->getViewURI(); 285 - $cache->setKey($cache_key_logo, $logo_uri); 286 - } 287 - } 267 + $custom_header = PhabricatorCustomLogoConfigType::getLogoImagePHID(); 268 + if ($custom_header) { 269 + $viewer = $this->getViewer(); 270 + $logo_uri = PhabricatorCustomLogoConfigType::getLogoURI($viewer); 288 271 289 - if ($logo_uri) { 290 - $logo_style[] = 'background-size: 40px 40px;'; 291 - $logo_style[] = 'background-position: 0 0;'; 292 - $logo_style[] = 'background-image: url('.$logo_uri.')'; 293 - } 272 + $logo_style[] = 'background-size: 40px 40px;'; 273 + $logo_style[] = 'background-position: 0 0;'; 274 + $logo_style[] = 'background-image: url('.$logo_uri.')'; 294 275 } 295 276 296 277 $logo_node = phutil_tag( ··· 299 280 'class' => 'phabricator-main-menu-eye', 300 281 'style' => implode(' ', $logo_style), 301 282 )); 302 - 303 283 304 284 $wordmark_text = PhabricatorCustomLogoConfigType::getLogoWordmark(); 305 285 if (!strlen($wordmark_text)) {