chef-server-webui 0.9.10.rc.2 → 0.9.10.rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,7 @@ class Application < Merb::Controller
|
|
29
29
|
def login_required
|
30
30
|
if session[:user]
|
31
31
|
begin
|
32
|
-
|
32
|
+
load_session_user
|
33
33
|
rescue
|
34
34
|
logout_and_redirect_to_login
|
35
35
|
else
|
@@ -41,6 +41,12 @@ class Application < Merb::Controller
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def load_session_user
|
45
|
+
Chef::WebUIUser.load(session[:user])
|
46
|
+
rescue
|
47
|
+
raise NotFound, "Cannot find User #{session[:user]}, maybe it got deleted by an Administrator."
|
48
|
+
end
|
49
|
+
|
44
50
|
def cleanup_session
|
45
51
|
[:user,:level].each { |n| session.delete(n) }
|
46
52
|
end
|
@@ -214,6 +220,25 @@ class Application < Merb::Controller
|
|
214
220
|
highlighted_file
|
215
221
|
end
|
216
222
|
|
223
|
+
def show_plain_file(file_url)
|
224
|
+
Chef::Log.debug("fetching file from '#{file_url}' for highlighting")
|
225
|
+
r = Chef::REST.new(Chef::Config[:chef_server_url])
|
226
|
+
r.fetch(file_url) do |tempfile|
|
227
|
+
if binary?(tempfile.path)
|
228
|
+
return "Binary file not shown"
|
229
|
+
elsif ((File.size(tempfile.path) / (1048576)) > 5)
|
230
|
+
return "File too large to display"
|
231
|
+
else
|
232
|
+
return IO.read(tempfile.path)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def binary?(file)
|
238
|
+
s = (File.read(file, File.stat(file).blksize) || "")
|
239
|
+
s.empty? || ( s.count( "^ -~", "^\r\n" ).fdiv(s.size) > 0.3 || s.index( "\x00" ))
|
240
|
+
end
|
241
|
+
|
217
242
|
def str_to_bool(str)
|
218
243
|
str =~ /true/ ? true : false
|
219
244
|
end
|
@@ -46,4 +46,11 @@
|
|
46
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(f["url"])
|
49
|
+
%pre.ruby= syntax_highlight(f["url"])
|
50
|
+
- unless @manifest["files"].empty?
|
51
|
+
%h2.head= link_to "Cookbook Files", "JavaScript:void(0);"
|
52
|
+
.files
|
53
|
+
- @manifest["files"].each do |f|
|
54
|
+
.code
|
55
|
+
%h4.head= link_to File.basename(f["name"]), "JavaScript:void(0);"
|
56
|
+
%pre= show_plain_file(f["url"])
|
metadata
CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 9
|
8
8
|
- 10
|
9
9
|
- rc
|
10
|
-
-
|
11
|
-
version: 0.9.10.rc.
|
10
|
+
- 3
|
11
|
+
version: 0.9.10.rc.3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Opscode
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-10-
|
19
|
+
date: 2010-10-12 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|