summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-14 21:10:41 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-14 21:10:41 +0200
commita62a304249f7fcd7fca0123986d170cac8fd75db (patch)
treee376c17bff3a2d272daf4a5f159533497d2100b9
parent15001355da1f704c69138f696e97b040db965d43 (diff)
downloadgitlab-ci-a62a304249f7fcd7fca0123986d170cac8fd75db.tar.gz
ajax image. Changed trace logic. Make sure we always close tags for trace
-rw-r--r--app/assets/images/loader.gifbin0 -> 4405 bytes
-rw-r--r--app/helpers/application_helper.rb3
-rw-r--r--app/models/build.rb10
-rw-r--r--app/views/builds/show.html.haml2
-rw-r--r--app/views/builds/show.js.haml3
-rw-r--r--db/seeds.rb2
-rw-r--r--lib/ansi2html.rb12
7 files changed, 24 insertions, 8 deletions
diff --git a/app/assets/images/loader.gif b/app/assets/images/loader.gif
new file mode 100644
index 0000000..2fcb8f2
--- /dev/null
+++ b/app/assets/images/loader.gif
Binary files differ
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index de6be79..51a7063 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,2 +1,5 @@
module ApplicationHelper
+ def loader_html
+ image_tag 'loader.gif'
+ end
end
diff --git a/app/models/build.rb b/app/models/build.rb
index 2f425ce..fd3daea 100644
--- a/app/models/build.rb
+++ b/app/models/build.rb
@@ -41,15 +41,19 @@ class Build < ActiveRecord::Base
def write_trace(trace)
self.reload
- update_attributes(trace: ansi_color_codes(trace))
+ update_attributes(trace: trace)
end
def short_sha
sha[0..8]
end
- def ansi_color_codes(string)
- Ansi2html::convert(string)
+ def trace_html
+ if trace.present?
+ Ansi2html::convert(trace)
+ else
+ ''
+ end
end
def to_param
diff --git a/app/views/builds/show.html.haml b/app/views/builds/show.html.haml
index 55092ae..7fec127 100644
--- a/app/views/builds/show.html.haml
+++ b/app/views/builds/show.html.haml
@@ -39,7 +39,7 @@
.clearfix
%pre.trace#build-trace
= preserve do
- = raw @build.trace
+ = raw @build.trace_html
.span3
.builds
%h5 Builds for #{@build.short_sha}
diff --git a/app/views/builds/show.js.haml b/app/views/builds/show.js.haml
index 29accab..d47a8b8 100644
--- a/app/views/builds/show.js.haml
+++ b/app/views/builds/show.js.haml
@@ -1,6 +1,7 @@
- if @build.running?
:plain
- $('#build-trace').html("#{escape_javascript(@build.trace)}");
+ $('#build-trace').html("#{escape_javascript(@build.trace_html)}");
+ $('#build-trace').append('#{loader_html}');
getBuild('#{project_build_path(@project, @build)}');
- else
:plain
diff --git a/db/seeds.rb b/db/seeds.rb
index 0157426..e0573ca 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -10,7 +10,7 @@ User.create(
if Rails.env == 'development'
`cd #{Rails.root.join('tmp')} && git clone https://github.com/randx/six.git test_repo`
- 10.times do |i|
+ 3.times do |i|
FactoryGirl.create :project,
name: "Six #{i}",
scripts: 'bundle exec rspec spec'
diff --git a/lib/ansi2html.rb b/lib/ansi2html.rb
index 5650d81..9375075 100644
--- a/lib/ansi2html.rb
+++ b/lib/ansi2html.rb
@@ -15,13 +15,21 @@ module Ansi2html
def self.convert(ansi)
out = ""
+ tag_open = false
s = StringScanner.new(ansi.gsub("<", "&lt;"))
while(!s.eos?)
- if s.scan(/\e\[(3[0-7]|90|1)m/)
+ if s.scan(/\e\[(3[0-7]|90|1)m/) || s.scan(/\[1;(3[0-7])m/)
+ if tag_open
+ out << %{</span>}
+ end
out << %{<span class="#{COLOR[s[1]]}">}
+ tag_open = true
else
if s.scan(/\e\[0m/)
- out << %{</span>}
+ if tag_open
+ out << %{</span>}
+ end
+ tag_open = false
else
out << s.scan(/./m)
end