Class: ConcertoHardware::Engine
- Inherits:
-
Rails::Engine
- Object
- Rails::Engine
- ConcertoHardware::Engine
- Defined in:
- lib/concerto_hardware/engine.rb
Instance Method Summary collapse
-
#plugin_info(plugin_info_class) ⇒ Object
Define plugin information for the Concerto application to read.
Instance Method Details
#plugin_info(plugin_info_class) ⇒ Object
Define plugin information for the Concerto application to read. Do not modify @plugin_info outside of this static configuration block.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/concerto_hardware/engine.rb', line 14 def plugin_info(plugin_info_class) @plugin_info ||= plugin_info_class.new do # Make the engine's controller accessible at /hardware add_route("hardware", ConcertoHardware::Engine) # Initialize configuration settings with a description and a default. # Administrators can change the value through the Concerto dashboard. add_config("poll_interval", "60", :value_type => "integer", :category => "System", :seq_no => 999, :description => "Client hardware polling interval in seconds") # Some code to run at app boot (example) # init do # Rails.logger.info "ConcertoHardware: Initialization code is running" # end # The following hooks allow integration into the main Concerto app # at the controller and view levels. do javascript_include_tag "concerto_hardware/application" end add_controller_hook "ScreensController", :show, :before do @player = Player.find_by_screen_id(@screen.id) end add_controller_hook "ScreensController", :change, :before do Rails.logger.info "concerto-hardware: screen change callback" if @screen.auth_in_progress? # have a temp token to look at if Player.where(:screen_id => @screen.id).count == 0 # No existing player if ((@screen.temp_token.length > Screen::TEMP_TOKEN_LENGTH) and (@screen.temp_token[Screen::TEMP_TOKEN_LENGTH].downcase == "s")) # Okay, we have a legit player situation. Rails.logger.info "concerto-hardware: creating Player for the new Screen!" flash[:notice] ||= "" player = Player.new player.screen_id = @screen.id player.activated = true if player.save Rails.logger.info " Success!" #flash[:notice] << " A player hardware profile was automatically created!" # TODO: User notification. else Rails.logger.info " Failed." #flash[:notice] << " We could not create a player hardware profile, however." end end end end end add_view_hook "ScreensController", :screen_details, :partial => "concerto_hardware/screens/screen_link" add_view_hook "ScreensController", :screen_statistics, :partial => "concerto_hardware/screens/player_stats" end end |