1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00

Add syntax highlight to diffusion.

Summary:
use XHPAST parser to parse the file, and generate a table for
the code to highlight it.  This is part of the task of "Port Diffusion's
Browse File view to Phabricator".

Test Plan:
browse file, try commit version, line number functionality.

Reviewed By: epriestley
Reviewers: epriestley
CC: epriestley
Differential Revision: 83
This commit is contained in:
jungejason 2011-03-22 19:34:47 -07:00
parent 370ba966db
commit 431552c357
9 changed files with 496 additions and 307 deletions

View file

@ -7,50 +7,41 @@
*/
celerity_register_resource_map(array(
'aphront-crumbs-view-css' =>
'phabricator-remarkup-css' =>
array(
'uri' => '/res/c666a518/rsrc/css/aphront/crumbs-view.css',
'uri' => '/res/786989c3/rsrc/css/core/remarkup.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/crumbs-view.css',
'disk' => '/rsrc/css/core/remarkup.css',
),
'aphront-dark-console-css' =>
'phabricator-core-css' =>
array(
'uri' => '/res/056b0c12/rsrc/css/aphront/dark-console.css',
'uri' => '/res/6eebb99b/rsrc/css/core/core.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/dark-console.css',
'disk' => '/rsrc/css/core/core.css',
),
'aphront-dialog-view-css' =>
'phabricator-core-buttons-css' =>
array(
'uri' => '/res/7101ab69/rsrc/css/aphront/dialog-view.css',
'uri' => '/res/53b4f712/rsrc/css/core/buttons.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/dialog-view.css',
'disk' => '/rsrc/css/core/buttons.css',
),
'aphront-error-view-css' =>
'syntax-highlighting-css' =>
array(
'uri' => '/res/19b27527/rsrc/css/aphront/error-view.css',
'uri' => '/res/fb673ece/rsrc/css/core/syntax.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/error-view.css',
),
'aphront-form-view-css' =>
array(
'uri' => '/res/472d41b4/rsrc/css/aphront/form-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/form-view.css',
'disk' => '/rsrc/css/core/syntax.css',
),
'aphront-headsup-action-list-view-css' =>
array(
@ -61,6 +52,24 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/aphront/headsup-action-list-view.css',
),
'aphront-dark-console-css' =>
array(
'uri' => '/res/056b0c12/rsrc/css/aphront/dark-console.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/dark-console.css',
),
'aphront-error-view-css' =>
array(
'uri' => '/res/19b27527/rsrc/css/aphront/error-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/error-view.css',
),
'aphront-panel-view-css' =>
array(
'uri' => '/res/63672373/rsrc/css/aphront/panel-view.css',
@ -70,14 +79,23 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/aphront/panel-view.css',
),
'aphront-request-failure-view-css' =>
'aphront-dialog-view-css' =>
array(
'uri' => '/res/97b8337a/rsrc/css/aphront/request-failure-view.css',
'uri' => '/res/7101ab69/rsrc/css/aphront/dialog-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/request-failure-view.css',
'disk' => '/rsrc/css/aphront/dialog-view.css',
),
'aphront-form-view-css' =>
array(
'uri' => '/res/472d41b4/rsrc/css/aphront/form-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/form-view.css',
),
'aphront-side-nav-view-css' =>
array(
@ -88,15 +106,6 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/aphront/side-nav-view.css',
),
'aphront-table-view-css' =>
array(
'uri' => '/res/7bf17fb8/rsrc/css/aphront/table-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/table-view.css',
),
'aphront-tokenizer-control-css' =>
array(
'uri' => '/res/a3d23074/rsrc/css/aphront/tokenizer.css',
@ -107,6 +116,24 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/aphront/tokenizer.css',
),
'aphront-crumbs-view-css' =>
array(
'uri' => '/res/c666a518/rsrc/css/aphront/crumbs-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/crumbs-view.css',
),
'aphront-request-failure-view-css' =>
array(
'uri' => '/res/97b8337a/rsrc/css/aphront/request-failure-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/request-failure-view.css',
),
'aphront-typeahead-control-css' =>
array(
'uri' => '/res/928df9f0/rsrc/css/aphront/typeahead.css',
@ -116,86 +143,14 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/aphront/typeahead.css',
),
'phabricator-standard-page-view' =>
'aphront-table-view-css' =>
array(
'uri' => '/res/0d41ea7c/rsrc/css/application/base/standard-page-view.css',
'uri' => '/res/7bf17fb8/rsrc/css/aphront/table-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/base/standard-page-view.css',
),
'differential-revision-add-comment-css' =>
array(
'uri' => '/res/aaae14d3/rsrc/css/application/differential/add-comment.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/add-comment.css',
),
'differential-changeset-view-css' =>
array(
'uri' => '/res/f26ca6f9/rsrc/css/application/differential/changeset-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/changeset-view.css',
),
'differential-core-view-css' =>
array(
'uri' => '/res/525d1a12/rsrc/css/application/differential/core.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/core.css',
),
'differential-revision-comment-list-css' =>
array(
'uri' => '/res/10b9a829/rsrc/css/application/differential/revision-comment-list.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/revision-comment-list.css',
),
'differential-revision-comment-css' =>
array(
'uri' => '/res/b271baaf/rsrc/css/application/differential/revision-comment.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/revision-comment.css',
),
'differential-revision-detail-css' =>
array(
'uri' => '/res/623e3946/rsrc/css/application/differential/revision-detail.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/revision-detail.css',
),
'differential-revision-history-css' =>
array(
'uri' => '/res/755f3da3/rsrc/css/application/differential/revision-history.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/revision-history.css',
),
'differential-table-of-contents-css' =>
array(
'uri' => '/res/e68f6f05/rsrc/css/application/differential/table-of-contents.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/table-of-contents.css',
'disk' => '/rsrc/css/aphront/table-view.css',
),
'diffusion-commit-view-css' =>
array(
@ -206,14 +161,50 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/application/diffusion/commit-view.css',
),
'phabricator-directory-css' =>
'diffusion-source-css' =>
array(
'uri' => '/res/6a000601/rsrc/css/application/directory/phabricator-directory.css',
'uri' => '/res/7f50817b/rsrc/css/application/diffusion/diffusion-source.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/directory/phabricator-directory.css',
'disk' => '/rsrc/css/application/diffusion/diffusion-source.css',
),
'phabricator-standard-page-view' =>
array(
'uri' => '/res/0d41ea7c/rsrc/css/application/base/standard-page-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/base/standard-page-view.css',
),
'maniphest-task-summary-css' =>
array(
'uri' => '/res/94d01e6f/rsrc/css/application/maniphest/task-summary.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/maniphest/task-summary.css',
),
'maniphest-transaction-detail-css' =>
array(
'uri' => '/res/9418efc9/rsrc/css/application/maniphest/transaction-detail.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/maniphest/transaction-detail.css',
),
'mainphest-task-detail-css' =>
array(
'uri' => '/res/e5f3beca/rsrc/css/application/maniphest/task-detail.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/maniphest/task-detail.css',
),
'herald-test-css' =>
array(
@ -233,32 +224,86 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/application/herald/herald.css',
),
'mainphest-task-detail-css' =>
'differential-table-of-contents-css' =>
array(
'uri' => '/res/e5f3beca/rsrc/css/application/maniphest/task-detail.css',
'uri' => '/res/e68f6f05/rsrc/css/application/differential/table-of-contents.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/maniphest/task-detail.css',
'disk' => '/rsrc/css/application/differential/table-of-contents.css',
),
'maniphest-task-summary-css' =>
'differential-revision-history-css' =>
array(
'uri' => '/res/94d01e6f/rsrc/css/application/maniphest/task-summary.css',
'uri' => '/res/755f3da3/rsrc/css/application/differential/revision-history.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/maniphest/task-summary.css',
'disk' => '/rsrc/css/application/differential/revision-history.css',
),
'maniphest-transaction-detail-css' =>
'differential-revision-add-comment-css' =>
array(
'uri' => '/res/9418efc9/rsrc/css/application/maniphest/transaction-detail.css',
'uri' => '/res/aaae14d3/rsrc/css/application/differential/add-comment.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/maniphest/transaction-detail.css',
'disk' => '/rsrc/css/application/differential/add-comment.css',
),
'differential-revision-comment-css' =>
array(
'uri' => '/res/b271baaf/rsrc/css/application/differential/revision-comment.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/revision-comment.css',
),
'differential-revision-detail-css' =>
array(
'uri' => '/res/623e3946/rsrc/css/application/differential/revision-detail.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/revision-detail.css',
),
'differential-core-view-css' =>
array(
'uri' => '/res/525d1a12/rsrc/css/application/differential/core.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/core.css',
),
'differential-revision-comment-list-css' =>
array(
'uri' => '/res/10b9a829/rsrc/css/application/differential/revision-comment-list.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/revision-comment-list.css',
),
'differential-changeset-view-css' =>
array(
'uri' => '/res/f26ca6f9/rsrc/css/application/differential/changeset-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/changeset-view.css',
),
'phabricator-directory-css' =>
array(
'uri' => '/res/6a000601/rsrc/css/application/directory/phabricator-directory.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/directory/phabricator-directory.css',
),
'phabricator-object-selector-css' =>
array(
@ -279,41 +324,97 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/application/people/profile.css',
),
'phabricator-core-buttons-css' =>
'javelin-typeahead-dev' =>
array(
'uri' => '/res/53b4f712/rsrc/css/core/buttons.css',
'type' => 'css',
'uri' => '/res/6de6ae59/rsrc/js/javelin/typeahead.dev.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/css/core/buttons.css',
'disk' => '/rsrc/js/javelin/typeahead.dev.js',
),
'phabricator-core-css' =>
'javelin-workflow-prod' =>
array(
'uri' => '/res/6eebb99b/rsrc/css/core/core.css',
'type' => 'css',
'uri' => '/res/b758e0a0/rsrc/js/javelin/workflow.min.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/css/core/core.css',
'disk' => '/rsrc/js/javelin/workflow.min.js',
),
'phabricator-remarkup-css' =>
'javelin-workflow-dev' =>
array(
'uri' => '/res/786989c3/rsrc/css/core/remarkup.css',
'type' => 'css',
'uri' => '/res/c6b17f93/rsrc/js/javelin/workflow.dev.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/css/core/remarkup.css',
'disk' => '/rsrc/js/javelin/workflow.dev.js',
),
'syntax-highlighting-css' =>
'javelin-lib-dev' =>
array(
'uri' => '/res/fb673ece/rsrc/css/core/syntax.css',
'type' => 'css',
'uri' => '/res/a0e7a5e9/rsrc/js/javelin/javelin.dev.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/css/core/syntax.css',
'disk' => '/rsrc/js/javelin/javelin.dev.js',
),
'javelin-init-prod' =>
array(
'uri' => '/res/1267c868/rsrc/js/javelin/init.min.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/init.min.js',
),
'javelin-typeahead-prod' =>
array(
'uri' => '/res/69d5fad1/rsrc/js/javelin/typeahead.min.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/typeahead.min.js',
),
'javelin-lib-prod' =>
array(
'uri' => '/res/2f2b3b2e/rsrc/js/javelin/javelin.min.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/javelin.min.js',
),
'javelin-magical-init' =>
array(
'uri' => '/res/76614f84/rsrc/js/javelin/init.dev.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/init.dev.js',
),
'javelin-behavior-diffusion-jump-to' =>
array(
'uri' => '/res/4f3f6cdc/rsrc/js/application/diffusion/behavior-jump-to.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/diffusion/behavior-jump-to.js',
),
'javelin-behavior-maniphest-transaction-controls' =>
array(
'uri' => '/res/fc6a8722/rsrc/js/application/maniphest/behavior-transaction-controls.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/maniphest/behavior-transaction-controls.js',
),
'javelin-behavior-dark-console' =>
array(
@ -324,16 +425,6 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/core/behavior-dark-console.js',
),
'javelin-behavior-phabricator-object-selector' =>
array(
'uri' => '/res/4fe735af/rsrc/js/application/core/behavior-object-selector.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/core/behavior-object-selector.js',
),
'javelin-behavior-aphront-basic-tokenizer' =>
array(
'uri' => '/res/8317d761/rsrc/js/application/core/behavior-tokenizer.js',
@ -344,6 +435,26 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/core/behavior-tokenizer.js',
),
'multirow-row-manager' =>
array(
'uri' => '/res/330d076b/rsrc/js/application/core/MultirowRowManager.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/core/MultirowRowManager.js',
),
'javelin-behavior-phabricator-object-selector' =>
array(
'uri' => '/res/4fe735af/rsrc/js/application/core/behavior-object-selector.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/core/behavior-object-selector.js',
),
'javelin-behavior-workflow' =>
array(
'uri' => '/res/15446e7e/rsrc/js/application/core/behavior-workflow.js',
@ -354,15 +465,45 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/core/behavior-workflow.js',
),
'multirow-row-manager' =>
'herald-rule-editor' =>
array(
'uri' => '/res/330d076b/rsrc/js/application/core/MultirowRowManager.js',
'uri' => '/res/8b5e9d5e/rsrc/js/application/herald/HeraldRuleEditor.js',
'type' => 'js',
'requires' =>
array(
0 => 'multirow-row-manager',
),
'disk' => '/rsrc/js/application/herald/HeraldRuleEditor.js',
),
'javelin-behavior-herald-rule-editor' =>
array(
'uri' => '/res/48108130/rsrc/js/application/herald/herald-rule-editor.js',
'type' => 'js',
'requires' =>
array(
0 => 'herald-rule-editor',
),
'disk' => '/rsrc/js/application/herald/herald-rule-editor.js',
),
'javelin-behavior-differential-diff-radios' =>
array(
'uri' => '/res/fdeb3823/rsrc/js/application/differential/behavior-diff-radios.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/core/MultirowRowManager.js',
'disk' => '/rsrc/js/application/differential/behavior-diff-radios.js',
),
'javelin-behavior-differential-show-more' =>
array(
'uri' => '/res/ea998002/rsrc/js/application/differential/behavior-show-more.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/differential/behavior-show-more.js',
),
'javelin-behavior-differential-add-reviewers' =>
array(
@ -384,15 +525,15 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/differential/behavior-comment-preview.js',
),
'javelin-behavior-differential-diff-radios' =>
'javelin-behavior-differential-populate' =>
array(
'uri' => '/res/fdeb3823/rsrc/js/application/differential/behavior-diff-radios.js',
'uri' => '/res/a13dcd7e/rsrc/js/application/differential/behavior-populate.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/differential/behavior-diff-radios.js',
'disk' => '/rsrc/js/application/differential/behavior-populate.js',
),
'javelin-behavior-differential-edit-inline-comments' =>
array(
@ -404,16 +545,6 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/differential/behavior-edit-inline-comments.js',
),
'javelin-behavior-differential-populate' =>
array(
'uri' => '/res/a13dcd7e/rsrc/js/application/differential/behavior-populate.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/differential/behavior-populate.js',
),
'javelin-behavior-differential-show-all-comments' =>
array(
'uri' => '/res/2a3592b8/rsrc/js/application/differential/behavior-show-all-comments.js',
@ -424,121 +555,6 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/differential/behavior-show-all-comments.js',
),
'javelin-behavior-differential-show-more' =>
array(
'uri' => '/res/ea998002/rsrc/js/application/differential/behavior-show-more.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/differential/behavior-show-more.js',
),
'javelin-behavior-herald-rule-editor' =>
array(
'uri' => '/res/48108130/rsrc/js/application/herald/herald-rule-editor.js',
'type' => 'js',
'requires' =>
array(
0 => 'herald-rule-editor',
1 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/herald/herald-rule-editor.js',
),
'herald-rule-editor' =>
array(
'uri' => '/res/8b5e9d5e/rsrc/js/application/herald/HeraldRuleEditor.js',
'type' => 'js',
'requires' =>
array(
0 => 'multirow-row-manager',
1 => 'javelin-lib-dev',
2 => 'javelin-typeahead-dev',
),
'disk' => '/rsrc/js/application/herald/HeraldRuleEditor.js',
),
'javelin-behavior-maniphest-transaction-controls' =>
array(
'uri' => '/res/fc6a8722/rsrc/js/application/maniphest/behavior-transaction-controls.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/maniphest/behavior-transaction-controls.js',
),
'javelin-magical-init' =>
array(
'uri' => '/res/76614f84/rsrc/js/javelin/init.dev.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/init.dev.js',
),
'javelin-init-prod' =>
array(
'uri' => '/res/1267c868/rsrc/js/javelin/init.min.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/init.min.js',
),
'javelin-lib-dev' =>
array(
'uri' => '/res/a0e7a5e9/rsrc/js/javelin/javelin.dev.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/javelin.dev.js',
),
'javelin-lib-prod' =>
array(
'uri' => '/res/2f2b3b2e/rsrc/js/javelin/javelin.min.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/javelin.min.js',
),
'javelin-typeahead-dev' =>
array(
'uri' => '/res/6de6ae59/rsrc/js/javelin/typeahead.dev.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/typeahead.dev.js',
),
'javelin-typeahead-prod' =>
array(
'uri' => '/res/69d5fad1/rsrc/js/javelin/typeahead.min.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/typeahead.min.js',
),
'javelin-workflow-dev' =>
array(
'uri' => '/res/c6b17f93/rsrc/js/javelin/workflow.dev.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/workflow.dev.js',
),
'javelin-workflow-prod' =>
array(
'uri' => '/res/b758e0a0/rsrc/js/javelin/workflow.min.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/javelin/workflow.min.js',
),
), array (
'packages' =>
array (

View file

@ -177,6 +177,7 @@ phutil_register_library_map(array(
'DiffusionSvnBrowseQuery' => 'applications/diffusion/query/browse/svn',
'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/svn',
'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/svn',
'DiffusionSvnRequest' => 'applications/diffusion/request/svn',
'DiffusionView' => 'applications/diffusion/view/base',
'HeraldAction' => 'applications/herald/storage/action',
'HeraldActionConfig' => 'applications/herald/config/action',
@ -535,6 +536,7 @@ phutil_register_library_map(array(
'DiffusionSvnBrowseQuery' => 'DiffusionBrowseQuery',
'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery',
'DiffusionSvnRequest' => 'DiffusionRequest',
'DiffusionView' => 'AphrontView',
'HeraldAction' => 'HeraldDAO',
'HeraldApplyTranscript' => 'HeraldDAO',

View file

@ -20,21 +20,18 @@ class DiffusionBrowseFileController extends DiffusionController {
public function processRequest() {
$content = array();
$content[] = $this->buildCrumbs(
array(
'branch' => true,
'path' => true,
'view' => 'browse',
));
// Build the view selection form.
$select_map = array(
//'highlighted' => 'View as Highlighted Text',
'highlighted' => 'View as Highlighted Text',
//'blame' => 'View as Highlighted Text with Blame',
'plain' => 'View as Plain Text',
//'plainblame' => 'View as Plain Text with Blame',
);
$selected = $this->getRequest()->getStr('view');
$drequest = $this->getDiffusionRequest();
$request = $this->getRequest();
$selected = $request->getStr('view');
$select = '<select name="view">';
foreach ($select_map as $k => $v) {
$option = phutil_render_tag(
@ -49,39 +46,101 @@ class DiffusionBrowseFileController extends DiffusionController {
}
$select .= '</select>';
if ($selected == 'plain') {
$style =
"margin: 1em 2em; width: 90%; height: 80em; font-family: monospace";
} else {
// default style.
$style =
"margin: 1em 2em; width: 90%; height: 80em; font-family: monospace";
}
// TODO: blame, color, line numbers, highlighting, etc etc
$view_form = phutil_render_tag(
$view_select_panel = new AphrontPanelView();
$view_select_form = phutil_render_tag(
'form',
array(
'action' => $this->getRequest()->getRequestURI(),
'action' => $request->getRequestURI(),
'method' => 'get',
'style' => 'display: inline',
),
$select.
'<button>view</button>');
$view_select_panel->appendChild($view_select_form);
$file_query = DiffusionFileContentQuery::newFromDiffusionRequest(
$this->diffusionRequest);
$file_content = $file_query->loadFileContent();
$corpus = phutil_render_tag(
'textarea',
array(
'style' => $style,
),
phutil_escape_html($file_content->getCorpus()));
// Build the content of the file.
// TODO: image
// TODO: blame.
switch ($selected) {
case 'plain':
$style =
"margin: 1em 2em; width: 90%; height: 80em; font-family: monospace";
$corpus = phutil_render_tag(
'textarea',
array(
'style' => $style,
),
phutil_escape_html($file_content->getCorpus()));
break;
$content[] = $view_form;
case 'highlighted':
default:
require_celerity_resource('syntax-highlighting-css');
require_celerity_resource('diffusion-source-css');
$path = $drequest->getPath();
$highlightEngine = new PhutilDefaultSyntaxHighlighterEngine();
$data = $highlightEngine->highlightSource($path,
$file_content->getCorpus());
$data = explode("\n", rtrim($data));
$uri_path = $request->getPath();
$uri_rev = $drequest->getCommit();
$color = null;
$rows = array();
$n = 1;
foreach ($data as $k => $line) {
if ($n == $drequest->getLine()) {
$tr = '<tr style="background: #ffff00;">';
$targ = '<a id="scroll_target"></a>';
Javelin::initBehavior('diffusion-jump-to',
array('target' => 'scroll_target'));
} else {
$tr = '<tr>';
$targ = null;
}
$l = phutil_render_tag(
'a',
array(
'href' => $uri_path.';'.$uri_rev.'$'.$n,
),
$n);
$rows[] = $tr.'<th>'.$l.'</th><td>'.$targ.$line.'</td></tr>';
++$n;
}
$corpus_table = phutil_render_tag(
'table',
array(
'class' => "diffusion-source remarkup-code",
),
implode("\n", $rows));
$corpus = phutil_render_tag(
'div',
array(
'style' => 'padding: 0pt 2em;',
),
$corpus_table);
break;
}
// Render the page.
$content = array();
$content[] = $this->buildCrumbs(
array(
'branch' => true,
'path' => true,
'view' => 'browse',
));
$content[] = $view_select_panel;
$content[] = $corpus;
$nav = $this->buildSideNav('browse', true);

View file

@ -8,8 +8,12 @@
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
phutil_require_module('phabricator', 'applications/diffusion/query/filecontent/base');
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/javelin/api');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'markup/syntax/engine/default');
phutil_require_source('DiffusionBrowseFileController.php');

View file

@ -51,6 +51,9 @@ class DiffusionRequest {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$class = 'DiffusionGitRequest';
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$class = 'DiffusionSvnRequest';
break;
default:
$class = 'DiffusionRequest';
break;

View file

@ -0,0 +1,37 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class DiffusionSvnRequest extends DiffusionRequest {
private $loadedCommit;
public function getCommit() {
if ($this->commit) {
return $this->commit;
}
if (!$this->loadedCommit) {
$this->loadedCommit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
'repositoryID = %d ORDER BY epoch DESC LIMIT 1',
$this->getRepository()->getID())->getCommitIdentifier();
}
return $this->loadedCommit;
}
}

View file

@ -0,0 +1,15 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/diffusion/request/base');
phutil_require_module('phabricator', 'applications/repository/storage/commit');
phutil_require_module('phutil', 'utils');
phutil_require_source('DiffusionSvnRequest.php');

View file

@ -0,0 +1,39 @@
/**
* @provides diffusion-source-css
*/
.diffusion-source {
margin: 1em 0 2em;
table-layout: fixed;
width: 100%;
font-family: "Monaco", Consolas, monospace;
font-size: 10px;
}
.diffusion-source th {
text-align: right;
padding: 2px 6px;
width: 44px;
vertical-align: top;
background: #eeeeee;
color: #888888;
cursor: pointer;
border-style: solid;
border-width: 0px 1px;
border-color: #eeeeee #999999 #eeeeee #dddddd;
font-weight: bold;
font-family: "Verdana";
font-size: 11px;
overflow: hidden;
}
.diffusion-source td {
letter-spacing: 0.0083334px;
vertical-align: top;
white-space: pre;
padding-bottom: 1px;
padding-left: 8px;
line-height: 16px;
overflow: hidden;
}

View file

@ -0,0 +1,14 @@
/**
* @provides javelin-behavior-diffusion-jump-to
* @requires javelin-lib-dev
*/
JX.behavior('diffusion-jump-to', function(config) {
JX.defer(
function() {
window.scrollTo(0, JX.$V(JX.$(config.target)).y - 100);
});
});