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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user