Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15289668
D21196.id50480.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D21196.id50480.diff
View Options
diff --git a/src/applications/console/core/DarkConsoleCore.php b/src/applications/console/core/DarkConsoleCore.php
--- a/src/applications/console/core/DarkConsoleCore.php
+++ b/src/applications/console/core/DarkConsoleCore.php
@@ -121,6 +121,8 @@
$data[$key] = $this->sanitizeForJSON($value);
}
return $data;
+ } else if (is_resource($data)) {
+ return '<resource>';
} else {
// Truncate huge strings. Since the data doesn't really matter much,
// just truncate bytes to avoid PhutilUTF8StringTruncator overhead.
diff --git a/src/applications/files/document/PhabricatorDocumentEngine.php b/src/applications/files/document/PhabricatorDocumentEngine.php
--- a/src/applications/files/document/PhabricatorDocumentEngine.php
+++ b/src/applications/files/document/PhabricatorDocumentEngine.php
@@ -281,4 +281,8 @@
));
}
+ public function shouldSuggestEngine(PhabricatorDocumentRef $ref) {
+ return false;
+ }
+
}
diff --git a/src/applications/files/document/PhabricatorJupyterDocumentEngine.php b/src/applications/files/document/PhabricatorJupyterDocumentEngine.php
--- a/src/applications/files/document/PhabricatorJupyterDocumentEngine.php
+++ b/src/applications/files/document/PhabricatorJupyterDocumentEngine.php
@@ -748,4 +748,8 @@
return $content;
}
+ public function shouldSuggestEngine(PhabricatorDocumentRef $ref) {
+ return true;
+ }
+
}
diff --git a/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php b/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
--- a/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
+++ b/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
@@ -305,6 +305,12 @@
return $crumbs;
}
+ public function getRefViewURI(
+ PhabricatorDocumentRef $ref,
+ PhabricatorDocumentEngine $engine) {
+ return $this->newRefViewURI($ref, $engine);
+ }
+
abstract protected function newRefViewURI(
PhabricatorDocumentRef $ref,
PhabricatorDocumentEngine $engine);
diff --git a/src/applications/paste/controller/PhabricatorPasteViewController.php b/src/applications/paste/controller/PhabricatorPasteViewController.php
--- a/src/applications/paste/controller/PhabricatorPasteViewController.php
+++ b/src/applications/paste/controller/PhabricatorPasteViewController.php
@@ -51,16 +51,19 @@
$timeline->setQuoteRef($monogram);
$comment_view->setTransactionTimeline($timeline);
+ $recommendation_view = $this->newDocumentRecommendationView($paste);
+
$paste_view = id(new PHUITwoColumnView())
->setHeader($header)
->setSubheader($subheader)
- ->setMainColumn(array(
+ ->setMainColumn(
+ array(
+ $recommendation_view,
$source_code,
$timeline,
$comment_view,
))
- ->setCurtain($curtain)
- ->addClass('ponder-question-view');
+ ->setCurtain($curtain);
return $this->newPage()
->setTitle($paste->getFullName())
@@ -170,4 +173,58 @@
->setContent($content);
}
+ private function newDocumentRecommendationView(PhabricatorPaste $paste) {
+ $viewer = $this->getViewer();
+
+ // See PHI1703. If a viewer is looking at a document in Paste which has
+ // a good rendering via a DocumentEngine, suggest they view the content
+ // in Files instead so they can see it rendered.
+
+ $ref = id(new PhabricatorDocumentRef())
+ ->setName($paste->getTitle())
+ ->setData($paste->getRawContent());
+
+ $engines = PhabricatorDocumentEngine::getEnginesForRef($viewer, $ref);
+ if (!$engines) {
+ return null;
+ }
+
+ $engine = head($engines);
+ if (!$engine->shouldSuggestEngine($ref)) {
+ return null;
+ }
+
+ $file = id(new PhabricatorFileQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($paste->getFilePHID()))
+ ->executeOne();
+ if (!$file) {
+ return null;
+ }
+
+ $file_ref = id(new PhabricatorDocumentRef())
+ ->setFile($file);
+
+ $view_uri = id(new PhabricatorFileDocumentRenderingEngine())
+ ->getRefViewURI($file_ref, $engine);
+
+ $view_as_label = $engine->getViewAsLabel($file_ref);
+
+ $view_as_hint = pht(
+ 'This content can be rendered as a document in Files.');
+
+ return id(new PHUIInfoView())
+ ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
+ ->addButton(
+ id(new PHUIButtonView())
+ ->setTag('a')
+ ->setText($view_as_label)
+ ->setHref($view_uri)
+ ->setColor('grey'))
+ ->setErrors(
+ array(
+ $view_as_hint,
+ ));
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 5, 10:10 PM (13 h, 36 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7227604
Default Alt Text
D21196.id50480.diff (4 KB)
Attached To
Mode
D21196: When a Paste has a useful alternative rendering in Files, provide a hint
Attached
Detach File
Event Timeline
Log In to Comment