./lib/dolt/sinatra/actions.rb in dolt-0.3.0 vs ./lib/dolt/sinatra/actions.rb in dolt-0.3.1

- old
+ new

@@ -26,13 +26,17 @@ response.status = 302 response["Location"] = url body "" end - def error(error) - response["Content-Type"] = "text/plain" - body("Process failed with exit code #{error.exit_code}:\n#{error.message}") + def error(error, repo, ref) + response["Content-Type"] = "text/html" + body(renderer.render(:"500", { + :error => error, + :repository => repo, + :ref => ref + })) end def raw(repo, ref, path) blob(repo, ref, path, { :template => :raw, @@ -41,47 +45,47 @@ }) end def blob(repo, ref, path, options = { :template => :blob, :content_type => "text/html" }) actions.blob(repo, ref, path) do |err, data| - return error(err) if !err.nil? + return error(err, repo, ref) if !err.nil? blob = data[:blob] return redirect(tree_url(repo, ref, path)) if !blob.is_a?(Rugged::Blob) response["Content-Type"] = options[:content_type] tpl_options = options[:template_options] || {} body(renderer.render(options[:template], data, tpl_options)) end end def tree(repo, ref, path) actions.tree(repo, ref, path) do |err, data| - return error(err) if !err.nil? + return error(err, repo, ref) if !err.nil? tree = data[:tree] return redirect(blob_url(repo, ref, path)) if !tree.is_a?(Rugged::Tree) response["Content-Type"] = "text/html" body(renderer.render(:tree, data)) end end def blame(repo, ref, path) actions.blame(repo, ref, path) do |err, data| - return error(err) if !err.nil? + return error(err, repo, ref) if !err.nil? response["Content-Type"] = "text/html" body(renderer.render(:blame, data)) end end def history(repo, ref, path, count) actions.history(repo, ref, path, count) do |err, data| - return error(err) if !err.nil? + return error(err, repo, ref) if !err.nil? response["Content-Type"] = "text/html" body(renderer.render(:commits, data)) end end def refs(repo) actions.refs(repo) do |err, data| - return error(err) if !err.nil? + return error(err, repo, ref) if !err.nil? response["Content-Type"] = "application/json" body(renderer.render(:refs, data, :layout => nil)) end end end