diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -7,7 +7,7 @@ */ return array( 'names' => array( - 'core.pkg.css' => '5242a859', + 'core.pkg.css' => 'b7b8d101', 'core.pkg.js' => '6972d365', 'darkconsole.pkg.js' => 'e7393ebb', 'differential.pkg.css' => '7ba78475', @@ -105,7 +105,7 @@ 'rsrc/css/application/uiexample/example.css' => '528b19de', 'rsrc/css/core/core.css' => 'd0801452', 'rsrc/css/core/remarkup.css' => '787105d6', - 'rsrc/css/core/syntax.css' => '9fd11da8', + 'rsrc/css/core/syntax.css' => '5101175d', 'rsrc/css/core/z-index.css' => '5b6fcf3f', 'rsrc/css/diviner/diviner-shared.css' => 'aa3656aa', 'rsrc/css/font/font-aleo.css' => '8bdb2835', @@ -164,6 +164,7 @@ 'rsrc/css/sprite-login.css' => '60e8560e', 'rsrc/css/sprite-menu.css' => '9dd65b92', 'rsrc/css/sprite-tokens.css' => '4f399012', + 'rsrc/css/syntax/syntax-default.css' => '9923583c', 'rsrc/externals/d3/d3.min.js' => 'a11a5ff2', 'rsrc/externals/font/aleo/aleo-bold.eot' => 'd3d3bed7', 'rsrc/externals/font/aleo/aleo-bold.svg' => '45899c8e', @@ -877,7 +878,8 @@ 'sprite-login-css' => '60e8560e', 'sprite-menu-css' => '9dd65b92', 'sprite-tokens-css' => '4f399012', - 'syntax-highlighting-css' => '9fd11da8', + 'syntax-default-css' => '9923583c', + 'syntax-highlighting-css' => '5101175d', 'tokens-css' => '3d0f239e', 'typeahead-browse-css' => 'd8581d2c', 'unhandled-exception-css' => '4c96257a', @@ -1239,6 +1241,9 @@ 'javelin-typeahead-source', 'javelin-util', ), + '5101175d' => array( + 'syntax-default-css', + ), '519705ea' => array( 'javelin-install', 'javelin-dom', @@ -2192,6 +2197,7 @@ 'aphront-list-filter-view-css', 'phabricator-remarkup-css', 'syntax-highlighting-css', + 'syntax-default-css', 'phui-pager-css', 'aphront-tooltip-css', 'phabricator-flag-css', diff --git a/resources/celerity/packages.php b/resources/celerity/packages.php --- a/resources/celerity/packages.php +++ b/resources/celerity/packages.php @@ -97,6 +97,7 @@ 'phabricator-remarkup-css', 'syntax-highlighting-css', + 'syntax-default-css', 'phui-pager-css', 'aphront-tooltip-css', 'phabricator-flag-css', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -226,6 +226,7 @@ 'CelerityHighContrastPostprocessor' => 'applications/celerity/postprocessor/CelerityHighContrastPostprocessor.php', 'CelerityLargeFontPostprocessor' => 'applications/celerity/postprocessor/CelerityLargeFontPostprocessor.php', 'CelerityManagementMapWorkflow' => 'applications/celerity/management/CelerityManagementMapWorkflow.php', + 'CelerityManagementSyntaxWorkflow' => 'applications/celerity/management/CelerityManagementSyntaxWorkflow.php', 'CelerityManagementWorkflow' => 'applications/celerity/management/CelerityManagementWorkflow.php', 'CelerityPhabricatorResourceController' => 'applications/celerity/controller/CelerityPhabricatorResourceController.php', 'CelerityPhabricatorResources' => 'applications/celerity/resources/CelerityPhabricatorResources.php', @@ -2273,6 +2274,7 @@ 'PhabricatorDateTimeSettingsPanel' => 'applications/settings/panel/PhabricatorDateTimeSettingsPanel.php', 'PhabricatorDebugController' => 'applications/system/controller/PhabricatorDebugController.php', 'PhabricatorDefaultRequestExceptionHandler' => 'aphront/handler/PhabricatorDefaultRequestExceptionHandler.php', + 'PhabricatorDefaultSyntaxStyle' => 'infrastructure/syntax/PhabricatorDefaultSyntaxStyle.php', 'PhabricatorDesktopNotificationsSettingsPanel' => 'applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php', 'PhabricatorDestructibleInterface' => 'applications/system/interface/PhabricatorDestructibleInterface.php', 'PhabricatorDestructionEngine' => 'applications/system/engine/PhabricatorDestructionEngine.php', @@ -3454,6 +3456,7 @@ 'PhabricatorSupportApplication' => 'applications/support/application/PhabricatorSupportApplication.php', 'PhabricatorSyntaxHighlighter' => 'infrastructure/markup/PhabricatorSyntaxHighlighter.php', 'PhabricatorSyntaxHighlightingConfigOptions' => 'applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php', + 'PhabricatorSyntaxStyle' => 'infrastructure/syntax/PhabricatorSyntaxStyle.php', 'PhabricatorSystemAction' => 'applications/system/action/PhabricatorSystemAction.php', 'PhabricatorSystemActionEngine' => 'applications/system/engine/PhabricatorSystemActionEngine.php', 'PhabricatorSystemActionGarbageCollector' => 'applications/system/garbagecollector/PhabricatorSystemActionGarbageCollector.php', @@ -4397,6 +4400,7 @@ 'CelerityHighContrastPostprocessor' => 'CelerityPostprocessor', 'CelerityLargeFontPostprocessor' => 'CelerityPostprocessor', 'CelerityManagementMapWorkflow' => 'CelerityManagementWorkflow', + 'CelerityManagementSyntaxWorkflow' => 'CelerityManagementWorkflow', 'CelerityManagementWorkflow' => 'PhabricatorManagementWorkflow', 'CelerityPhabricatorResourceController' => 'CelerityResourceController', 'CelerityPhabricatorResources' => 'CelerityResourcesOnDisk', @@ -6764,6 +6768,7 @@ 'PhabricatorDateTimeSettingsPanel' => 'PhabricatorSettingsPanel', 'PhabricatorDebugController' => 'PhabricatorController', 'PhabricatorDefaultRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', + 'PhabricatorDefaultSyntaxStyle' => 'PhabricatorSyntaxStyle', 'PhabricatorDesktopNotificationsSettingsPanel' => 'PhabricatorSettingsPanel', 'PhabricatorDestructionEngine' => 'Phobject', 'PhabricatorDestructionEngineExtension' => 'Phobject', @@ -8150,6 +8155,7 @@ 'PhabricatorSupportApplication' => 'PhabricatorApplication', 'PhabricatorSyntaxHighlighter' => 'Phobject', 'PhabricatorSyntaxHighlightingConfigOptions' => 'PhabricatorApplicationConfigOptions', + 'PhabricatorSyntaxStyle' => 'Phobject', 'PhabricatorSystemAction' => 'Phobject', 'PhabricatorSystemActionEngine' => 'Phobject', 'PhabricatorSystemActionGarbageCollector' => 'PhabricatorGarbageCollector', diff --git a/src/applications/celerity/management/CelerityManagementSyntaxWorkflow.php b/src/applications/celerity/management/CelerityManagementSyntaxWorkflow.php new file mode 100644 --- /dev/null +++ b/src/applications/celerity/management/CelerityManagementSyntaxWorkflow.php @@ -0,0 +1,67 @@ +setName('syntax') + ->setExamples('**syntax** [options]') + ->setSynopsis(pht('Rebuild syntax highlighting CSS.')) + ->setArguments( + array()); + } + + public function execute(PhutilArgumentParser $args) { + $styles = PhabricatorSyntaxStyle::getAllStyles(); + + $root = dirname(phutil_get_library_root('phabricator')); + $root = $root.'/webroot/rsrc/css/syntax/'; + + foreach ($styles as $key => $style) { + $content = $this->generateCSS($style); + $path = $root.'/syntax-'.$key.'.css'; + Filesystem::writeFile($path, $content); + + echo tsprintf( + "%s\n", + pht( + 'Rebuilt "%s" syntax CSS.', + basename($path))); + } + + return 0; + } + + private function generateCSS(PhabricatorSyntaxStyle $style) { + $key = $style->getSyntaxStyleKey(); + $provides = "syntax-{$key}-css"; + $generated = 'generated'; + + $header = + "/**\n". + " * @provides {$provides}\n". + " * @{$generated}\n". + " */\n\n"; + + $groups = array(); + $map = $style->getStyleMap(); + ksort($map); + foreach ($map as $key => $value) { + $groups[$value][] = $key; + } + + $rules = array(); + foreach ($groups as $body => $classes) { + $parts = array(); + foreach ($classes as $class) { + $parts[] = ".remarkup-code .{$class}"; + } + $rules[] = implode(",\n", $parts)." {\n {$body}\n}"; + } + $rules = implode("\n\n", $rules); + + return $header.$rules."\n"; + } + +} diff --git a/src/infrastructure/syntax/PhabricatorDefaultSyntaxStyle.php b/src/infrastructure/syntax/PhabricatorDefaultSyntaxStyle.php new file mode 100644 --- /dev/null +++ b/src/infrastructure/syntax/PhabricatorDefaultSyntaxStyle.php @@ -0,0 +1,76 @@ + 'color: #ffffcc', + 'c' => 'color: #74777d', + 'cm' => 'color: #74777d', + 'c1' => 'color: #74777d', + 'cs' => 'color: #74777d', + 'sd' => 'color: #000000', + 'sh' => 'color: #000000', + 's' => 'color: #766510', + 'sb' => 'color: #766510', + 'sc' => 'color: #766510', + 's2' => 'color: #766510', + 's1' => 'color: #766510', + 'sx' => 'color: #766510', + 'sr' => 'color: #bb6688', + 'nv' => 'color: #001294', + 'vi' => 'color: #001294', + 'vg' => 'color: #001294', + 'na' => 'color: #354bb3', + 'kc' => 'color: #000a65', + 'no' => 'color: #000a65', + 'k' => 'color: #aa4000', + 'kd' => 'color: #aa4000', + 'kn' => 'color: #aa4000', + 'kt' => 'color: #aa4000', + 'cp' => 'color: #304a96', + 'kp' => 'color: #304a96', + 'kr' => 'color: #304a96', + 'nb' => 'color: #304a96', + 'bp' => 'color: #304a96', + 'nc' => 'color: #00702a', + 'nt' => 'color: #00702a', + 'vc' => 'color: #00702a', + 'nf' => 'color: #004012', + 'nx' => 'color: #004012', + 'o' => 'color: #aa2211', + 'ss' => 'color: #aa2211', + 'm' => 'color: #601200', + 'mf' => 'color: #601200', + 'mh' => 'color: #601200', + 'mi' => 'color: #601200', + 'mo' => 'color: #601200', + 'il' => 'color: #601200', + 'gd' => 'color: #a00000', + 'gr' => 'color: #ff0000', + 'gh' => 'color: #000080', + 'gi' => 'color: #00a000', + 'go' => 'color: #808080', + 'gp' => 'color: #000080', + 'gu' => 'color: #800080', + 'gt' => 'color: #0040d0', + 'nd' => 'color: #aa22ff', + 'ni' => 'color: #92969d', + 'ne' => 'color: #d2413a', + 'nl' => 'color: #a0a000', + 'nn' => 'color: #0000ff', + 'ow' => 'color: #aa22ff', + 'w' => 'color: #bbbbbb', + 'se' => 'color: #bb6622', + 'si' => 'color: #bb66bb', + ); + } + +} diff --git a/src/infrastructure/syntax/PhabricatorSyntaxStyle.php b/src/infrastructure/syntax/PhabricatorSyntaxStyle.php new file mode 100644 --- /dev/null +++ b/src/infrastructure/syntax/PhabricatorSyntaxStyle.php @@ -0,0 +1,30 @@ +addInt($this->isDefaultStyle() ? 0 : 1) + ->addString($this->getStyleName()); + } + + final public function getSyntaxStyleKey() { + return $this->getPhobjectClassConstant('STYLEKEY'); + } + + final public function isDefaultStyle() { + return ($this->getSyntaxStyleKey() == 'default'); + } + + public static function getAllStyles() { + return id(new PhutilClassMapQuery()) + ->setAncestorClass(__CLASS__) + ->setUniqueMethod('getSyntaxStyleKey') + ->setSortMethod('getStyleName') + ->execute(); + } + +} diff --git a/webroot/rsrc/css/core/syntax.css b/webroot/rsrc/css/core/syntax.css --- a/webroot/rsrc/css/core/syntax.css +++ b/webroot/rsrc/css/core/syntax.css @@ -1,5 +1,6 @@ /** * @provides syntax-highlighting-css + * @requires syntax-default-css */ .remarkup-code .uu { /* Forbidden Unicode */ color: #aa0066; @@ -19,110 +20,6 @@ border-bottom: 1px solid transparent; } -.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: {$greytext}; -} - -.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: {$lightgreytext} } /* 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 */ - .remarkup-code .rbw_r { color: red; } .remarkup-code .rbw_o { color: orange; } .remarkup-code .rbw_y { color: yellow; } diff --git a/webroot/rsrc/css/syntax/syntax-default.css b/webroot/rsrc/css/syntax/syntax-default.css new file mode 100644 --- /dev/null +++ b/webroot/rsrc/css/syntax/syntax-default.css @@ -0,0 +1,150 @@ +/** + * @provides syntax-default-css + * @generated + */ + +.remarkup-code .bp, +.remarkup-code .cp, +.remarkup-code .kp, +.remarkup-code .kr, +.remarkup-code .nb { + color: #304a96 +} + +.remarkup-code .c, +.remarkup-code .c1, +.remarkup-code .cm, +.remarkup-code .cs { + color: #74777d +} + +.remarkup-code .gd { + color: #a00000 +} + +.remarkup-code .gh, +.remarkup-code .gp { + color: #000080 +} + +.remarkup-code .gi { + color: #00a000 +} + +.remarkup-code .go { + color: #808080 +} + +.remarkup-code .gr { + color: #ff0000 +} + +.remarkup-code .gt { + color: #0040d0 +} + +.remarkup-code .gu { + color: #800080 +} + +.remarkup-code .hll { + color: #ffffcc +} + +.remarkup-code .il, +.remarkup-code .m, +.remarkup-code .mf, +.remarkup-code .mh, +.remarkup-code .mi, +.remarkup-code .mo { + color: #601200 +} + +.remarkup-code .k, +.remarkup-code .kd, +.remarkup-code .kn, +.remarkup-code .kt { + color: #aa4000 +} + +.remarkup-code .kc, +.remarkup-code .no { + color: #000a65 +} + +.remarkup-code .na { + color: #354bb3 +} + +.remarkup-code .nc, +.remarkup-code .nt, +.remarkup-code .vc { + color: #00702a +} + +.remarkup-code .nd, +.remarkup-code .ow { + color: #aa22ff +} + +.remarkup-code .ne { + color: #d2413a +} + +.remarkup-code .nf, +.remarkup-code .nx { + color: #004012 +} + +.remarkup-code .ni { + color: #92969d +} + +.remarkup-code .nl { + color: #a0a000 +} + +.remarkup-code .nn { + color: #0000ff +} + +.remarkup-code .nv, +.remarkup-code .vg, +.remarkup-code .vi { + color: #001294 +} + +.remarkup-code .o, +.remarkup-code .ss { + color: #aa2211 +} + +.remarkup-code .s, +.remarkup-code .s1, +.remarkup-code .s2, +.remarkup-code .sb, +.remarkup-code .sc, +.remarkup-code .sx { + color: #766510 +} + +.remarkup-code .sd, +.remarkup-code .sh { + color: #000000 +} + +.remarkup-code .se { + color: #bb6622 +} + +.remarkup-code .si { + color: #bb66bb +} + +.remarkup-code .sr { + color: #bb6688 +} + +.remarkup-code .w { + color: #bbbbbb +}