From 4c4bffe48daf15ee6b8bfb2917ae9f3077fcf63a Mon Sep 17 00:00:00 2001 From: tye Date: Fri, 30 Nov 2012 14:43:10 -0500 Subject: [PATCH] Improving the layout of the header so the path name will have a maximum width Be able to toggle params --- .../images/rubyception/entry_collapse.png | Bin 0 -> 199 bytes .../images/rubyception/entry_expand.png | Bin 0 -> 209 bytes .../rubyception/syntax_highlighting.js | 3 - .../rubyception/views/entries/entry.coffee | 43 +++++++++---- .../stylesheets/rubyception/entries.sass | 59 ++++++++++++++++-- app/models/rubyception/entry.rb | 39 +++++++++++- app/views/rubyception/entries/_entry.haml | 21 ++++--- 7 files changed, 137 insertions(+), 28 deletions(-) create mode 100644 app/assets/images/rubyception/entry_collapse.png create mode 100644 app/assets/images/rubyception/entry_expand.png diff --git a/app/assets/images/rubyception/entry_collapse.png b/app/assets/images/rubyception/entry_collapse.png new file mode 100644 index 0000000000000000000000000000000000000000..4505d1b7ca9957b6930f9ac6c4e14270d99f5406 GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPax12B|NBX?OKskmGPZ!4!iOaR;H}X0JNVq=y|57E* zph5Lag528BEnyd5UX8j~C&l&1^6N?4osACSmU@Xtd%pSam>KY&vmn7CH04yZi;m{f ozk3T7xc{6gA^&#zg(q?I?CXjy9atvH4>X^_)78&qol`;+0B(Uo?f?J) literal 0 HcmV?d00001 diff --git a/app/assets/images/rubyception/entry_expand.png b/app/assets/images/rubyception/entry_expand.png new file mode 100644 index 0000000000000000000000000000000000000000..29ace75d732106ab6e32693d0da99d1d5fc805db GIT binary patch literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPax12DeruO&CzCfWkPZ!4!iOaS9dwCraBwFU1U-UTh zfj5CuJM*Yb)LO$c2Lz_{yFGE<@vdn4Z_cUqA`ZMh@>SdoRzHr_+`O_RkKeiYbkJ`f ynfTPKm3rwxr`(wY1b5$JEOl8kfBO}!=j;wv;hpNQvV(y(F?hQAxvX @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, '&' + text = text.replace //g, '>' + 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 = "#{@escape_html v}" + "
#{@escape_html k}:
#{definition}" + console.log(inner_html) + html = "
#{inner_html.join('')}
" + $(@el).find('.params .nested').html html - "#{k}: #{v}" - $(@el).find('.params').html html.join('') + params:-> + params = @model.get 'parsed_params' + html = _.map params, (v,k)=> + v = JSON.stringify JSON.parse v + "#{@escape_html k}: #{@escape_html v}" + $(@el).find('.params .basic').append html.join('') backtrace:-> backtrace = @model.get 'backtrace' if backtrace diff --git a/app/assets/stylesheets/rubyception/entries.sass b/app/assets/stylesheets/rubyception/entries.sass index f18052a..5235bca 100644 --- a/app/assets/stylesheets/rubyception/entries.sass +++ b/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 + diff --git a/app/models/rubyception/entry.rb b/app/models/rubyception/entry.rb index 8b5869e..c30a506 100644 --- a/app/models/rubyception/entry.rb +++ b/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| diff --git a/app/views/rubyception/entries/_entry.haml b/app/views/rubyception/entries/_entry.haml index ec7f1e3..f99f51d 100644 --- a/app/views/rubyception/entries/_entry.haml +++ b/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