Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15516255
D18780.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D18780.id.diff
View Options
diff --git a/src/applications/config/custom/PhabricatorCustomLogoConfigType.php b/src/applications/config/custom/PhabricatorCustomLogoConfigType.php
--- a/src/applications/config/custom/PhabricatorCustomLogoConfigType.php
+++ b/src/applications/config/custom/PhabricatorCustomLogoConfigType.php
@@ -13,6 +13,39 @@
return idx($logo, 'wordmarkText');
}
+ public static function getLogoURI(PhabricatorUser $viewer) {
+ $logo_uri = null;
+
+ $custom_header = self::getLogoImagePHID();
+ if ($custom_header) {
+ $cache = PhabricatorCaches::getImmutableCache();
+ $cache_key_logo = 'ui.custom-header.logo-phid.v3.'.$custom_header;
+ $logo_uri = $cache->getKey($cache_key_logo);
+
+ if (!$logo_uri) {
+ // NOTE: If the file policy has been changed to be restrictive, we'll
+ // miss here and just show the default logo. The cache will fill later
+ // when someone who can see the file loads the page. This might be a
+ // little spooky, see T11982.
+ $files = id(new PhabricatorFileQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($custom_header))
+ ->execute();
+ $file = head($files);
+ if ($file) {
+ $logo_uri = $file->getViewURI();
+ $cache->setKey($cache_key_logo, $logo_uri);
+ }
+ }
+ }
+
+ if (!$logo_uri) {
+ $logo_uri = celerity_get_resource_uri('/rsrc/image/logo/light-eye.png');
+ }
+
+ return $logo_uri;
+ }
+
public function validateOption(PhabricatorConfigOption $option, $value) {
if (!is_array($value)) {
throw new Exception(
diff --git a/src/view/page/PhabricatorStandardPageView.php b/src/view/page/PhabricatorStandardPageView.php
--- a/src/view/page/PhabricatorStandardPageView.php
+++ b/src/view/page/PhabricatorStandardPageView.php
@@ -426,10 +426,11 @@
}
return hsprintf(
- '%s%s%s',
+ '%s%s%s%s',
parent::getHead(),
$font_css,
- $response->renderSingleResource('javelin-magical-init', 'phabricator'));
+ $response->renderSingleResource('javelin-magical-init', 'phabricator'),
+ $this->newOpenGraphTags());
}
public function setGlyph($glyph) {
@@ -911,4 +912,45 @@
return $response;
}
+ private function newOpenGraphTags() {
+ // If we don't allow public access, there's no point in emitting OpenGraph
+ // tags because external systems can't fetch pages.
+ if (!PhabricatorEnv::getEnvConfig('policy.allow-public')) {
+ return array();
+ }
+
+ $viewer = $this->getViewer();
+
+ $properties = array(
+ array(
+ 'og:title',
+ $this->getTitle(),
+ ),
+ array(
+ 'og:type',
+ 'website',
+ ),
+ array(
+ 'og:url',
+ PhabricatorEnv::getProductionURI($this->getRequest()->getRequestURI()),
+ ),
+ array(
+ 'og:image',
+ PhabricatorCustomLogoConfigType::getLogoURI($viewer),
+ ),
+ );
+
+ $tags = array();
+ foreach ($properties as $property) {
+ $tags[] = phutil_tag(
+ 'meta',
+ array(
+ 'property' => $property[0],
+ 'content' => $property[1],
+ ));
+ }
+
+ return $tags;
+ }
+
}
diff --git a/src/view/page/menu/PhabricatorMainMenuView.php b/src/view/page/menu/PhabricatorMainMenuView.php
--- a/src/view/page/menu/PhabricatorMainMenuView.php
+++ b/src/view/page/menu/PhabricatorMainMenuView.php
@@ -262,35 +262,16 @@
}
private function renderPhabricatorLogo() {
- $custom_header = PhabricatorCustomLogoConfigType::getLogoImagePHID();
-
$logo_style = array();
+
+ $custom_header = PhabricatorCustomLogoConfigType::getLogoImagePHID();
if ($custom_header) {
- $cache = PhabricatorCaches::getImmutableCache();
- $cache_key_logo = 'ui.custom-header.logo-phid.v3.'.$custom_header;
-
- $logo_uri = $cache->getKey($cache_key_logo);
- if (!$logo_uri) {
- // NOTE: If the file policy has been changed to be restrictive, we'll
- // miss here and just show the default logo. The cache will fill later
- // when someone who can see the file loads the page. This might be a
- // little spooky, see T11982.
- $files = id(new PhabricatorFileQuery())
- ->setViewer($this->getViewer())
- ->withPHIDs(array($custom_header))
- ->execute();
- $file = head($files);
- if ($file) {
- $logo_uri = $file->getViewURI();
- $cache->setKey($cache_key_logo, $logo_uri);
- }
- }
+ $viewer = $this->getViewer();
+ $logo_uri = PhabricatorCustomLogoConfigType::getLogoURI($viewer);
- if ($logo_uri) {
- $logo_style[] = 'background-size: 40px 40px;';
- $logo_style[] = 'background-position: 0 0;';
- $logo_style[] = 'background-image: url('.$logo_uri.')';
- }
+ $logo_style[] = 'background-size: 40px 40px;';
+ $logo_style[] = 'background-position: 0 0;';
+ $logo_style[] = 'background-image: url('.$logo_uri.')';
}
$logo_node = phutil_tag(
@@ -300,7 +281,6 @@
'style' => implode(' ', $logo_style),
));
-
$wordmark_text = PhabricatorCustomLogoConfigType::getLogoWordmark();
if (!strlen($wordmark_text)) {
$wordmark_text = pht('Phabricator');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 19, 5:32 PM (3 d, 17 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7725744
Default Alt Text
D18780.id.diff (5 KB)
Attached To
Mode
D18780: Add basic support for OpenGraph header tags for public installs
Attached
Detach File
Event Timeline
Log In to Comment