Paste embeds look super cool
Summary: Make Paste embeds look super cool
Test Plan: {F35387}
Reviewers: epriestley
CC: aran, Korvin, chad, btrahan, AnhNhan
Maniphest Tasks: T1770
Differential Revision: https://secure.phabricator.com/D5323
This commit is contained in:
committed by
epriestley
parent
9303bf50bf
commit
1341c8a6c1
@@ -2644,6 +2644,15 @@ celerity_register_resource_map(array(
|
|||||||
),
|
),
|
||||||
'disk' => '/rsrc/css/application/owners/owners-path-editor.css',
|
'disk' => '/rsrc/css/application/owners/owners-path-editor.css',
|
||||||
),
|
),
|
||||||
|
'paste-css' =>
|
||||||
|
array(
|
||||||
|
'uri' => '/res/5081cf13/rsrc/css/application/paste/paste.css',
|
||||||
|
'type' => 'css',
|
||||||
|
'requires' =>
|
||||||
|
array(
|
||||||
|
),
|
||||||
|
'disk' => '/rsrc/css/application/paste/paste.css',
|
||||||
|
),
|
||||||
'path-typeahead' =>
|
'path-typeahead' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/50246fb6/rsrc/js/application/herald/PathTypeahead.js',
|
'uri' => '/res/50246fb6/rsrc/js/application/herald/PathTypeahead.js',
|
||||||
|
|||||||
@@ -637,6 +637,7 @@ phutil_register_library_map(array(
|
|||||||
'PackageDeleteMail' => 'applications/owners/mail/PackageDeleteMail.php',
|
'PackageDeleteMail' => 'applications/owners/mail/PackageDeleteMail.php',
|
||||||
'PackageMail' => 'applications/owners/mail/PackageMail.php',
|
'PackageMail' => 'applications/owners/mail/PackageMail.php',
|
||||||
'PackageModifyMail' => 'applications/owners/mail/PackageModifyMail.php',
|
'PackageModifyMail' => 'applications/owners/mail/PackageModifyMail.php',
|
||||||
|
'PasteEmbedView' => 'applications/paste/view/PasteEmbedView.php',
|
||||||
'Phabricator404Controller' => 'applications/base/controller/Phabricator404Controller.php',
|
'Phabricator404Controller' => 'applications/base/controller/Phabricator404Controller.php',
|
||||||
'PhabricatorAWSConfigOptions' => 'applications/config/option/PhabricatorAWSConfigOptions.php',
|
'PhabricatorAWSConfigOptions' => 'applications/config/option/PhabricatorAWSConfigOptions.php',
|
||||||
'PhabricatorAccessLog' => 'infrastructure/PhabricatorAccessLog.php',
|
'PhabricatorAccessLog' => 'infrastructure/PhabricatorAccessLog.php',
|
||||||
@@ -2159,6 +2160,7 @@ phutil_register_library_map(array(
|
|||||||
'PackageDeleteMail' => 'PackageMail',
|
'PackageDeleteMail' => 'PackageMail',
|
||||||
'PackageMail' => 'PhabricatorMail',
|
'PackageMail' => 'PhabricatorMail',
|
||||||
'PackageModifyMail' => 'PackageMail',
|
'PackageModifyMail' => 'PackageMail',
|
||||||
|
'PasteEmbedView' => 'AphrontView',
|
||||||
'Phabricator404Controller' => 'PhabricatorController',
|
'Phabricator404Controller' => 'PhabricatorController',
|
||||||
'PhabricatorAWSConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorAWSConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
'PhabricatorAccessLogConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorAccessLogConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
|
|||||||
@@ -16,8 +16,17 @@ final class PhabricatorPasteRemarkupRule
|
|||||||
return id(new PhabricatorPasteQuery())
|
return id(new PhabricatorPasteQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withIDs($ids)
|
->withIDs($ids)
|
||||||
|
->needContent(true)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function renderObjectEmbed($object, $handle, $options) {
|
||||||
|
$embed_paste = id(new PasteEmbedView())
|
||||||
|
->setPaste($object)
|
||||||
|
->setHandle($handle);
|
||||||
|
|
||||||
|
return $embed_paste->render();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
54
src/applications/paste/view/PasteEmbedView.php
Normal file
54
src/applications/paste/view/PasteEmbedView.php
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
final class PasteEmbedView extends AphrontView {
|
||||||
|
|
||||||
|
private $paste;
|
||||||
|
private $handle;
|
||||||
|
|
||||||
|
public function setPaste(PhabricatorPaste $paste) {
|
||||||
|
$this->paste = $paste;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHandle(PhabricatorObjectHandle $handle) {
|
||||||
|
$this->handle = $handle;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
if (!$this->paste) {
|
||||||
|
throw new Exception("Call setPaste() before render()!");
|
||||||
|
}
|
||||||
|
|
||||||
|
$lines = phutil_split_lines($this->paste->getContent());
|
||||||
|
require_celerity_resource('paste-css');
|
||||||
|
|
||||||
|
$link = phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => '/P'.$this->paste->getID()
|
||||||
|
),
|
||||||
|
$this->handle->getFullName());
|
||||||
|
|
||||||
|
$head = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'paste-embed-head'
|
||||||
|
),
|
||||||
|
$link);
|
||||||
|
|
||||||
|
$body = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(),
|
||||||
|
id(new PhabricatorSourceCodeView())
|
||||||
|
->setLines($lines));
|
||||||
|
|
||||||
|
return phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'paste-embed'
|
||||||
|
),
|
||||||
|
array($head, $body));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
20
webroot/rsrc/css/application/paste/paste.css
Normal file
20
webroot/rsrc/css/application/paste/paste.css
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* @provides paste-css
|
||||||
|
*/
|
||||||
|
|
||||||
|
.paste-embed {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 5px;
|
||||||
|
background: #f7f7f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paste-embed-head {
|
||||||
|
border-bottom: 1px solid #3d3d3d;
|
||||||
|
padding: 2px;
|
||||||
|
margin:2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paste-embed-head a {
|
||||||
|
color: #282828;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user