@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.

When creating a File storage object for a Paste, try to give it the same name as the Paste

Summary:
Ref T13528. Paste data is stored in files, but the files are always named "raw.txt".

Now that Paste provides a hint to use Files for "DocumentEngine" rendering, try to use the same name as the paste instead.

Test Plan:
- Created a paste named "staggering-insight.ipynb".
- Clicked "View as Jupyter Notebook" from Paste.
- Saw a file named "staggering-insight.ipynb", not "raw.txt".
- Created a paste with no name, saw a file named "raw-paste-data.txt" get created.

Maniphest Tasks: T13528

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

+30 -1
+22
src/applications/paste/editor/PhabricatorPasteEditor.php
··· 3 3 final class PhabricatorPasteEditor 4 4 extends PhabricatorApplicationTransactionEditor { 5 5 6 + private $newPasteTitle; 7 + 8 + public function getNewPasteTitle() { 9 + return $this->newPasteTitle; 10 + } 11 + 6 12 public function getEditorApplicationClass() { 7 13 return 'PhabricatorPasteApplication'; 8 14 } ··· 27 33 $types[] = PhabricatorTransactions::TYPE_COMMENT; 28 34 29 35 return $types; 36 + } 37 + 38 + protected function expandTransactions( 39 + PhabricatorLiskDAO $object, 40 + array $xactions) { 41 + 42 + $new_title = $object->getTitle(); 43 + foreach ($xactions as $xaction) { 44 + $type = $xaction->getTransactionType(); 45 + if ($type === PhabricatorPasteTitleTransaction::TRANSACTIONTYPE) { 46 + $new_title = $xaction->getNewValue(); 47 + } 48 + } 49 + $this->newPasteTitle = $new_title; 50 + 51 + return parent::expandTransactions($object, $xactions); 30 52 } 31 53 32 54 protected function shouldSendMail(
+8 -1
src/applications/paste/xaction/PhabricatorPasteContentTransaction.php
··· 50 50 } 51 51 52 52 private function newFileForPaste(PhabricatorUser $actor, $data) { 53 + $editor = $this->getEditor(); 54 + 55 + $file_name = $editor->getNewPasteTitle(); 56 + if (!strlen($file_name)) { 57 + $file_name = 'raw-paste-data.txt'; 58 + } 59 + 53 60 return PhabricatorFile::newFromFileData( 54 61 $data, 55 62 array( 56 - 'name' => 'raw.txt', 63 + 'name' => $file_name, 57 64 'mime-type' => 'text/plain; charset=utf-8', 58 65 'authorPHID' => $actor->getPHID(), 59 66 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,