Skip to content

Commit 55a09fc

Browse files
committed
Merge branch 'chef-129' of git://github.com/fujin/chef into aj-ui
Conflicts: chef-server-slice/app/controllers/nodes.rb
2 parents 6d9b684 + 8d656d9 commit 55a09fc

57 files changed

Lines changed: 3813 additions & 417 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "chef-server-slice/public/javascripts/jsoneditor"]
2+
path = chef-server-slice/public/javascripts/jsoneditor
3+
url = git://github.com/iterationlabs/jsoneditor.git
4+
[submodule "chef-server-slice/public/web-app-theme"]
5+
path = chef-server-slice/public/web-app-theme
6+
url = git://github.com/pilu/web-app-theme.git

README.rdoc

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
== DESCRIPTION:
66

7-
Chef is a systems management framework masquerading as a configuration management tool.
8-
9-
I'm in ur netwerk, cookin up yer servers. :)
7+
Chef is a systems integration framework masquerading as a configuration management tool.
108

119
== REQUIREMENTS:
1210

@@ -19,7 +17,7 @@ chef:
1917
* stomp
2018
* ohai
2119

22-
chef-server and the chefserverslice (merb slice), same requires as chef above, plus:
20+
chef-server and the chef-server-slice (merb slice), same requires as chef above, plus:
2321

2422
* stompserver
2523
* ferret
@@ -30,23 +28,14 @@ chef-server and the chefserverslice (merb slice), same requires as chef above, p
3028
* ruby-openid
3129
* syntax
3230

33-
Interim Note:
34-
35-
Once the {chef,chef-server,chefserverslice}.gem set is installed, do the following:
36-
37-
> cd /Library/Ruby/Gems/1.8/gems/chef-server<xxx> # or wherever your gems land
38-
> sudo rake slices:chefserverslice:install
39-
40-
This installs the chefserverslice into the chef-server merb application
41-
4231
External Servers:
4332

4433
* stompserver (for easy stomp mq testing)
4534
* CouchDB
4635

4736
== INSTALL:
4837

49-
Install all of the above. To fire up a develpment environment, do the following:
38+
Install all of the above. To fire up a development environment, do the following:
5039

5140
* Start CouchDB with 'couchdb'
5241
* Start stompserver with 'stompserver'
@@ -57,10 +46,13 @@ Install all of the above. To fire up a develpment environment, do the following
5746
* Start chef-server:
5847

5948
chef-server -N -c 2
49+
OR
50+
(in chef-server-slice)
51+
slice -N -c 2
6052

6153
* Test run chef to begin node registration:
6254

63-
sudo ./bin/chef-client
55+
chef-client
6456

6557
* Validate the node registration:
6658

Rakefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@ gems = %w[chef chef-server-slice chef-server]
22
require 'rubygems'
33
require 'cucumber/rake/task'
44

5+
namespace :git do
6+
desc "Initialise and update the Git submodules"
7+
task :submodule_update do
8+
sh "git submodule update --init"
9+
end
10+
end
11+
512
desc "Build the chef gems"
6-
task :gem do
13+
task :gem => "git:submodule_update" do
714
gems.each do |dir|
815
Dir.chdir(dir) { sh "rake package" }
916
end
1017
end
1118

1219
desc "Install the chef gems"
13-
task :install do
20+
task :install => "git:submodule_update" do
1421
gems.each do |dir|
1522
Dir.chdir(dir) { sh "rake install" }
1623
end

chef-server-slice/app/controllers/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def access_denied
107107
case content_type
108108
when :html
109109
store_location
110-
redirect url(:openid_consumer)
110+
redirect slice_url(:openid_consumer), :message => { :error => "You don't have access to that, please login."}
111111
else
112112
raise Unauthorized, "You must authenticate first!"
113113
end

chef-server-slice/app/controllers/nodes.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def show
3838
rescue Net::HTTPServerException => e
3939
raise NotFound, "Cannot load node #{params[:id]}"
4040
end
41-
if params[:ajax] == "true"
42-
render JSON.pretty_generate(@node), :layout=>false
41+
if request.xhr?
42+
render JSON.pretty_generate(@node), :layout => false
4343
else
4444
display @node
4545
end
@@ -57,7 +57,7 @@ def create
5757
end
5858

