Skip to content

Commit

Permalink
tweaks to filesystem and added $design_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
onkis authored and Charles Jolley committed Apr 9, 2010
1 parent c1b70b5 commit 66e05e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/sproutcore/rack/builder.rb
Expand Up @@ -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?
Expand Down
9 changes: 6 additions & 3 deletions lib/sproutcore/rack/filesystem.rb
Expand Up @@ -102,25 +102,28 @@ 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
success(results.to_json)
end

def folder_contents(dir, root_path)
results = [];
results = []

Dir.new(dir).each do |path|
name = path
path = dir + path
sc_path = path.gsub(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
Expand Down

0 comments on commit 66e05e6

Please sign in to comment.