class RhetButler::Web::MainApp
Attributes
assets_app_class[RW]
capture_exceptions[RW]
presentation_app_class[RW]
Public Class Methods
new(file_manager)
click to toggle source
# File lib/rhet-butler/web/main-app.rb, line 30 def initialize(file_manager) @file_manager = file_manager @capture_exceptions = true end
Public Instance Methods
build_authentication_block(creds_config)
click to toggle source
# File lib/rhet-butler/web/main-app.rb, line 71 def build_authentication_block(creds_config) return (proc do |user, pass| creds_config.username == user && creds_config.password == pass end) end
build_server()
click to toggle source
# File lib/rhet-butler/web/main-app.rb, line 130 def build_server configuration = @file_manager.base_config Thin::Logging.log_info "Starting server. Try one of these:" require 'system/getifaddrs' System.get_all_ifaddrs.each do |interface| Thin::Logging.log_info " http://#{interface[:inet_addr].to_s}:#{configuration.serve_port}/" Thin::Logging.log_info " http://#{interface[:inet_addr].to_s}:#{configuration.serve_port}/qr" end server = Thin::Server.new(builder.to_app, configuration.serve_port) server.threaded = true server end
builder()
click to toggle source
# File lib/rhet-butler/web/main-app.rb, line 78 def builder sockjs_options = { :sockjs_url => "/assets/javascript/sockjs-0.3.4.js", :queue => SlideMessageQueue.new } viewer_app = self.viewer_app presenter_app = presentation_app_class.new(:presenter, @file_manager) assets_app = assets_app_class.new(@file_manager) qr_app = QrDisplayApp.new(@file_manager, "/presenter") presenter_config = presenter_app.configuration auth_validation = build_authentication_block(presenter_config) Rack::Builder.new do #SockJS.debug! map "/live/follower" do run Rack::SockJS.new(FollowerSession, sockjs_options) end map "/live/leader" do use SelectiveAuth, "Rhet Butler Presenter", &auth_validation run Rack::SockJS.new(LeaderSession, sockjs_options) end if @capture_exceptions use Rack::ShowExceptions end map "/assets" do run assets_app end map "/qr" do run qr_app end map "/presenter" do use SelectiveAuth, "Rhet Butler Presenter", &auth_validation run presenter_app end run lambda{|env| if env["PATH_INFO"] == "/" viewer_app.call(env) else assets_app.call(env) end } end end
check()
click to toggle source
Simply renders the bodies of the viewer and presenter apps to make sure there aren't any exceptions
# File lib/rhet-butler/web/main-app.rb, line 63 def check presenter_app = presentation_app_class.new(:presenter, @file_manager) viewer_app.body presenter_app.body #XXX static generator "populate assets" - make sure all the assets #render as well end
slides()
click to toggle source
Notes re filesets config and slides: All PresentationApps need the same slides but different configs (including templates, etc.)
So: there need to be TWO valises:
1) The slides valise - including slidesets that might get included - this one is common between all Apps
2) The config valise - there should be a “common” base to this, and a role specific variation. Built special, because the /viewer app should allow for config in the root of the project etc, while the /presenter version should require special config (since I'm assuming a boring presentation view)
# File lib/rhet-butler/web/main-app.rb, line 53 def slides @file_manager.slide_files end
start()
click to toggle source
:nocov:
# File lib/rhet-butler/web/main-app.rb, line 145 def start build_server.start end
viewer_app()
click to toggle source
# File lib/rhet-butler/web/main-app.rb, line 57 def viewer_app @viewer_app ||= presentation_app_class.new(:viewer, @file_manager) end