Add paste samples to list view.

Summary:
This adds a "body" field to `PhabricatorObjectItemView` which lets you optionally
add more information to the list view. It then uses this new field to show
samples of pastes in the paste list view.

Test Plan:
{F27147}

{F27148}

Reviewers: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4188
This commit is contained in:
Ricky Elrod
2012-12-16 12:02:34 -08:00
committed by epriestley
parent 4c7c518c63
commit 6f9683dc90
4 changed files with 44 additions and 25 deletions

View File

@@ -39,4 +39,31 @@ abstract class PhabricatorPasteController extends PhabricatorController {
return $crumbs;
}
public function buildSourceCodeView(
PhabricatorPaste $paste,
PhabricatorFile $file,
$max_lines = null) {
$language = $paste->getLanguage();
$source = $file->loadFileData();
if (empty($language)) {
$source = PhabricatorSyntaxHighlighter::highlightWithFilename(
$paste->getTitle(),
$source);
} else {
$source = PhabricatorSyntaxHighlighter::highlightWithLanguage(
$language,
$source);
}
$lines = explode("\n", $source);
if ($max_lines) {
$lines = array_slice($lines, 0, $max_lines);
}
return id(new PhabricatorSourceCodeView())
->setLines($lines);
}
}