bone_tree 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +17 -0
  3. data/Gemfile.lock +190 -0
  4. data/Guardfile +14 -0
  5. data/README +1 -0
  6. data/Rakefile +21 -0
  7. data/app/assets/images/bonetree.png +0 -0
  8. data/app/assets/images/crushed_bone.png +0 -0
  9. data/app/assets/index.html +439 -0
  10. data/app/assets/javascripts/bone_tree.js +1292 -0
  11. data/app/assets/stylesheets/bone_tree.css +186 -0
  12. data/app/assets/stylesheets/bone_tree_repo.css +73 -0
  13. data/bone_tree-0.0.1.gem +0 -0
  14. data/bone_tree.gemspec +20 -0
  15. data/config.rb +26 -0
  16. data/config.ru +4 -0
  17. data/docs/index.html +222 -0
  18. data/docs/resources/base.css +70 -0
  19. data/docs/resources/index.css +20 -0
  20. data/docs/resources/module.css +24 -0
  21. data/docs/source/javascripts/bone_tree/_namespace.js.html +45 -0
  22. data/docs/source/javascripts/bone_tree/models/_directory.js.html +126 -0
  23. data/docs/source/javascripts/bone_tree/models/_file.js.html +112 -0
  24. data/docs/source/javascripts/bone_tree/models/_nodes.js.html +174 -0
  25. data/docs/source/javascripts/bone_tree/models/_settings.js.html +75 -0
  26. data/docs/source/javascripts/bone_tree/views/_directory.js.html +94 -0
  27. data/docs/source/javascripts/bone_tree/views/_file.js.html +82 -0
  28. data/docs/source/javascripts/bone_tree/views/_menu.js.html +110 -0
  29. data/docs/source/javascripts/bone_tree/views/_tree.js.html +432 -0
  30. data/lib/version.rb +4 -0
  31. data/source/images/bonetree.png +0 -0
  32. data/source/images/crushed_bone.png +0 -0
  33. data/source/index.html.haml +438 -0
  34. data/source/javascripts/_backbone.js +1293 -0
  35. data/source/javascripts/_jquery.min.js +5 -0
  36. data/source/javascripts/_underscore.js +999 -0
  37. data/source/javascripts/bone_tree/_namespace.js.coffee +7 -0
  38. data/source/javascripts/bone_tree/models/_directory.js.coffee +63 -0
  39. data/source/javascripts/bone_tree/models/_file.js.coffee +55 -0
  40. data/source/javascripts/bone_tree/models/_nodes.js.coffee +117 -0
  41. data/source/javascripts/bone_tree/models/_settings.js.coffee +25 -0
  42. data/source/javascripts/bone_tree/views/_directory.js.coffee +73 -0
  43. data/source/javascripts/bone_tree/views/_file.js.coffee +49 -0
  44. data/source/javascripts/bone_tree/views/_menu.js.coffee +97 -0
  45. data/source/javascripts/bone_tree/views/_tree.js.coffee +498 -0
  46. data/source/javascripts/bone_tree.js.coffee +1 -0
  47. data/source/layout.haml +13 -0
  48. data/source/stylesheets/bone_tree.css.sass +107 -0
  49. data/source/stylesheets/bone_tree_repo.css.sass +65 -0
  50. data/spec/javascripts/directory_view_spec.coffee +91 -0
  51. data/spec/javascripts/file_view_spec.coffee +70 -0
  52. data/spec/javascripts/helpers/spec_helper.coffee +7 -0
  53. data/spec/javascripts/menu_view_spec.coffee +42 -0
  54. data/spec/javascripts/nodes_spec.coffee +37 -0
  55. data/spec/javascripts/support/jasmine.yml +8 -0
  56. data/spec/javascripts/support/jasmine_config.rb +23 -0
  57. data/spec/javascripts/support/jasmine_runner.rb +32 -0
  58. data/spec/javascripts/tree_view_spec.coffee +39 -0
  59. metadata +123 -0
