lib/gitdocs/server.rb in gitdocs-0.4.9 vs lib/gitdocs/server.rb in gitdocs-0.4.10

- old
+ new

@@ -88,16 +88,21 @@ 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) + 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) redirect! "/" + idx.to_s + parent elsif mode == 'edit' && mime.match(%r{text/}) # edit file contents = File.read(expanded_path) render! "edit", :layout => 'app', :locals => locals.merge(:contents => contents) elsif mode != 'raw' # render file + revision = request.params['revision'] + expanded_path = gd.file_revision_at(file_path, revision) if revision begin # attempting to render file contents = '<div class="tilt">' + render(expanded_path) + '</div>' rescue RuntimeError => e # not tilt supported contents = if mime.match(%r{text/}) '<pre class="CodeRay">' + CodeRay.scan_file(expanded_path).encode(:html) + '</pre>' \ No newline at end of file