chef-server-webui 0.9.0.a4 → 0.9.0.a6

Sign up to get free protection for your applications and to get access to all the features.
@@ -209,19 +209,15 @@ class Application < Merb::Controller
209
209
  count
210
210
  end
211
211
 
212
- def syntax_highlight(code)
213
- tokens = File.exists?(code) ? CodeRay.scan_file(code, :ruby) : CodeRay.scan(code, :ruby)
214
- CodeRay.encode_tokens(tokens, :span)
215
- end
216
-
217
- def get_file(uri)
212
+ def syntax_highlight(file_url)
213
+ Chef::Log.debug("fetching file from '#{file_url}' for highlighting")
218
214
  r = Chef::REST.new(Chef::Config[:chef_server_url])
219
- content = r.get_rest(uri)
220
- a = Tempfile.new("cookbook_temp_file")
221
- File.open(a.path, 'w'){|f| f.write(content)}
222
- path = a.path
223
- a.close
224
- path
215
+ highlighted_file = nil
216
+ r.fetch(file_url) do |tempfile|
217
+ tokens = CodeRay.scan_file(tempfile.path, :ruby)
218
+ highlighted_file = CodeRay.encode_tokens(tokens, :span)
219
+ end
220
+ highlighted_file
225
221
  end
226
222
 
227
223
  def str_to_bool(str)
@@ -240,21 +236,7 @@ class Application < Merb::Controller
240
236
 
241
237
  def get_available_recipes
242
238
  r = Chef::REST.new(Chef::Config[:chef_server_url])
243
- result = Array.new
244
- cookbooks = r.get_rest("cookbooks")
245
- cookbooks.keys.sort.each do |key|
246
- cb = r.get_rest(cookbooks[key])
247
- cb["recipes"].each do |recipe|
248
- recipe["name"] =~ /(.+)\.rb/
249
- r_name = $1;
250
- if r_name == "default"
251
- result << key
252
- else
253
- result << "#{key}::#{r_name}"
254
- end
255
- end
256
- end
257
- result
239
+ r.get_rest('cookbooks/_recipes')
258
240
  end
259
241
 
260
242
  def convert_newline_to_br(string)
@@ -18,11 +18,12 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require 'chef' / 'cookbook_loader'
21
+ require 'chef/cookbook_loader'
22
+ require 'chef/cookbook_version'
22
23
 
23
24
  class Cookbooks < Application
24
25
 
25
- provides :html, :json
26
+ provides :html
26
27
  before :login_required
27
28
  before :params_helper
28
29
 
@@ -58,6 +59,8 @@ class Cookbooks < Application
58
59
  # by default always show the largest version number (assuming largest means most recent)
59
60
  @other_versions = versions - [version]
60
61
  raise NotFound unless @cookbook
62
+
63
+ @manifest = @cookbook.manifest
61
64
  display @cookbook
62
65
  rescue => e
63
66
  Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}")
@@ -18,7 +18,7 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require 'chef' / 'node'
21
+ require 'chef/node'
22
22
 
23
23
  class Nodes < Application
24
24
 
@@ -29,7 +29,9 @@ class Nodes < Application
29
29
  def index
30
30
  begin
31
31
  node_hash = Chef::Node.list
32
- @node_list = node_hash.keys.sort_by {|a,b| node_hash[a] <=> node_hash[b]}
32
+ require 'pp'
33
+ pp node_hash
34
+ @node_list = node_hash.keys.sort
33
35
  rescue => e
34
36
  Chef::Log.error("#{e}\n#{e.backtrace.join("\n")}")
35
37
  @_message = {:error => "Could not list nodes"}
@@ -3,7 +3,7 @@
3
3
  .content
4
4
  %h2
5
5
  .title
6
- = "Cookbook: #{h @cookbook.manifest["name"]}"
6
+ = "Cookbook: #{h @manifest["name"]}"
7
7
  - unless @other_versions.nil? || @other_versions.empty?
8
8
  %select{:name => "choice", :onchange => "jump(this)", :size => "1"}
9
9
  %option{:value => ""} Other Versions
@@ -12,38 +12,38 @@
12
12
  %option{:value => url(:show_specific_version_cookbook, :cookbook_id => @cookbook_id, :cb_version => v)} "#{v}"
13
13
  .inner
14
14
  .accordion
15
- - unless @cookbook.manifest["libraries"].empty?
15
+ - unless @manifest["libraries"].empty?
16
16
  %h2.head= link_to "Library Files", "JavaScript:void(0);"
17
17
  .files
18
- - @cookbook.manifest["libraries"].each do |f|
18
+ - @manifest["libraries"].each do |f|
19
19
  .code
20
20
  %h4.head= link_to File.basename(f["name"]), "JavaScript:void(0);"
21
- %pre.ruby= syntax_highlight(get_file(f["uri"]))
22
- - unless @cookbook.manifest["attributes"].empty?
21
+ %pre.ruby= syntax_highlight(f["url"])
22
+ - unless @manifest["attributes"].empty?
23
23
  %h2.head= link_to "Attribute Files", "JavaScript:void(0);"
24
24
  .files
25
- - @cookbook.manifest["attributes"].each do |f|
25
+ - @manifest["attributes"].each do |f|
26
26
  .code
27
27
  %h4.head= link_to File.basename(f["name"]), "JavaScript:void(0);"
