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:
Lauri-Henrik Jalonen
2013-03-13 06:44:27 -07:00
committed by epriestley
parent 9303bf50bf
commit 1341c8a6c1
5 changed files with 94 additions and 0 deletions

View File

@@ -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();
}
}

View 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));
}
}