private function buildCorpus($show_blame, $show_color, DiffusionFileContent $file_content, $needs_blame, DiffusionRequest $drequest, $path, $data)
 {
     if (!$show_color) {
         $style = 'border: none; width: 100%; height: 80em; font-family: monospace';
         if (!$show_blame) {
             $corpus = phutil_tag('textarea', array('style' => $style), $file_content->getCorpus());
         } else {
             $text_list = $file_content->getTextList();
             $rev_list = $file_content->getRevList();
             $blame_dict = $file_content->getBlameDict();
             $rows = array();
             foreach ($text_list as $k => $line) {
                 $rev = $rev_list[$k];
                 $author = $blame_dict[$rev]['author'];
                 $rows[] = sprintf('%-10s %-20s %s', substr($rev, 0, 7), $author, $line);
             }
             $corpus = phutil_tag('textarea', array('style' => $style), implode("\n", $rows));
         }
     } else {
         require_celerity_resource('syntax-highlighting-css');
         $text_list = $file_content->getTextList();
         $rev_list = $file_content->getRevList();
         $blame_dict = $file_content->getBlameDict();
         $text_list = implode("\n", $text_list);
         $text_list = PhabricatorSyntaxHighlighter::highlightWithFilename($path, $text_list);
         $text_list = explode("\n", $text_list);
         $rows = $this->buildDisplayRows($text_list, $rev_list, $blame_dict, $needs_blame, $drequest, $show_blame, $show_color);
         $corpus_table = javelin_tag('table', array('class' => 'diffusion-source remarkup-code PhabricatorMonospaced', 'sigil' => 'phabricator-source'), $rows);
         if ($this->getRequest()->isAjax()) {
             return $corpus_table;
         }
         $id = celerity_generate_unique_node_id();
         $repo = $drequest->getRepository();
         $symbol_repos = nonempty($repo->getSymbolSources(), array());
         $symbol_repos[] = $repo;
         $lang = last(explode('.', $drequest->getPath()));
         $repo_languages = $repo->getSymbolLanguages();
         $repo_languages = nonempty($repo_languages, array());
         $repo_languages = array_fill_keys($repo_languages, true);
         $needs_symbols = true;
         if ($repo_languages && $symbol_repos) {
             $have_symbols = id(new DiffusionSymbolQuery())->existsSymbolsInRepository($repo->getPHID());
             if (!$have_symbols) {
                 $needs_symbols = false;
             }
         }
         if ($needs_symbols && $repo_languages) {
             $needs_symbols = isset($repo_languages[$lang]);
         }
         if ($needs_symbols) {
             Javelin::initBehavior('repository-crossreference', array('container' => $id, 'lang' => $lang, 'repositories' => $symbol_repos));
         }
         $corpus = phutil_tag('div', array('id' => $id), $corpus_table);
         Javelin::initBehavior('load-blame', array('id' => $id));
     }
     $edit = $this->renderEditButton();
     $file = $this->renderFileButton();
     $header = id(new PHUIHeaderView())->setHeader(pht('File Contents'))->addActionLink($edit)->addActionLink($file);
     $corpus = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($corpus);
     return $corpus;
 }
 private function buildCorpus($show_blame, $show_color, DiffusionFileContent $file_content, $needs_blame, DiffusionRequest $drequest, $path, $data)
 {
     $viewer = $this->getViewer();
     $blame_timeout = 15;
     $blame_failed = false;
     $file_corpus = $file_content->getCorpus();
     $highlight_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT;
     $blame_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT;
     $can_highlight = strlen($file_corpus) <= $highlight_limit;
     $can_blame = strlen($file_corpus) <= $blame_limit;
     if ($needs_blame && $can_blame) {
         $blame = $this->loadBlame($path, $drequest->getCommit(), $blame_timeout);
         list($blame_list, $blame_commits) = $blame;
         if ($blame_list === null) {
             $blame_failed = true;
             $blame_list = array();
         }
     } else {
         $blame_list = array();
         $blame_commits = array();
     }
     if (!$show_color) {
         $corpus = $this->renderPlaintextCorpus($file_corpus, $blame_list, $blame_commits, $show_blame);
     } else {
         if ($can_highlight) {
             require_celerity_resource('syntax-highlighting-css');
             $highlighted = PhabricatorSyntaxHighlighter::highlightWithFilename($path, $file_corpus);
             $lines = phutil_split_lines($highlighted);
         } else {
             $lines = phutil_split_lines($file_corpus);
         }
         $rows = $this->buildDisplayRows($lines, $blame_list, $blame_commits, $show_blame, $show_color);
         $corpus_table = javelin_tag('table', array('class' => 'diffusion-source remarkup-code PhabricatorMonospaced', 'sigil' => 'phabricator-source'), $rows);
         if ($this->getRequest()->isAjax()) {
             return $corpus_table;
         }
         $id = celerity_generate_unique_node_id();
         $repo = $drequest->getRepository();
         $symbol_repos = nonempty($repo->getSymbolSources(), array());
         $symbol_repos[] = $repo->getPHID();
         $lang = last(explode('.', $drequest->getPath()));
         $repo_languages = $repo->getSymbolLanguages();
         $repo_languages = nonempty($repo_languages, array());
         $repo_languages = array_fill_keys($repo_languages, true);
         $needs_symbols = true;
         if ($repo_languages && $symbol_repos) {
             $have_symbols = id(new DiffusionSymbolQuery())->existsSymbolsInRepository($repo->getPHID());
             if (!$have_symbols) {
                 $needs_symbols = false;
             }
         }
         if ($needs_symbols && $repo_languages) {
             $needs_symbols = isset($repo_languages[$lang]);
         }
         if ($needs_symbols) {
             Javelin::initBehavior('repository-crossreference', array('container' => $id, 'lang' => $lang, 'repositories' => $symbol_repos));
         }
         $corpus = phutil_tag('div', array('id' => $id), $corpus_table);
         Javelin::initBehavior('load-blame', array('id' => $id));
     }
     $edit = $this->renderEditButton();
     $file = $this->renderFileButton();
     $header = id(new PHUIHeaderView())->setHeader(pht('File Contents'))->addActionLink($edit)->addActionLink($file);
     $corpus = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($corpus)->setCollapsed(true);
     $messages = array();
     if (!$can_highlight) {
         $messages[] = pht('This file is larger than %s, so syntax highlighting is disabled ' . 'by default.', phutil_format_bytes($highlight_limit));
     }
     if ($show_blame && !$can_blame) {
         $messages[] = pht('This file is larger than %s, so blame is disabled.', phutil_format_bytes($blame_limit));
     }
     if ($blame_failed) {
         $messages[] = pht('Failed to load blame information for this file in %s second(s).', new PhutilNumber($blame_timeout));
     }
     if ($messages) {
         $corpus->setInfoView(id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_WARNING)->setErrors($messages));
     }
     return $corpus;
 }