diff options
Diffstat (limited to 'app')
26 files changed, 481 insertions, 727 deletions
diff --git a/app/assets/images/dark-scheme-preview.png b/app/assets/images/dark-scheme-preview.png Binary files differindex 6dac6cd8ca1..2d631a49fd3 100644 --- a/app/assets/images/dark-scheme-preview.png +++ b/app/assets/images/dark-scheme-preview.png diff --git a/app/assets/images/monokai-scheme-preview.png b/app/assets/images/monokai-scheme-preview.png Binary files differindex 3aeed886a02..6791d1ee33d 100644 --- a/app/assets/images/monokai-scheme-preview.png +++ b/app/assets/images/monokai-scheme-preview.png diff --git a/app/assets/images/solarized-dark-scheme-preview.png b/app/assets/images/solarized-dark-scheme-preview.png Binary files differindex ae092ab5213..8f904405310 100644 --- a/app/assets/images/solarized-dark-scheme-preview.png +++ b/app/assets/images/solarized-dark-scheme-preview.png diff --git a/app/assets/images/solarized-light-scheme-preview.png b/app/assets/images/solarized-light-scheme-preview.png Binary files differnew file mode 100644 index 00000000000..7da5d2d2090 --- /dev/null +++ b/app/assets/images/solarized-light-scheme-preview.png diff --git a/app/assets/images/white-scheme-preview.png b/app/assets/images/white-scheme-preview.png Binary files differindex d1866e00158..d32b7485e1e 100644 --- a/app/assets/images/white-scheme-preview.png +++ b/app/assets/images/white-scheme-preview.png diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 6d038f772e9..a3ed19d61ba 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -25,7 +25,6 @@ #= require g.bar-min #= require chart-lib.min #= require branch-graph -#= require highlight.pack #= require ace/ace #= require ace/ext-searchbox #= require d3 diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index e5349d80e94..ef86c2781c9 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -4,7 +4,6 @@ $ -> class Dispatcher constructor: () -> @initSearch() - @initHighlight() @initPageScripts() initPageScripts: -> @@ -130,10 +129,3 @@ class Dispatcher project_ref = opts.data('autocomplete-project-ref') new SearchAutocomplete(path, project_id, project_ref) - - initHighlight: -> - $('.highlight pre code').each (i, e) -> - $(e).html($.map($(e).html().split("\n"), (line, i) -> - "<span class='line' id='LC" + (i + 1) + "'>" + line + "</span>" - ).join("\n")) - hljs.highlightBlock(e) diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index d1935d1d007..ac1353b8bb6 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -114,10 +114,6 @@ class @Notes if @isNewNote(note) @note_ids.push(note.id) $('ul.main-notes-list').append(note.html) - code = "#note_" + note.id + " .highlight pre code" - $(code).each (i, e) -> - hljs.highlightBlock(e) - ### Check if note does not exists on page @@ -265,9 +261,6 @@ class @Notes note_li.replaceWith(note.html) note_li.find('.note-edit-form').hide() note_li.find('.note-text').show() - code = "#note_" + note.id + " .highlight pre code" - $(code).each (i, e) -> - hljs.highlightBlock(e) ### Called in response to clicking the edit note link diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 0d404f15055..3cf08782c3c 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -6,7 +6,6 @@ *= require jquery.ui.autocomplete *= require jquery.atwho *= require select2 - *= require highlightjs.min *= require_self *= require dropzone/basic */ diff --git a/app/assets/stylesheets/generic/highlight.scss b/app/assets/stylesheets/generic/highlight.scss index ae08539d454..83dc7ab491a 100644 --- a/app/assets/stylesheets/generic/highlight.scss +++ b/app/assets/stylesheets/generic/highlight.scss @@ -1,4 +1,4 @@ -.highlighted-data { +.file-content.code { border: none; box-shadow: none; margin: 0px; @@ -13,8 +13,13 @@ font-size: 12px !important; line-height: 16px !important; margin: 0; + overflow: auto; + overflow-y: hidden; + white-space: pre; + word-wrap: normal; code { + font-family: $monospace_font; white-space: pre; word-wrap: normal; padding: 0; @@ -25,10 +30,6 @@ } } - .hljs { - padding: 0; - } - .line-numbers { padding: 10px; text-align: right; @@ -51,18 +52,18 @@ } } } +} - .highlight { - overflow: auto; - overflow-y: hidden; - - pre { - white-space: pre; - word-wrap: normal; +.note-text .code { + border: none; + box-shadow: none; + background: $box_bg; + padding: 1em; - code { - font-family: $monospace_font; - } - } + code { + font-family: $monospace_font; + white-space: pre; + word-wrap: normal; + padding: 0; } } diff --git a/app/assets/stylesheets/highlight/dark.scss b/app/assets/stylesheets/highlight/dark.scss index ca51da3fdd4..4095d35b05f 100644 --- a/app/assets/stylesheets/highlight/dark.scss +++ b/app/assets/stylesheets/highlight/dark.scss @@ -1,199 +1,83 @@ -.dark { - background-color: #232323; - - .line.hll { - background: #558; - } - - .highlight{ - border-left: 1px solid #444; - } - - .no-highlight { - color: #DDD; - } +/* https://github.com/MozMorris/tomorrow-pygments */ +.code.dark { + pre.code, + .line-numbers, .line-numbers a { - color: #666; - } - - pre { - background-color: #232323; - } - - .hljs { - display: block; - background: #232323; - color: #E6E1DC; - } - - .hljs-comment, - .hljs-template_comment, - .hljs-javadoc, - .hljs-shebang { - color: #BC9458; - font-style: italic; - } - - .hljs-keyword, - .ruby .hljs-function .hljs-keyword, - .hljs-request, - .hljs-status, - .nginx .hljs-title, - .method, - .hljs-list .hljs-title { - color: #C26230; - } - - .hljs-string, - .hljs-number, - .hljs-regexp, - .hljs-tag .hljs-value, - .hljs-cdata, - .hljs-filter .hljs-argument, - .hljs-attr_selector, - .apache .hljs-cbracket, - .hljs-date, - .tex .hljs-command, - .markdown .hljs-link_label { - color: #A5C261; - } - - .hljs-subst { - color: #519F50; - } - - .hljs-tag, - .hljs-tag .hljs-keyword, - .hljs-tag .hljs-title, - .hljs-doctype, - .hljs-sub .hljs-identifier, - .hljs-pi, - .input_number { - color: #E8BF6A; - } - - .hljs-identifier { - color: #D0D0FF; - } - - .hljs-class .hljs-title, - .haskell .hljs-type, - .smalltalk .hljs-class, - .hljs-javadoctag, - .hljs-yardoctag, - .hljs-phpdoc { - text-decoration: none; - } - - .hljs-constant { - color: #DA4939; - } - - - .hljs-symbol, - .hljs-built_in, - .ruby .hljs-symbol .hljs-string, - .ruby .hljs-symbol .hljs-identifier, - .markdown .hljs-link_url, - .hljs-attribute { - color: #6D9CBE; - } - - .markdown .hljs-link_url { - text-decoration: underline; - } - - - - .hljs-params, - .hljs-variable, - .clojure .hljs-attribute { - color: #D0D0FF; - } - - .css .hljs-tag, - .hljs-rules .hljs-property, - .hljs-pseudo, - .tex .hljs-special { - color: #CDA869; - } - - .css .hljs-class { - color: #9B703F; - } - - .hljs-rules .hljs-keyword { - color: #C5AF75; - } - - .hljs-rules .hljs-value { - color: #CF6A4C; - } - - .css .hljs-id { - color: #8B98AB; - } - - .hljs-annotation, - .apache .hljs-sqbracket, - .nginx .hljs-built_in { - color: #9B859D; - } - - .hljs-preprocessor, - .hljs-preprocessor *, - .hljs-pragma { - color: #8996A8 !important; - } - - .hljs-hexcolor, - .css .hljs-value .hljs-number { - color: #A5C261; - } - - .hljs-title, - .hljs-decorator, - .css .hljs-function { - color: #FFC66D; - } - - .diff .hljs-header, - .hljs-chunk { - background-color: #2F33AB; - color: #E6E1DC; - display: inline-block; - width: 100%; - } - - .diff .hljs-change { - background-color: #4A410D; - color: #F8F8F8; - display: inline-block; - width: 100%; - } - - .hljs-addition { - background-color: #144212; - color: #E6E1DC; - display: inline-block; - width: 100%; - } - - .hljs-deletion { - background-color: #600; - color: #E6E1DC; - display: inline-block; - width: 100%; - } - - .coffeescript .javascript, - .javascript .xml, - .tex .hljs-formula, - .xml .javascript, - .xml .vbscript, - .xml .css, - .xml .hljs-cdata { - opacity: 0.7; - } + background-color: #1d1f21 !important; + color: #c5c8c6 !important; + } + + pre.code { + border-left: 1px solid #666; + } + + pre.hll { + background-color: #fff !important; + } + + .hll { background-color: #373b41 } + .c { color: #969896 } /* Comment */ + .err { color: #cc6666 } /* Error */ + .k { color: #b294bb } /* Keyword */ + .l { color: #de935f } /* Literal */ + .n { color: #c5c8c6 } /* Name */ + .o { color: #8abeb7 } /* Operator */ + .p { color: #c5c8c6 } /* Punctuation */ + .cm { color: #969896 } /* Comment.Multiline */ + .cp { color: #969896 } /* Comment.Preproc */ + .c1 { color: #969896 } /* Comment.Single */ + .cs { color: #969896 } /* Comment.Special */ + .gd { color: #cc6666 } /* Generic.Deleted */ + .ge { font-style: italic } /* Generic.Emph */ + .gh { color: #c5c8c6; font-weight: bold } /* Generic.Heading */ + .gi { color: #b5bd68 } /* Generic.Inserted */ + .gp { color: #969896; font-weight: bold } /* Generic.Prompt */ + .gs { font-weight: bold } /* Generic.Strong */ + .gu { color: #8abeb7; font-weight: bold } /* Generic.Subheading */ + .kc { color: #b294bb } /* Keyword.Constant */ + .kd { color: #b294bb } /* Keyword.Declaration */ + .kn { color: #8abeb7 } /* Keyword.Namespace */ + .kp { color: #b294bb } /* Keyword.Pseudo */ + .kr { color: #b294bb } /* Keyword.Reserved */ + .kt { color: #f0c674 } /* Keyword.Type */ + .ld { color: #b5bd68 } /* Literal.Date */ + .m { color: #de935f } /* Literal.Number */ + .s { color: #b5bd68 } /* Literal.String */ + .na { color: #81a2be } /* Name.Attribute */ + .nb { color: #c5c8c6 } /* Name.Builtin */ + .nc { color: #f0c674 } /* Name.Class */ + .no { color: #cc6666 } /* Name.Constant */ + .nd { color: #8abeb7 } /* Name.Decorator */ + .ni { color: #c5c8c6 } /* Name.Entity */ + .ne { color: #cc6666 } /* Name.Exception */ + .nf { color: #81a2be } /* Name.Function */ + .nl { color: #c5c8c6 } /* Name.Label */ + .nn { color: #f0c674 } /* Name.Namespace */ + .nx { color: #81a2be } /* Name.Other */ + .py { color: #c5c8c6 } /* Name.Property */ + .nt { color: #8abeb7 } /* Name.Tag */ + .nv { color: #cc6666 } /* Name.Variable */ + .ow { color: #8abeb7 } /* Operator.Word */ + .w { color: #c5c8c6 } /* Text.Whitespace */ + .mf { color: #de935f } /* Literal.Number.Float */ + .mh { color: #de935f } /* Literal.Number.Hex */ + .mi { color: #de935f } /* Literal.Number.Integer */ + .mo { color: #de935f } /* Literal.Number.Oct */ + .sb { color: #b5bd68 } /* Literal.String.Backtick */ + .sc { color: #c5c8c6 } /* Literal.String.Char */ + .sd { color: #969896 } /* Literal.String.Doc */ + .s2 { color: #b5bd68 } /* Literal.String.Double */ + .se { color: #de935f } /* Literal.String.Escape */ + .sh { color: #b5bd68 } /* Literal.String.Heredoc */ + .si { color: #de935f } /* Literal.String.Interpol */ + .sx { color: #b5bd68 } /* Literal.String.Other */ + .sr { color: #b5bd68 } /* Literal.String.Regex */ + .s1 { color: #b5bd68 } /* Literal.String.Single */ + .ss { color: #b5bd68 } /* Literal.String.Symbol */ + .bp { color: #c5c8c6 } /* Name.Builtin.Pseudo */ + .vc { color: #cc6666 } /* Name.Variable.Class */ + .vg { color: #cc6666 } /* Name.Variable.Global */ + .vi { color: #cc6666 } /* Name.Variable.Instance */ + .il { color: #de935f } /* Literal.Number.Integer.Long */ } diff --git a/app/assets/stylesheets/highlight/monokai.scss b/app/assets/stylesheets/highlight/monokai.scss index dffa2dc9ed2..730018e3e28 100644 --- a/app/assets/stylesheets/highlight/monokai.scss +++ b/app/assets/stylesheets/highlight/monokai.scss @@ -1,159 +1,79 @@ -.monokai { - background-color: #272822; - - .highlight{ - border-left: 1px solid #444; - } - - .line.hll { - background: #558; - } - - .no-highlight { - color: #DDD; - } +/* https://github.com/richleland/pygments-css/blob/master/monokai.css */ +.code.monokai { + pre.highlight, + .line-numbers, .line-numbers a { - color: #666; - } - - pre { - background-color: #272822; - color: #f8f8f2; - } - - .hljs { - display: block; - background: #272822; - } - - .hljs-tag, - .hljs-tag .hljs-title, - .hljs-strong, - .hljs-change, - .hljs-winutils, - .hljs-flow, - .lisp .hljs-title, - .clojure .hljs-built_in, - .hljs-keyword, - .nginx .hljs-title, - .tex .hljs-special { - color: #F92672; - } - - .hljs { - color: #F8F8F2; - } - - .asciidoc .hljs-code, - .markdown .hljs-code, - .hljs-literal, - .hljs-function .hljs-keyword { - color: #66D9EF; - } - - - .hljs-code, - .hljs-class .hljs-title, - .hljs-header { - color: white; - } - - .hljs-link_label, - .hljs-attribute, - .hljs-symbol, - .hljs-symbol .hljs-string, - .hljs-value, - .hljs-constant, - .hljs-number, - .hljs-regexp { - color: #AE81FF; - } - - .hljs-string { - color: #E6DB74; - } - - .hljs-params { - color: #fd971f; - } - - .hljs-link_url, - .hljs-tag .hljs-value, - .hljs-bullet, - .hljs-subst, - .hljs-title, - .hljs-emphasis, - .hljs-type, - .hljs-preprocessor, - .hljs-pragma, - .ruby .hljs-class .hljs-parent, - .hljs-built_in, - .sql .hljs-aggregate, - .django .hljs-template_tag, - .django .hljs-variable, - .smalltalk .hljs-class, - .hljs-javadoc, - .django .hljs-filter .hljs-argument, - .smalltalk .hljs-localvars, - .smalltalk .hljs-array, - .hljs-attr_selector, - .hljs-pseudo, - .hljs-addition, - .hljs-stream, - .hljs-envvar, - .apache .hljs-tag, - .apache .hljs-cbracket, - .tex .hljs-command, - .hljs-prompt { - color: #A6E22E; - } - - .hljs-comment, - .hljs-annotation, - .smartquote, - .hljs-blockquote, - .hljs-horizontal_rule, - .hljs-template_comment, - .hljs-decorator, - .hljs-pi, - .hljs-doctype, - .hljs-deletion, - .hljs-shebang, - .apache .hljs-sqbracket, - .tex .hljs-formula { - color: #75715E; - } - - .hljs-keyword, - .hljs-literal, - .css .hljs-id, - .hljs-phpdoc, - .hljs-title, - .hljs-header, - .haskell .hljs-type, - .vbscript .hljs-built_in, - .sql .hljs-aggregate, - .rsl .hljs-built_in, - .smalltalk .hljs-class, - .diff .hljs-header, - .hljs-chunk, - .hljs-winutils, - .bash .hljs-variable, - .apache .hljs-tag, - .tex .hljs-special, - .hljs-request, - .hljs-status { - font-weight: bold; - } - - .coffeescript .javascript, - .javascript .xml, - .tex .hljs-formula, - .xml .javascript, - .xml .vbscript, - .xml .css, - .xml .hljs-cdata { - opacity: 0.5; - } + background:#272822 !important; + color:#f8f8f2 !important; + } + + pre.code { + border-left: 1px solid #555; + } + + .hll { background-color: #49483e } + .c { color: #75715e } /* Comment */ + .err { color: #960050; background-color: #1e0010 } /* Error */ + .k { color: #66d9ef } /* Keyword */ + .l { color: #ae81ff } /* Literal */ + .n { color: #f8f8f2 } /* Name */ + .o { color: #f92672 } /* Operator */ + .p { color: #f8f8f2 } /* Punctuation */ + .cm { color: #75715e } /* Comment.Multiline */ + .cp { color: #75715e } /* Comment.Preproc */ + .c1 { color: #75715e } /* Comment.Single */ + .cs { color: #75715e } /* Comment.Special */ + .ge { font-style: italic } /* Generic.Emph */ + .gs { font-weight: bold } /* Generic.Strong */ + .kc { color: #66d9ef } /* Keyword.Constant */ + .kd { color: #66d9ef } /* Keyword.Declaration */ + .kn { color: #f92672 } /* Keyword.Namespace */ + .kp { color: #66d9ef } /* Keyword.Pseudo */ + .kr { color: #66d9ef } /* Keyword.Reserved */ + .kt { color: #66d9ef } /* Keyword.Type */ + .ld { color: #e6db74 } /* Literal.Date */ + .m { color: #ae81ff } /* Literal.Number */ + .s { color: #e6db74 } /* Literal.String */ + .na { color: #a6e22e } /* Name.Attribute */ + .nb { color: #f8f8f2 } /* Name.Builtin */ + .nc { color: #a6e22e } /* Name.Class */ + .no { color: #66d9ef } /* Name.Constant */ + .nd { color: #a6e22e } /* Name.Decorator */ + .ni { color: #f8f8f2 } /* Name.Entity */ + .ne { color: #a6e22e } /* Name.Exception */ + .nf { color: #a6e22e } /* Name.Function */ + .nl { color: #f8f8f2 } /* Name.Label */ + .nn { color: #f8f8f2 } /* Name.Namespace */ + .nx { color: #a6e22e } /* Name.Other */ + .py { color: #f8f8f2 } /* Name.Property */ + .nt { color: #f92672 } /* Name.Tag */ + .nv { color: #f8f8f2 } /* Name.Variable */ + .ow { color: #f92672 } /* Operator.Word */ + .w { color: #f8f8f2 } /* Text.Whitespace */ + .mf { color: #ae81ff } /* Literal.Number.Float */ + .mh { color: #ae81ff } /* Literal.Number.Hex */ + .mi { color: #ae81ff } /* Literal.Number.Integer */ + .mo { color: #ae81ff } /* Literal.Number.Oct */ + .sb { color: #e6db74 } /* Literal.String.Backtick */ + .sc { color: #e6db74 } /* Literal.String.Char */ + .sd { color: #e6db74 } /* Literal.String.Doc */ + .s2 { color: #e6db74 } /* Literal.String.Double */ + .se { color: #ae81ff } /* Literal.String.Escape */ + .sh { color: #e6db74 } /* Literal.String.Heredoc */ + .si { color: #e6db74 } /* Literal.String.Interpol */ + .sx { color: #e6db74 } /* Literal.String.Other */ + .sr { color: #e6db74 } /* Literal.String.Regex */ + .s1 { color: #e6db74 } /* Literal.String.Single */ + .ss { color: #e6db74 } /* Literal.String.Symbol */ + .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ + .vc { color: #f8f8f2 } /* Name.Variable.Class */ + .vg { color: #f8f8f2 } /* Name.Variable.Global */ + .vi { color: #f8f8f2 } /* Name.Variable.Instance */ + .il { color: #ae81ff } /* Literal.Number.Integer.Long */ + + .gh { } /* Generic Heading & Diff Header */ + .gu { color: #75715e; } /* Generic.Subheading & Diff Unified/Comment? */ + .gd { color: #f92672; } /* Generic.Deleted & Diff Deleted */ + .gi { color: #a6e22e; } /* Generic.Inserted & Diff Inserted */ } diff --git a/app/assets/stylesheets/highlight/solarized_dark.scss b/app/assets/stylesheets/highlight/solarized_dark.scss index b9bec225188..be6904100ec 100644 --- a/app/assets/stylesheets/highlight/solarized_dark.scss +++ b/app/assets/stylesheets/highlight/solarized_dark.scss @@ -1,125 +1,101 @@ -.solarized-dark { - background-color: #002B36; - - .highlight{ - border-left: 1px solid #113b46; - } - - .line.hll { - background: #000; - } - - .no-highlight { - color: #DDD; - } - - pre { - background-color: #002B36; - color: #eee; - } +/* https://gist.github.com/qguv/7936275 */ +.code.solarized-dark { + pre.code, + .line-numbers, .line-numbers a { - color: #666; + background-color: #002b36 !important; + color: #93a1a1 !important; } - .hljs { - display: block; - background: #002b36; - color: #839496; - } - - .hljs-comment, - .hljs-template_comment, - .diff .hljs-header, - .hljs-doctype, - .hljs-pi, - .lisp .hljs-string, - .hljs-javadoc { - color: #586e75; - } - - /* Solarized Green */ - .hljs-keyword, - .hljs-winutils, - .method, - .hljs-addition, - .css .hljs-tag, - .hljs-request, - .hljs-status, - .nginx .hljs-title { - color: #859900; + pre.code { + border-left: 1px solid #113b46; } - /* Solarized Cyan */ - .hljs-number, - .hljs-command, - .hljs-string, - .hljs-tag .hljs-value, - .hljs-rules .hljs-value, - .hljs-phpdoc, - .tex .hljs-formula, - .hljs-regexp, - .hljs-hexcolor, - .hljs-link_url { - color: #2aa198; - } + /* Solarized Dark - /* Solarized Blue */ - .hljs-title, - .hljs-localvars, - .hljs-chunk, - .hljs-decorator, - .hljs-built_in, - .hljs-identifier, - .vhdl .hljs-literal, - .hljs-id, - .css .hljs-function { - color: #268bd2; - } + For use with Jekyll and Pygments - /* Solarized Yellow */ - .hljs-attribute, - .hljs-variable, - .lisp .hljs-body, - .smalltalk .hljs-number, - .hljs-constant, - .hljs-class .hljs-title, - .hljs-parent, - .haskell .hljs-type, - .hljs-link_reference { - color: #b58900; - } + http://ethanschoonover.com/solarized - /* Solarized Orange */ - .hljs-preprocessor, - .hljs-preprocessor .hljs-keyword, - .hljs-pragma, - .hljs-shebang, - .hljs-symbol, - .hljs-symbol .hljs-string, - .diff .hljs-change, - .hljs-special, - .hljs-attr_selector, - .hljs-subst, - .hljs-cdata, - .clojure .hljs-title, - .css .hljs-pseudo, - .hljs-header { - color: #cb4b16; - } + SOLARIZED HEX ROLE + --------- -------- ------------------------------------------ + base03 #002b36 background + base01 #586e75 comments / secondary content + base1 #93a1a1 body text / default code / primary content + orange #cb4b16 constants + red #dc322f regex, special keywords + blue #268bd2 reserved keywords + cyan #2aa198 strings, numbers + green #859900 operators, other keywords + */ - /* Solarized Red */ - .hljs-deletion, - .hljs-important { - color: #dc322f; - } - - /* Solarized Violet */ - .hljs-link_label { - color: #6c71c4; - } - - .tex .hljs-formula { - background: #073642; - } + .c { color: #586e75 } /* Comment */ + .err { color: #93a1a1 } /* Error */ + .g { color: #93a1a1 } /* Generic */ + .k { color: #859900 } /* Keyword */ + .l { color: #93a1a1 } /* Literal */ + .n { color: #93a1a1 } /* Name */ + .o { color: #859900 } /* Operator */ + .x { color: #cb4b16 } /* Other */ + .p { color: #93a1a1 } /* Punctuation */ + .cm { color: #586e75 } /* Comment.Multiline */ + .cp { color: #859900 } /* Comment.Preproc */ + .c1 { color: #586e75 } /* Comment.Single */ + .cs { color: #859900 } /* Comment.Special */ + .gd { color: #2aa198 } /* Generic.Deleted */ + .ge { color: #93a1a1; font-style: italic } /* Generic.Emph */ + .gr { color: #dc322f } /* Generic.Error */ + .gh { color: #cb4b16 } /* Generic.Heading */ + .gi { color: #859900 } /* Generic.Inserted */ + .go { color: #93a1a1 } /* Generic.Output */ + .gp { color: #93a1a1 } /* Generic.Prompt */ + .gs { color: #93a1a1; font-weight: bold } /* Generic.Strong */ + .gu { color: #cb4b16 } /* Generic.Subheading */ + .gt { color: #93a1a1 } /* Generic.Traceback */ + .kc { color: #cb4b16 } /* Keyword.Constant */ + .kd { color: #268bd2 } /* Keyword.Declaration */ + .kn { color: #859900 } /* Keyword.Namespace */ + .kp { color: #859900 } /* Keyword.Pseudo */ + .kr { color: #268bd2 } /* Keyword.Reserved */ + .kt { color: #dc322f } /* Keyword.Type */ + .ld { color: #93a1a1 } /* Literal.Date */ + .m { color: #2aa198 } /* Literal.Number */ + .s { color: #2aa198 } /* Literal.String */ + .na { color: #93a1a1 } /* Name.Attribute */ + .nb { color: #B58900 } /* Name.Builtin */ + .nc { color: #268bd2 } /* Name.Class */ + .no { color: #cb4b16 } /* Name.Constant */ + .nd { color: #268bd2 } /* Name.Decorator */ + .ni { color: #cb4b16 } /* Name.Entity */ + .ne { color: #cb4b16 } /* Name.Exception */ + .nf { color: #268bd2 } /* Name.Function */ + .nl { color: #93a1a1 } /* Name.Label */ + .nn { color: #93a1a1 } /* Name.Namespace */ + .nx { color: #93a1a1 } /* Name.Other */ + .py { color: #93a1a1 } /* Name.Property */ + .nt { color: #268bd2 } /* Name.Tag */ + .nv { color: #268bd2 } /* Name.Variable */ + .ow { color: #859900 } /* Operator.Word */ + .w { color: #93a1a1 } /* Text.Whitespace */ + .mf { color: #2aa198 } /* Literal.Number.Float */ + .mh { color: #2aa198 } /* Literal.Number.Hex */ + .mi { color: #2aa198 } /* Literal.Number.Integer */ + .mo { color: #2aa198 } /* Literal.Number.Oct */ + .sb { color: #586e75 } /* Literal.String.Backtick */ + .sc { color: #2aa198 } /* Literal.String.Char */ + .sd { color: #93a1a1 } /* Literal.String.Doc */ + .s2 { color: #2aa198 } /* Literal.String.Double */ + .se { color: #cb4b16 } /* Literal.String.Escape */ + .sh { color: #93a1a1 } /* Literal.String.Heredoc */ + .si { color: #2aa198 } /* Literal.String.Interpol */ + .sx { color: #2aa198 } /* Literal.String.Other */ + .sr { color: #dc322f } /* Literal.String.Regex */ + .s1 { color: #2aa198 } /* Literal.String.Single */ + .ss { color: #2aa198 } /* Literal.String.Symbol */ + .bp { color: #268bd2 } /* Name.Builtin.Pseudo */ + .vc { color: #268bd2 } /* Name.Variable.Class */ + .vg { color: #268bd2 } /* Name.Variable.Global */ + .vi { color: #268bd2 } /* Name.Variable.Instance */ + .il { color: #2aa198 } /* Literal.Number.Integer.Long */ } diff --git a/app/assets/stylesheets/highlight/solarized_light.scss b/app/assets/stylesheets/highlight/solarized_light.scss new file mode 100644 index 00000000000..55be6e30383 --- /dev/null +++ b/app/assets/stylesheets/highlight/solarized_light.scss @@ -0,0 +1,101 @@ +/* https://gist.github.com/qguv/7936275 */ +.code.solarized-light { + + pre.code, + .line-numbers, + .line-numbers a { + background-color: #fdf6e3 !important; + color: #586e75 !important; + } + + pre.code { + border-left: 1px solid #c5d0d4; + } + + /* Solarized Light + + For use with Jekyll and Pygments + + http://ethanschoonover.com/solarized + + SOLARIZED HEX ROLE + --------- -------- ------------------------------------------ + base01 #586e75 body text / default code / primary content + base1 #93a1a1 comments / secondary content + base3 #fdf6e3 background + orange #cb4b16 constants + red #dc322f regex, special keywords + blue #268bd2 reserved keywords + cyan #2aa198 strings, numbers + green #859900 operators, other keywords + */ + + .c { color: #93a1a1 } /* Comment */ + .err { color: #586e75 } /* Error */ + .g { color: #586e75 } /* Generic */ + .k { color: #859900 } /* Keyword */ + .l { color: #586e75 } /* Literal */ + .n { color: #586e75 } /* Name */ + .o { color: #859900 } /* Operator */ + .x { color: #cb4b16 } /* Other */ + .p { color: #586e75 } /* Punctuation */ + .cm { color: #93a1a1 } /* Comment.Multiline */ + .cp { color: #859900 } /* Comment.Preproc */ + .c1 { color: #93a1a1 } /* Comment.Single */ + .cs { color: #859900 } /* Comment.Special */ + .gd { color: #2aa198 } /* Generic.Deleted */ + .ge { color: #586e75; font-style: italic } /* Generic.Emph */ + .gr { color: #dc322f } /* Generic.Error */ + .gh { color: #cb4b16 } /* Generic.Heading */ + .gi { color: #859900 } /* Generic.Inserted */ + .go { color: #586e75 } /* Generic.Output */ + .gp { color: #586e75 } /* Generic.Prompt */ + .gs { color: #586e75; font-weight: bold } /* Generic.Strong */ + .gu { color: #cb4b16 } /* Generic.Subheading */ + .gt { color: #586e75 } /* Generic.Traceback */ + .kc { color: #cb4b16 } /* Keyword.Constant */ + .kd { color: #268bd2 } /* Keyword.Declaration */ + .kn { color: #859900 } /* Keyword.Namespace */ + .kp { color: #859900 } /* Keyword.Pseudo */ + .kr { color: #268bd2 } /* Keyword.Reserved */ + .kt { color: #dc322f } /* Keyword.Type */ + .ld { color: #586e75 } /* Literal.Date */ + .m { color: #2aa198 } /* Literal.Number */ + .s { color: #2aa198 } /* Literal.String */ + .na { color: #586e75 } /* Name.Attribute */ + .nb { color: #B58900 } /* Name.Builtin */ + .nc { color: #268bd2 } /* Name.Class */ + .no { color: #cb4b16 } /* Name.Constant */ + .nd { color: #268bd2 } /* Name.Decorator */ + .ni { color: #cb4b16 } /* Name.Entity */ + .ne { color: #cb4b16 } /* Name.Exception */ + .nf { color: #268bd2 } /* Name.Function */ + .nl { color: #586e75 } /* Name.Label */ + .nn { color: #586e75 } /* Name.Namespace */ + .nx { color: #586e75 } /* Name.Other */ + .py { color: #586e75 } /* Name.Property */ + .nt { color: #268bd2 } /* Name.Tag */ + .nv { color: #268bd2 } /* Name.Variable */ + .ow { color: #859900 } /* Operator.Word */ + .w { color: #586e75 } /* Text.Whitespace */ + .mf { color: #2aa198 } /* Literal.Number.Float */ + .mh { color: #2aa198 } /* Literal.Number.Hex */ + .mi { color: #2aa198 } /* Literal.Number.Integer */ + .mo { color: #2aa198 } /* Literal.Number.Oct */ + .sb { color: #93a1a1 } /* Literal.String.Backtick */ + .sc { color: #2aa198 } /* Literal.String.Char */ + .sd { color: #586e75 } /* Literal.String.Doc */ + .s2 { color: #2aa198 } /* Literal.String.Double */ + .se { color: #cb4b16 } /* Literal.String.Escape */ + .sh { color: #586e75 } /* Literal.String.Heredoc */ + .si { color: #2aa198 } /* Literal.String.Interpol */ + .sx { color: #2aa198 } /* Literal.String.Other */ + .sr { color: #dc322f } /* Literal.String.Regex */ + .s1 { color: #2aa198 } /* Literal.String.Single */ + .ss { color: #2aa198 } /* Literal.String.Symbol */ + .bp { color: #268bd2 } /* Name.Builtin.Pseudo */ + .vc { color: #268bd2 } /* Name.Variable.Class */ + .vg { color: #268bd2 } /* Name.Variable.Global */ + .vi { color: #268bd2 } /* Name.Variable.Instance */ + .il { color: #2aa198 } /* Literal.Number.Integer.Long */ +} diff --git a/app/assets/stylesheets/highlight/white.scss b/app/assets/stylesheets/highlight/white.scss index 8d5822937a0..050a5d241a6 100644 --- a/app/assets/stylesheets/highlight/white.scss +++ b/app/assets/stylesheets/highlight/white.scss @@ -1,196 +1,78 @@ -.white { - .line.hll { - background: #FFA; - } - - pre { - background-color: #fff; - color: #333; - } - - .hljs { - background: #FFF; - } +/* https://github.com/aahan/pygments-github-style */ +.code.white { + pre.highlight, + .line-numbers, .line-numbers a { - color: #999; - } - - .hljs { - display: block; - background: #fff; color: black; - } - - .hljs-comment, - .hljs-template_comment, - .hljs-javadoc, - .hljs-comment * { - color: #006a00; - } - - .hljs-keyword, - .hljs-literal, - .nginx .hljs-title { - color: #aa0d91; - } - .method, - .hljs-list .hljs-title, - .hljs-tag .hljs-title, - .setting .hljs-value, - .hljs-winutils, - .tex .hljs-command, - .http .hljs-title, - .hljs-request, - .hljs-status { - color: #008; - } - - .hljs-envvar, - .tex .hljs-special { - color: #660; - } - - .hljs-string { - color: #c41a16; - } - .hljs-tag .hljs-value, - .hljs-cdata, - .hljs-filter .hljs-argument, - .hljs-attr_selector, - .apache .hljs-cbracket, - .hljs-date, - .hljs-regexp { - color: #080; - } - - .hljs-sub .hljs-identifier, - .hljs-pi, - .hljs-tag, - .hljs-tag .hljs-keyword, - .hljs-decorator, - .ini .hljs-title, - .hljs-shebang, - .hljs-prompt, - .hljs-hexcolor, - .hljs-rules .hljs-value, - .hljs-symbol, - .hljs-symbol .hljs-string, - .hljs-number, - .css .hljs-function, - .clojure .hljs-title, - .clojure .hljs-built_in, - .hljs-function .hljs-title, - .coffeescript .hljs-attribute { - color: #1c00cf; - } - - .hljs-class .hljs-title, - .haskell .hljs-type, - .smalltalk .hljs-class, - .hljs-javadoctag, - .hljs-yardoctag, - .hljs-phpdoc, - .hljs-typename, - .hljs-tag .hljs-attribute, - .hljs-doctype, - .hljs-class .hljs-id, - .hljs-built_in, - .setting, - .hljs-params, - .clojure .hljs-attribute { - color: #5c2699; - } - - .hljs-variable { - color: #3f6e74; - } - .css .hljs-tag, - .hljs-rules .hljs-property, - .hljs-pseudo, - .hljs-subst { - color: #000; - } - - .css .hljs-class, - .css .hljs-id { - color: #9B703F; - } - - .hljs-value .hljs-important { - color: #ff7700; - font-weight: bold; - } - - .hljs-rules .hljs-keyword { - color: #C5AF75; - } - - .hljs-annotation, - .apache .hljs-sqbracket, - .nginx .hljs-built_in { - color: #9B859D; - } - - .hljs-preprocessor, - .hljs-preprocessor *, - .hljs-pragma { - color: #643820; - } - - .tex .hljs-formula { - background-color: #EEE; - font-style: italic; - } - - .diff .hljs-header, - .hljs-chunk { - color: #808080; - font-weight: bold; - } - - .diff .hljs-change { - background-color: #BCCFF9; - } - - .hljs-addition { - background-color: #BAEEBA; - } - - .hljs-deletion { - background-color: #FFC8BD; - } - - .hljs-comment .hljs-yardoctag { - font-weight: bold; - } - - .method .hljs-id { - color: #000; - } -} - -.shadow { - @include box-shadow(0 5px 15px #000); -} - -.file-content { - &.code .white { - .highlight { - border-left: 1px solid #eee; - } - } - - &.wiki .white { - .highlight, pre, .hljs { - background: #F9F9F9; - } - } -} - -.readme-holder .wiki, .note-body, .wiki-holder { - .white { - .highlight, pre, .hljs { - background: #F9F9F9; - } - } + background-color: #fff !important; + color: #333 !important; + } + + pre.code { + border-left: 1px solid #bbb; + } + + .hll { background-color: #f8f8f8 } + .c { color: #999988; font-style: italic; } + .err { color: #a61717; background-color: #e3d2d2; } + .k { font-weight: bold; } + .o { font-weight: bold; } + .cm { color: #999988; font-style: italic; } + .cp { color: #999999; font-weight: bold; } + .c1 { color: #999988; font-style: italic; } + .cs { color: #999999; font-weight: bold; font-style: italic; } + .gd { color: #000000; background-color: #ffdddd; } + .gd .x { color: #000000; background-color: #ffaaaa; } + .ge { font-style: italic; } + .gr { color: #aa0000; } + .gh { color: #999999; } + .gi { color: #000000; background-color: #ddffdd; } + .gi .x { color: #000000; background-color: #aaffaa; } + .go { color: #888888; } + .gp { color: #555555; } + .gs { font-weight: bold; } + .gu { color: #800080; font-weight: bold; } + .gt { color: #aa0000; } + .kc { font-weight: bold; } + .kd { font-weight: bold; } + .kn { font-weight: bold; } + .kp { font-weight: bold; } + .kr { font-weight: bold; } + .kt { color: #445588; font-weight: bold; } + .m { color: #009999; } + .s { color: #dd1144; } + .n { color: #333333; } + .na { color: teal; } + .nb { color: #0086b3; } + .nc { color: #445588; font-weight: bold; } + .no { color: teal; } + .ni { color: purple; } + .ne { color: #990000; font-weight: bold; } + .nf { color: #990000; font-weight: bold; } + .nn { color: #555555; } + .nt { color: navy; } + .nv { color: teal; } + .ow { font-weight: bold; } + .w { color: #bbbbbb; } + .mf { color: #009999; } + .mh { color: #009999; } + .mi { color: #009999; } + .mo { color: #009999; } + .sb { color: #dd1144; } + .sc { color: #dd1144; } + .sd { color: #dd1144; } + .s2 { color: #dd1144; } + .se { color: #dd1144; } + .sh { color: #dd1144; } + .si { color: #dd1144; } + .sx { color: #dd1144; } + .sr { color: #009926; } + .s1 { color: #dd1144; } + .ss { color: #990073; } + .bp { color: #999999; } + .vc { color: teal; } + .vg { color: teal; } + .vi { color: teal; } + .il { color: #009999; } + .gc { color: #999; background-color: #EAF2F5; } } diff --git a/app/assets/stylesheets/main/mixins.scss b/app/assets/stylesheets/main/mixins.scss index ebf68850f98..8435d1dae79 100644 --- a/app/assets/stylesheets/main/mixins.scss +++ b/app/assets/stylesheets/main/mixins.scss @@ -65,7 +65,16 @@ max-width: 100%; } - code { padding: 0 4px; } + *:first-child { + margin-top: 0; + } + + code { + font-family: $monospace_font; + white-space: pre; + word-wrap: normal; + padding: 0; + } h1 { margin-top: 45px; diff --git a/app/assets/stylesheets/sections/tree.scss b/app/assets/stylesheets/sections/tree.scss index bc7451e2d53..ff9464e217f 100644 --- a/app/assets/stylesheets/sections/tree.scss +++ b/app/assets/stylesheets/sections/tree.scss @@ -98,6 +98,11 @@ background: #f1f1f1; border-left: 1px solid #DDD; } + td.lines { + code { + font-family: $monospace_font; + } + } } } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f21b0bd1f50..67c02f5dfa4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5,8 +5,9 @@ module ApplicationHelper COLOR_SCHEMES = { 1 => 'white', 2 => 'dark', - 3 => 'solarized-dark', - 4 => 'monokai', + 3 => 'solarized-light', + 4 => 'solarized-dark', + 5 => 'monokai', } COLOR_SCHEMES.default = 'white' @@ -189,20 +190,6 @@ module ApplicationHelper BroadcastMessage.current end - def highlight_js(&block) - string = capture(&block) - - content_tag :div, class: "highlighted-data #{user_color_scheme_class}" do - content_tag :div, class: 'highlight' do - content_tag :pre do - content_tag :code do - string.html_safe - end - end - end - end - end - def time_ago_with_tooltip(date, placement = 'top', html_class = 'time_ago') capture_haml do haml_tag :time, date.to_s, diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 420ac3f77c7..3a282803963 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -1,10 +1,19 @@ module BlobHelper - def highlightjs_class(blob_name) - if no_highlight_files.include?(blob_name.downcase) - 'no-highlight' - else - blob_name.downcase + def highlight(blob_name, blob_content, nowrap = false) + formatter = Rugments::Formatters::HTML.new( + nowrap: nowrap, + cssclass: 'code highlight', + lineanchors: true, + lineanchorsid: 'LC' + ) + + begin + lexer = Rugments::Lexer.guess(filename: blob_name, source: blob_content) + rescue Rugments::Lexer::AmbiguousGuess + lexer = Rugments::Lexers::PlainText end + + formatter.format(lexer.lex(blob_content)).html_safe end def no_highlight_files diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml index bdf02c6285d..c507ecf2e49 100644 --- a/app/views/projects/blame/show.html.haml +++ b/app/views/projects/blame/show.html.haml @@ -26,9 +26,9 @@ = i \ %td.lines - %pre - %code{ class: highlightjs_class(@blob.name) } + %pre{class: 'code highlight white'} + %code :erb <% lines.each do |line| %> - <%= line %> + <%= highlight(@blob.name, line, true).html_safe %> <% end %> diff --git a/app/views/projects/blob/_text.html.haml b/app/views/projects/blob/_text.html.haml index 7cbea7c3eb6..f6bd62f239b 100644 --- a/app/views/projects/blob/_text.html.haml +++ b/app/views/projects/blob/_text.html.haml @@ -8,6 +8,6 @@ - else .file-content.code - unless blob.empty? - = render 'shared/file_hljs', blob: blob + = render 'shared/file_highlight', blob: blob - else .nothing-here-block Empty file diff --git a/app/views/projects/wikis/history.html.haml b/app/views/projects/wikis/history.html.haml index b30eff94f2c..9c9a9933dcf 100644 --- a/app/views/projects/wikis/history.html.haml +++ b/app/views/projects/wikis/history.html.haml @@ -24,7 +24,7 @@ %td = commit.message %td - #{time_ago_with_tooltip(version.date)} + #{time_ago_with_tooltip(version.authored_date)} %td %strong = @page.page.wiki.page(@page.page.name, commit.id).try(:format) diff --git a/app/views/search/results/_blob.html.haml b/app/views/search/results/_blob.html.haml index b46b4832e19..dae641dab4f 100644 --- a/app/views/search/results/_blob.html.haml +++ b/app/views/search/results/_blob.html.haml @@ -6,4 +6,4 @@ %strong = blob.filename .file-content.code.term - = render 'shared/file_hljs', blob: blob, first_line_number: blob.startline + = render 'shared/file_highlight', blob: blob, first_line_number: blob.startline, user_color_scheme_class: 'white' diff --git a/app/views/search/results/_wiki_blob.html.haml b/app/views/search/results/_wiki_blob.html.haml index e361074b6a0..c7bc596eb14 100644 --- a/app/views/search/results/_wiki_blob.html.haml +++ b/app/views/search/results/_wiki_blob.html.haml @@ -6,4 +6,4 @@ %strong = wiki_blob.filename .file-content.code.term - = render 'shared/file_hljs', blob: wiki_blob, first_line_number: wiki_blob.startline + = render 'shared/file_highlight', blob: wiki_blob, first_line_number: wiki_blob.startline, user_color_scheme_class: 'white' diff --git a/app/views/shared/_file_hljs.html.haml b/app/views/shared/_file_highlight.html.haml index 444c948b026..52b48ff7451 100644 --- a/app/views/shared/_file_hljs.html.haml +++ b/app/views/shared/_file_highlight.html.haml @@ -1,4 +1,4 @@ -%div.highlighted-data{class: user_color_scheme_class} +.file-content.code{class: user_color_scheme_class} .line-numbers - if blob.data.present? - blob.data.lines.to_a.size.times do |index| @@ -7,7 +7,4 @@ = link_to "#L#{i}", id: "L#{i}", rel: "#L#{i}" do %i.fa.fa-link = i - .highlight - %pre - %code{ class: highlightjs_class(blob.name) } - #{blob.data} + = highlight(blob.name, blob.data) diff --git a/app/views/shared/snippets/_blob.html.haml b/app/views/shared/snippets/_blob.html.haml index 8cec6168ab8..30458793fd1 100644 --- a/app/views/shared/snippets/_blob.html.haml +++ b/app/views/shared/snippets/_blob.html.haml @@ -8,7 +8,7 @@ = render_markup(@snippet.file_name, @snippet.data) - else .file-content.code - = render 'shared/file_hljs', blob: @snippet + = render 'shared/file_highlight', blob: @snippet - else .file-content.code .nothing-here-block Empty file |