superconductor 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,126 @@
1
+ /**
2
+ * jQuery Lined Textarea Plugin
3
+ * http://alan.blog-city.com/jquerylinedtextarea.htm
4
+ *
5
+ * Copyright (c) 2010 Alan Williamson
6
+ *
7
+ * Version:
8
+ * $Id: jquery-linedtextarea.js 464 2010-01-08 10:36:33Z alan $
9
+ *
10
+ * Released under the MIT License:
11
+ * http://www.opensource.org/licenses/mit-license.php
12
+ *
13
+ * Usage:
14
+ * Displays a line number count column to the left of the textarea
15
+ *
16
+ * Class up your textarea with a given class, or target it directly
17
+ * with JQuery Selectors
18
+ *
19
+ * $(".lined").linedtextarea({
20
+ * selectedLine: 10,
21
+ * selectedClass: 'lineselect'
22
+ * });
23
+ *
24
+ * History:
25
+ * - 2010.01.08: Fixed a Google Chrome layout problem
26
+ * - 2010.01.07: Refactored code for speed/readability; Fixed horizontal sizing
27
+ * - 2010.01.06: Initial Release
28
+ *
29
+ */
30
+ (function($) {
31
+
32
+ $.fn.linedtextarea = function(options) {
33
+
34
+ // Get the Options
35
+ var opts = $.extend({}, $.fn.linedtextarea.defaults, options);
36
+
37
+
38
+ /*
39
+ * Helper function to make sure the line numbers are always
40
+ * kept up to the current system
41
+ */
42
+ var fillOutLines = function(codeLines, h, lineNo){
43
+ while ( (codeLines.height() - h ) <= 0 ){
44
+ if ( lineNo == opts.selectedLine )
45
+ codeLines.append("<div class='lineno lineselect'>" + lineNo + "</div>");
46
+ else
47
+ codeLines.append("<div class='lineno'>" + lineNo + "</div>");
48
+
49
+ lineNo++;
50
+ }
51
+ return lineNo;
52
+ };
53
+
54
+
55
+ /*
56
+ * Iterate through each of the elements are to be applied to
57
+ */
58
+ return this.each(function() {
59
+ var lineNo = 1;
60
+ var textarea = $(this);
61
+
62
+ /* Turn off the wrapping of as we don't want to screw up the line numbers */
63
+ textarea.attr("wrap", "off");
64
+ textarea.css({resize:'none'});
65
+ var originalTextAreaWidth = textarea.outerWidth();
66
+
67
+ /* Wrap the text area in the elements we need */
68
+ textarea.wrap("<div class='linedtextarea'></div>");
69
+ var linedTextAreaDiv = textarea.parent().wrap("<div class='linedwrap' style='width:" + originalTextAreaWidth + "px'></div>");
70
+ var linedWrapDiv = linedTextAreaDiv.parent();
71
+
72
+ linedWrapDiv.prepend("<div class='lines' style='width:50px'></div>");
73
+
74
+ var linesDiv = linedWrapDiv.find(".lines");
75
+ linesDiv.height( textarea.height() + 6 );
76
+
77
+
78
+ /* Draw the number bar; filling it out where necessary */
79
+ linesDiv.append( "<div class='codelines'></div>" );
80
+ var codeLinesDiv = linesDiv.find(".codelines");
81
+ lineNo = fillOutLines( codeLinesDiv, linesDiv.height(), 1 );
82
+
83
+ /* Move the textarea to the selected line */
84
+ if ( opts.selectedLine != -1 && !isNaN(opts.selectedLine) ){
85
+ var fontSize = parseInt( textarea.height() / (lineNo-2) );
86
+ var position = parseInt( fontSize * opts.selectedLine ) - (textarea.height()/2);
87
+ textarea[0].scrollTop = position;
88
+ }
89
+
90
+
91
+ /* Set the width */
92
+ var sidebarWidth = linesDiv.outerWidth();
93
+ var paddingHorizontal = parseInt( linedWrapDiv.css("border-left-width") ) + parseInt( linedWrapDiv.css("border-right-width") ) + parseInt( linedWrapDiv.css("padding-left") ) + parseInt( linedWrapDiv.css("padding-right") );
94
+ var linedWrapDivNewWidth = originalTextAreaWidth - paddingHorizontal;
95
+ var textareaNewWidth = originalTextAreaWidth - sidebarWidth - paddingHorizontal - 20;
96
+
97
+ textarea.width( textareaNewWidth );
98
+ linedWrapDiv.width( linedWrapDivNewWidth );
99
+
100
+
101
+
102
+ /* React to the scroll event */
103
+ textarea.scroll( function(tn){
104
+ var domTextArea = $(this)[0];
105
+ var scrollTop = domTextArea.scrollTop;
106
+ var clientHeight = domTextArea.clientHeight;
107
+ codeLinesDiv.css( {'margin-top': (-1*scrollTop) + "px"} );
108
+ lineNo = fillOutLines( codeLinesDiv, scrollTop + clientHeight, lineNo );
109
+ });
110
+
111
+
112
+ /* Should the textarea get resized outside of our control */
113
+ textarea.resize( function(tn){
114
+ var domTextArea = $(this)[0];
115
+ linesDiv.height( domTextArea.clientHeight + 6 );
116
+ });
117
+
118
+ });
119
+ };
120
+
121
+ // default options
122
+ $.fn.linedtextarea.defaults = {
123
+ selectedLine: -1,
124
+ selectedClass: 'lineselect'
125
+ };
126
+ })(jQuery);
@@ -20,3 +20,23 @@ jQuery ->
20
20
  $(window).keyup (e) ->
