@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.

Allow the Jupyter engine to elect to emit diffs, and emit Jupyter documents as blocks

Summary:
Depends on D20832. Ref T13425. Emit Jupyter notebooks as diffable blocks with block keys.

No diffing or proper inlines yet.

Test Plan: {F6888058}

Maniphest Tasks: T13425

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

+189 -83
+9 -9
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => '3c8a0668', 11 11 'conpherence.pkg.js' => '020aebcf', 12 - 'core.pkg.css' => 'c69171e6', 12 + 'core.pkg.css' => '6a8c9533', 13 13 'core.pkg.js' => '6e5c894f', 14 - 'differential.pkg.css' => 'eef74643', 14 + 'differential.pkg.css' => 'ce54994e', 15 15 'differential.pkg.js' => '49515551', 16 16 'diffusion.pkg.css' => '42c75c37', 17 17 'diffusion.pkg.js' => 'a98c0bf7', ··· 61 61 'rsrc/css/application/dashboard/dashboard.css' => '5a205b9d', 62 62 'rsrc/css/application/diff/inline-comment-summary.css' => '81eb368d', 63 63 'rsrc/css/application/differential/add-comment.css' => '7e5900d9', 64 - 'rsrc/css/application/differential/changeset-view.css' => '215129ef', 64 + 'rsrc/css/application/differential/changeset-view.css' => 'db306b82', 65 65 'rsrc/css/application/differential/core.css' => '7300a73e', 66 66 'rsrc/css/application/differential/phui-inline-comment.css' => '48acce5b', 67 67 'rsrc/css/application/differential/revision-comment.css' => '7dbc8d1d', ··· 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' => 'cad62236', 172 + 'rsrc/css/phui/phui-property-list-view.css' => '34180764', 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', ··· 554 554 'conpherence-thread-manager' => 'aec8e38c', 555 555 'conpherence-transaction-css' => '3a3f5e7e', 556 556 'd3' => '9d068042', 557 - 'differential-changeset-view-css' => '215129ef', 557 + 'differential-changeset-view-css' => 'db306b82', 558 558 'differential-core-view-css' => '7300a73e', 559 559 'differential-revision-add-comment-css' => '7e5900d9', 560 560 'differential-revision-comment-css' => '7dbc8d1d', ··· 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' => 'cad62236', 868 + 'phui-property-list-view-css' => '34180764', 869 869 'phui-remarkup-preview-css' => '91767007', 870 870 'phui-segment-bar-view-css' => '5166b370', 871 871 'phui-spacing-css' => 'b05cadc3', ··· 1064 1064 '202bfa3f' => array( 1065 1065 'javelin-behavior', 1066 1066 'javelin-request', 1067 - ), 1068 - '215129ef' => array( 1069 - 'phui-inline-comment-view-css', 1070 1067 ), 1071 1068 '225bbb98' => array( 1072 1069 'javelin-install', ··· 2071 2068 'javelin-behavior', 2072 2069 'javelin-uri', 2073 2070 'phabricator-notification', 2071 + ), 2072 + 'db306b82' => array( 2073 + 'phui-inline-comment-view-css', 2074 2074 ), 2075 2075 'dfa1d313' => array( 2076 2076 'javelin-behavior',
+1 -1
src/applications/differential/parser/DifferentialChangesetParser.php
··· 1693 1693 $new_data = ipull($new_data, 'text'); 1694 1694 $new_data = implode('', $new_data); 1695 1695 1696 - $new_ref->setData($old_data); 1696 + $new_ref->setData($new_data); 1697 1697 } 1698 1698 1699 1699 $old_engines = PhabricatorDocumentEngine::getEnginesForRef(
+1 -1
src/applications/differential/render/DifferentialChangesetOneUpRenderer.php
··· 241 241 $primitives[] = array( 242 242 'type' => 'old-file', 243 243 'htype' => '', 244 - 'line' => 1, 244 + 'line' => $block->getBlockKey(), 245 245 'render' => $block->newContentView(), 246 246 ); 247 247 }
+94 -68
src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
··· 369 369 $old_changeset_key, 370 370 $new_changeset_key) { 371 371 372 - $old_view = null; 373 - $new_view = null; 372 + $old_comments = $this->getOldComments(); 373 + $new_comments = $this->getNewComments(); 374 374 375 + $rows = array(); 375 376 foreach ($block_list->newTwoUpLayout() as $row) { 376 377 list($old, $new) = $row; 377 378 378 379 if ($old) { 379 - $old_view = $old->newContentView(); 380 + $old_content = $old->newContentView(); 381 + $old_key = $old->getBlockKey(); 382 + $old_classes = implode(' ', $old->getClasses()); 380 383 } else { 381 - $old_view = null; 384 + $old_content = null; 385 + $old_key = null; 386 + $old_classes = null; 382 387 } 383 388 384 389 if ($new) { 385 - $new_view = $new->newContentView(); 390 + $new_content = $new->newContentView(); 391 + $new_key = $new->getBlockKey(); 392 + $new_classes = implode(' ', $new->getClasses()); 386 393 } else { 387 - $new_view = null; 394 + $new_content = null; 395 + $new_key = null; 396 + $new_classes = null; 388 397 } 389 - } 390 398 391 - $html_old = array(); 392 - $html_new = array(); 393 - foreach ($this->getOldComments() as $on_line => $comment_group) { 394 - foreach ($comment_group as $comment) { 395 - $inline = $this->buildInlineComment( 396 - $comment, 397 - $on_right = false); 398 - $html_old[] = $this->getRowScaffoldForInline($inline); 399 + $old_inline_rows = array(); 400 + if ($old_key !== null) { 401 + $old_inlines = idx($old_comments, $old_key, array()); 402 + foreach ($old_inlines as $inline) { 403 + $inline = $this->buildInlineComment( 404 + $inline, 405 + $on_right = false); 406 + $old_inline_rows[] = $this->getRowScaffoldForInline($inline); 407 + } 399 408 } 400 - } 401 - foreach ($this->getNewComments() as $lin_line => $comment_group) { 402 - foreach ($comment_group as $comment) { 403 - $inline = $this->buildInlineComment( 404 - $comment, 405 - $on_right = true); 406 - $html_new[] = $this->getRowScaffoldForInline($inline); 409 + 410 + $new_inline_rows = array(); 411 + if ($new_key !== null) { 412 + $new_inlines = idx($new_comments, $new_key, array()); 413 + foreach ($new_inlines as $inline) { 414 + $inline = $this->buildInlineComment( 415 + $inline, 416 + $on_right = true); 417 + $new_inline_rows[] = $this->getRowScaffoldForInline($inline); 418 + } 407 419 } 408 - } 409 420 410 - if ($old_view === null) { 411 - $old_id = null; 412 - $old_label = null; 413 - } else { 414 - $old_id = "C{$old_changeset_key}OL1"; 415 - $old_label = '1'; 416 - } 421 + if ($old_content === null) { 422 + $old_id = null; 423 + $old_label = null; 424 + } else { 425 + $old_id = "C{$old_changeset_key}OL{$old_key}"; 426 + $old_label = $old_key; 427 + } 417 428 418 - $old_cell = phutil_tag( 419 - 'td', 420 - array( 421 - 'id' => $old_id, 422 - 'class' => 'n', 423 - ), 424 - $old_label); 429 + $old_line_cell = phutil_tag( 430 + 'td', 431 + array( 432 + 'id' => $old_id, 433 + 'class' => 'n', 434 + ), 435 + $old_label); 425 436 426 - if ($new_view === null) { 427 - $new_id = null; 428 - $new_label = null; 429 - } else { 430 - $new_id = "C{$new_changeset_key}NL1"; 431 - $new_label = '1'; 432 - } 437 + $old_content_cell = phutil_tag( 438 + 'td', 439 + array( 440 + 'class' => $old_classes, 441 + ), 442 + $old_content); 443 + 444 + if ($new_content === null) { 445 + $new_id = null; 446 + $new_label = null; 447 + } else { 448 + $new_id = "C{$new_changeset_key}NL{$new_key}"; 449 + $new_label = $new_key; 450 + } 451 + 452 + $new_line_cell = phutil_tag( 453 + 'td', 454 + array( 455 + 'id' => $new_id, 456 + 'class' => 'n', 457 + ), 458 + $new_label); 459 + 460 + $new_content_cell = phutil_tag( 461 + 'td', 462 + array( 463 + 'class' => $new_classes, 464 + 'colspan' => '3', 465 + ), 466 + $new_content); 433 467 434 - $new_cell = phutil_tag( 435 - 'td', 436 - array( 437 - 'id' => $new_id, 438 - 'class' => 'n', 439 - ), 440 - $new_label); 468 + $row_view = phutil_tag( 469 + 'tr', 470 + array(), 471 + array( 472 + $old_line_cell, 473 + $old_content_cell, 474 + $new_line_cell, 475 + $new_content_cell, 476 + )); 441 477 442 - $output = hsprintf( 443 - '<tr class="differential-image-diff">'. 444 - '%s'. 445 - '<td class="differential-old-image diff-image-cell">%s</td>'. 446 - '%s'. 447 - '<td class="differential-new-image diff-image-cell" '. 448 - 'colspan="3">%s</td>'. 449 - '</tr>'. 450 - '%s'. 451 - '%s', 452 - $old_cell, 453 - $old_view, 454 - $new_cell, 455 - $new_view, 456 - phutil_implode_html('', $html_old), 457 - phutil_implode_html('', $html_new)); 478 + $rows[] = array( 479 + $row_view, 480 + $old_inline_rows, 481 + $new_inline_rows, 482 + ); 483 + } 458 484 459 - $output = $this->wrapChangeInTable($output); 485 + $output = $this->wrapChangeInTable($rows); 460 486 461 487 return $this->renderChangesetTable($output); 462 488 }
+20
src/applications/files/diff/PhabricatorDocumentEngineBlock.php
··· 3 3 final class PhabricatorDocumentEngineBlock 4 4 extends Phobject { 5 5 6 + private $blockKey; 6 7 private $content; 8 + private $classes = array(); 7 9 8 10 public function setContent($content) { 9 11 $this->content = $content; ··· 16 18 17 19 public function newContentView() { 18 20 return $this->getContent(); 21 + } 22 + 23 + public function setBlockKey($block_key) { 24 + $this->blockKey = $block_key; 25 + return $this; 26 + } 27 + 28 + public function getBlockKey() { 29 + return $this->blockKey; 30 + } 31 + 32 + public function addClass($class) { 33 + $this->classes[] = $class; 34 + return $this; 35 + } 36 + 37 + public function getClasses() { 38 + return $this->classes; 19 39 } 20 40 21 41 }
+2
src/applications/files/document/PhabricatorImageDocumentEngine.php
··· 56 56 ))); 57 57 58 58 $blocks[] = id(new PhabricatorDocumentEngineBlock()) 59 + ->setBlockKey('1') 60 + ->addClass('diff-image-cell') 59 61 ->setContent($image_view); 60 62 61 63 return $blocks;
+57
src/applications/files/document/PhabricatorJupyterDocumentEngine.php
··· 35 35 return $ref->isProbablyJSON(); 36 36 } 37 37 38 + public function canDiffDocuments( 39 + PhabricatorDocumentRef $uref, 40 + PhabricatorDocumentRef $vref) { 41 + return true; 42 + } 43 + 44 + public function newDiffView( 45 + PhabricatorDocumentRef $uref, 46 + PhabricatorDocumentRef $vref) { 47 + 48 + $u_blocks = $this->newDiffBlocks($uref); 49 + $v_blocks = $this->newDiffBlocks($vref); 50 + 51 + return id(new PhabricatorDocumentEngineBlocks()) 52 + ->addBlockList($uref, $u_blocks) 53 + ->addBlockList($vref, $v_blocks); 54 + } 55 + 56 + private function newDiffBlocks(PhabricatorDocumentRef $ref) { 57 + $viewer = $this->getViewer(); 58 + $content = $ref->loadData(); 59 + 60 + $data = phutil_json_decode($content); 61 + $cells = idx($data, 'cells'); 62 + if (!is_array($cells)) { 63 + throw new Exception('Missing "cells".'); 64 + } 65 + 66 + $idx = 1; 67 + $blocks = array(); 68 + foreach ($cells as $cell) { 69 + $cell_content = $this->renderJupyterCell($viewer, $cell); 70 + 71 + $notebook_table = phutil_tag( 72 + 'table', 73 + array( 74 + 'class' => 'jupyter-notebook', 75 + ), 76 + $cell_content); 77 + 78 + $container = phutil_tag( 79 + 'div', 80 + array( 81 + 'class' => 'document-engine-jupyter document-engine-diff', 82 + ), 83 + $notebook_table); 84 + 85 + $blocks[] = id(new PhabricatorDocumentEngineBlock()) 86 + ->setBlockKey($idx) 87 + ->setContent($container); 88 + 89 + $idx++; 90 + } 91 + 92 + return $blocks; 93 + } 94 + 38 95 protected function newDocumentContent(PhabricatorDocumentRef $ref) { 39 96 $viewer = $this->getViewer(); 40 97 $content = $ref->loadData();
+1 -4
webroot/rsrc/css/application/differential/changeset-view.css
··· 284 284 285 285 .differential-diff .diff-image-cell { 286 286 background-image: url(/rsrc/image/checker_light.png); 287 + padding: 8px; 287 288 } 288 289 289 290 .device-desktop .differential-diff .diff-image-cell:hover { 290 291 background-image: url(/rsrc/image/checker_dark.png); 291 - } 292 - 293 - .differential-diff .differential-image-diff td { 294 - padding: 8px; 295 292 } 296 293 297 294 .differential-image-stage {
+4
webroot/rsrc/css/phui/phui-property-list-view.css
··· 268 268 margin: 20px; 269 269 } 270 270 271 + .document-engine-jupyter.document-engine-diff { 272 + margin: 0; 273 + } 274 + 271 275 .document-engine-in-flight { 272 276 opacity: 0.25; 273 277 }