@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make basic Juypter notebook rendering improvements and roughly support folding unchanged context

Summary:
Depends on D20843. Ref T13425. Add very basic support for "Show Hidden Context", in the form of folding it behind an unclickable shield. This isn't ideal, but should be better than nothing.

Prepare for "intraline" diffs on content blocks.

Fix newline handling in Markdown sections in Jupyter notebooks.

Remove the word "visibile" from the codebase.

Test Plan: {F6898192}

Maniphest Tasks: T13425

Differential Revision: https://secure.phabricator.com/D20844

+137 -33
+3 -3
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => '3c8a0668', 11 11 'conpherence.pkg.js' => '020aebcf', 12 - 'core.pkg.css' => '19ec9519', 12 + 'core.pkg.css' => '7ce5a944', 13 13 'core.pkg.js' => '6e5c894f', 14 14 'differential.pkg.css' => '607c84be', 15 15 'differential.pkg.js' => 'a0212a0b', ··· 169 169 'rsrc/css/phui/phui-pager.css' => 'd022c7ad', 170 170 'rsrc/css/phui/phui-pinboard-view.css' => '1f08f5d8', 171 171 'rsrc/css/phui/phui-policy-section-view.css' => '139fdc64', 172 - 'rsrc/css/phui/phui-property-list-view.css' => 'ad841f1c', 172 + 'rsrc/css/phui/phui-property-list-view.css' => '807b1632', 173 173 'rsrc/css/phui/phui-remarkup-preview.css' => '91767007', 174 174 'rsrc/css/phui/phui-segment-bar-view.css' => '5166b370', 175 175 'rsrc/css/phui/phui-spacing.css' => 'b05cadc3', ··· 865 865 'phui-pager-css' => 'd022c7ad', 866 866 'phui-pinboard-view-css' => '1f08f5d8', 867 867 'phui-policy-section-view-css' => '139fdc64', 868 - 'phui-property-list-view-css' => 'ad841f1c', 868 + 'phui-property-list-view-css' => '807b1632', 869 869 'phui-remarkup-preview-css' => '91767007', 870 870 'phui-segment-bar-view-css' => '5166b370', 871 871 'phui-spacing-css' => 'b05cadc3',
+3 -3
src/applications/differential/parser/DifferentialChangesetParser.php
··· 247 247 return $this->depthOnlyLines; 248 248 } 249 249 250 - public function setVisibileLinesMask(array $mask) { 250 + public function setVisibleLinesMask(array $mask) { 251 251 $this->visible = $mask; 252 252 return $this; 253 253 } ··· 699 699 $lines_context = $this->getLinesOfContext(); 700 700 701 701 $hunk_parser->generateIntraLineDiffs(); 702 - $hunk_parser->generateVisibileLinesMask($lines_context); 702 + $hunk_parser->generateVisibleLinesMask($lines_context); 703 703 704 704 $this->setOldLines($hunk_parser->getOldLines()); 705 705 $this->setNewLines($hunk_parser->getNewLines()); 706 706 $this->setIntraLineDiffs($hunk_parser->getIntraLineDiffs()); 707 707 $this->setDepthOnlyLines($hunk_parser->getDepthOnlyLines()); 708 - $this->setVisibileLinesMask($hunk_parser->getVisibleLinesMask()); 708 + $this->setVisibleLinesMask($hunk_parser->getVisibleLinesMask()); 709 709 $this->hunkStartLines = $hunk_parser->getHunkStartLines( 710 710 $changeset->getHunks()); 711 711
+2 -2
src/applications/differential/parser/DifferentialHunkParser.php
··· 36 36 } 37 37 public function getVisibleLinesMask() { 38 38 if ($this->visibleLinesMask === null) { 39 - throw new PhutilInvalidStateException('generateVisibileLinesMask'); 39 + throw new PhutilInvalidStateException('generateVisibleLinesMask'); 40 40 } 41 41 return $this->visibleLinesMask; 42 42 } ··· 354 354 return $this; 355 355 } 356 356 357 - public function generateVisibileLinesMask($lines_context) { 357 + public function generateVisibleLinesMask($lines_context) { 358 358 $old = $this->getOldLines(); 359 359 $new = $this->getNewLines(); 360 360 $max_length = max(count($old), count($new));
+61 -4
src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
··· 372 372 $old_comments = $this->getOldComments(); 373 373 $new_comments = $this->getNewComments(); 374 374 375 + $gap_view = javelin_tag( 376 + 'tr', 377 + array( 378 + 'sigil' => 'context-target', 379 + ), 380 + phutil_tag( 381 + 'td', 382 + array( 383 + 'colspan' => 6, 384 + 'class' => 'show-more', 385 + ), 386 + pht("\xE2\x80\xA2 \xE2\x80\xA2 \xE2\x80\xA2"))); 387 + 375 388 $rows = array(); 389 + $in_gap = false; 376 390 foreach ($block_list->newTwoUpLayout() as $row) { 377 391 list($old, $new) = $row; 378 392 379 393 if ($old) { 380 - $old_content = $old->newContentView(); 381 394 $old_key = $old->getBlockKey(); 382 395 383 396 $old_classes = $old->getClasses(); ··· 390 403 $old_classes[] = 'diff-flush'; 391 404 392 405 $old_classes = implode(' ', $old_classes); 406 + 407 + $is_visible = $old->getIsVisible(); 393 408 } else { 394 - $old_content = null; 395 409 $old_key = null; 396 410 $old_classes = null; 397 411 } 398 412 399 413 if ($new) { 400 - $new_content = $new->newContentView(); 401 414 $new_key = $new->getBlockKey(); 402 415 $new_classes = $new->getClasses(); 403 416 ··· 409 422 $new_classes[] = 'diff-flush'; 410 423 411 424 $new_classes = implode(' ', $new_classes); 425 + 426 + $is_visible = $new->getIsVisible(); 412 427 } else { 413 - $new_content = null; 414 428 $new_key = null; 415 429 $new_classes = null; 430 + } 431 + 432 + if (!$is_visible) { 433 + if (!$in_gap) { 434 + $in_gap = true; 435 + $rows[] = $gap_view; 436 + } 437 + continue; 438 + } 439 + 440 + if ($in_gap) { 441 + $in_gap = false; 442 + } 443 + 444 + if ($old) { 445 + $is_rem = ($old->getDifferenceType() === '-'); 446 + } else { 447 + $is_rem = false; 448 + } 449 + 450 + if ($new) { 451 + $is_add = ($new->getDifferenceType() === '+'); 452 + } else { 453 + $is_add = false; 454 + } 455 + 456 + if ($is_rem && $is_add) { 457 + list($old_content, $new_content) = array( 458 + $old->newContentView(), 459 + $new->newContentView(), 460 + ); 461 + } else { 462 + if ($old) { 463 + $old_content = $old->newContentView(); 464 + } else { 465 + $old_content = null; 466 + } 467 + 468 + if ($new) { 469 + $new_content = $new->newContentView(); 470 + } else { 471 + $new_content = null; 472 + } 416 473 } 417 474 418 475 $old_inline_rows = array();
+10
src/applications/files/diff/PhabricatorDocumentEngineBlock.php
··· 8 8 private $classes = array(); 9 9 private $differenceHash; 10 10 private $differenceType; 11 + private $isVisible; 11 12 12 13 public function setContent($content) { 13 14 $this->content = $content; ··· 56 57 57 58 public function getDifferenceType() { 58 59 return $this->differenceType; 60 + } 61 + 62 + public function setIsVisible($is_visible) { 63 + $this->isVisible = $is_visible; 64 + return $this; 65 + } 66 + 67 + public function getIsVisible() { 68 + return $this->isVisible; 59 69 } 60 70 61 71 }
+18 -2
src/applications/files/diff/PhabricatorDocumentEngineBlocks.php
··· 52 52 ->parseHunksForLineData($changeset->getHunks()) 53 53 ->reparseHunksForSpecialAttributes(); 54 54 55 + $hunk_parser->generateVisibleLinesMask(2); 56 + $mask = $hunk_parser->getVisibleLinesMask(); 57 + 55 58 $old_lines = $hunk_parser->getOldLines(); 56 59 $new_lines = $hunk_parser->getNewLines(); 57 60 ··· 62 65 $old_line = idx($old_lines, $ii); 63 66 $new_line = idx($new_lines, $ii); 64 67 68 + $is_visible = !empty($mask[$ii + 1]); 69 + 70 + // TODO: There's currently a bug where one-line files get incorrectly 71 + // masked. This causes images to completely fail to render. Just ignore 72 + // the mask if it came back empty. 73 + if (!$mask) { 74 + $is_visible = true; 75 + } 76 + 65 77 if ($old_line) { 66 78 $old_hash = rtrim($old_line['text'], "\n"); 67 79 if (!strlen($old_hash)) { ··· 69 81 $old_block = null; 70 82 } else { 71 83 $old_block = array_shift($old_map[$old_hash]); 72 - $old_block->setDifferenceType($old_line['type']); 84 + $old_block 85 + ->setDifferenceType($old_line['type']) 86 + ->setIsVisible($is_visible); 73 87 } 74 88 } else { 75 89 $old_block = null; ··· 81 95 $new_block = null; 82 96 } else { 83 97 $new_block = array_shift($new_map[$new_hash]); 84 - $new_block->setDifferenceType($new_line['type']); 98 + $new_block 99 + ->setDifferenceType($new_line['type']) 100 + ->setIsVisible($is_visible); 85 101 } 86 102 } else { 87 103 $new_block = null;
+17 -10
src/applications/files/document/PhabricatorJupyterDocumentEngine.php
··· 307 307 return $this->newCodeOutputCell($cell); 308 308 } 309 309 310 - return $this->newRawCell(id(new PhutilJSON())->encodeFormatted($cell)); 310 + return $this->newRawCell(id(new PhutilJSON()) 311 + ->encodeFormatted($cell)); 311 312 } 312 313 313 314 private function newRawCell($content) { ··· 328 329 $content = array(); 329 330 } 330 331 331 - $content = implode('', $content); 332 - $content = phutil_escape_html_newlines($content); 332 + // TODO: This should ideally highlight as Markdown, but the "md" 333 + // highlighter in Pygments is painfully slow and not terribly useful. 334 + $content = $this->highlightLines($content, 'txt'); 333 335 334 336 return array( 335 337 null, ··· 514 516 return $label; 515 517 } 516 518 517 - private function highlightLines(array $lines) { 518 - $head = head($lines); 519 - $matches = null; 520 - if (preg_match('/^%%(.*)$/', $head, $matches)) { 521 - $restore = array_shift($lines); 522 - $lang = $matches[1]; 519 + private function highlightLines(array $lines, $force_language = null) { 520 + if ($force_language === null) { 521 + $head = head($lines); 522 + $matches = null; 523 + if (preg_match('/^%%(.*)$/', $head, $matches)) { 524 + $restore = array_shift($lines); 525 + $lang = $matches[1]; 526 + } else { 527 + $restore = null; 528 + $lang = 'py'; 529 + } 523 530 } else { 524 531 $restore = null; 525 - $lang = 'py'; 532 + $lang = $force_language; 526 533 } 527 534 528 535 $content = PhabricatorSyntaxHighlighter::highlightWithLanguage(
+9 -9
src/applications/paste/query/PhabricatorPasteQuery.php
··· 378 378 } 379 379 380 380 private function highlightSource($source, $title, $language) { 381 - if (empty($language)) { 382 - return PhabricatorSyntaxHighlighter::highlightWithFilename( 383 - $title, 384 - $source); 385 - } else { 386 - return PhabricatorSyntaxHighlighter::highlightWithLanguage( 387 - $language, 388 - $source); 389 - } 381 + if (empty($language)) { 382 + return PhabricatorSyntaxHighlighter::highlightWithFilename( 383 + $title, 384 + $source); 385 + } else { 386 + return PhabricatorSyntaxHighlighter::highlightWithLanguage( 387 + $language, 388 + $source); 389 + } 390 390 } 391 391 392 392 public function getQueryApplicationClass() {
+14
webroot/rsrc/css/phui/phui-property-list-view.css
··· 315 315 border-width: 0 1px; 316 316 } 317 317 318 + td.new .jupyter-cell-code-line { 319 + background: {$new-background}; 320 + border-color: {$new-bright}; 321 + } 322 + 323 + td.old .jupyter-cell-code-line { 324 + background: {$old-background}; 325 + border-color: {$old-bright}; 326 + } 327 + 318 328 .jupyter-cell-code-head { 319 329 border-top-width: 1px; 320 330 margin-top: 4px; ··· 364 374 .jupyter-output-html { 365 375 background: {$sh-indigobackground}; 366 376 } 377 + 378 + .jupyter-cell-markdown { 379 + white-space: pre-wrap; 380 + }