From 66e05e6a95152cf313fb593aef3521c110fa3913 Mon Sep 17 00:00:00 2001 From: Mike Ball Date: Sat, 20 Feb 2010 00:48:51 -0500 Subject: [PATCH] tweaks to filesystem and added $design_mode --- lib/sproutcore/rack/builder.rb | 7 +++++-- lib/sproutcore/rack/filesystem.rb | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/sproutcore/rack/builder.rb b/lib/sproutcore/rack/builder.rb index 66246b4..d8dedf7 100644 --- a/lib/sproutcore/rack/builder.rb +++ b/lib/sproutcore/rack/builder.rb @@ -89,11 +89,14 @@ def call(env) project_mutex.synchronize do did_reload = reload_project! # if needed - + # collect some standard info url = env['PATH_INFO'] url = '/sproutcore/welcome' if url == '/' - + + #designer mode? + $design_mode = true if /designMode=YES/ =~ env['QUERY_STRING'] + SC.logger.info $design_mode # look for a matching target target = target_for(url) ret = not_found("No matching target") if target.nil? diff --git a/lib/sproutcore/rack/filesystem.rb b/lib/sproutcore/rack/filesystem.rb index 222469e..4dfb4b3 100644 --- a/lib/sproutcore/rack/filesystem.rb +++ b/lib/sproutcore/rack/filesystem.rb @@ -102,6 +102,7 @@ def call(env) def list_files(original_path) results = [] + @id = 0 with_sanitized_path(original_path) do |root_path| results = folder_contents(root_path, root_path) end @@ -109,7 +110,8 @@ def list_files(original_path) end def folder_contents(dir, root_path) - results = []; + results = [] + Dir.new(dir).each do |path| name = path path = dir + path @@ -117,10 +119,11 @@ def folder_contents(dir, root_path) sc_path = sc_path.gsub(name,"") if FileTest.directory?(path) if not (File.basename(path)[0] == ?. or @ignore_directories.include?(File.basename(path))) - results<< {:type => :dir, :dir => sc_path, :name =>name, :contents=> folder_contents(path+"/", root_path)} + results<< {:type => :Dir, :dir => sc_path, :name =>name, + :contents=> folder_contents(path+"/", root_path), :id => @id+=1} end else #just a regular file - results<< {:type => :file, :dir => sc_path, :name => name} + results<< {:type => :File, :dir => sc_path, :name => name, :id => @id+=1 } end end return results