Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2681473
D25668.1734642829.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.1734642829.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,45 @@
return idx($logo, 'wordmarkText');
}
+ /**
+ * Return the full URI of the Phorge logo
+ * @param PhabricatorUser Current viewer
+ * @return string Full URI of the Phorge logo
+ */
+ 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,73 @@
))
->appendChild($view);
+ if ($this->showOpenGraphMetadata($viewer, $task)) {
+ $page = $this->addOpenGraphProtocolMetadataTags($page, $task);
+ }
+
+ return $page;
+ }
+
+ /**
+ * Check if page should include Open Graph metadata tags
+ * @param PhabricatorUser $viewer Viewer of the object
+ * @param object $object
+ * @return bool
+ */
+ private function showOpenGraphMetadata(PhabricatorUser $viewer, $object) {
+ // Don't waste time adding OpenGraph metadata for logged-in users
+ if ($viewer->getIsStandardUser()) {
+ return false;
+ }
+ // Include OpenGraph tags only for public objects
+ return $object->getViewPolicy() === PhabricatorPolicies::POLICY_PUBLIC;
+ }
+
+ /**
+ * Get Open Graph Protocol metadata values
+ * @param ManiphestTask $task
+ * @return array Map of Open Graph property => value
+ */
+ private function getOpenGraphProtocolMetadataValues($task) {
+ $viewer = $this->getViewer();
+
+ $v = [];
+ $v['og:site_name'] = PlatformSymbols::getPlatformServerName();
+ $v['og:type'] = 'object';
+ $v['og:url'] = PhabricatorEnv::getProductionURI($task->getURI());
+ $v['og:title'] = $task->getMonogram().' '.$task->getTitle();
+
+ $desc = $task->getDescription();
+ if (phutil_nonempty_string($desc)) {
+ $v['og:description'] =
+ PhabricatorMarkupEngine::summarizeSentence($desc);
+ }
+
+ $v['og:image'] =
+ PhabricatorCustomLogoConfigType::getLogoURI($viewer);
+
+ $v['og:image:height'] = 64;
+ $v['og:image:width'] = 64;
+
+ return $v;
+ }
+
+ /**
+ * 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 addOpenGraphProtocolMetadataTags($page, $task) {
+ foreach ($this->getOpenGraphProtocolMetadataValues($task) as $k => $v) {
+ $page->addHeadItem(phutil_tag(
+ 'meta',
+ array(
+ 'property' => $k,
+ 'content' => $v,
+ )));
+ }
+ 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, 21:13 (17 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015628
Default Alt Text
D25668.1734642829.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