28
- %pre.ruby= syntax_highlight(get_file(f["uri"]))
29
- - unless @cookbook.manifest["definitions"].empty?
28
+ %pre.ruby= syntax_highlight(f["url"])
29
+ - unless @manifest["definitions"].empty?
30
30
  %h2.head= link_to "Definition Files", "JavaScript:void(0);"
31
31
  .files
32
- - @cookbook.manifest["definitions"].each do |f|
32
+ - @manifest["definitions"].each do |f|
33
33
  .code
34
34
  %h4.head= link_to File.basename(f["name"]), "JavaScript:void(0);"
35
- %pre.ruby= syntax_highlight(get_file(f["uri"]))
36
- - unless @cookbook.manifest["recipes"].empty?
35
+ %pre.ruby= syntax_highlight(f["url"])
36
+ - unless @manifest["recipes"].empty?
37
37
  %h2.head= link_to "Recipe Files", "JavaScript:void(0);"
38
38
  .files
39
- - @cookbook.manifest["recipes"].each do |f|
39
+ - @manifest["recipes"].each do |f|
40
40
  .code
41
41
  %h4.head= link_to File.basename(f["name"]), "JavaScript:void(0);"
42
- %pre.ruby= syntax_highlight(get_file(f["uri"]))
43
- - unless @cookbook.manifest["templates"].empty?
42
+ %pre.ruby= syntax_highlight(f["url"])
43
+ - unless @manifest["templates"].empty?
44
44
  %h2.head= link_to "Template Files", "JavaScript:void(0);"
45
45
  .files
46
- - @cookbook.manifest["templates"].each do |f|
46
+ - @manifest["templates"].each do |f|
47
47
  .code
48
48
  %h4.head= link_to File.basename(f["name"]), "JavaScript:void(0);"
49
- %pre.ruby= syntax_highlight(get_file(f["uri"]))
49
+ %pre.ruby= syntax_highlight(f["url"])
@@ -27,21 +27,12 @@ require "rubygems"
27
27
  require "merb-core"
28
28
 
29
29
  # Load chef and chef-server-api from source rather than gem, if present
30
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../../chef/lib/chef'))
30
+ $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../../chef/lib'))
31
31
  $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
32
32
 
33
33
  require 'chef'
34
34
  require 'chef-server-webui'
35
35
 
36
- # Ensure the chef gem we load is the same version as the chef server
37
- unless defined?(Chef)
38
- gem "chef", "=" + CHEF_SERVER_WEBUI_VERSION
39
- require 'chef'
40
- end
41
-
42
- #Dir.chdir File.join(File.dirname(__FILE__),"..")
43
- #__DIR__ = Dir.getwd
44
-
45
36
  if ARGV[0] && ARGV[0] =~ /^[^-]/
46
37
  ARGV.push "-H"
47
38
  end
@@ -1,3 +1,3 @@
1
1
  module ChefServerWebui
2
- VERSION = '0.9.0.a4'
2
+ VERSION = '0.9.0.a6'
3
3
  end
@@ -51,22 +51,27 @@ dl dt { font-weight: bold; }
51
51
 
52
52
  div.sortable {
53
53
  height: 200px;
54
- width: 225px;
54
+ width: 350px;
55
55
  margin-right: 10px;
56
56
  border: 1px solid black;
57
- overflow: scroll;
57
+ overflow-y: scroll;
58
58
  background: #777777;
59
59
  }
60
60
 
61
61
  div.sortable.run-list {
62
62
  height: 430px;
63
- width: 225px;
63
+ width: 350px;
64
64
  margin-right: 10px;
65
65
  border: 1px solid black;
66
- overflow: scroll;
66
+ overflow-y: scroll;
67
67
  background: #777777;
68
68
  }
69
69
 
70
+ div.run-list ul.ui-sortable#for_node, div.run-list ul.ui-sortable#for_role {
71
+ min-height: 420px;
72
+ }
73
+
74
+
70
75
  div.clear {
71
76
  clear: left;
72
77
  }
@@ -125,9 +130,24 @@ div.editor {
125
130
  border: 1px solid black;
126
131
  }
127
132
 
128
- #node_available_roles, #node_available_recipes, #for_node, #for_role, #available_recipes { list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 10px; background: #eee; padding: 5px; width: 200px;}
133
+ #node_available_roles, #node_available_recipes, #for_node, #for_role, #available_recipes {
134
+ list-style-type: none;
135
+ margin: 0;
136
+ padding: 0;
137
+ float: left;
138
+ margin-right: 10px;
139
+ background: #eee;
140
+ padding: 5px;
141
+ width: 325px;
142
+ min-height:200px;
143
+ }
129
144
 
130
- #node_available_roles li, #node_available_recipes li, #for_node li, #for_role li, #available_recipes li { margin: 0 5px 5px 5px; padding: 5px; width: 175px; }
145
+ #node_available_roles li, #node_available_recipes li, #for_node li, #for_role li, #available_recipes li {
146
+ margin: 0 5px 5px 5px;
147
+ padding: 5px;
148
+ width: 310px;
149
+ overflow:hidden;
150
+ }
131
151
 
132
152
  #sidebar_block {
133
153
  display: none;
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 9
8
8
  - 0
9
- - a4
10
- version: 0.9.0.a4
9
+ - a6
10
+ version: 0.9.0.a6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Opscode
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-04 00:00:00 -07:00
18
+ date: 2010-06-07 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency