1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Improve robustnesss of feed text rendering

Summary:
Couple of minor cleanup things here:

  - Pass handles to ApplicationTransactions when rendering their stories; this happened implicitly before but doesn't now.
  - Add `?text=1` to do ad-hoc rendering of a story in text mode.
  - Make Conduit skip unrenderable stories.
  - Fix/modernize some text in the Commit story.

Test Plan: Rendered text versions of stories via Conduit and `?text=1`.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: zeeg, spicyj, epriestley

Differential Revision: https://secure.phabricator.com/D8793
This commit is contained in:
epriestley 2014-04-17 15:57:18 -07:00
parent 4a6d2e9c97
commit e49251ec98
5 changed files with 24 additions and 6 deletions

View file

@ -16,7 +16,7 @@ final class AphrontPlainTextResponse extends AphrontResponse {
public function getHeaders() {
$headers = array(
array('Content-Type', 'text/plain'),
array('Content-Type', 'text/plain; charset=utf-8'),
);
return array_merge(parent::getHeaders(), $headers);

View file

@ -95,7 +95,14 @@ final class ConduitAPI_feed_query_Method
$data = null;
$view = $story->renderView();
try {
$view = $story->renderView();
} catch (Exception $ex) {
// When stories fail to render, just fail that story.
phlog($ex);
continue;
}
$view->setEpoch($story->getEpoch());
$view->setUser($user);

View file

@ -20,6 +20,11 @@ final class PhabricatorFeedDetailController extends PhabricatorFeedController {
return new Aphront404Response();
}
if ($request->getStr('text')) {
$text = $story->renderText();
return id(new AphrontPlainTextResponse())->setContent($text);
}
$feed = array($story);
$builder = new PhabricatorFeedBuilder($feed);
$builder->setUser($user);
@ -32,7 +37,6 @@ final class PhabricatorFeedDetailController extends PhabricatorFeedController {
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title);
return $this->buildApplicationPage(
array(
$crumbs,

View file

@ -90,10 +90,16 @@ final class PhabricatorFeedStoryCommit extends PhabricatorFeedStory {
}
if ($author) {
$text = "{$committer} (authored by {$author})".
"committed {$commit_name} {$commit_uri}";
$text = pht(
'%s committed %s (authored by %s).',
$committer,
$commit_name,
$author);
} else {
$text = "{$committer} committed {$commit_name} {$commit_uri}";
$text = pht(
'%s committed %s.',
$committer,
$commit_name);
}
return $text;

View file

@ -69,6 +69,7 @@ class PhabricatorApplicationTransactionFeedStory
$old_target = $xaction->getRenderingTarget();
$new_target = PhabricatorApplicationTransaction::TARGET_TEXT;
$xaction->setRenderingTarget($new_target);
$xaction->setHandles($this->getHandles());
$text = $xaction->getTitleForFeed($this);
$xaction->setRenderingTarget($old_target);
return $text;