21
21
  clearTimeout(initialTimeout)
22
22
  panel.toggleClass('closed') if e.which == 27
23
+
24
+ $('aside#superconductor ul.methods li a').live 'click', (e) ->
25
+ e.preventDefault()
26
+ parent = $(this).parent('li')
27
+ if parent.hasClass('open')
28
+ parent.removeClass('open').children('form').remove()
29
+ else
30
+ $.ajax {
31
+ url: this.href,
32
+ dataType: 'json',
33
+ context: this,
34
+ success: (data, status, xhr) ->
35
+ form = $('<form action="'+this.href+'" method="post" data-method="put"></form>')
36
+ form.append($('<textarea'+( if data.writable then '' else ' disabled="disabled"' )+'>'+data.content+'</textarea>'))
37
+ form.append($('<input type="submit" value="Save Changes" />')) if data.writable
38
+ parent.addClass('open').append(form)
39
+ form.find('textarea').linedtextarea({selectedLine: this.hash.slice(1)})
40
+ }
41
+
42
+
@@ -1 +1,2 @@
1
+ //= require 'jquery-linedtextarea'
1
2
  //= require_tree ./superconductor
@@ -0,0 +1,68 @@
1
+ /**
2
+ * jQuery Lined Textarea Plugin
3
+ * http://alan.blog-city.com/jquerylinedtextarea.htm
4
+ *
5
+ * Copyright (c) 2010 Alan Williamson
6
+ *
7
+ * Released under the MIT License:
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ *
10
+ * Usage:
11
+ * Displays a line number count column to the left of the textarea
12
+ *
13
+ * Class up your textarea with a given class, or target it directly
14
+ * with JQuery Selectors
15
+ *
16
+ * $(".lined").linedtextarea({
17
+ * selectedLine: 10,
18
+ * selectedClass: 'lineselect'
19
+ * });
20
+ *
21
+ */
22
+
23
+ .linedwrap {
24
+ border: 1px solid #c0c0c0;
25
+ padding: 3px;
26
+ }
27
+
28
+ .linedtextarea {
29
+ padding: 0px;
30
+ margin: 0px;
31
+ }
32
+
33
+ .linedtextarea textarea, .linedwrap .codelines .lineno {
34
+ font-size: 10pt;
35
+ font-family: monospace;
36
+ line-height: normal !important;
37
+ }
38
+
39
+ .linedtextarea textarea {
40
+ padding-right:0.3em;
41
+ padding-top:0.3em;
42
+ border: 0;
43
+ }
44
+
45
+ .linedwrap .lines {
46
+ margin-top: 0px;
47
+ width: 50px;
48
+ float: left;
49
+ overflow: hidden;
50
+ border-right: 1px solid #c0c0c0;
51
+ margin-right: 10px;
52
+ }
53
+
54
+ .linedwrap .codelines {
55
+ padding-top: 5px;
56
+ }
57
+
58
+ .linedwrap .codelines .lineno {
59
+ color:#AAAAAA;
60
+ padding-right: 0.5em;
61
+ padding-top: 0.0em;
62
+ text-align: right;
63
+ white-space: nowrap;
64
+ }
65
+
66
+ .linedwrap .codelines .lineselect {
67
+ color: red;
68
+ }
@@ -3,7 +3,7 @@ aside#superconductor {
3
3
  top: 0;