@@ -0,0 +1,45 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>_namespace.js.coffee</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
+ <link rel="stylesheet" media="all" href="../../../resources/base.css" />
8
+ <link rel="stylesheet" media="all" href="../../../resources/module.css" />
9
+ </head>
10
+ <body>
11
+ <header>
12
+ <h1>_namespace.js.coffee</h1>
13
+ </header>
14
+ <div id="content">
15
+ <div id="sidebar">
16
+
17
+
18
+ <h4>Functions</h4>
19
+ <ul class="functionlist">
20
+
21
+ <li><a href="#BoneTree.namespace">BoneTree.namespace</a></li>
22
+
23
+ </ul>
24
+
25
+ </div>
26
+ <div id="main">
27
+
28
+
29
+
30
+ <div id="functions">
31
+ <h2>Functions</h2>
32
+
33
+ <div class="function">
34
+ <div class="header">
35
+ <a id="BoneTree.namespace"><h3>BoneTree.namespace(target, name, block)</h3></a>
36
+ </div>
37
+
38
+ </div>
39
+
40
+ </div>
41
+
42
+ </div>
43
+ </div>
44
+ </body>
45
+ </html>
@@ -0,0 +1,126 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>_directory.js.coffee</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
+ <link rel="stylesheet" media="all" href="../../../../resources/base.css" />
8
+ <link rel="stylesheet" media="all" href="../../../../resources/module.css" />
9
+ </head>
10
+ <body>
11
+ <header>
12
+ <h1>_directory.js.coffee</h1>
13
+ </header>
14
+ <div id="content">
15
+ <div id="sidebar">
16
+
17
+ <h4>Classes</h4>
18
+ <ul class="classlist">
19
+
20
+ <li><a href="#Models.Directory">Models.Directory</a></li>
21
+
22
+ </ul>
23
+
24
+
25
+ <h4>Functions</h4>
26
+ <ul class="functionlist">
27
+
28
+ <li><a href="#Models.Directory.find">Models.Directory.find</a></li>
29
+
30
+ </ul>
31
+
32
+ </div>
33
+ <div id="main">
34
+
35
+
36
+ <div id="classes">
37
+ <h2>Classes</h2>
38
+
39
+ <div class="class">
40
+ <div class="header">
41
+ <a id="Models.Directory"><h3>Models.Directory</h3></a>
42
+
43
+
44
+ <a class="parent" href="#Models.Node"><h3>extends Models.Node</h3></a>
45
+
46
+
47
+ </div>
48
+ <div class="class_content">
49
+ <p>Public: Object representing a directory.</p>
50
+
51
+ <ul>
52
+ <li>defaults
53
+ <ul><li>name - A String naming the directory (default: "New Directory").</li>
54
+ <li>sortPriority - A String representing the priority with which the
55
+ node is sorted. Directories have sortPriority "0"
56
+ allowing them to be sorted before Files which have
57
+ sortPriority "1".</li>
58
+ <li>nodeType - A String denoting what type of node this object is.
59
+ The two types are "file" and "directory".</li>
60
+ <li>open - The state of the directory. Controls whether or not
61
+ to display files and directories contained within this
62
+ Directory (default: false).</li></ul></li>
63
+ </ul>
64
+ <div class="methods">
65
+
66
+
67
+ <div class="instancemethods">
68
+ <h3>Instance Methods</h3>
69
+
70
+ <div class="method">
71
+ <h4>toggleOpen()</h4>
72
+ <p>Public: Toggle the open state of this Directory.</p>
73
+
74
+ <p>Examples</p>
75
+
76
+ <pre><code>dir = new BoneTree.Models.Directory
77
+
78
+ dir.get('open')
79
+ # =&gt; false
80
+
81
+ dir.toggleOpen()
82
+ dir.get('open')
83
+ # =&gt; true
84
+ </code></pre>
85
+
86
+ <p>Returns this Directory.</p>
87
+ </div>
88
+
89
+ </div>
90
+
91
+ </div>
92
+ </div>
93
+ </div>
94
+
95
+ </div>
96
+
97
+
98
+ <div id="functions">
99
+ <h2>Functions</h2>
100
+
101
+ <div class="function">
102
+ <div class="header">
103
+ <a id="Models.Directory.find"><h3>Models.Directory.find(currentDirectory, name)</h3></a>
104
+ </div>
105
+
106
+ <div>
107
+ <p>Internal: Check to see if there is a directory with the matching name
108
+ contained within currentDirectory.</p>
109
+
110
+ <ul>
111
+ <li><p>currentDirectory - A Directory object to search for the matching directory name.</p></li>
112
+ <li><p>name - A String name used to check for matching directory
113
+ names in currentDirectory.</p></li>
114
+ </ul>
115
+
116
+ <p>Returns The Directory object with the matching name if it exists and undefined otherwise.</p>
117
+ </div>
118
+
119
+ </div>
120
+
121
+ </div>
122
+
123
+ </div>
124
+ </div>
125
+ </body>
126
+ </html>
@@ -0,0 +1,112 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>_file.js.coffee</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
+ <link rel="stylesheet" media="all" href="../../../../resources/base.css" />
8
+ <link rel="stylesheet" media="all" href="../../../../resources/module.css" />
9
+ </head>
10
+ <body>
11
+ <header>
12
+ <h1>_file.js.coffee</h1>
13
+ </header>
14
+ <div id="content">
15
+ <div id="sidebar">
16
+
17
+ <h4>Classes</h4>
18
+ <ul class="classlist">
19
+
20
+ <li><a href="#Models.File">Models.File</a></li>
21
+
22
+ </ul>
23
+
24
+
25
+ <h4>Functions</h4>
26
+ <ul class="functionlist">
27
+
28
+ <li><a href="#Models.File.createFromFileName">Models.File.createFromFileName</a></li>
29
+
30
+ </ul>
31
+
32
+ </div>
33
+ <div id="main">
34
+
35
+
36
+ <div id="classes">
37
+ <h2>Classes</h2>
38
+
39
+ <div class="class">
40
+ <div class="header">
41
+ <a id="Models.File"><h3>Models.File</h3></a>
42
+
43
+
44
+ <a class="parent" href="#Models.Node"><h3>extends Models.Node</h3></a>
45
+
46
+
47
+ </div>
48
+ <div class="class_content">
49
+ <p>Public: Object representing file data in the tree.</p>
50
+
51
+ <ul>
52
+ <li>defaults
53
+ <ul><li>name - A String naming the file (default: "New File").</li>
54
+ <li>sortPriority - A String representing the priority with which the
55
+ node is sorted. Directories have sortPriority "0"
56
+ allowing them to be sorted before Files which have
57
+ sortPriority "1".</li>
58
+ <li>nodeType - A String denoting what type of node this object is.
59
+ The two types are "file" and "directory".</li></ul></li>
60
+ </ul>
61
+ <div class="methods">
62
+
63
+
64
+ </div>
65
+ </div>
66
+ </div>
67
+
68
+ </div>
69
+
70
+
71
+ <div id="functions">
72
+ <h2>Functions</h2>
73
+
74
+ <div class="function">
75
+ <div class="header">
76
+ <a id="Models.File.createFromFileName"><h3>Models.File.createFromFileName(fileName, fileData)</h3></a>
77
+ </div>
78
+
79
+ <div>
80
+ <p>Public: Class method to create a new File object based on the fileName
81
+ and fileData passed in.</p>
82
+
83
+ <ul>
84
+ <li><p>fileName - A String representing the name of the file to be created.
85
+ files with '.' in the name will be parsed out and only the
86
+ string after the final '.' will be considered the extension.</p></li>
87
+ <li><p>fileData - An Object of attributes to associate with the file.</p></li>
88
+ </ul>
89
+
90
+ <p>Examples</p>
91
+
92
+ <pre><code>data = {
93
+ contents: alert 'this is the code in the file'
94
+ createdAt: 1330846900589
95
+ language: 'CoffeeScript'
96
+ }
97
+
98
+ BoneTree.Models.File.createFromFileName('example.coffee', data)
99
+ # =&gt; &lt;File&gt;
100
+ </code></pre>
101
+
102
+ <p>Returns the File object just created.</p>
103
+ </div>
104
+
105
+ </div>
106
+
107
+ </div>
108
+
109
+ </div>
110
+ </div>
111
+ </body>
112
+ </html>
@@ -0,0 +1,174 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>_nodes.js.coffee</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
+ <link rel="stylesheet" media="all" href="../../../../resources/base.css" />
8
+ <link rel="stylesheet" media="all" href="../../../../resources/module.css" />
9
+ </head>
10
+ <body>
11
+ <header>
12
+ <h1>_nodes.js.coffee</h1>
13
+ </header>
14
+ <div id="content">
15
+ <div id="sidebar">
16
+
17
+ <h4>Classes</h4>
18
+ <ul class="classlist">
19
+
20
+ <li><a href="#Models.Node">Models.Node</a></li>
21
+
22
+ <li><a href="#Models.Nodes">Models.Nodes</a></li>
23
+
24
+ </ul>
25
+
26
+
27
+ </div>
28
+ <div id="main">
29
+
30
+
31
+ <div id="classes">
32
+ <h2>Classes</h2>
33
+
34
+ <div class="class">
35
+ <div class="header">
36
+ <a id="Models.Node"><h3>Models.Node</h3></a>
37
+
38
+
39
+ <a class="parent" href="#Backbone.Model"><h3>extends Backbone.Model</h3></a>
40
+
41
+
42
+ </div>
43
+ <div class="class_content">
44
+ <p>Internal: An abstract super class for File and Directory objects to inherit from.</p>
45
+ <div class="methods">
46
+
47
+
48
+ <div class="instancemethods">
49
+ <h3>Instance Methods</h3>
50
+
51
+ <div class="method">
52
+ <h4>initialize()</h4>
53
+ <p>Internal: Initialize a new Node object. Set it up to contain a collection of
54
+ children nodes.</p>
55
+ </div>
56
+
57
+ <div class="method">
58
+ <h4>constantize()</h4>
59
+ <p>Public: Returns a String with the nodeType capitalized so that it may be used
60
+ to instatiate the appropriate view type</p>
61
+
62
+ <p>Examples</p>
63
+
64
+ <pre><code>file = new BoneTree.Models.File
65
+ directory = new BoneTree.Models.Directory
66
+
67
+ file.constantize()
68
+ # =&gt; 'File'
69
+
70
+ directory.constantize()
71
+ # =&gt; 'Directory'
72
+
73
+ # use it to create a new view of the appropriate type
74
+ view = new BoneTree.Views[file.constantize()]
75
+ </code></pre>
76
+
77
+ <p>Returns a String of the nodeType with the first letter capitalized.</p>
78
+ </div>
79
+
80
+ <div class="method">
81
+ <h4>nameWithExtension()</h4>
82
+ <p>Public: Returns the node name with the extension if it has
83
+ one and just the node name if there is no extension.</p>
84
+
85
+ <p>Examples</p>
86
+
87
+ <pre><code>file = new BoneTree.Models.File
88
+ name: "file"
89
+ extension: "coffee"
90
+
91
+ noExt = new BoneTree.Models.File
92
+ name: "file2"
93
+
94
+ directory = new BoneTree.Model.Directory
95
+ name: "source"
96
+
97
+ file.nameWithExtension()
98
+ # =&gt; "file.coffee"
99
+
100
+ noExt.nameWithExtension()
101
+ # =&gt; "file2"
102
+
103
+ directory.nameWithExtension()
104
+ # =&gt; "source"
105
+ </code></pre>
106
+
107
+ <p>Returns a String. If the extension exists then the node name plus the extension
108
+ are returned. If there is no extension, then just the node name is returned.</p>
109
+ </div>
110
+
111
+ </div>
112
+
113
+ </div>
114
+ </div>
115
+ </div>
116
+
117
+ <div class="class">
118
+ <div class="header">
119
+ <a id="Models.Nodes"><h3>Models.Nodes</h3></a>
120
+
121
+
122
+ <a class="parent" href="#Backbone.Collection"><h3>extends Backbone.Collection</h3></a>
123
+
124
+
125
+ </div>
126
+ <div class="class_content">
127
+ <p>Internal: A collection of node models. Since Node is an abstract super
128
+ class, in practice this collection will hold File objects
129
+ and Directory objects.</p>
130
+ <div class="methods">
131
+
132
+
133
+ <div class="instancemethods">
134
+ <h3>Instance Methods</h3>
135
+
136
+ <div class="method">
137
+ <h4>comparator(node)</h4>
138
+ <p>Internal: Function that determines how the file tree is sorted. Directories
139
+ are sorted before files. After node type sort
140
+ priority, nodes are sorted by name.</p>
141
+
142
+ <p>Examples</p>
143
+
144
+ <pre><code>tree.addFile('/source/file1.coffee')
145
+ tree.addFile('/source/file2.coffee')
146
+ tree.addFile('main.coffee')
147
+
148
+ tree.render()
149
+
150
+ # even though 'main' comes before 'source' alphabetically it is placed
151
+ # after the 'source' directory due to the sortPriority of the Directory object.
152
+ tree.toAscii()
153
+ # =&gt; "
154
+ -source
155
+ -file1.coffee
156
+ -file2.coffee
157
+ -main.coffee
158
+ "
159
+ </code></pre>
160
+ </div>
161
+
162
+ </div>
163
+
164
+ </div>
165
+ </div>
166
+ </div>
167
+
168
+ </div>
169
+
170
+
171
+ </div>
172
+ </div>
173
+ </body>
174
+ </html>
@@ -0,0 +1,75 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>_settings.js.coffee</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
+ <link rel="stylesheet" media="all" href="../../../../resources/base.css" />
8
+ <link rel="stylesheet" media="all" href="../../../../resources/module.css" />
9
+ </head>
10
+ <body>
11
+ <header>
12
+ <h1>_settings.js.coffee</h1>
13
+ </header>
14
+ <div id="content">
15
+ <div id="sidebar">
16
+
17
+ <h4>Classes</h4>
18
+ <ul class="classlist">
19
+
20
+ <li><a href="#Models.Settings">Models.Settings</a></li>
21
+
22
+ </ul>
23
+
24
+
25
+ </div>
26
+ <div id="main">
27
+
28
+
29
+ <div id="classes">
30
+ <h2>Classes</h2>
31
+
32
+ <div class="class">
33
+ <div class="header">
34
+ <a id="Models.Settings"><h3>Models.Settings</h3></a>
35
+
36
+
37
+ <a class="parent" href="#Backbone.Model"><h3>extends Backbone.Model</h3></a>
38
+
39
+
40
+ </div>
41
+ <div class="class_content">
42
+ <p>Internal: A configuration object. Consumers of the API don't need to
43
+ worry about this. It is used internally to manage the options
44
+ passed into the file tree.</p>
45
+
46
+ <ul>
47
+ <li>defaults
48
+ <ul><li>autoOpenFiles - A Boolean. If true, each file that is added to the tree
49
+ immediately triggers an <code>openFile</code> event (default: true).</li>
50
+ <li>beforeAdd - A Function that is invoked before each file is added to the tree.
51
+ It is passed the raw file attributes and should return true if
52
+ that file should be added to the tree and false if not. The
53
+ default implementation is to return true.</li>
54
+ <li>confirmDeletes - A Boolean. If true, the tree will prompt the user, making
55
+ sure they want to delete the file (default: false).</li>
56
+ <li>showExtensions - A Boolean. If true, files display their extensions. Internally,
57
+ extensions are always kept track of but by default they are
58
+ hidden (default: false).</li>
59
+ <li>viewCache - An Object that stores views when they are created and is used
60
+ to look them up to prevent extra views from being created.</li></ul></li>
61
+ </ul>
62
+ <div class="methods">
63
+
64
+
65
+ </div>
66
+ </div>
67
+ </div>
68
+
69
+ </div>
70
+
71
+
72
+ </div>
73
+ </div>
74
+ </body>
75
+ </html>
@@ -0,0 +1,94 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>_directory.js.coffee</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
+ <link rel="stylesheet" media="all" href="../../../../resources/base.css" />
8
+ <link rel="stylesheet" media="all" href="../../../../resources/module.css" />
9
+ </head>
10
+ <body>
11
+ <header>
12
+ <h1>_directory.js.coffee</h1>
13
+ </header>
14
+ <div id="content">
15
+ <div id="sidebar">
16
+
17
+ <h4>Classes</h4>
18
+ <ul class="classlist">
19
+
20
+ <li><a href="#Views.Directory">Views.Directory</a></li>
21
+
22
+ </ul>
23
+
24
+
25
+ </div>
26
+ <div id="main">
27
+
28
+
29
+ <div id="classes">
30
+ <h2>Classes</h2>
31
+
32
+ <div class="class">
33
+ <div class="header">
34
+ <a id="Views.Directory"><h3>Views.Directory</h3></a>
35
+
36
+
37
+ <a class="parent" href="#Backbone.View"><h3>extends Backbone.View</h3></a>
38
+
39
+
40
+ </div>
41
+ <div class="class_content">
42
+ <p>Internal: View that renders a Directory node and controls its behavior (class: 'directory', tag: 'ul').</p>
43
+ <div class="methods">
44
+
45
+
46
+ <div class="instancemethods">
47
+ <h3>Instance Methods</h3>
48
+
49
+ <div class="method">
50
+ <h4>initialize(options)</h4>
51
+ <p>Internal: Initialize a new directory node. Adds associated model cid to the
52
+ view element. Binds change handler to the <code>change:open</code> event that
53
+ toggles the display of directory contents. Binds change handler to
54
+ the <code>change:name</code> event that re-renders a sorted file tree.</p>
55
+
56
+ <ul>
57
+ <li>options - Passes in settings object, which is used for access to the
58
+ tree view root in order to proxy events to it.</li>
59
+ </ul>
60
+ </div>
61
+
62
+ <div class="method">
63
+ <h4>appendView(node)</h4>
64
+ <p>Internal: Appends a view based on the underlying node model to this view.</p>
65
+
66
+ <p>node - A Node model. Either a File or a Directory. This is the model the
67
+ created view will be associated with.</p>
68
+ </div>
69
+
70
+ <div class="method">
71
+ <h4>render()</h4>
72
+ <p>Internal: Set the text of the view element based on the underlying model name.</p>
73
+
74
+ <p>Returns <code>this</code> view.</p>
75
+ </div>
76
+
77
+ <div class="method">
78
+ <h4>displayChildren(open)</h4>
79
+ <p>Internal: Toggles display of the children Files or Diretories of this view.</p>
80
+ </div>
81
+
82
+ </div>
83
+
84
+ </div>
85
+ </div>
86
+ </div>
87
+
88
+ </div>
89
+
90
+
91
+ </div>
92
+ </div>
93
+ </body>
94
+ </html>