5959
def update
60-
if params[:ajax]
60+
if request.xhr?
6161
@node = JSON.parse(params[:value])
6262
else
6363
@node = params.has_key?("inflated_object") ? params["inflated_object"] : nil
@@ -66,8 +66,8 @@ def update
6666
if @node
6767
@status = 202
6868
@node.save
69-
if params[:ajax]
70-
partial("nodes/node", :node => @node)
69+
if request.xhr?
70+
partial :node, :node => @node
7171
else
7272
display @node
7373
end

chef-server-slice/app/controllers/openid_consumer.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ class ChefServerSlice::OpenidConsumer < ChefServerSlice::Application
2626
provides :html, :json
2727

2828
def index
29-
render
29+
if request.xhr?
30+
render :layout => false
31+
else
32+
render
33+
end
3034
end
3135

3236
def start

chef-server-slice/app/controllers/openid_register.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class ChefServerSlice::OpenidRegister < ChefServerSlice::Application
2525
provides :html, :json
2626

2727
before :fix_up_node_id
28+
before :login_required, :only => [ :update, :destroy, :validate, :admin ]
29+
before :authorized_node, :only => [ :update, :destroy, :validate, :admin ]
2830

2931
def index
3032
@headers['X-XRDS-Location'] = Chef::Config[:openid_url] + "/openid/server/server/xrds"

chef-server-slice/app/helpers/cookbooks_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ module CookbooksHelper
2222
def syntax_highlight(code)
2323
converter = Syntax::Convertors::HTML.for_syntax "ruby"
2424
if File.exists?(code)
25-
converter.convert(File.read(code))
25+
converter.convert(File.read(code), false)
2626
else
27-
converter.convert(code)
27+
converter.convert(code, false)
2828
end
2929
end
3030
end

chef-server-slice/app/helpers/global_helpers.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def resource_collection(collection)
3333
def node_escape(node)
3434
node.gsub(/\./, '_')
3535
end
36+
3637
end
3738
end
3839
end

chef-server-slice/app/helpers/nodes_helper.rb

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#
22
# Author:: Adam Jacob (<adam@opscode.com>)
3+
# Author:: AJ Christensen (<aj@junglist.gen.nz>)
34
# Copyright:: Copyright (c) 2008 Opscode, Inc.
45
# License:: Apache License, Version 2.0
56
#
@@ -22,19 +23,43 @@ module NodesHelper
2223
def recipe_list(node)
2324
response = ""
2425
node.recipes.each do |recipe|
25-
response << "<li>#{recipe}</li>"
26+
response << "<li>#{recipe}</li>\n"
2627
end
2728
response
2829
end
2930

3031
def attribute_list(node)
3132
response = ""
3233
node.each_attribute do |k,v|
33-
response << "<li><b>#{k}</b>: #{v}</li>"
34+
response << "<li><b>#{k}</b>: #{v}</li>\n"
3435
end
3536
response
3637
end
38+
39+
# Recursively build a tree of lists.
40+
def build_tree(node)
41+
list = "<dl>"
42+
list << "\n<!-- Beginning of Node Tree -->"
43+
walk = lambda do |key,value|
44+
case value
45+
when Hash, Array
46+
list << "\n<!-- Beginning of Enumerable obj -->"
47+
list << "\n<dt>#{key}</dt>"
48+
list << "<dd>"
49+
list << "\t<dl>\n"
50+
value.each(&walk)
51+
list << "\t</dl>\n"
52+
list << "</dd>"
53+
list << "\n<!-- End of Enumerable obj -->"
54+
55+
else
56+
list << "\n<dt>#{key}</dt>"
57+
list << "<dd>#{value}</dd>"
58+
end
59+
end
60+
node.attribute.sort{ |a,b| a[0] <=> b[0] }.each(&walk)
61+
list << "</dl>"
62+
end
3763
end
38-
3964
end
4065
end

0 commit comments

Comments
 (0)