Skip to content
Browse files

Merge branch 'hstove-master'

  • Loading branch information...
2 parents d2e16f3 + 7791f8f commit 29c80b8a29f52e4f9e6a497dd01cef78d1685d1d Kevin Burke committed Jan 20, 2013
Showing with 40 additions and 19 deletions.
  1. +3 −1 app/app.rb
  2. +3 −1 app/templates/index.mustache
  3. +11 −1 app/views/index.rb
  4. +6 −0 public/css/style.css
  5. +17 −16 public/js/hurl.js
View
4 app/app.rb
@@ -171,13 +171,15 @@ def initialize(*args)
type = url =~ /(\.js)$/ ? 'js' : curl.content_type
body = pretty_print(type, curl.body_str)
request = pretty_print_requests(sent_headers, post_data)
+ params['response_time'] = curl.total_time
json :header => header,
:body => body,
:request => request,
:hurl_id => save_hurl(params),
:prev_hurl => @user ? @user.second_to_last_hurl_id : nil,
- :view_id => save_view(header, body, request)
+ :view_id => save_view(header, body, request),
+ :response_time => curl.total_time
rescue => e
json :error => CGI::escapeHTML(e.to_s)
end
View
4 app/templates/index.mustache
@@ -126,6 +126,7 @@
</div>
<div id="request-and-response" {{# hide_request_and_response? }}style="display:none;"{{/ hide_request_and_response? }}>
<div class="utils">
+ <span class="response-time">{{ hurl_response_time_pretty }}</span>
<a href="{{ view_permalink }}" class="full-size-link nav-item" target="_blank">view full size</a>
<a href="{{ hurl_permalink }}" class="permalink nav-item">permalink</a>
</div>
@@ -150,7 +151,8 @@
</div>
</div>
<div class="utils">
+ <span class="response-time">{{ hurl_response_time_pretty }}</span>
<a href="#" class="full-size-link nav-item" target="_blank">view full size</a>
<a href="#" class="permalink nav-item">permalink</a>
</div>
-</div>
+</div>
View
12 app/views/index.rb
@@ -114,6 +114,16 @@ def follows_redirects?
@hurl['follows_redirects']
end
+ def hurl_response_time
+ @hurl['response_time']
+ end
+
+ def hurl_response_time_pretty
+ if hurl_response_time
+ hurl_response_time.round(3).to_s + " seconds"
+ end
+ end
+
#
# view related
@@ -132,4 +142,4 @@ def view
[ :header => @view['header'], :body => @view['body'] ]
end
end
-end
+end
View
6 public/css/style.css
@@ -275,3 +275,9 @@ td.date {
.unicorn {
text-align: center;
}
+
+.response-time{
+ margin-right: 10px;
+ color: #ddd;
+ font-size: 12px;
+}
View
33 public/js/hurl.js
@@ -8,23 +8,23 @@ var Hurl = {
// indicate inputs using defaults
self.addClass('defaulted')
- if (self.val() === '' || self.val() === title) {
- self.val(title).css('color', '#E9EAEA')
- } else {
- self.addClass('focused')
+ if (self.val() === '' || self.val() === title) {
+ self.val(title).css('color', '#E9EAEA')
+ } else {
+ self.addClass('focused')
}
- self.focus(function() {
- if (self.val() === title) {
- self.val('').addClass('focused').css('color', '#333')
- }
- })
-
- self.blur(function() {
- if (self.val() === '') {
- self.val(title).removeClass('focused').css('color', '#E9EAEA')
- }
- })
+ self.focus(function() {
+ if (self.val() === title) {
+ self.val('').addClass('focused').css('color', '#333')
+ }
+ })
+
+ self.blur(function() {
+ if (self.val() === '') {
+ self.val(title).removeClass('focused').css('color', '#E9EAEA')
+ }
+ })
})
},
@@ -211,6 +211,7 @@ $(document).ready(function() {
$('#request').html(data.request)
$('#response').html('<pre>' + data.header + '</pre>' + data.body)
$('.help-blurb').hide()
+ $('.response-time').text((data.response_time.toFixed(3) + " seconds"))
$('#request-and-response').show()
} else {
$('#flash-error-msg').html("Weird response. Sorry.")
@@ -252,7 +253,7 @@ $(document).ready(function() {
})
// in-field labels
- Hurl.labelHints('input[title]')
+ Hurl.labelHints('input[title]')
// relatize dates
$('.relatize').relatizeDate()

0 comments on commit 29c80b8

Please sign in to comment.
Something went wrong with that request. Please try again.