Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2681424
D25668.1734641653.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
6 KB
Referenced Files
None
Subscribers
None
D25668.1734641653.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,40 @@
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/project-logo.png');
+ }
+
+ return $logo_uri;
+ }
+
public function validateOption(PhabricatorConfigOption $option, $value) {
if (!is_array($value)) {
throw new Exception(
diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php
--- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php
+++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php
@@ -203,8 +203,7 @@
->addPropertySection(pht('Description'), $description)
->addPropertySection(pht('Details'), $details);
-
- return $this->newPage()
+ $page = $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setPageObjectPHIDs(
@@ -213,6 +212,76 @@
))
->appendChild($view);
+ // If we don't allow public access, don't waste time adding OpenGraph tags
+ if (PhabricatorEnv::getEnvConfig('policy.allow-public')) {
+ $page = $this->addOpenGraphProtocolMetadata($page, $task);
+ }
+
+ return $page;
+ }
+
+ /**
+ * Add Open Graph Protocol metadata tags to Maniphest task page
+ *
+ * @param PhabricatorStandardPageView $page
+ * @param ManiphestTask $task
+ * @return $page with additional OGP <meta> tags
+ */
+ private function addOpenGraphProtocolMetadata($page, $task) {
+ $viewer = $this->getViewer();
+
+ $page->addHeadItem(phutil_tag(
+ 'meta',
+ array(
+ 'property' => 'og:site_name',
+ 'content' => PhabricatorEnv::getEnvConfig('ui.logo'),
+ )));
+ $page->addHeadItem(phutil_tag(
+ 'meta',
+ array(
+ 'property' => 'og:type',
+ 'content' => 'object',
+ )));
+ $page->addHeadItem(phutil_tag(
+ 'meta',
+ array(
+ 'property' => 'og:url',
+ 'content' => PhabricatorEnv::getProductionURI($task->getURI()),
+ )));
+ $page->addHeadItem(phutil_tag(
+ 'meta',
+ array(
+ 'property' => 'og:title',
+ 'content' => $task->getMonogram().' '.$task->getTitle(),
+ )));
+ $desc = $task->getDescription();
+ if (strlen($desc) > 0) {
+ $page->addHeadItem(phutil_tag(
+ 'meta',
+ array(
+ 'property' => 'og:description',
+ 'content' => mb_substr($desc, 0, 140).'...',
+ )));
+ }
+ $page->addHeadItem(phutil_tag(
+ 'meta',
+ array(
+ 'property' => 'og:image',
+ 'content' => PhabricatorCustomLogoConfigType::getLogoURI($viewer),
+ )));
+ $page->addHeadItem(phutil_tag(
+ 'meta',
+ array(
+ 'property' => 'og:image:height',
+ 'content' => '64',
+ )));
+ $page->addHeadItem(phutil_tag(
+ 'meta',
+ array(
+ 'property' => 'og:image:width',
+ 'content' => '64',
+ )));
+ return $page;
}
private function buildHeaderView(ManiphestTask $task) {
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
@@ -378,7 +378,6 @@
/**
* Insert a HTML element into <head> of the page to render.
- * Used by PhameBlogViewController.
*
* @param PhutilSafeHTML HTML header to add
*/
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
@@ -293,35 +293,14 @@
}
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);
- }
- }
-
- if ($logo_uri) {
- $logo_style[] = 'background-size: 40px 40px;';
- $logo_style[] = 'background-position: 0 0;';
- $logo_style[] = 'background-image: url('.$logo_uri.')';
- }
+ $viewer = $this->getViewer();
+ $logo_uri = PhabricatorCustomLogoConfigType::getLogoURI($viewer);
+ $logo_style[] = 'background-size: 40px 40px;';
+ $logo_style[] = 'background-position: 0 0;';
+ $logo_style[] = 'background-image: url('.$logo_uri.')';
}
$logo_node = phutil_tag(
@@ -331,7 +310,6 @@
'style' => implode(' ', $logo_style),
));
-
$wordmark_text = PhabricatorCustomLogoConfigType::getLogoWordmark();
if (!phutil_nonempty_string($wordmark_text)) {
$wordmark_text = PlatformSymbols::getPlatformServerName();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 20:54 (17 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015590
Default Alt Text
D25668.1734641653.diff (6 KB)
Attached To
Mode
D25668: Add Open Graph protocol meta tags to Maniphest task pages
Attached
Detach File
Event Timeline
Log In to Comment