lib/stackprof-webnav/server.rb in stackprof-webnav-0.0.4 vs lib/stackprof-webnav/server.rb in stackprof-webnav-0.1.0
- old
+ new
@@ -1,14 +1,14 @@
-require 'nyny'
+require 'sinatra'
require 'haml'
require "stackprof"
require 'net/http'
require_relative 'presenter'
module StackProf
module Webnav
- class Server < NYNY::App
+ class Server < Sinatra::Application
class << self
attr_accessor :cmd_options, :report_dump_path, :report_dump_uri, :report_dump_listing
def presenter regenerate=false
return @presenter unless regenerate || @presenter.nil?
@@ -36,19 +36,10 @@
end
end
helpers do
- def template_path name
- File.join(__dir__, name)
- end
-
- def render_with_layout *args
- args[0] = template_path("views/#{args[0]}.haml")
- render(template_path('views/layout.haml')) { render(*args) }
- end
-
def presenter
Server.presenter
end
def method_url name
@@ -65,13 +56,13 @@
end
get '/' do
presenter
if Server.report_dump_listing
- redirect_to '/listing'
+ redirect '/listing'
else
- redirect_to '/overview'
+ redirect '/overview'
end
end
get '/overview' do
if params[:path]
@@ -79,30 +70,30 @@
Server.presenter(true)
end
@file = Server.report_dump_path || Server.report_dump_uri
@action = "overview"
@frames = presenter.overview_frames
- render_with_layout :overview
+ haml :overview
end
get '/listing' do
@file = Server.report_dump_listing
@action = "listing"
@dumps = presenter.listing_dumps
- render_with_layout :listing
+ haml :listing
end
get '/method' do
@action = params[:name]
@frames = presenter.method_info(params[:name])
- render_with_layout :method
+ haml :method
end
get '/file' do
path = params[:path]
@path = path
@data = presenter.file_overview(path)
- render_with_layout :file
+ haml :file
end
end
end
end