4
4
  right: 0;
5
5
  bottom: 0;
6
- width: 30%;
6
+ width: 35%;
7
7
  margin: 0;
8
8
  z-index: 99999;
9
9
  font-family: arial, helvetica, verdana, sans-serif;
@@ -18,6 +18,7 @@ aside#superconductor {
18
18
  opacity: 1;
19
19
  -webkit-transition: width 0.5s, opacity 0.5s;
20
20
  box-shadow: 0 0 10px rgba(0,0,0,0.7);
21
+ color: white;
21
22
  &.expanded {
22
23
  width: 100%;
23
24
  menu[type=toolbar] button.expander:before { content: '\21E5' }
@@ -30,22 +31,20 @@ aside#superconductor {
30
31
  }
31
32
 
32
33
  // **
33
-
34
- &, * {
35
- color: white;
36
- }
37
- > h1, > h2, > h3, > h4, > h5, > h6, > p, > ul, > dl, > section {
34
+ h1, h2, h3, h4, h5, h6, p, ul, dl, section {
38
35
  text-align: left;
39
- margin-left: 10px;
36
+ margin-left: 5px;
40
37
  }
38
+ h1 { font-size: 1.25em; }
39
+ h2 { font-size: 1.1em; }
41
40
  dl {
42
41
  dt {
43
42
  float: left;
44
43
  min-width: 80px;
45
- margin-left: 5px;
44
+ margin-left: 10px;
46
45
  }
47
46
  dd {
48
- margin-left: 85px;
47
+ margin-left: 90px;
49
48
  }
50
49
  }
51
50
  code {
@@ -60,8 +59,13 @@ aside#superconductor {
60
59
  > hr {
61
60
  margin-left: -15px;
62
61
  }
62
+ textarea {
63
+ font-size: 10pt;
64
+ margin: 0;
65
+ padding: 2px;
66
+ }
63
67
  details {
64
- margin: 1px 20px;
68
+ margin: -1px 20px 0 20px;
65
69
  &[open] {
66
70
  border-left: dotted #555555 1px;
67
71
  margin-left: 19px;
@@ -80,18 +84,38 @@ aside#superconductor {
80
84
  margin-left: -15px;
81
85
  cursor: pointer;
82
86
  }
83
- &.methods {
84
- ul {
85
- li {
87
+ ul.methods {
88
+ padding: 0;
89
+ list-style-type: none;
90
+ li {
91
+ > a, > span {
92
+ padding: 3px 5px;
93
+ display: block;
86
94
  width: 200px;
87
95
  float: left;
88
96
  white-space: nowrap;
89
97
  text-overflow: ellipsis;
90
98
  overflow: hidden;
91
99
  }
92
- &:after { display: block; content: ''; clear: both; }
100
+ &.open {
101
+ a {
102
+ padding: 2px 4px;
103
+ border: dotted #555555 1px;
104
+ background-color: rgba(50,50,50,0.5);
105
+ margin-bottom: -1px;
106
+ }
107
+ form {
108
+ clear: left;
109
+ border: dotted #555555 1px;
110
+ margin: 0;
111
+ textarea { width: 100%; height: 200px; }
112
+ .linedwrap { border: none; }
113
+ }
114
+ }
93
115
  }
116
+ &:after { display: block; content: ''; clear: both; }
94
117
  }
118
+
95
119
  ul.array {
96
120
  margin: 0.2em;
97
121
  padding-left: 1.75em;
@@ -1,3 +1,4 @@
1
1
  /*
2
+ *= require jquery-linedtextarea
2
3
  *= require_tree ./superconductor/
3
4
  */
@@ -1,9 +1,19 @@
1
1
  class Superconductor::FileController < ApplicationController
2
2
  def edit
3
+ respond_to do |format|
4
+ format.json do
5
+ if File.exists?('/'+params[:file])
6
+ @file = File.open('/'+params[:file],'r')
7
+ render json: { content: @file.read, writable: false && File.writable?(@file.path) }
8
+ else
9
+ render json: nil, status: :not_found
10
+ end
11
+ end
12
+ end
3
13
  end
4
14
 
5
15
  def update
6
- @file = File.open(params[:file],'w')
16
+ @file = File.open('/'+params[:file],'w')
7
17
  @file.puts(params[:content])
8
18
  @file.close
9
19
 
@@ -6,12 +6,10 @@
6
6
  <button class="directory">≡</button> |
7
7
  <button class="expander"></button><button class="closer">✕</button>
8
8
  </menu>
9
+ <p>
10
+ Load Time: <code><%= sprintf('%.3f', (Time.now.usec - @_start_time).abs / 1000000.0) %> seconds</code>
11
+ </p>
9
12
  <section class="instance-variables">
10
- <h1>Statistics</h1>
11
- <dl>
12
- <dt>Load Time:</dt>
13
- <dd><code><%= sprintf('%.3f', (Time.now.usec - @_start_time).abs / 1000000.0) %> seconds</code></dd>
14
- </dl>
15
13
  <h1>Instance Variables</h1>
16
14
  <% controller.instance_variables.reject { |k| k.to_s.starts_with?('@_') }.map { |k| [k, instance_variable_get(k)] }.each do |k, v| %>
17
15
  <details <%='open' if controller.class.name.starts_with?(k[1..-1].pluralize.titleize) %>><summary><%= k %>:&nbsp;<%= v.to_s %></summary>
@@ -58,22 +56,73 @@
58
56
  <% else %>
59
57
  <%= content_tag :code, v.inspect %>
60
58
  <% end %>
61
- <% methods = Hash[v.public_methods.map{|m|v.method(m)}.group_by(&:owner)] %>
62
- <details class="methods"><summary><%= v.class.name %> Methods</summary>
63
- <ul>
64
- <% methods[v.class].sort_by(&:name).each do |method| %>
65
- <li><%= link_to_if method.source_location, method.name, superconductor_file_path((method.source_location||[]).join('#')), remote: true %></li>
66
- <% end %>
67
- </ul>
68
- <% methods.except(v.class).sort_by{|m|m.first.name.to_s}.each do |owner,methods| %>
69
- <details class="methods"><summary><%= owner.name || "Dynamic" %> Methods</summary>
70
- <ul>
71
- <% methods.sort_by(&:name).each do |method| %>
72
- <li><%= link_to_if method.source_location, method.name, superconductor_file_path((method.source_location||[]).join('#')), remote: true %></li>
59
+ <% obfuscated_methods, public_methods = v.public_methods.partition{ |name| name[0] == '_' }.map{ |names| Hash[names.map{ |method| v.method(method) }.group_by(&:owner)] } %>
60
+ <% private_methods = Hash[v.private_methods.map{|m|v.method(m)}.group_by(&:owner)] %>
61
+ <% protected_methods = Hash[v.protected_methods.map{|m|v.method(m)}.group_by(&:owner)] %>
62
+ <details><summary><%= v.class.name %> Methods</summary>
63
+ <% if public_methods[v.class].detect { |method| method.source_location && method.source_location.first.starts_with?(Rails.root.to_s) } %>
64
+ <ul class="methods">
65
+ <% public_methods[v.class].select{ |method| method.source_location}.select{ |method| method.source_location.first.starts_with?(Rails.root.to_s) }.sort_by(&:name).each do |method| %>
66
+ <li><%= link_to_if method.source_location && method.source_location.first != '(eval)', content_tag(:span,method.name), method.source_location ? superconductor_file_path(method.source_location.first, anchor: method.source_location.last) : nil %></li>
67
+ <% end %>
68
+ </ul>
69
+ <% end %>
70
+ <details><summary>External Methods</summary>
71
+ <ul class="methods">
72
+ <% public_methods[v.class].sort_by(&:name).each do |method| %>
73
+ <li><%= link_to_if method.source_location && method.source_location.first != '(eval)', content_tag(:span,method.name), method.source_location ? superconductor_file_path(method.source_location.first, anchor: method.source_location.last) : nil %></li>
74
+ <% end %>
75
+ </ul>
76
+ </details>
77
+ <% if obfuscated_methods[v.class].present? %>
78
+ <details><summary>Obfuscated Methods</summary>
79
+ <ul class="methods">
80
+ <% obfuscated_methods[v.class].sort_by(&:name).each do |method| %>
81
+ <li><%= link_to_if method.source_location && method.source_location.first != '(eval)', content_tag(:span,method.name), method.source_location ? superconductor_file_path(method.source_location.first, anchor: method.source_location.last) : nil %></li>
82
+ <% end %>
83
+ </ul>
84
+ </details>
85
+ <% end %>
86
+ <% if private_methods[v.class].present? %>
87
+ <details><summary>Private Methods</summary>
88
+ <ul class="methods">
89
+ <% private_methods[v.class].sort_by(&:name).each do |method| %>
90
+ <li><%= link_to_if method.source_location && method.source_location.first != '(eval)', content_tag(:span,method.name), method.source_location ? superconductor_file_path(method.source_location.first, anchor: method.source_location.last) : nil %></li>
73
91
  <% end %>
74
92
  </ul>
75
93
  </details>
76
94
  <% end %>
95
+ <% if protected_methods[v.class].present? %>
96
+ <details><summary>Protected Methods</summary>
97
+ <ul class="methods">
98
+ <% protected_methods[v.class].sort_by(&:name).each do |method| %>
99
+ <li><%= link_to_if method.source_location && method.source_location.first != '(eval)', content_tag(:span,method.name), method.source_location ? superconductor_file_path(method.source_location.first, anchor: method.source_location.last) : nil %></li>
100
+ <% end %>
101
+ </ul>
102
+ </details>
103
+ <% end %>
104
+ <details><summary>Inherited Methods</summary>
105
+ <h2>Public Methods</h2>
106
+ <% public_methods.except(v.class).sort_by{|m|m.first.name.to_s}.each do |owner,methods| %>
107
+ <details><summary><%= owner.name || "Dynamic" %> Methods</summary>
108
+ <ul class="methods">
109
+ <% methods.sort_by(&:name).each do |method| %>
110
+ <li><%= link_to_if method.source_location && method.source_location.first != '(eval)', content_tag(:span,method.name), method.source_location ? superconductor_file_path(method.source_location.first, anchor: method.source_location.last) : nil %></li>
111
+ <% end %>
112
+ </ul>
113
+ </details>
114
+ <% end %>
115
+ <h2>Protected Methods</h2>
116
+ <% protected_methods.except(v.class).sort_by{|m|m.first.name.to_s}.each do |owner,methods| %>
117
+ <details><summary><%= owner.name || "Dynamic" %> Methods</summary>
118
+ <ul class="methods">
119
+ <% methods.sort_by(&:name).each do |method| %>
120
+ <li><%= link_to_if method.source_location && method.source_location.first != '(eval)', content_tag(:span,method.name), method.source_location ? superconductor_file_path(method.source_location.first, anchor: method.source_location.last) : nil %></li>
121
+ <% end %>
122
+ </ul>
123
+ </details>
124
+ <% end %>
125
+ </details>
77
126
  </details>
78
127
  </details>
79
128
  <% end %>
data/config/routes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  Rails.application.routes.draw do
2
2
  namespace :superconductor, module: 'Superconductor' do
3
- put 'edit(/*id)' => 'file#update', :as => nil
4
- get 'edit(/*id)' => 'file#edit', :as => :file
3
+ put 'edit/*file(.:format)' => 'file#update', :as => nil
4
+ get 'edit/*file(.:format)' => 'file#edit', :as => :file
5
5
  end
6
6
  end
@@ -13,7 +13,10 @@ module Superconductor
13
13
  @_start_time = Time.now.usec
14
14
  end
15
15
  after_filter do
16
- response.body += render_to_string(:partial => 'superconductor/panel')
16
+ respond_to do |format|
17
+ format.html { response.body += render_to_string(:partial => 'superconductor/panel') }
18
+ format.all(:json,:js,:xml) { }
19
+ end
17
20
  end
18
21
  end
19
22
  end
@@ -1,3 +1,3 @@
1
1
  module Superconductor
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superconductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-17 00:00:00.000000000 Z
12
+ date: 2012-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -50,8 +50,10 @@ executables: []
50
50
  extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
+ - app/assets/javascripts/jquery-linedtextarea.js
53
54
  - app/assets/javascripts/superconductor/panel.js.coffee
54
55
  - app/assets/javascripts/superconductor.js
56
+ - app/assets/stylesheets/jquery-linedtextarea.css
55
57
  - app/assets/stylesheets/scaffold.css
56
58
  - app/assets/stylesheets/superconductor/panel.css.scss
57
59
  - app/assets/stylesheets/superconductor.css
@@ -61,7 +63,6 @@ files:
61
63
  - app/models/superconductor.rb
62
64
  - app/views/superconductor/_panel.html.erb
63
65
  - app/views/superconductor/_panel.js.erb
64
- - app/views/superconductor/file/edit.js.erb
65
66
  - config/routes.rb
66
67
  - lib/superconductor/engine.rb
67
68
  - lib/superconductor/version.rb
File without changes