From 16ad2386d8e61f05287e983320daae267620a5fc Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 25 Jan 2011 11:57:47 -0800 Subject: [PATCH] Javelin integration. --- src/__celerity_resource_map__.php | 36 +++-- src/__phutil_library_map__.php | 7 + ...AphrontDefaultApplicationConfiguration.php | 2 +- .../response/ajax/AphrontAjaxResponse.php | 45 ++++++ src/aphront/response/ajax/__init__.php | 13 ++ .../DifferentialChangesetViewController.php | 14 +- .../controller/changesetview/__init__.php | 3 +- .../DifferentialDiffViewController.php | 2 +- .../controller/diffview/__init__.php | 1 + .../DifferentialChangesetDetailView.php | 130 ++++-------------- .../view/changesetdetailview/__init__.php | 4 +- .../DifferentialChangesetListView.php | 126 +++++++++++++++++ .../view/changesetlistview/__init__.php | 19 +++ .../DifferentialDiffTableOfContentsView.php | 1 + .../view/difftableofcontents/__init__.php | 1 + .../celerity/api/CelerityAPI.php | 9 ++ .../CelerityStaticResourceResponse.php | 84 ++++++++++- src/infratructure/javelin/api/Javelin.php | 24 ++++ src/infratructure/javelin/api/__init__.php | 12 ++ src/infratructure/javelin/markup/__init__.php | 14 ++ src/infratructure/javelin/markup/markup.php | 55 ++++++++ .../standard/PhabricatorStandardPageView.php | 6 +- webroot/rsrc/css/core/syntax.css | 122 ++++++++++++++++ .../differential/behavior-populate.js | 22 +++ 24 files changed, 630 insertions(+), 122 deletions(-) create mode 100644 src/aphront/response/ajax/AphrontAjaxResponse.php create mode 100644 src/aphront/response/ajax/__init__.php create mode 100644 src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php create mode 100644 src/applications/differential/view/changesetlistview/__init__.php create mode 100644 src/infratructure/javelin/api/Javelin.php create mode 100644 src/infratructure/javelin/api/__init__.php create mode 100644 src/infratructure/javelin/markup/__init__.php create mode 100644 src/infratructure/javelin/markup/markup.php create mode 100644 webroot/rsrc/css/core/syntax.css create mode 100644 webroot/rsrc/js/application/differential/behavior-populate.js diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index fb8ecbb0c1..07f979a06f 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -9,7 +9,7 @@ celerity_register_resource_map(array( 'aphront-dialog-view-css' => array( - 'path' => '/res/2ef90210/rsrc/css/aphront/dialog-view.css', + 'path' => '/res/771b987d/rsrc/css/aphront/dialog-view.css', 'type' => 'css', 'requires' => array( @@ -17,7 +17,7 @@ celerity_register_resource_map(array( ), 'aphront-form-view-css' => array( - 'path' => '/res/517031e5/rsrc/css/aphront/form-view.css', + 'path' => '/res/20ebc99b/rsrc/css/aphront/form-view.css', 'type' => 'css', 'requires' => array( @@ -25,7 +25,7 @@ celerity_register_resource_map(array( ), 'aphront-panel-view-css' => array( - 'path' => '/res/d96d5826/rsrc/css/aphront/panel-view.css', + 'path' => '/res/d1ce0c3d/rsrc/css/aphront/panel-view.css', 'type' => 'css', 'requires' => array( @@ -33,7 +33,7 @@ celerity_register_resource_map(array( ), 'aphront-side-nav-view-css' => array( - 'path' => '/res/89b99d7d/rsrc/css/aphront/side-nav-view.css', + 'path' => '/res/1a16f19a/rsrc/css/aphront/side-nav-view.css', 'type' => 'css', 'requires' => array( @@ -41,7 +41,7 @@ celerity_register_resource_map(array( ), 'aphront-table-view-css' => array( - 'path' => '/res/639b3af2/rsrc/css/aphront/table-view.css', + 'path' => '/res/52b0191f/rsrc/css/aphront/table-view.css', 'type' => 'css', 'requires' => array( @@ -49,7 +49,7 @@ celerity_register_resource_map(array( ), 'phabricator-standard-page-view' => array( - 'path' => '/res/f1a74aa4/rsrc/css/application/base/standard-page-view.css', + 'path' => '/res/0eef6905/rsrc/css/application/base/standard-page-view.css', 'type' => 'css', 'requires' => array( @@ -57,7 +57,7 @@ celerity_register_resource_map(array( ), 'differential-changeset-view-css' => array( - 'path' => '/res/08a5c816/rsrc/css/application/differential/changeset-view.css', + 'path' => '/res/921d3a0c/rsrc/css/application/differential/changeset-view.css', 'type' => 'css', 'requires' => array( @@ -73,7 +73,7 @@ celerity_register_resource_map(array( ), 'differential-table-of-contents-css' => array( - 'path' => '/res/cd5c966d/rsrc/css/application/differential/table-of-contents.css', + 'path' => '/res/ebf6641c/rsrc/css/application/differential/table-of-contents.css', 'type' => 'css', 'requires' => array( @@ -81,7 +81,7 @@ celerity_register_resource_map(array( ), 'phabricator-directory-css' => array( - 'path' => '/res/795c7b4e/rsrc/css/application/directory/phabricator-directory.css', + 'path' => '/res/6a000601/rsrc/css/application/directory/phabricator-directory.css', 'type' => 'css', 'requires' => array( @@ -89,7 +89,7 @@ celerity_register_resource_map(array( ), 'phabricator-core-buttons-css' => array( - 'path' => '/res/5f44fe89/rsrc/css/core/buttons.css', + 'path' => '/res/6e348ba4/rsrc/css/core/buttons.css', 'type' => 'css', 'requires' => array( @@ -103,6 +103,22 @@ celerity_register_resource_map(array( array( ), ), + 'syntax-highlighting-css' => + array( + 'path' => '/res/fb673ece/rsrc/css/core/syntax.css', + 'type' => 'css', + 'requires' => + array( + ), + ), + 'javelin-behavior-differential-populate' => + array( + 'path' => '/res/b419291a/rsrc/js/application/differential/behavior-populate.js', + 'type' => 'js', + 'requires' => + array( + ), + ), 'javelin-init-dev' => array( 'path' => '/res/c57a9e89/rsrc/js/javelin/init.dev.js', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index e663af492f..a413bd6734 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -9,6 +9,7 @@ phutil_register_library_map(array( 'class' => array( 'Aphront404Response' => 'aphront/response/404', + 'AphrontAjaxResponse' => 'aphront/response/ajax', 'AphrontApplicationConfiguration' => 'aphront/applicationconfiguration', 'AphrontController' => 'aphront/controller', 'AphrontDatabaseConnection' => 'storage/connection/base', @@ -62,6 +63,7 @@ phutil_register_library_map(array( 'DifferentialChangeType' => 'applications/differential/constants/changetype', 'DifferentialChangeset' => 'applications/differential/storage/changeset', 'DifferentialChangesetDetailView' => 'applications/differential/view/changesetdetailview', + 'DifferentialChangesetListView' => 'applications/differential/view/changesetlistview', 'DifferentialChangesetParser' => 'applications/differential/parser/changeset', 'DifferentialChangesetViewController' => 'applications/differential/controller/changesetview', 'DifferentialController' => 'applications/differential/controller/base', @@ -76,6 +78,7 @@ phutil_register_library_map(array( 'DifferentialRevisionControlSystem' => 'applications/differential/constants/revisioncontrolsystem', 'DifferentialRevisionStatus' => 'applications/differential/constants/revisionstatus', 'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus', + 'Javelin' => 'infratructure/javelin/api', 'LiskDAO' => 'storage/lisk/dao', 'PhabricatorConduitAPIController' => 'applications/conduit/controller/api', 'PhabricatorConduitConnectionLog' => 'applications/conduit/storage/connectionlog', @@ -125,7 +128,9 @@ phutil_register_library_map(array( array( '_qsprintf_check_scalar_type' => 'storage/qsprintf', '_qsprintf_check_type' => 'storage/qsprintf', + 'celerity_gen_unique_node_id' => 'infratructure/celerity/api', 'celerity_register_resource_map' => 'infratructure/celerity/map', + 'javelin_render_tag' => 'infratructure/javelin/markup', 'qsprintf' => 'storage/qsprintf', 'queryfx' => 'storage/queryfx', 'queryfx_all' => 'storage/queryfx', @@ -138,6 +143,7 @@ phutil_register_library_map(array( 'requires_class' => array( 'Aphront404Response' => 'AphrontResponse', + 'AphrontAjaxResponse' => 'AphrontResponse', 'AphrontDefaultApplicationConfiguration' => 'AphrontApplicationConfiguration', 'AphrontDefaultApplicationController' => 'AphrontController', 'AphrontDialogResponse' => 'AphrontResponse', @@ -175,6 +181,7 @@ phutil_register_library_map(array( 'ConduitAPI_user_find_Method' => 'ConduitAPIMethod', 'DifferentialChangeset' => 'DifferentialDAO', 'DifferentialChangesetDetailView' => 'AphrontView', + 'DifferentialChangesetListView' => 'AphrontView', 'DifferentialChangesetViewController' => 'DifferentialController', 'DifferentialController' => 'PhabricatorController', 'DifferentialDAO' => 'PhabricatorLiskDAO', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index d6f7168334..67f624a94f 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -82,7 +82,7 @@ class AphrontDefaultApplicationConfiguration ), '/res/' => array( - '(?[a-f0-9]{8})/(?[^.]+\.(?:css|js))$' + '(?[a-f0-9]{8})/(?.+\.(?:css|js))$' => 'CelerityResourceController', ), diff --git a/src/aphront/response/ajax/AphrontAjaxResponse.php b/src/aphront/response/ajax/AphrontAjaxResponse.php new file mode 100644 index 0000000000..959e2cfc1d --- /dev/null +++ b/src/aphront/response/ajax/AphrontAjaxResponse.php @@ -0,0 +1,45 @@ +content = $content; + return $this; + } + + public function buildResponseString() { + $response = CelerityAPI::getStaticResourceResponse(); + return $response->renderAjaxResponse( + $this->content, + $this->error); + } + + public function getHeaders() { + return array( + array('Content-Type', 'text/plain; charset=UTF-8'), + ); + } + +} diff --git a/src/aphront/response/ajax/__init__.php b/src/aphront/response/ajax/__init__.php new file mode 100644 index 0000000000..c0dd276bb7 --- /dev/null +++ b/src/aphront/response/ajax/__init__.php @@ -0,0 +1,13 @@ +render(); + $request = $this->getRequest(); + if ($request->isAjax()) { + return id(new AphrontAjaxResponse()) + ->setContent($output); + } + + $detail = new DifferentialChangesetDetailView(); + $detail->setChangeset($changeset); + $detail->appendChild($output); + // TODO: This is a bit of a hacky mess. $output = '
'. '
'. '
'. - '

'.phutil_escape_html($changeset->getDisplayFilename()).'

'. - '
'. - $output. + $detail->render(). '
'. '
'. '
'; diff --git a/src/applications/differential/controller/changesetview/__init__.php b/src/applications/differential/controller/changesetview/__init__.php index 8090d629af..f872d3acbd 100644 --- a/src/applications/differential/controller/changesetview/__init__.php +++ b/src/applications/differential/controller/changesetview/__init__.php @@ -7,11 +7,12 @@ phutil_require_module('phabricator', 'aphront/response/404'); +phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'applications/differential/controller/base'); phutil_require_module('phabricator', 'applications/differential/parser/changeset'); phutil_require_module('phabricator', 'applications/differential/storage/changeset'); +phutil_require_module('phabricator', 'applications/differential/view/changesetdetailview'); -phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/differential/controller/diffview/DifferentialDiffViewController.php b/src/applications/differential/controller/diffview/DifferentialDiffViewController.php index a146528ca4..58fefe64a9 100644 --- a/src/applications/differential/controller/diffview/DifferentialDiffViewController.php +++ b/src/applications/differential/controller/diffview/DifferentialDiffViewController.php @@ -36,7 +36,7 @@ class DifferentialDiffViewController extends DifferentialController { $table_of_contents = id(new DifferentialDiffTableOfContentsView()) ->setChangesets($changesets); - $details = id(new DifferentialChangesetDetailView()) + $details = id(new DifferentialChangesetListView()) ->setChangesets($changesets); return $this->buildStandardPageResponse( diff --git a/src/applications/differential/controller/diffview/__init__.php b/src/applications/differential/controller/diffview/__init__.php index 5a2715daa8..7303dd9ed7 100644 --- a/src/applications/differential/controller/diffview/__init__.php +++ b/src/applications/differential/controller/diffview/__init__.php @@ -9,6 +9,7 @@ phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'applications/differential/controller/base'); phutil_require_module('phabricator', 'applications/differential/storage/diff'); +phutil_require_module('phabricator', 'applications/differential/view/changesetlistview'); phutil_require_module('phabricator', 'applications/differential/view/difftableofcontents'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/differential/view/changesetdetailview/DifferentialChangesetDetailView.php b/src/applications/differential/view/changesetdetailview/DifferentialChangesetDetailView.php index db0f3efd42..8a57f48a36 100644 --- a/src/applications/differential/view/changesetdetailview/DifferentialChangesetDetailView.php +++ b/src/applications/differential/view/changesetdetailview/DifferentialChangesetDetailView.php @@ -18,115 +18,45 @@ class DifferentialChangesetDetailView extends AphrontView { - private $changesets = array(); + private $changeset; + private $buttons = array(); - public function setChangesets($changesets) { - $this->changesets = $changesets; + public function setChangeset($changeset) { + $this->changeset = $changeset; + return $this; + } + + public function addButton($button) { + $this->buttons[] = $button; return $this; } public function render() { - $against = array(); // TODO - $edit = false; + require_celerity_resource('differential-changeset-view-css'); + require_celerity_resource('syntax-highlighting-css'); - $changesets = $this->changesets; - foreach ($changesets as $key => $changeset) { - if (empty($against[$changeset->getID()])) { - $type = $changeset->getChangeType(); - if ($type == DifferentialChangeType::TYPE_MOVE_AWAY || - $type == DifferentialChangeType::TYPE_MULTICOPY) { - unset($changesets[$key]); - } - } + $edit = false; // TODO + + $changeset = $this->changeset; + $class = 'differential-changeset'; + if (!$edit) { + $class .= ' differential-changeset-immutable'; } - $output = array(); - $mapping = array(); - foreach ($changesets as $key => $changeset) { - $file = $changeset->getFilename(); - $class = 'differential-changeset'; - if (!$edit) { - $class .= ' differential-changeset-noneditable'; - } - $id = $changeset->getID(); - if ($id) { - $against_id = idx($against, $id); - } else { - $against_id = null; - } + $display_filename = $changeset->getDisplayFilename(); + $output = javelin_render_tag( + 'div', + array( + 'sigil' => 'differential-changeset', + 'class' => $class, + ), + ''. + implode('', $this->buttons). + '

'.phutil_escape_html($display_filename).'

'. + '
'. + $this->renderChildren()); -/* - $detail_uri = URI($render_uri) - ->addQueryData(array( - 'changeset' => $id, - 'against' => $against_id, - 'whitespace' => $whitespace, - )); -*/ - $detail_uri = '/differential/changeset/'.$changeset->getID().'/'; - - $detail = phutil_render_tag( - 'a', - array( - 'style' => 'float: right', - 'class' => 'button small grey', - 'href' => $detail_uri, - 'target' => '_blank', - ), - 'Standalone View'); - -// $div =
Loading…
; - - $display_filename = $changeset->getDisplayFilename(); - $output[] = - '
'. - '

'.$detail.phutil_escape_html($display_filename).'

'. - '
Loading...
'. - '
'; - -/* -
getID()}> - {$detail} -

{$file}

- {$div} -
; -*/ -/* - $mapping[$div->requireUniqueId()] = array_filter( - array( - $changeset->getID(), - idx($against, $changeset->getID()), - )); - -*/ - } -/* - require_static('differential-diff-css'); - require_static('differential-syntax-css'); - - Javelin::initBehavior('differential-populate', array( - 'registry' => $mapping, - 'whitespace' => $whitespace, - 'uri' => $render_uri, - )); - - Javelin::initBehavior('differential-context', array( - 'uri' => $render_uri, - )); - - if ($edit) { - require_static('remarkup-css'); - Javelin::initBehavior('differential-inline', array( - 'uri' => '/differential/feedback/'.$revision->getID().'/', - )); - } -*/ - return - '
'. - implode("\n", $output). - '
'; + return $output; } } diff --git a/src/applications/differential/view/changesetdetailview/__init__.php b/src/applications/differential/view/changesetdetailview/__init__.php index 51175da167..575d0c87f4 100644 --- a/src/applications/differential/view/changesetdetailview/__init__.php +++ b/src/applications/differential/view/changesetdetailview/__init__.php @@ -6,11 +6,11 @@ -phutil_require_module('phabricator', 'applications/differential/constants/changetype'); +phutil_require_module('phabricator', 'infratructure/celerity/api'); +phutil_require_module('phabricator', 'infratructure/javelin/markup'); phutil_require_module('phabricator', 'view/base'); phutil_require_module('phutil', 'markup'); -phutil_require_module('phutil', 'utils'); phutil_require_source('DifferentialChangesetDetailView.php'); diff --git a/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php b/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php new file mode 100644 index 0000000000..476813604a --- /dev/null +++ b/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php @@ -0,0 +1,126 @@ +changesets = $changesets; + return $this; + } + + public function render() { + require_celerity_resource('differential-changeset-view-css'); + + $against = array(); // TODO + $edit = false; + + $changesets = $this->changesets; + foreach ($changesets as $key => $changeset) { + if (empty($against[$changeset->getID()])) { + $type = $changeset->getChangeType(); + if ($type == DifferentialChangeType::TYPE_MOVE_AWAY || + $type == DifferentialChangeType::TYPE_MULTICOPY) { + unset($changesets[$key]); + } + } + } + + $output = array(); + $mapping = array(); + foreach ($changesets as $key => $changeset) { + $file = $changeset->getFilename(); + $class = 'differential-changeset'; + if (!$edit) { + $class .= ' differential-changeset-noneditable'; + } + $id = $changeset->getID(); + if ($id) { + $against_id = idx($against, $id); + } else { + $against_id = null; + } + +/* + TODO + $detail_uri = URI($render_uri) + ->addQueryData(array( + 'changeset' => $id, + 'against' => $against_id, + 'whitespace' => $whitespace, + )); +*/ + $detail_uri = '/differential/changeset/'.$changeset->getID().'/'; + + $detail_button = phutil_render_tag( + 'a', + array( + 'style' => 'float: right', + 'class' => 'button small grey', + 'href' => $detail_uri, + 'target' => '_blank', + ), + 'Standalone View'); + + $uniq_id = celerity_generate_unique_node_id(); + + $detail = new DifferentialChangesetDetailView(); + $detail->setChangeset($changeset); + $detail->addButton($detail_button); + $detail->appendChild( + phutil_render_tag( + 'div', + array( + 'id' => $uniq_id, + ), + '
Loading...
')); + $output[] = $detail->render(); + + $mapping[$uniq_id] = array($changeset->getID()); + } + + $whitespace = null; + Javelin::initBehavior('differential-populate', array( + 'registry' => $mapping, + 'whitespace' => $whitespace, + 'uri' => '/differential/changeset/',//$render_uri, + )); + + +/* + + + Javelin::initBehavior('differential-context', array( + 'uri' => $render_uri, + )); + + if ($edit) { + require_static('remarkup-css'); + Javelin::initBehavior('differential-inline', array( + 'uri' => '/differential/feedback/'.$revision->getID().'/', + )); + } +*/ + return + '
'. + implode("\n", $output). + '
'; + } + +} diff --git a/src/applications/differential/view/changesetlistview/__init__.php b/src/applications/differential/view/changesetlistview/__init__.php new file mode 100644 index 0000000000..f7d535542a --- /dev/null +++ b/src/applications/differential/view/changesetlistview/__init__.php @@ -0,0 +1,19 @@ +requireResource($symbol); } + +function celerity_generate_unique_node_id() { + static $uniq = 0; + $response = CelerityAPI::getStaticResourceResponse(); + $block = $response->getMetadataBlock(); + + return 'UQ'.$block.'_'.($uniq++); +} + diff --git a/src/infratructure/celerity/response/CelerityStaticResourceResponse.php b/src/infratructure/celerity/response/CelerityStaticResourceResponse.php index 59d9c8a00e..2207602a8a 100644 --- a/src/infratructure/celerity/response/CelerityStaticResourceResponse.php +++ b/src/infratructure/celerity/response/CelerityStaticResourceResponse.php @@ -21,6 +21,31 @@ final class CelerityStaticResourceResponse { private $symbols = array(); private $needsResolve = true; private $resolved; + private $metadata = array(); + private $metadataBlock = 0; + private $behaviors = array(); + + public function __construct() { + if (isset($_REQUEST['__metablock__'])) { + $this->metadataBlock = (int)$_REQUEST['__metablock__']; + } + } + + public function addMetadata($metadata) { + $id = count($this->metadata); + $this->metadata[$id] = $metadata; + return $this->metadataBlock.'_'.$id; + } + + public function getMetadataBlock() { + return $this->metadataBlock; + } + + public function initBehavior($behavior, array $config = array()) { + $this->requireResource('javelin-behavior-'.$behavior); + $this->behaviors[$behavior][] = $config; + return $this; + } public function requireResource($symbol) { $this->symbols[$symbol] = true; @@ -55,9 +80,66 @@ final class CelerityStaticResourceResponse { return ''; case 'js': $path = phutil_escape_html($resource['path']); - return ''; } throw new Exception("Unable to render resource."); } + public function renderHTMLFooter() { + $data = array(); + if ($this->metadata) { + $json_metadata = json_encode($this->metadata); + $this->metadata = array(); + } else { + $json_metadata = '{}'; + } + // Even if there is no metadata on the page, Javelin uses the mergeData() + // call to start dispatching the event queue. + $data[] = 'JX.Stratcom.mergeData('.$this->metadataBlock.', '. + $json_metadata.');'; + + $onload = array(); + if ($this->behaviors) { + $behavior = json_encode($this->behaviors); + $onload[] = 'JX.initBehaviors('.$behavior.')'; + $this->behaviors = array(); + } + + if ($onload) { + foreach ($onload as $func) { + $data[] = 'JX.onload(function(){'.$func.'});'; + } + } + + if ($data) { + $data = implode("\n", $data); + return ''; + } else { + return ''; + } + } + + public function renderAjaxResponse($payload, $error = null) { + $response = array( + 'error' => $error, + 'payload' => $payload, + ); + + if ($this->metadata) { + $response['javelin_metadata'] = $this->metadata; + $this->metadata = array(); + } + + if ($this->behaviors) { + $response['javelin_behaviors'] = $this->behaviors; + $this->behaviors = array(); + } + + $response = 'for (;;);'.json_encode($response); + return $response; + } + + } diff --git a/src/infratructure/javelin/api/Javelin.php b/src/infratructure/javelin/api/Javelin.php new file mode 100644 index 0000000000..b6e2a3d9cf --- /dev/null +++ b/src/infratructure/javelin/api/Javelin.php @@ -0,0 +1,24 @@ +initBehavior($behavior, $config); + } +} diff --git a/src/infratructure/javelin/api/__init__.php b/src/infratructure/javelin/api/__init__.php new file mode 100644 index 0000000000..59283cfb85 --- /dev/null +++ b/src/infratructure/javelin/api/__init__.php @@ -0,0 +1,12 @@ + $v) { + switch ($k) { + case 'sigil': + $classes[] = 'FN_'.$v; + unset($attributes[$k]); + break; + case 'meta': + $response = CelerityAPI::getStaticResourceResponse(); + $id = $response->addMetadata($v); + $classes[] = 'FD_'.$id; + unset($attributes[$k]); + break; + case 'mustcapture': + $classes[] = 'FI_CAPTURE'; + unset($attributes[$k]); + break; + } + } + + if (isset($attributes['class'])) { + $classes[] = $attributes['class']; + } + + $attributes['class'] = implode(' ', $classes); + } + + return phutil_render_tag($tag, $attributes, $content); +} diff --git a/src/view/page/standard/PhabricatorStandardPageView.php b/src/view/page/standard/PhabricatorStandardPageView.php index 235df76475..e8e544d43b 100755 --- a/src/view/page/standard/PhabricatorStandardPageView.php +++ b/src/view/page/standard/PhabricatorStandardPageView.php @@ -59,6 +59,8 @@ class PhabricatorStandardPageView extends AphrontPageView { require_celerity_resource('phabricator-core-buttons-css'); require_celerity_resource('phabricator-standard-page-view'); + require_celerity_resource('javelin-lib-dev'); + $this->bodyContent = $this->renderChildren(); } @@ -122,9 +124,7 @@ class PhabricatorStandardPageView extends AphrontPageView { $response = CelerityAPI::getStaticResourceResponse(); return $response->renderResourcesOfType('js'). - ''; + $response->renderHTMLFooter(); } } diff --git a/webroot/rsrc/css/core/syntax.css b/webroot/rsrc/css/core/syntax.css new file mode 100644 index 0000000000..e7ca2ce578 --- /dev/null +++ b/webroot/rsrc/css/core/syntax.css @@ -0,0 +1,122 @@ +/** + * @provides syntax-highlighting-css + */ +.remarkup-code .uu { /* Forbidden Unicode */ + color: #aa0066; +} + +.remarkup-code .over-the-line { + color: #aa0066; + margin-right: 1px; +} + +.remarkup-code td span { + padding: 1px 0 3px; +} + + +.remarkup-code .hll { + background-color: #ffffcc; +} + +.remarkup-code .c, /* Comment */ +.remarkup-code .cm, /* Comment.Multiline */ +.remarkup-code .c1, /* Comment.Single */ +.remarkup-code .cs { /* Comment.Special */ + color: #666666; +} + +.remarkup-code .sd, /* Literal.String.Doc */ +.remarkup-code .sh { /* Literal.String.Heredoc */ + color: #000000; +} + +.remarkup-code .s, /* Literal.String */ +.remarkup-code .sb, /* Literal.String.Backtick */ +.remarkup-code .sc, /* Literal.String.Char */ +.remarkup-code .s2, /* Literal.String.Double */ +.remarkup-code .s1, /* Literal.String.Single */ +.remarkup-code .sx { /* Literal.String.Other */ + color: #766510; +} + +.remarkup-code .sr { /* Literal.String.Regex */ + color: #BB6688; +} + +.remarkup-code .nv, /* Name.Variable */ +.remarkup-code .vi, /* Name.Variable.Instance */ +.remarkup-code .vg { /* Name.Variable.Global */ + color: #001294; +} + +.remarkup-code .na { /* Name.Attribute */ + color: #354BB3; +} + +.remarkup-code .kc, /* Keyword.Constant */ +.remarkup-code .no { /* Name.Constant */ + color: #000A65; +} + +.remarkup-code .k, /* Keyword */ +.remarkup-code .kd, /* Keyword.Declaration */ +.remarkup-code .kn, /* Keyword.Namespace */ +.remarkup-code .kt { /* Keyword.Type */ + color: #AA4000; +} + +.remarkup-code .cp, /* Comment.Preproc */ +.remarkup-code .kp, /* Keyword.Pseudo */ +.remarkup-code .kr, /* Keyword.Reserved */ +.remarkup-code .nb, /* Name.Builtin */ +.remarkup-code .bp { /* Name.Builtin.Pseudo */ + color: #304A96; +} + +.remarkup-code .nc, /* Name.Class */ +.remarkup-code .nt, /* Name.Tag */ +.remarkup-code .vc { /* Name.Variable.Class */ + color: #00702A; +} + +.remarkup-code .nf, /* Name.Function */ +.remarkup-code .nx { /* Name.Other */ + color: #004012; +} + +.remarkup-code .o, /* Operator */ +.remarkup-code .ss { /* Literal.String.Symbol */ + color: #AA2211; +} + +.remarkup-code .m, /* Literal.Number */ +.remarkup-code .mf, /* Literal.Number.Float */ +.remarkup-code .mh, /* Literal.Number.Hex */ +.remarkup-code .mi, /* Literal.Number.Integer */ +.remarkup-code .mo, /* Literal.Number.Oct */ +.remarkup-code .il { /* Literal.Number.Integer.Long */ + color: #601200; +} + +.remarkup-code .gd { color: #A00000 } /* Generic.Deleted */ +.remarkup-code .ge { } /* Generic.Emph */ +.remarkup-code .gr { color: #FF0000 } /* Generic.Error */ +.remarkup-code .gh { color: #000080; } /* Generic.Heading */ +.remarkup-code .gi { color: #00A000 } /* Generic.Inserted */ +.remarkup-code .go { color: #808080 } /* Generic.Output */ +.remarkup-code .gp { color: #000080 } /* Generic.Prompt */ +.remarkup-code .gs { } /* Generic.Strong */ +.remarkup-code .gu { color: #800080 } /* Generic.Subheading */ +.remarkup-code .gt { color: #0040D0 } /* Generic.Traceback */ +.remarkup-code .nd { color: #AA22FF } /* Name.Decorator */ +.remarkup-code .ni { color: #999999 } /* Name.Entity */ +.remarkup-code .ne { color: #D2413A } /* Name.Exception */ +.remarkup-code .nl { color: #A0A000 } /* Name.Label */ +.remarkup-code .nn { color: #0000FF } /* Name.Namespace */ +.remarkup-code .ow { color: #AA22FF } /* Operator.Word */ +.remarkup-code .w { color: #bbbbbb } /* Text.Whitespace */ +.remarkup-code .se { color: #BB6622 } /* Literal.String.Escape */ +.remarkup-code .si { color: #BB6688 } /* Literal.String.Interpol */ + + diff --git a/webroot/rsrc/js/application/differential/behavior-populate.js b/webroot/rsrc/js/application/differential/behavior-populate.js new file mode 100644 index 0000000000..14be5b2f8d --- /dev/null +++ b/webroot/rsrc/js/application/differential/behavior-populate.js @@ -0,0 +1,22 @@ +/** + * @provides javelin-behavior-differential-populate + */ + +JX.behavior('differential-populate', function(config) { + + function onresponse(target, response) { + JX.DOM.replace(JX.$(target), JX.HTML(response)); + } + + var uri; + for (var k in config.registry) { + uri = config.uri + config.registry[k][0] + '/'; + new JX.Request(uri, JX.bind(null, onresponse, k)) + .setData({ + against: config.registry[k][1], + whitespace: config.whitespace + }) + .send(); + } + +});