mirror of
https://we.phorge.it/source/phorge.git
synced 2025-04-12 20:38:41 +02:00
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
This commit is contained in:
parent
3c1f393c81
commit
d6928a3c26
2 changed files with 30 additions and 1 deletions
|
@ -3,6 +3,12 @@
|
||||||
final class PhabricatorPasteEditor
|
final class PhabricatorPasteEditor
|
||||||
extends PhabricatorApplicationTransactionEditor {
|
extends PhabricatorApplicationTransactionEditor {
|
||||||
|
|
||||||
|
private $newPasteTitle;
|
||||||
|
|
||||||
|
public function getNewPasteTitle() {
|
||||||
|
return $this->newPasteTitle;
|
||||||
|
}
|
||||||
|
|
||||||
public function getEditorApplicationClass() {
|
public function getEditorApplicationClass() {
|
||||||
return 'PhabricatorPasteApplication';
|
return 'PhabricatorPasteApplication';
|
||||||
}
|
}
|
||||||
|
@ -29,6 +35,22 @@ final class PhabricatorPasteEditor
|
||||||
return $types;
|
return $types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function expandTransactions(
|
||||||
|
PhabricatorLiskDAO $object,
|
||||||
|
array $xactions) {
|
||||||
|
|
||||||
|
$new_title = $object->getTitle();
|
||||||
|
foreach ($xactions as $xaction) {
|
||||||
|
$type = $xaction->getTransactionType();
|
||||||
|
if ($type === PhabricatorPasteTitleTransaction::TRANSACTIONTYPE) {
|
||||||
|
$new_title = $xaction->getNewValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->newPasteTitle = $new_title;
|
||||||
|
|
||||||
|
return parent::expandTransactions($object, $xactions);
|
||||||
|
}
|
||||||
|
|
||||||
protected function shouldSendMail(
|
protected function shouldSendMail(
|
||||||
PhabricatorLiskDAO $object,
|
PhabricatorLiskDAO $object,
|
||||||
array $xactions) {
|
array $xactions) {
|
||||||
|
|
|
@ -50,10 +50,17 @@ final class PhabricatorPasteContentTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
private function newFileForPaste(PhabricatorUser $actor, $data) {
|
private function newFileForPaste(PhabricatorUser $actor, $data) {
|
||||||
|
$editor = $this->getEditor();
|
||||||
|
|
||||||
|
$file_name = $editor->getNewPasteTitle();
|
||||||
|
if (!strlen($file_name)) {
|
||||||
|
$file_name = 'raw-paste-data.txt';
|
||||||
|
}
|
||||||
|
|
||||||
return PhabricatorFile::newFromFileData(
|
return PhabricatorFile::newFromFileData(
|
||||||
$data,
|
$data,
|
||||||
array(
|
array(
|
||||||
'name' => 'raw.txt',
|
'name' => $file_name,
|
||||||
'mime-type' => 'text/plain; charset=utf-8',
|
'mime-type' => 'text/plain; charset=utf-8',
|
||||||
'authorPHID' => $actor->getPHID(),
|
'authorPHID' => $actor->getPHID(),
|
||||||
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
|
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
|
||||||
|
|
Loading…
Add table
Reference in a new issue