Skip to content
Browse files

Improving the layout of the header so the path name will have a maxim…

…um width

Be able to toggle params
  • Loading branch information...
1 parent f532034 commit 4c4bffe48daf15ee6b8bfb2917ae9f3077fcf63a @tye committed
View
BIN app/assets/images/rubyception/entry_collapse.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN app/assets/images/rubyception/entry_expand.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3 app/assets/javascripts/rubyception/syntax_highlighting.js
@@ -515,12 +515,9 @@ function sh_highlightDocument(prefix, suffix) {
for (var i = 0; i < nodeList.length; i++) {
var element = nodeList.item(i);
var htmlClasses = sh_getClasses(element);
- console.log(htmlClasses)
if (_.include(htmlClasses, 'sh_sourceCode')) {
- console.log('Skipping')
continue;
}
- console.log('Parsing')
for (var j = 0; j < htmlClasses.length; j++) {
var htmlClass = htmlClasses[j].toLowerCase();
if (htmlClass === 'sh_sourcecode') {
View
43 app/assets/javascripts/rubyception/views/entries/entry.coffee
@@ -1,11 +1,17 @@
class App.Views.Entries.Entry extends Backbone.View
className: 'entry'
events:
+ 'click .toggle_params': 'toggle_params'
'click': 'select_and_toggle'
initialize: ->
@model.bind 'notice', @notice
@model.bind 'ignore', @ignore
@render()
+ toggle_params: (e) =>
+ params = @$ '.params'
+ params.toggleClass 'nested'
+ e.preventDefault()
+ e.stopPropagation()
select_and_toggle: (event) =>
target = $ event.target
# Return unless we clicked directory on .details, or .heading, or a child of .heading
@@ -20,21 +26,36 @@ class App.Views.Entries.Entry extends Backbone.View
@color_marker()
@params()
@backtrace()
+ @nested_params @model.get 'parsed_nested_params'
@lines()
_.defer window.sh_highlightDocument
- params:->
- params = @model.get 'params'
- html = _.map params, (v,k)->
- boolean = v is true or v is false
- number = !isNaN(parseFloat(v)) && isFinite(v)
- kind = if boolean then 'boolean'
- else if number then 'number'
+ escape_html: (text) =>
+ text = text.replace /&/g, '&amp;'
+ text = text.replace /</g, '&lt;'
+ text = text.replace />/g, '&gt;'
+ text
+ nested_params: (params)=>
+ console.log 'Nested', params
+ inner_html = _.map params, (v,k) =>
+ name = k
+ if typeof v != 'string'
+ console.log "Recursing into", v
+ definition = @nested_params(v).html()
+ console.log "Rescuring definition is", definition
else
- v = "'#{v}'"
- 'string'
+ console.log "Its a string", v
+ definition = "<span class='value string'>#{@escape_html v}</span>"
+ "<dt class='key'>#{@escape_html k}<span class='colon'>:</span></dt><dd>#{definition}</dt>"
+ console.log(inner_html)
+ html = "<dl>#{inner_html.join('')}</dl>"
+ $(@el).find('.params .nested').html html
- "<span class='param'><span class='key'>#{k}</span><span class='colon'>:</span> <span class='value #{kind}'>#{v}</span></span>"
- $(@el).find('.params').html html.join('')
+ params:->
+ params = @model.get 'parsed_params'
+ html = _.map params, (v,k)=>
+ v = JSON.stringify JSON.parse v
+ "<span class='param'><span class='key'>#{@escape_html k}</span><span class='colon'>:</span> <span class='value string'>#{@escape_html v}</span></span>"
+ $(@el).find('.params .basic').append html.join('')
backtrace:->
backtrace = @model.get 'backtrace'
if backtrace
View
59 app/assets/stylesheets/rubyception/entries.sass
@@ -1,3 +1,5 @@
+body
+ :width 100%
.entry
:position relative
:-webkit-box-shadow rgba(255, 255, 255, 0.07) 0px 1px 0
@@ -27,14 +29,33 @@
:background rgb(250,50,0)
.details
:padding 0 10px
+ .method
+ :width 70px
+ .controller
+ :width 200px
+ .format
+ :width 50px
+ .datetime
+ :width 70px
+ .ms
+ :width 80px
.method, .format
:text-transform uppercase
- .heading
+ .heading_wrapper
:padding 10px 0 10px 0
- div
- :display inline-block
+ .heading
+ :overflow auto
+ :table-layout fixed
+ :border-collapse collapse
+ :width 100%
+ td
+ :padding-right 5px
+ :white-space nowrap
+ :overflow hidden
+ :text-overflow ellipsis
+ td:last-child
+ :padding-right 0
.ms, .datetime
- :float right
:margin
:left 10px
.ms.slow
@@ -60,7 +81,7 @@
:height 2px
:margin 2px 0
-.params
+.params, .nested_params
:padding 5px
:top 0px
:font-size 12px
@@ -92,3 +113,31 @@ body.pretty_params
//:display table-cell
//.key, .colon
//:width 1%
+.params
+ .nested
+ :display none
+ a.toggle_params
+ :display block
+ :float left
+ :width 15px
+ :height 15px
+ :background image-url('rubyception/entry_collapse.png') no-repeat center center
+
+.params.nested
+ a.toggle_params
+ :background image-url('rubyception/entry_expand.png') no-repeat center center
+ .basic
+ :display none
+ .nested
+ :display block
+.nested
+ :clear both
+dt
+ :clear both
+ :margin-right 10px
+ :text-align right
+ :width 120px
+ :word-wrap break-word
+dt, dd
+ :float left
+
View
39 app/models/rubyception/entry.rb
@@ -32,8 +32,41 @@ def set_values event
params.delete 'controller'
params.delete 'action'
self.params = params
- self.start_time = event.time.to_s :entry
- self.end_time = event.end.to_s :entry
+ self.start_time = event.time.strftime('%H:%M:%S')
+ self.end_time = event.end.strftime('%H:%M:%S')
+ end
+
+
+ def parsed_params
+ result = {}
+ jsonified = params.collect do |key,val|
+ [key, val.to_json]
+ end
+ Hash[jsonified]
+ end
+
+ def deep_clone_hash hash
+ result = {}
+ hash.each do |k,v|
+ if v.is_a? Hash
+ result[k] = deep_clone_hash v
+ else
+ result[k] = v
+ end
+ end
+ result
+ end
+
+ def parsed_nested_params params=nil
+ params ||= deep_clone_hash(self.params)
+ if params.kind_of? Hash
+ params.each do |key,val|
+ params[key] = parsed_nested_params(params[key])
+ end
+ else
+ return params.inspect
+ end
+ params
end
def error?; error; end
@@ -97,6 +130,8 @@ def to_json
backtrace
finished
start_time
+ parsed_params
+ parsed_nested_params
end_time}
result = {}
methods.each do |method|
View
21 app/views/rubyception/entries/_entry.haml
@@ -1,13 +1,20 @@
.marker
.details
- .heading
- .method {{method}}
- .format {{format}}
- = '{{controller}}#{{action}}'
- .path {{path}}
- .datetime {{start_time}}
- .ms {{duration}}ms
+ .heading_wrapper
+ %table.heading
+ %tr
+ %td.method {{method}}
+ %td.controller{title: '{{controller}}#{{action}}'}
+ = '{{controller}}#{{action}}'
+ %td.format {{format}}
+ %td.path{title: '{{path}}'} {{path}}
+ %td.datetime {{start_time}}
+ %td.ms {{duration}}ms
.params
+ %a.toggle_params{href: '#'}
+ .basic
+ %dl.nested
+ .clear
.lines
.backtrace_lines
.clear

0 comments on commit 4c4bffe

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