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
@@ -16,8 +16,17 @@ final class PhabricatorPasteRemarkupRule
|
||||
return id(new PhabricatorPasteQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs($ids)
|
||||
->needContent(true)
|
||||
->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));
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user