From 676933bdfe3b740c3f30dd040cf544e02e406ae3 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 5 Jul 2016 11:51:31 +0100 Subject: [PATCH 01/10] Moved ansi2html into the frontend JS --- app/assets/javascripts/ci/ansi2html.js.coffee | 73 +++++++++++++++++++ app/assets/javascripts/ci/build.coffee | 7 +- app/assets/stylesheets/pages/builds.scss | 12 +++ 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/ci/ansi2html.js.coffee diff --git a/app/assets/javascripts/ci/ansi2html.js.coffee b/app/assets/javascripts/ci/ansi2html.js.coffee new file mode 100644 index 000000000000..ce1660a5822d --- /dev/null +++ b/app/assets/javascripts/ci/ansi2html.js.coffee @@ -0,0 +1,73 @@ +class @Ansi2Html + constructor: -> + @_colorRegex = /\[[0-9]+;[0-9]?m/g + @_colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'] + @_html = [] + + html: -> + @_html + + convertTrace: (trace) -> + if trace? + @trace = trace.trim().split('\n') + + for line, i in @trace + @convertLine(line, i+1) + + return @ + + convertLine: (line, number) -> + lineText = if line is '' then ' ' else line + codes = @getAnsiCodes(line) + + lineEl = @createLine(lineText, number) + lineEl.prepend @lineLink(number) + + if codes? + lineEl + .find('span') + .addClass @getColorClass(codes.color, codes.modifier) + + @_html.push(lineEl) + + createLine: (line, number) -> + $('

', + id: "line-#{number}" + class: 'build-trace-line' + ).append $('', + text: @removeAnsiCodes(line) + ) + + lineLink: (number) -> + $('', + class: 'build-trace-line-number' + href: "#line-#{number}" + text: number + ) + + getAnsiCodes: (line) -> + matches = line.match(@_colorRegex) + + if matches? + match = matches[0] + modifierSplit = match.split(';') + color = modifierSplit[0].substring(1) + colorText = @_colors[color[1]] + modifier = modifierSplit[1][0] + + if colorText? + return { + color: colorText + modifier: modifier + } + + removeAnsiCodes: (line) -> + line.replace(@_colorRegex, '') + + getColorClass: (color, modifier) -> + if modifier? and modifier is "1" + modifier = "l-" + else + modifier = '' + + "term-fg-#{modifier}#{color}" diff --git a/app/assets/javascripts/ci/build.coffee b/app/assets/javascripts/ci/build.coffee index 74691b2c1b51..e49b362567da 100644 --- a/app/assets/javascripts/ci/build.coffee +++ b/app/assets/javascripts/ci/build.coffee @@ -5,6 +5,8 @@ class @CiBuild constructor: (@page_url, @build_url, @build_status, @state) -> clearInterval(CiBuild.interval) + @ansi = new Ansi2Html() + # Init breakpoint checker @bp = Breakpoints.get() @hideSidebar() @@ -49,8 +51,9 @@ class @CiBuild $.ajax url: @build_url dataType: 'json' - success: (build_data) -> - $('.js-build-output').html build_data.trace_html + success: (build_data) => + html = @ansi.convertTrace(build_data.trace).html() + $('.js-build-output').replaceWith html if build_data.status is 'success' or build_data.status is 'failed' $('.js-build-refresh').remove() diff --git a/app/assets/stylesheets/pages/builds.scss b/app/assets/stylesheets/pages/builds.scss index e8f1935d239e..6d774c976146 100644 --- a/app/assets/stylesheets/pages/builds.scss +++ b/app/assets/stylesheets/pages/builds.scss @@ -142,3 +142,15 @@ table.builds { right: 0; margin-top: -17px; } + +.build-trace-line { + margin: 0; + padding: 0; +} + +.build-trace-line-number { + display: inline-block; + padding-right: 10px; + min-width: 40px; + text-align: right; +} -- GitLab From e78fd8da106986cbfefedad2e94032ead40ab0be Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 5 Jul 2016 12:31:24 +0100 Subject: [PATCH 02/10] Converts background colors and modifiers --- app/assets/javascripts/ci/ansi2html.js.coffee | 34 ++++++++++++++----- app/assets/javascripts/ci/build.coffee | 2 +- app/assets/stylesheets/pages/builds.scss | 19 +++++++++-- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/ci/ansi2html.js.coffee b/app/assets/javascripts/ci/ansi2html.js.coffee index ce1660a5822d..776a80bdf42c 100644 --- a/app/assets/javascripts/ci/ansi2html.js.coffee +++ b/app/assets/javascripts/ci/ansi2html.js.coffee @@ -26,7 +26,8 @@ class @Ansi2Html if codes? lineEl .find('span') - .addClass @getColorClass(codes.color, codes.modifier) + .addClass @getColorClass(codes.color, codes.type, codes.bold) + .addClass @getModifierClass(codes.modifier) @_html.push(lineEl) @@ -52,6 +53,7 @@ class @Ansi2Html match = matches[0] modifierSplit = match.split(';') color = modifierSplit[0].substring(1) + colorInt = parseInt(color) colorText = @_colors[color[1]] modifier = modifierSplit[1][0] @@ -59,15 +61,31 @@ class @Ansi2Html return { color: colorText modifier: modifier + bold: modifier is "1" + type: @getLineType(color) } + getLineType: (code) -> + if code >= 40 and code < 90 or code >= 100 + 'bg' + else + 'fg' + removeAnsiCodes: (line) -> line.replace(@_colorRegex, '') - getColorClass: (color, modifier) -> - if modifier? and modifier is "1" - modifier = "l-" - else - modifier = '' - - "term-fg-#{modifier}#{color}" + getColorClass: (color, type, bold) -> + bold = if bold then 'l-' else '' + + "term-#{type}-#{bold}#{color}" + + getModifierClass: (modifier) -> + unless modifier is "1" + if modifier is "3" + "term-italic" + else if modifier is "4" + "term-underline" + else if modifier is "8" + "term-conceal" + else if modifier is "9" + "term-cross" diff --git a/app/assets/javascripts/ci/build.coffee b/app/assets/javascripts/ci/build.coffee index e49b362567da..a4f000aa5027 100644 --- a/app/assets/javascripts/ci/build.coffee +++ b/app/assets/javascripts/ci/build.coffee @@ -53,7 +53,7 @@ class @CiBuild dataType: 'json' success: (build_data) => html = @ansi.convertTrace(build_data.trace).html() - $('.js-build-output').replaceWith html + $('.js-build-output').append html if build_data.status is 'success' or build_data.status is 'failed' $('.js-build-refresh').remove() diff --git a/app/assets/stylesheets/pages/builds.scss b/app/assets/stylesheets/pages/builds.scss index 6d774c976146..93261c1681de 100644 --- a/app/assets/stylesheets/pages/builds.scss +++ b/app/assets/stylesheets/pages/builds.scss @@ -92,11 +92,13 @@ table.builds { } .build-trace { + padding: 10px 0; background: $ci-output-bg; color: $ci-text-color; white-space: pre; overflow-x: auto; - font-size: 12px; + font-size: 13px; + line-height: 20px; .fa-refresh { font-size: 24px; @@ -145,12 +147,23 @@ table.builds { .build-trace-line { margin: 0; - padding: 0; + padding-left: 60px; + + &:hover { + background-color: lighten($ci-output-bg, 10%); + } } .build-trace-line-number { display: inline-block; padding-right: 10px; - min-width: 40px; + margin-left: -60px; + min-width: 60px; + color: $gl-text-color; text-align: right; + + &:hover { + color: $gl-text-color; + text-decoration: none; + } } -- GitLab From d34fbdc3c7064b5d5532ef6c658c4f5c0f0a49da Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 5 Jul 2016 12:50:08 +0100 Subject: [PATCH 03/10] Replaces previous line --- app/assets/javascripts/ci/ansi2html.js.coffee | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/ci/ansi2html.js.coffee b/app/assets/javascripts/ci/ansi2html.js.coffee index 776a80bdf42c..5b4de44ea3e3 100644 --- a/app/assets/javascripts/ci/ansi2html.js.coffee +++ b/app/assets/javascripts/ci/ansi2html.js.coffee @@ -21,15 +21,22 @@ class @Ansi2Html codes = @getAnsiCodes(line) lineEl = @createLine(lineText, number) - lineEl.prepend @lineLink(number) - if codes? - lineEl + if lineText.indexOf('\r') >= 0 + lastEl = @_html[@_html.length - 1] + lastEl .find('span') - .addClass @getColorClass(codes.color, codes.type, codes.bold) - .addClass @getModifierClass(codes.modifier) + .text(@removeAnsiCodes(lineText)) + else + lineEl.prepend @lineLink(number) + + if codes? + lineEl + .find('span') + .addClass @getColorClass(codes.color, codes.type, codes.bold) + .addClass @getModifierClass(codes.modifier) - @_html.push(lineEl) + @_html.push(lineEl) createLine: (line, number) -> $('

', -- GitLab From 20ba272a66ec62b55f64b84d09f3ca0ea6442bd9 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 6 Jul 2016 14:27:21 +0100 Subject: [PATCH 04/10] Split up the JS to have a 'ci' application.js Fixed auto-reload build to use new renderer --- app/assets/javascripts/application.js.coffee | 1 - app/assets/javascripts/ci/ansi2html.js.coffee | 20 ++++++++++--------- app/assets/javascripts/ci/build.coffee | 7 +++---- app/assets/stylesheets/pages/builds.scss | 3 ++- app/views/projects/builds/show.html.haml | 3 +++ 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 20fe5a5cc273..6c3f3da0f945 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -47,7 +47,6 @@ #= require date.format #= require_directory ./behaviors #= require_directory ./blob -#= require_directory ./ci #= require_directory ./commit #= require_directory ./extensions #= require_directory ./lib/utils diff --git a/app/assets/javascripts/ci/ansi2html.js.coffee b/app/assets/javascripts/ci/ansi2html.js.coffee index 5b4de44ea3e3..4282ff33bcd0 100644 --- a/app/assets/javascripts/ci/ansi2html.js.coffee +++ b/app/assets/javascripts/ci/ansi2html.js.coffee @@ -1,5 +1,6 @@ class @Ansi2Html constructor: -> + @_currentLine = 0 @_colorRegex = /\[[0-9]+;[0-9]?m/g @_colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'] @_html = [] @@ -12,15 +13,16 @@ class @Ansi2Html @trace = trace.trim().split('\n') for line, i in @trace - @convertLine(line, i+1) + @_currentLine = @_currentLine + 1 + @convertLine(line) return @ - convertLine: (line, number) -> + convertLine: (line) -> lineText = if line is '' then ' ' else line codes = @getAnsiCodes(line) - lineEl = @createLine(lineText, number) + lineEl = @createLine(lineText) if lineText.indexOf('\r') >= 0 lastEl = @_html[@_html.length - 1] @@ -28,7 +30,7 @@ class @Ansi2Html .find('span') .text(@removeAnsiCodes(lineText)) else - lineEl.prepend @lineLink(number) + lineEl.prepend @lineLink() if codes? lineEl @@ -38,19 +40,19 @@ class @Ansi2Html @_html.push(lineEl) - createLine: (line, number) -> + createLine: (line) -> $('

', - id: "line-#{number}" + id: "line-#{@_currentLine}" class: 'build-trace-line' ).append $('', text: @removeAnsiCodes(line) ) - lineLink: (number) -> + lineLink: -> $('', class: 'build-trace-line-number' - href: "#line-#{number}" - text: number + href: "#line-#{@_currentLine}" + text: @_currentLine ) getAnsiCodes: (line) -> diff --git a/app/assets/javascripts/ci/build.coffee b/app/assets/javascripts/ci/build.coffee index a4f000aa5027..97f86585dc47 100644 --- a/app/assets/javascripts/ci/build.coffee +++ b/app/assets/javascripts/ci/build.coffee @@ -67,10 +67,9 @@ class @CiBuild @state = log.state if log.status is "running" - if log.append - $('.js-build-output').append log.html - else - $('.js-build-output').html log.html + unless log.text is '' + html = @ansi.convertTrace(log.text).html() + $('.js-build-output').append html @checkAutoscroll() else if log.status isnt @build_status Turbolinks.visit @page_url diff --git a/app/assets/stylesheets/pages/builds.scss b/app/assets/stylesheets/pages/builds.scss index 93261c1681de..700a9011c6b1 100644 --- a/app/assets/stylesheets/pages/builds.scss +++ b/app/assets/stylesheets/pages/builds.scss @@ -95,12 +95,13 @@ table.builds { padding: 10px 0; background: $ci-output-bg; color: $ci-text-color; - white-space: pre; + white-space: normal; overflow-x: auto; font-size: 13px; line-height: 20px; .fa-refresh { + margin-left: 10px; font-size: 24px; } diff --git a/app/views/projects/builds/show.html.haml b/app/views/projects/builds/show.html.haml index 4e801cc72fea..6a9a9aa8de5a 100644 --- a/app/views/projects/builds/show.html.haml +++ b/app/views/projects/builds/show.html.haml @@ -2,6 +2,9 @@ - trace_with_state = @build.trace_with_state - header_title project_title(@project, "Builds", project_builds_path(@project)) +- content_for :page_specific_javascripts do + = page_specific_javascript_tag('ci/application.js') + .build-page = render "header" -- GitLab From e6a03ba7d468878db85cbdfa4dd104be83111d23 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 6 Jul 2016 17:16:10 +0100 Subject: [PATCH 05/10] Clears previous text --- app/assets/javascripts/ci/ansi2html.js.coffee | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/ci/ansi2html.js.coffee b/app/assets/javascripts/ci/ansi2html.js.coffee index 4282ff33bcd0..ed1494ea1073 100644 --- a/app/assets/javascripts/ci/ansi2html.js.coffee +++ b/app/assets/javascripts/ci/ansi2html.js.coffee @@ -2,6 +2,7 @@ class @Ansi2Html constructor: -> @_currentLine = 0 @_colorRegex = /\[[0-9]+;[0-9]?m/g + @_replaceLineRegex = /(\r|(\[[0-9]+k))/g @_colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'] @_html = [] @@ -10,7 +11,7 @@ class @Ansi2Html convertTrace: (trace) -> if trace? - @trace = trace.trim().split('\n') + @trace = trace.split('\n') for line, i in @trace @_currentLine = @_currentLine + 1 @@ -19,17 +20,27 @@ class @Ansi2Html return @ convertLine: (line) -> + prepend = true lineText = if line is '' then ' ' else line codes = @getAnsiCodes(line) lineEl = @createLine(lineText) - if lineText.indexOf('\r') >= 0 + if lineText.indexOf(@_replaceLineRegex) >= 0 and lineText.indexOf('$') < 0 + prepend = false lastEl = @_html[@_html.length - 1] - lastEl - .find('span') - .text(@removeAnsiCodes(lineText)) - else + + if lastEl.find('span').text().indexOf('$') is 1 + prepend = true + else + lineText = @removeAnsiCodes(lineText) + lineText = @replaceLine(lineText) + + lastEl + .find('span') + .text(lineText) + + if prepend lineEl.prepend @lineLink() if codes? @@ -41,6 +52,9 @@ class @Ansi2Html @_html.push(lineEl) createLine: (line) -> + line = @removeAnsiCodes(line) + line = @replaceLine(line) + $('

', id: "line-#{@_currentLine}" class: 'build-trace-line' @@ -83,6 +97,10 @@ class @Ansi2Html removeAnsiCodes: (line) -> line.replace(@_colorRegex, '') + replaceLine: (line) -> + lineSplit = line.split(@_replaceLineRegex) + lineSplit[lineSplit.length - 1] + getColorClass: (color, type, bold) -> bold = if bold then 'l-' else '' -- GitLab From 7c5630eb50eea249570d89ec5ebebfac845fb867 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 6 Jul 2016 17:39:33 +0100 Subject: [PATCH 06/10] Correctly searchs for clear line --- app/assets/javascripts/ci/ansi2html.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/ci/ansi2html.js.coffee b/app/assets/javascripts/ci/ansi2html.js.coffee index ed1494ea1073..d06825c25d5b 100644 --- a/app/assets/javascripts/ci/ansi2html.js.coffee +++ b/app/assets/javascripts/ci/ansi2html.js.coffee @@ -26,7 +26,7 @@ class @Ansi2Html lineEl = @createLine(lineText) - if lineText.indexOf(@_replaceLineRegex) >= 0 and lineText.indexOf('$') < 0 + if lineText.search(@_replaceLineRegex) >= 0 and lineText.indexOf('$') < 0 prepend = false lastEl = @_html[@_html.length - 1] -- GitLab From f76d40119d77ce07a9a062a0060e8000728e3f63 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 8 Jul 2016 11:10:16 +0100 Subject: [PATCH 07/10] Color individual text --- app/assets/javascripts/ci/ansi2html.js.coffee | 58 +++++++++---------- app/assets/stylesheets/pages/xterm.scss | 1 + 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/app/assets/javascripts/ci/ansi2html.js.coffee b/app/assets/javascripts/ci/ansi2html.js.coffee index d06825c25d5b..ca1360f2bc91 100644 --- a/app/assets/javascripts/ci/ansi2html.js.coffee +++ b/app/assets/javascripts/ci/ansi2html.js.coffee @@ -1,7 +1,8 @@ class @Ansi2Html constructor: -> @_currentLine = 0 - @_colorRegex = /\[[0-9]+;[0-9]?m/g + @_ansiRegex = /\[[0-9]+;?[0-9]?m/g + @_colorRegex = /\[[0-9]+;?[0-9]?m((.*))\[0+;?m/g @_replaceLineRegex = /(\r|(\[[0-9]+k))/g @_colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'] @_html = [] @@ -22,11 +23,11 @@ class @Ansi2Html convertLine: (line) -> prepend = true lineText = if line is '' then ' ' else line - codes = @getAnsiCodes(line) + clearLineIndex = lineText.search(@_replaceLineRegex) lineEl = @createLine(lineText) - if lineText.search(@_replaceLineRegex) >= 0 and lineText.indexOf('$') < 0 + if (clearLineIndex >= 0 and clearLineIndex is not lineText.length - 1) and lineText.indexOf('$') < 0 prepend = false lastEl = @_html[@_html.length - 1] @@ -42,25 +43,16 @@ class @Ansi2Html if prepend lineEl.prepend @lineLink() - - if codes? - lineEl - .find('span') - .addClass @getColorClass(codes.color, codes.type, codes.bold) - .addClass @getModifierClass(codes.modifier) - @_html.push(lineEl) createLine: (line) -> - line = @removeAnsiCodes(line) line = @replaceLine(line) + line = @getInnerTextWithColors(line) $('

', id: "line-#{@_currentLine}" class: 'build-trace-line' - ).append $('', - text: @removeAnsiCodes(line) - ) + ).append $('').append line lineLink: -> $('', @@ -69,24 +61,28 @@ class @Ansi2Html text: @_currentLine ) - getAnsiCodes: (line) -> + getInnerTextWithColors: (line) -> matches = line.match(@_colorRegex) if matches? - match = matches[0] - modifierSplit = match.split(';') - color = modifierSplit[0].substring(1) - colorInt = parseInt(color) - colorText = @_colors[color[1]] - modifier = modifierSplit[1][0] - - if colorText? - return { - color: colorText - modifier: modifier - bold: modifier is "1" - type: @getLineType(color) - } + for match in matches + color = match.match(@_ansiRegex).slice(0, -1) + color = color[color.length - 1] + modifierSplit = color.split(/(;|m)/g) + color = modifierSplit[0].substring(1) + colorInt = parseInt(color) + colorText = @_colors[color[1]] + modifier = modifierSplit[1][0] + + # Create inner span + $span = $('', + text: @removeAnsiCodes(match) + class: @getColorClass(colorText, @getLineType(color), modifier is "1") + ) + line = line.replace(match, $span.get(0).outerHTML) + else + line = @removeAnsiCodes(line) + line getLineType: (code) -> if code >= 40 and code < 90 or code >= 100 @@ -95,11 +91,11 @@ class @Ansi2Html 'fg' removeAnsiCodes: (line) -> - line.replace(@_colorRegex, '') + line.replace(@_ansiRegex, '') replaceLine: (line) -> lineSplit = line.split(@_replaceLineRegex) - lineSplit[lineSplit.length - 1] + lineSplit[0] getColorClass: (color, type, bold) -> bold = if bold then 'l-' else '' diff --git a/app/assets/stylesheets/pages/xterm.scss b/app/assets/stylesheets/pages/xterm.scss index 8d855ce99b02..cf8d59d07fdc 100644 --- a/app/assets/stylesheets/pages/xterm.scss +++ b/app/assets/stylesheets/pages/xterm.scss @@ -92,6 +92,7 @@ background-color: $green; } .term-bg-yellow { + color: $black; background-color: $yellow; } .term-bg-blue { -- GitLab From aa9814c61ad4f265640fda66651b73e5d86eb86b Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 8 Jul 2016 11:29:38 +0100 Subject: [PATCH 08/10] Fixed issue with colors not setting correctly Fixed lines not clearing --- app/assets/javascripts/ci/ansi2html.js.coffee | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/ci/ansi2html.js.coffee b/app/assets/javascripts/ci/ansi2html.js.coffee index ca1360f2bc91..521bd690bd6d 100644 --- a/app/assets/javascripts/ci/ansi2html.js.coffee +++ b/app/assets/javascripts/ci/ansi2html.js.coffee @@ -2,7 +2,7 @@ class @Ansi2Html constructor: -> @_currentLine = 0 @_ansiRegex = /\[[0-9]+;?[0-9]?m/g - @_colorRegex = /\[[0-9]+;?[0-9]?m((.*))\[0+;?m/g + @_colorRegex = /\[[0-9]+;?[0-9]?m((.*))(\[0+;?m)?/g @_replaceLineRegex = /(\r|(\[[0-9]+k))/g @_colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'] @_html = [] @@ -66,9 +66,12 @@ class @Ansi2Html if matches? for match in matches - color = match.match(@_ansiRegex).slice(0, -1) + color = match.match(@_ansiRegex) + if color.length > 1 + color = color.slice(0, -1) + color = color[color.length - 1] - modifierSplit = color.split(/(;|m)/g) + modifierSplit = color.split(/;|m/) color = modifierSplit[0].substring(1) colorInt = parseInt(color) colorText = @_colors[color[1]] @@ -94,8 +97,10 @@ class @Ansi2Html line.replace(@_ansiRegex, '') replaceLine: (line) -> - lineSplit = line.split(@_replaceLineRegex) - lineSplit[0] + lineSplit = line.split(@_replaceLineRegex).filter (text) -> + text = '' if not text? + text.trim().length > 0 + lineSplit[lineSplit.length - 1] getColorClass: (color, type, bold) -> bold = if bold then 'l-' else '' -- GitLab From 2a68cbe9c6954beb0ac9ae44407243050a1db902 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 8 Jul 2016 12:06:10 +0100 Subject: [PATCH 09/10] Correctly clears ansi codes from output --- app/assets/javascripts/ci/ansi2html.js.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/ci/ansi2html.js.coffee b/app/assets/javascripts/ci/ansi2html.js.coffee index 521bd690bd6d..a1ec0fe0535e 100644 --- a/app/assets/javascripts/ci/ansi2html.js.coffee +++ b/app/assets/javascripts/ci/ansi2html.js.coffee @@ -3,7 +3,7 @@ class @Ansi2Html @_currentLine = 0 @_ansiRegex = /\[[0-9]+;?[0-9]?m/g @_colorRegex = /\[[0-9]+;?[0-9]?m((.*))(\[0+;?m)?/g - @_replaceLineRegex = /(\r|(\[[0-9]+k))/g + @_replaceLineRegex = /(\r|(\[([0-9]?)+k))/gi @_colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'] @_html = [] @@ -69,7 +69,7 @@ class @Ansi2Html color = match.match(@_ansiRegex) if color.length > 1 color = color.slice(0, -1) - + color = color[color.length - 1] modifierSplit = color.split(/;|m/) color = modifierSplit[0].substring(1) @@ -97,10 +97,15 @@ class @Ansi2Html line.replace(@_ansiRegex, '') replaceLine: (line) -> + return line if line.indexOf('$') >= 0 lineSplit = line.split(@_replaceLineRegex).filter (text) -> text = '' if not text? text.trim().length > 0 - lineSplit[lineSplit.length - 1] + + if lineSplit.length > 0 + lineSplit[lineSplit.length - 1] + else + line getColorClass: (color, type, bold) -> bold = if bold then 'l-' else '' -- GitLab From c418c70d3f4cddcff3ea348cf9779bacebfc4ec0 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 11 Jul 2016 11:23:08 +0100 Subject: [PATCH 10/10] Added CI JS file to application.rb --- config/application.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/application.rb b/config/application.rb index 2b0595ede2b2..81eda92b02ee 100644 --- a/config/application.rb +++ b/config/application.rb @@ -84,6 +84,7 @@ class Application < Rails::Application config.assets.precompile << "graphs/application.js" config.assets.precompile << "users/application.js" config.assets.precompile << "network/application.js" + config.assets.precompile << "ci/application.js" config.assets.precompile << "lib/utils/*.js" config.assets.precompile << "lib/*.js" -- GitLab