lib/gitdocs/server.rb in gitdocs-0.4.12 vs lib/gitdocs/server.rb in gitdocs-0.4.13

- old
+ new

@@ -19,11 +19,15 @@ Thin::Server.start('127.0.0.1', port) do use Rack::Static, :urls => ['/css', '/js', '/img', '/doc'], :root => File.expand_path("../public", __FILE__) use Rack::MethodOverride run Renee { if request.path_info == '/' - render! "home", :layout => 'app', :locals => {:conf => manager.config, :nav_state => "home" } + if manager.config.shares.size == 1 + redirect! "/0" + else + render! "home", :layout => 'app', :locals => {:conf => manager.config, :nav_state => "home" } + end else path 'settings' do get.render! 'settings', :layout => 'app', :locals => {:conf => manager.config, :nav_state => "settings" } post do shares = manager.config.shares @@ -87,10 +91,14 @@ redirect! "/" + idx.to_s + file_path + "/" + filename elsif !File.exist?(expanded_path) # edit for non-existent file render! "edit", :layout => 'app', :locals => locals.merge(:contents => "") elsif File.directory?(expanded_path) # list directory contents = gd.dir_files(expanded_path) - render! "dir", :layout => 'app', :locals => locals.merge(:contents => contents) + rendered_readme = nil + if readme = Dir[File.expand_path("README.{md,txt}", expanded_path)].first + rendered_readme = '<h3>' + File.basename(readme) + '</h3><div class="tilt">' + render(readme) + '</div>' + end + render! "dir", :layout => 'app', :locals => locals.merge(:contents => contents, :rendered_readme => rendered_readme) elsif mode == "revisions" # list revisions revisions = gd.file_revisions(file_path) render! "revisions", :layout => 'app', :locals => locals.merge(:revisions => revisions) elsif mode == 'delete' # delete file FileUtils.rm(expanded_path) \ No newline at end of file