├── log └── .keep ├── app ├── mailers │ └── .keep ├── models │ ├── .keep │ └── concerns │ │ └── .keep ├── controllers │ ├── concerns │ │ └── .keep │ ├── pages_controller.rb │ ├── application_controller.rb │ └── pusher_controller.rb ├── views │ ├── pages │ │ └── root.html.slim │ └── layouts │ │ └── application.html.slim ├── assets │ ├── stylesheets │ │ ├── _navbar.scss │ │ ├── _footer.scss │ │ └── application.css.scss │ └── javascripts │ │ └── application.js └── helpers │ └── application_helper.rb ├── lib ├── assets │ └── .keep ├── tasks │ ├── .keep │ ├── coverage.rake │ ├── db.rake │ └── spec.rake └── templates │ ├── slim │ └── scaffold │ │ ├── new.html.slim │ │ ├── edit.html.slim │ │ ├── _form.html.slim │ │ ├── show.html.slim │ │ └── index.html.slim │ ├── rspec │ ├── controller │ │ └── controller_spec.rb │ └── scaffold │ │ ├── show_spec.rb │ │ ├── new_spec.rb │ │ ├── edit_spec.rb │ │ ├── index_spec.rb │ │ └── controller_spec.rb │ └── rails │ └── scaffold_controller │ └── controller.rb ├── public ├── favicon.ico ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── .ruby-version ├── .ruby-gemset ├── vendor └── assets │ ├── javascripts │ ├── .keep │ ├── hark.js │ └── simplepeer.js │ └── stylesheets │ └── .keep ├── config ├── initializers │ ├── pusher.rb │ ├── cookies_serializer.rb │ ├── session_store.rb │ ├── mime_types.rb │ ├── filter_parameter_logging.rb │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── mailcatcher.rb │ ├── wrap_parameters.rb │ ├── inflections.rb │ ├── simple_form_bootstrap.rb │ └── simple_form.rb ├── routes.rb ├── environment.rb ├── boot.rb ├── environments │ ├── acceptance.rb │ ├── development.rb │ ├── test.rb │ └── production.rb ├── database.yml ├── locales │ ├── en.yml │ └── simple_form.en.yml ├── unicorn.rb ├── secrets.yml └── application.rb ├── spec ├── javascripts │ ├── spec.css │ ├── spec.js.coffee │ └── example_spec.js.coffee ├── support │ ├── factory_girl.rb │ ├── capybara.rb │ └── database_cleaner.rb ├── controllers │ └── pages_controller_spec.rb ├── features │ └── pages_spec.rb ├── rails_helper.rb └── spec_helper.rb ├── .rspec ├── Procfile ├── bin ├── bundle ├── rspec ├── rake ├── rails ├── spring └── deploy.sh ├── .env ├── README.md ├── db ├── seeds.rb ├── sample_data.rb └── schema.rb ├── Rakefile ├── circle.yml ├── .gitignore ├── config.ru ├── Gemfile ├── Guardfile └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.1.2 2 | -------------------------------------------------------------------------------- /.ruby-gemset: -------------------------------------------------------------------------------- 1 | pushertc 2 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/pages/root.html.slim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/initializers/pusher.rb: -------------------------------------------------------------------------------- 1 | Pusher.url = ENV['PUSHER_URL'] 2 | -------------------------------------------------------------------------------- /spec/javascripts/spec.css: -------------------------------------------------------------------------------- 1 | /* 2 | *=require application 3 | */ 4 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | #--warnings 3 | --require spec_helper 4 | --format Fuubar 5 | -------------------------------------------------------------------------------- /spec/javascripts/spec.js.coffee: -------------------------------------------------------------------------------- 1 | #=require application 2 | #=require_tree ./ 3 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec unicorn -c ./config/unicorn.rb 2 | #worker: bundle exec rake jobs:work 3 | -------------------------------------------------------------------------------- /spec/support/factory_girl.rb: -------------------------------------------------------------------------------- 1 | RSpec.configure do |config| 2 | config.include FactoryGirl::Syntax::Methods 3 | end 4 | -------------------------------------------------------------------------------- /app/controllers/pages_controller.rb: -------------------------------------------------------------------------------- 1 | class PagesController < ApplicationController 2 | 3 | def root 4 | end 5 | 6 | end 7 | -------------------------------------------------------------------------------- /lib/templates/slim/scaffold/new.html.slim: -------------------------------------------------------------------------------- 1 | .page-header 2 | h1 Create <%= singular_table_name %> 3 | 4 | == render 'form' 5 | -------------------------------------------------------------------------------- /lib/templates/slim/scaffold/edit.html.slim: -------------------------------------------------------------------------------- 1 | .page-header 2 | h1 Editing <%= singular_table_name %> 3 | 4 | == render 'form' 5 | 6 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Pushertc::Application.routes.draw do 2 | match '/pusher/auth' => 'pusher#auth', via: :post 3 | root to: 'pages#root' 4 | end 5 | -------------------------------------------------------------------------------- /app/assets/stylesheets/_navbar.scss: -------------------------------------------------------------------------------- 1 | // Navbar 2 | 3 | body { padding-top: 70px; } 4 | 5 | .nav a .glyphicon, form button.btn .glyphicon { 6 | padding-right: .2rem; 7 | } 8 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_pushertc_session' 4 | -------------------------------------------------------------------------------- /bin/rspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require 'bundler/setup' 7 | load Gem.bin_path('rspec', 'rspec') 8 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | 4 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) 5 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | # Set environment variables needed for development here. These values will be 2 | # used unless they're already set. 3 | # 4 | # http://ddollar.github.com/foreman/#ENVIRONMENT 5 | 6 | PORT=3000 7 | UNICORN_WORKERS=1 8 | UNICORN_BACKLOG=16 9 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /lib/tasks/coverage.rake: -------------------------------------------------------------------------------- 1 | namespace :spec do 2 | task :enable_coverage do 3 | ENV['COVERAGE'] = '1' 4 | end 5 | 6 | desc "Executes specs with code coverage reports" 7 | task coverage: :enable_coverage do 8 | Rake::Task[:spec].invoke 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /spec/controllers/pages_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | describe PagesController do 4 | 5 | describe "GET 'root'" do 6 | it "returns http success" do 7 | get 'root' 8 | expect(response).to be_success 9 | end 10 | end 11 | 12 | end 13 | -------------------------------------------------------------------------------- /spec/support/capybara.rb: -------------------------------------------------------------------------------- 1 | require 'capybara/poltergeist' 2 | 3 | Capybara.register_driver :poltergeist do |app| 4 | Capybara::Poltergeist::Driver.new(app, js_errors: true, inspector: true) 5 | end 6 | 7 | Capybara.default_driver = :rack_test 8 | Capybara.javascript_driver = :poltergeist 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PusherTC 2 | 3 | A WebRTC video chat application, written using [simple-peer](https://github.com/feross/simple-peer) and [Pusher](http://pusher.com/) 4 | 5 | Read the [blog post](http://blog.carbonfive.com/2014/10/16/webrtc-made-simple/) or see the [demo](http://pushertc.herokuapp.com) on Heroku. 6 | 7 | -------------------------------------------------------------------------------- /lib/tasks/db.rake: -------------------------------------------------------------------------------- 1 | namespace :db do 2 | desc "Load a small, representative set of data so that the application can start in an use state (for development)." 3 | task sample_data: :environment do 4 | sample_data = File.join(Rails.root, 'db', 'sample_data.rb') 5 | load(sample_data) if sample_data 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/controllers/pusher_controller.rb: -------------------------------------------------------------------------------- 1 | class PusherController < ApplicationController 2 | protect_from_forgery except: :auth 3 | 4 | def auth 5 | response = Pusher[params[:channel_name]].authenticate params[:socket_id], 6 | user_id: params[:id], 7 | user_info: { name: params[:name] } 8 | 9 | render json: response 10 | end 11 | end -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /config/environments/acceptance.rb: -------------------------------------------------------------------------------- 1 | # Acceptance builds on production's configuration. 2 | require Rails.root.join('config/environments/production') 3 | 4 | Rails.application.configure do 5 | # Settings specified here will take precedence over those in config/application.rb and config/production.rb. 6 | 7 | config.action_mailer.default_url_options = { host: 'pushertc-acceptance.herokuapp.com' } 8 | end 9 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | # Add your own tasks in files placed in lib/tasks ending in .rake, 3 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 4 | 5 | require File.expand_path('../config/application', __FILE__) 6 | 7 | Pushertc::Application.load_tasks 8 | 9 | # Spec is the default rake target. 10 | task(:default).clear 11 | task default: 'spec' 12 | -------------------------------------------------------------------------------- /lib/templates/rspec/controller/controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | <% module_namespacing do -%> 4 | describe <%= class_name %>Controller do 5 | 6 | <% for action in actions -%> 7 | describe "GET '<%= action %>'" do 8 | it "returns http success" do 9 | get '<%= action %>' 10 | expect(response).to be_success 11 | end 12 | end 13 | 14 | <% end -%> 15 | end 16 | <% end -%> 17 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Precompile additional assets. 7 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 8 | # Rails.application.config.assets.precompile += %w( search.js ) 9 | -------------------------------------------------------------------------------- /spec/javascripts/example_spec.js.coffee: -------------------------------------------------------------------------------- 1 | # This is an example spec, delete when there are some real specs. 2 | 3 | class Foo 4 | bar: -> 5 | false 6 | 7 | class Bar 8 | foo: -> 9 | false 10 | 11 | 12 | describe "Foo", -> 13 | it "it is not bar", -> 14 | v = new Foo() 15 | expect(v.bar()).toEqual(false) 16 | 17 | describe "Bar", -> 18 | it "it is not foo", -> 19 | v = new Bar() 20 | expect(v.foo()).toEqual(false) 21 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/mailcatcher.rb: -------------------------------------------------------------------------------- 1 | # http://www.mikeperham.com/2012/12/09/12-gems-of-christmas-4-mailcatcher-and-mail_view/ 2 | 3 | mailcatcher_port = 1025 4 | 5 | begin 6 | sock = TCPSocket.new('localhost', mailcatcher_port) 7 | sock.close 8 | mailcatcher = true 9 | rescue 10 | mailcatcher = false 11 | end 12 | 13 | if Rails.env.development? && mailcatcher 14 | ActionMailer::Base.smtp_settings = { host: 'localhost', port: mailcatcher_port } 15 | end 16 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | test: 2 | override: 3 | - bundle exec rake spec:without_features spec:features 4 | - bundle exec guard-jasmine 5 | post: 6 | - bundle exec rake db:sample_data 7 | 8 | deployment: 9 | acceptance: 10 | branch: development 11 | commands: 12 | - ./bin/deploy.sh pushertc-acceptance: 13 | timeout: 360 14 | 15 | production: 16 | branch: master 17 | commands: 18 | - ./bin/deploy.sh pushertc: 19 | timeout: 360 20 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 8.2 and up are supported. 2 | # Use 'createuser -s postgres' to create a general purpose db (super)user. 3 | 4 | development: &default 5 | adapter: postgresql 6 | encoding: unicode 7 | database: pushertc_development 8 | username: postgres 9 | pool: 5 10 | timeout: 5000 11 | 12 | test: 13 | <<: *default 14 | database: pushertc_test 15 | min_messages: warning 16 | 17 | acceptance: 18 | <<: *default 19 | url: <%= ENV['DATABASE_URL'] %> 20 | 21 | production: 22 | <<: *default 23 | url: <%= ENV['DATABASE_URL'] %> 24 | -------------------------------------------------------------------------------- /lib/templates/rspec/scaffold/show_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%> 4 | describe "<%= ns_table_name %>/show" do 5 | before(:each) do 6 | @<%= ns_file_name %> = assign(:<%= ns_file_name %>, build_stubbed(:<%= class_name.underscore %>)) 7 | end 8 | 9 | it "renders attributes" do 10 | render 11 | 12 | <% for attribute in output_attributes -%> 13 | expect(rendered).to match(/<%= eval(value_for(attribute)) %>/) 14 | <% end -%> 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast 4 | # It gets overwritten when you run the `spring binstub` command 5 | 6 | unless defined?(Spring) 7 | require "rubygems" 8 | require "bundler" 9 | 10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) 11 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) 12 | ENV["GEM_HOME"] = "" 13 | Gem.paths = ENV 14 | 15 | gem "spring", match[1] 16 | require "spring/binstub" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/features/pages_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | feature "Static Pages" do 4 | 5 | # Here's a placeholder feature spec to use as an example, uses the default driver. 6 | scenario "/ should include the application name in its title" do 7 | visit root_path 8 | 9 | expect(page).to have_title "Pushertc" 10 | end 11 | 12 | # Another contrived example, this one relies on the javascript driver. 13 | scenario "/ should include the warm closing text 'Enjoy!'", js: true do 14 | visit root_path 15 | 16 | expect(page).to have_content "Enjoy!" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/*.log 16 | /tmp 17 | 18 | # Ignore compiled assets. 19 | /public/assets 20 | 21 | .DS_Store 22 | .envrc -------------------------------------------------------------------------------- /lib/templates/slim/scaffold/_form.html.slim: -------------------------------------------------------------------------------- 1 | = simple_form_for(@<%= singular_table_name %>) do |f| 2 | = f.error_notification 3 | 4 | .form-inputs 5 | <%- attributes.each_with_index do |attribute, i| -%> 6 | = f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %><%= ', autofocus: true' if i == 0 %> 7 | <%- end -%> 8 | 9 | .form-actions 10 | = button_tag(type: 'submit', class: 'btn btn-primary') do 11 | = text_with_icon("#{btn_action_prefix} <%= singular_table_name.humanize %>", action_icon_name) 12 | ' 13 | = link_to text_with_icon('Back', 'chevron-left'), <%= index_helper %>_path, class: 'btn btn-default' 14 | 15 | -------------------------------------------------------------------------------- /spec/support/database_cleaner.rb: -------------------------------------------------------------------------------- 1 | # Good read on using database_cleaner (in lieu of a shared connection): 2 | # - http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/ 3 | 4 | RSpec.configure do |config| 5 | config.before(:suite) do 6 | DatabaseCleaner.clean_with(:truncation) 7 | end 8 | 9 | config.before(:each) do 10 | DatabaseCleaner.strategy = :transaction 11 | end 12 | 13 | config.before(:each, js: true) do 14 | DatabaseCleaner.strategy = :truncation 15 | end 16 | 17 | config.before(:each) do 18 | DatabaseCleaner.start 19 | end 20 | 21 | config.after(:each) do 22 | DatabaseCleaner.clean 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | 5 | # Redirect to the custom (canonical) hostname. 6 | use Rack::CanonicalHost, ENV['HOSTNAME'] if ENV['HOSTNAME'] 7 | 8 | # Optional Basic Auth - Enabled if BASIC_AUTH_PASSWORD is set. User is optional (any value will be accepted). 9 | BASIC_AUTH_USER = ENV['BASIC_AUTH_USER'] 10 | BASIC_AUTH_PASSWORD = ENV['BASIC_AUTH_PASSWORD'] 11 | 12 | if BASIC_AUTH_PASSWORD 13 | use Rack::Auth::Basic do |username, password| 14 | password == BASIC_AUTH_PASSWORD && (BASIC_AUTH_USER.blank? || username == BASIC_AUTH_USER) 15 | end 16 | end 17 | 18 | run Rails.application 19 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /lib/templates/rspec/scaffold/new_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%> 4 | describe "<%= ns_table_name %>/new" do 5 | before(:each) do 6 | assign(:<%= ns_file_name %>, build_stubbed(:<%= class_name.underscore %>)) 7 | end 8 | 9 | it "renders new <%= ns_file_name %> form" do 10 | render 11 | 12 | assert_select "form", action: <%= index_helper %>_path, method: "post" do 13 | <% for attribute in output_attributes -%> 14 | assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", name: "<%= ns_file_name %>[<%= attribute.name %>]" 15 | <% end -%> 16 | end 17 | end 18 | end 19 | 20 | -------------------------------------------------------------------------------- /db/sample_data.rb: -------------------------------------------------------------------------------- 1 | # Populate the database with a small set of realistic sample data so that as a developer/designer, you can use the 2 | # application without having to create a bunch of stuff or pull down production data. 3 | # 4 | # After running db:sample_data, a developer/designer should be able to fire up the app, sign in, browse data and see 5 | # examples of practically anything (interesting) that can happen in the system. 6 | # 7 | # It's a good idea to build this up along with the features; when you build a feature, make sure you can easily demo it 8 | # after running db:sample_data. 9 | # 10 | # Data that is required by the application across all environments (i.e. reference data) should _not_ be included here. 11 | # That belongs in seeds.rb instead. 12 | -------------------------------------------------------------------------------- /app/assets/stylesheets/_footer.scss: -------------------------------------------------------------------------------- 1 | $footer-height: 30px; 2 | 3 | html, body { 4 | /* The html and body elements cannot have any padding or margin. */ 5 | height: 100%; 6 | } 7 | 8 | .wrapper { 9 | min-height: 100%; 10 | height: auto; 11 | //margin: 0 auto -($footer-height + 1px) 0; // https://github.com/nex3/sass/issues/1023 12 | margin: 0 auto 0; 13 | margin-bottom: -($footer-height + 1); // +1 to account for the 1px border in the footer. 14 | padding-bottom: $footer-height + 10px; // The extra prevents content from bumping right into our footer. 15 | } 16 | 17 | footer { 18 | height: $footer-height; 19 | line-height: $footer-height; 20 | 21 | border-top: 1px solid $gray-lighter; 22 | 23 | p { 24 | margin: 0; 25 | color: $gray-light; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/templates/rspec/scaffold/edit_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%> 4 | describe "<%= ns_table_name %>/edit" do 5 | before(:each) do 6 | @<%= ns_file_name %> = assign(:<%= ns_file_name %>, build_stubbed(:<%= class_name.underscore %>)) 7 | end 8 | 9 | it "renders the edit <%= ns_file_name %> form" do 10 | render 11 | 12 | assert_select "form", action: <%= index_helper %>_path(@<%= ns_file_name %>), method: "post" do 13 | <% for attribute in output_attributes -%> 14 | assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", name: "<%= ns_file_name %>[<%= attribute.name %>]" 15 | <% end -%> 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/templates/slim/scaffold/show.html.slim: -------------------------------------------------------------------------------- 1 | .page-header 2 | h1 <%= singular_table_name.capitalize %> 3 | 4 | dl 5 | <% attributes.each do |attribute| -%> 6 | dt <%= attribute.human_name %> 7 | dd= @<%= singular_table_name %>.<%= attribute.name %> 8 | <% end -%> 9 | 10 | /- if can?(:edit, @<%= singular_table_name %>) 11 | = link_to text_with_icon('Edit', 'edit'), edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'btn btn-default' 12 | ' 13 | = link_to text_with_icon('Back', 'chevron-left'), <%= index_helper %>_path, class: 'btn btn-default' 14 | 15 | /- if can?(:destroy, @<%= singular_table_name %>) 16 | ' 17 | = link_to text_with_icon('Destroy', 'remove'), <%= singular_table_name %>_path(@<%= singular_table_name %>), \ 18 | method: :delete, data: { confirm: "Are you sure?" }, class: 'btn btn-danger' 19 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended that you check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(version: 0) do 15 | 16 | # These are extensions that must be enabled in order to support this database 17 | enable_extension "plpgsql" 18 | 19 | end 20 | -------------------------------------------------------------------------------- /config/unicorn.rb: -------------------------------------------------------------------------------- 1 | # http://unicorn.bogomips.org/ 2 | # https://blog.heroku.com/archives/2013/2/27/unicorn_rails 3 | # http://devblog.thinkthroughmath.com/blog/2013/02/27/managing-request-queuing-with-rails-on-heroku/ 4 | 5 | listen ENV['PORT'], backlog: Integer(ENV['UNICORN_BACKLOG'] || 16) 6 | worker_processes Integer(ENV['UNICORN_WORKERS'] || 3) 7 | timeout 15 8 | preload_app true 9 | 10 | before_fork do |server, worker| 11 | Signal.trap 'TERM' do 12 | puts 'Unicorn master intercepting TERM and sending myself QUIT instead.' 13 | Process.kill 'QUIT', Process.pid 14 | end 15 | 16 | defined?(ActiveRecord::Base) and 17 | ActiveRecord::Base.connection.disconnect! 18 | end 19 | 20 | after_fork do |server, worker| 21 | Signal.trap 'TERM' do 22 | puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT.' 23 | end 24 | 25 | defined?(ActiveRecord::Base) and 26 | ActiveRecord::Base.establish_connection 27 | end 28 | -------------------------------------------------------------------------------- /config/locales/simple_form.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | simple_form: 3 | "yes": 'Yes' 4 | "no": 'No' 5 | required: 6 | text: 'required' 7 | mark: '*' 8 | # You can uncomment the line below if you need to overwrite the whole required html. 9 | # When using html, text and mark won't be used. 10 | # html: '*' 11 | error_notification: 12 | default_message: "Please review the problems below:" 13 | # Examples 14 | # labels: 15 | # defaults: 16 | # password: 'Password' 17 | # user: 18 | # new: 19 | # email: 'E-mail to sign in.' 20 | # edit: 21 | # email: 'E-mail.' 22 | # hints: 23 | # defaults: 24 | # username: 'User name to sign in.' 25 | # password: 'No special characters, please.' 26 | # include_blanks: 27 | # defaults: 28 | # age: 'Rather not say' 29 | # prompts: 30 | # defaults: 31 | # age: 'Select your age' 32 | 33 | -------------------------------------------------------------------------------- /lib/templates/rspec/scaffold/index_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%> 4 | describe "<%= ns_table_name %>/index" do 5 | before(:each) do 6 | assign(:<%= table_name %>, [ 7 | <% [1,2].each_with_index do |id, model_index| -%> 8 | build_stubbed(:<%= class_name.underscore %><%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : ',' %> 9 | <% output_attributes.each_with_index do |attribute, attribute_index| -%> 10 | <%= attribute.name %>: <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> 11 | <% end -%> 12 | <% if !output_attributes.empty? -%> 13 | <%= model_index == 1 ? ')' : '),' %> 14 | <% end -%> 15 | <% end -%> 16 | ]) 17 | end 18 | 19 | it "renders a list of <%= ns_table_name %>" do 20 | render 21 | 22 | <% for attribute in output_attributes -%> 23 | assert_select "tr>td", text: <%= value_for(attribute) %>.to_s, count: 2 24 | <% end -%> 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: 42536768f866ff9cae2080fe5475077ea9c778fd0b398cd9c24874d0f8672c60b88c664f23ea16728b7c9864ab54ca5d6673a5db45c562c9b1c89ae2c1363261 15 | 16 | test: 17 | secret_key_base: 2d3fa4cd6244ffe06c65d14431f6eff0dfa11ef0c3cd30e79943ca470e87044c9ac5448fcd7fa7deedb9d76b0cd2590bc248c6eb4c4af3effd735dea9bd9608a 18 | 19 | # Do not keep server secrets in the repository, 20 | # instead read values from the environment. 21 | acceptance: 22 | secret_key_base: <%= ENV['SECRET_KEY_BASE'] %> 23 | 24 | production: 25 | secret_key_base: <%= ENV['SECRET_KEY_BASE'] %> 26 | -------------------------------------------------------------------------------- /bin/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | if [ $# -ne 1 ]; then 4 | echo 1>&2 "Usage: $0 " 5 | exit 1 6 | fi 7 | 8 | APP_NAME=$1 9 | 10 | if [ -n "$CIRCLE_SHA1" ]; then 11 | SHA_TO_DEPLOY=$CIRCLE_SHA1 12 | else 13 | echo "CIRCLE_SHA1 isn't set, deploying the latest revision." 14 | SHA_TO_DEPLOY=`git rev-parse HEAD` 15 | fi 16 | 17 | REMOTE_MISSING=$(git remote | grep heroku | wc -l) 18 | 19 | if [ $REMOTE_MISSING -eq 0 ] ; then 20 | git remote add heroku git@heroku.com:$APP_NAME.git 21 | fi 22 | 23 | PREV_WORKERS=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | xargs) 24 | 25 | heroku maintenance:on --app $APP_NAME 26 | 27 | heroku scale worker=0 --app $APP_NAME 28 | 29 | # This little hacky morsel gets around a change in the latest git client. 30 | # A better solution is in the works (we hope). 31 | [[ ! -s "$(git rev-parse --git-dir)/shallow" ]] || git fetch --unshallow 32 | 33 | git push -f heroku $SHA_TO_DEPLOY:refs/heads/master 34 | 35 | heroku run rake db:migrate db:seed --app $APP_NAME 36 | 37 | heroku scale worker=$PREV_WORKERS --app $APP_NAME 38 | 39 | heroku maintenance:off --app $APP_NAME 40 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | 3 | # create text with an icon to the left for bootstrap menus and buttons 4 | def text_with_icon(text, icon_name) 5 | raw("#{icon(icon_name)} #{text}") 6 | end 7 | 8 | # generate a standard bootstrap glyphicon 9 | def icon(name) 10 | content_tag(:span, nil, class: "glyphicon glyphicon-#{name}") 11 | end 12 | 13 | # action name to use for the primary submit button on scaffold-created CRUD forms 14 | def btn_action_prefix 15 | case action_name 16 | when 'new', 'create' 17 | 'Create' 18 | when 'edit', 'update' 19 | 'Update' 20 | else 21 | nil 22 | end 23 | end 24 | 25 | # bootstrap icon name to use for the primary submit button on scaffold-created forms 26 | def action_icon_name 27 | case action_name 28 | when 'new', 'create' 29 | 'plus' 30 | when 'edit', 'update' 31 | 'edit' 32 | else 33 | nil 34 | end 35 | end 36 | 37 | def alert_class(alert_type) 38 | alert_type = { 39 | alert: 'danger', 40 | notice: 'info' 41 | }.with_indifferent_access.fetch(alert_type, alert_type.to_s) 42 | "alert-#{alert_type}" 43 | end 44 | 45 | end 46 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css.scss: -------------------------------------------------------------------------------- 1 | @import 'bootstrap-sprockets'; 2 | @import 'bootstrap'; 3 | @import '_navbar'; 4 | @import '_footer'; 5 | 6 | #localVideo { 7 | -moz-transform: scaleX(-1); 8 | -o-transform: scaleX(-1); 9 | -webkit-transform: scaleX(-1); 10 | transform: scaleX(-1); 11 | filter: FlipH; 12 | -ms-filter: "FlipH"; 13 | } 14 | 15 | #remoteVideos video { 16 | position: fixed; 17 | right: 0; 18 | bottom: 0; 19 | min-width: 100%; 20 | min-height: 100%; 21 | width: auto; 22 | height: auto; 23 | z-index: -100; 24 | background-size: cover; 25 | } 26 | 27 | #allVideos { 28 | position: fixed; 29 | margin: 0; 30 | left: 5px; 31 | bottom: 0; 32 | 33 | li { 34 | position: relative; 35 | padding: 0 5px 0 0; 36 | } 37 | video { 38 | width: 160px; 39 | height: 90px; 40 | } 41 | 42 | .name { 43 | position: absolute; 44 | color: white; 45 | font-weight: bold; 46 | right: 5px; 47 | bottom: 5px; 48 | background-color: black; 49 | padding: 2px 5px; 50 | } 51 | } 52 | #messages { 53 | position: fixed; 54 | bottom: 0; 55 | margin-bottom: 0; 56 | padding: 10px; 57 | right: 0; 58 | background-color: black; 59 | color: white; 60 | opacity: 0.7; 61 | } 62 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Heroku uses the ruby version to configure your application's runtime. 4 | ruby '2.1.2' 5 | 6 | gem 'unicorn' 7 | gem 'rack-canonical-host' 8 | gem 'rails', '~> 4.1.5' 9 | gem 'pg' 10 | 11 | gem 'slim-rails' 12 | gem 'sass-rails' 13 | gem 'bootstrap-sass' 14 | gem 'jquery-rails' 15 | gem 'coffee-rails' 16 | gem 'turbolinks' 17 | gem 'simple_form', '~> 3.1.0.rc2' # Bootstrap 3 support 18 | gem 'uglifier' 19 | gem 'pusher' 20 | gem 'awesome_print' 21 | 22 | group :production, :acceptance do 23 | gem 'rails_stdout_logging' 24 | gem 'heroku_rails_deflate' 25 | end 26 | 27 | group :test do 28 | gem 'fuubar' 29 | gem 'jasminerice', github: 'bradphelan/jasminerice' # Latest release still depends on haml. 30 | gem 'capybara' 31 | #gem 'capybara-email' 32 | gem 'poltergeist' 33 | gem 'factory_girl_rails' 34 | #gem 'timecop' 35 | gem 'database_cleaner' 36 | gem 'simplecov' 37 | end 38 | 39 | group :test, :development do 40 | gem 'rspec-rails' 41 | #gem 'cane' 42 | #gem 'morecane' 43 | end 44 | 45 | group :development do 46 | gem 'spring' 47 | gem 'spring-commands-rspec' 48 | gem 'foreman' 49 | gem 'launchy' 50 | gem 'better_errors' 51 | gem 'binding_of_caller' 52 | gem 'quiet_assets' 53 | gem 'guard', '~> 2' 54 | gem 'guard-rspec' 55 | gem 'guard-jasmine' 56 | gem 'guard-livereload' 57 | gem 'rb-fsevent' 58 | gem 'growl' 59 | end 60 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | # More info at https://github.com/guard/guard#readme 2 | 3 | guard :livereload do 4 | watch(%r{app/views/.+\.slim$}) 5 | watch(%r{app/helpers/.+\.rb}) 6 | watch(%r{public/.+\.(css|js|html)}) 7 | watch(%r{conf ig/locales/.+\.yml}) 8 | 9 | # Rails Assets Pipeline 10 | watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|less|js|html))).*}) { |m| "/assets/#{m[3]}" } 11 | end 12 | 13 | guard :rspec do 14 | watch(%r{^spec/.+_spec\.rb$}) 15 | watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } 16 | watch('spec/spec_helper.rb') { "spec" } 17 | 18 | # Rails example 19 | watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } 20 | watch(%r{^app/(.*)(\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } 21 | watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] } 22 | watch(%r{^spec/support/(.+)\.rb$}) { "spec" } 23 | watch('app/controllers/application_controller.rb') { "spec/controllers" } 24 | 25 | # Capybara request specs 26 | watch(%r{^app/views/(.+)/.*(\.slim)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } 27 | end 28 | 29 | guard :jasmine do 30 | watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { 'spec/javascripts' } 31 | watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$}) 32 | watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{ m[1] }_spec.#{ m[2] }" } 33 | end 34 | 35 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 48 | 49 | 50 | 51 | 52 |
53 |

We're sorry, but something went wrong.

54 |
55 |

If you are the application owner check the logs for more information.

56 | 57 | 58 | -------------------------------------------------------------------------------- /lib/templates/slim/scaffold/index.html.slim: -------------------------------------------------------------------------------- 1 | div.page-header 2 | h1 Listing <%= plural_table_name %> 3 | 4 | table.table.table-striped 5 | thead 6 | tr 7 | th ID 8 | <% attributes.each do |attribute| -%> 9 | th <%= attribute.human_name %> 10 | <% end -%> 11 | th Actions 12 | 13 | tbody 14 | - @<%= plural_table_name %>.each do |<%= singular_table_name %>| 15 | tr 16 | /td= link_to_if can?(:show, <%= singular_table_name %>), <%= singular_table_name %>.id, <%= singular_table_name %>_path(<%= singular_table_name %>) 17 | td= link_to <%= singular_table_name %>.id, <%= singular_table_name %>_path(<%= singular_table_name %>) 18 | <% attributes.each do |attribute| -%> 19 | td= <%= singular_table_name %>.<%= attribute.name %> 20 | <% end -%> 21 | td 22 | /- if can? :edit, <%= singular_table_name %> 23 | = link_to text_with_icon('Edit', 'edit'), edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'btn btn-default btn-xs' 24 | ' 25 | /- if can? :destroy, <%= singular_table_name %> 26 | = link_to text_with_icon('Destroy', 'remove'), <%= singular_table_name %>_path(<%= singular_table_name %>), \ 27 | method: :delete, data: { confirm: "Are you sure?" }, class: 'btn btn-default btn-xs btn-danger' 28 | 29 | /- if can? :create, <%= singular_table_name.classify %> 30 | = link_to text_with_icon('New <%= human_name %>', 'plus'), new_<%= singular_table_name %>_path, class: 'btn btn-primary' 31 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 48 | 49 | 50 | 51 | 52 |
53 |

The change you wanted was rejected.

54 |

Maybe you tried to change something you didn't have access to.

55 |
56 |

If you are the application owner check the logs for more information.

57 | 58 | 59 | -------------------------------------------------------------------------------- /lib/tasks/spec.rake: -------------------------------------------------------------------------------- 1 | begin 2 | require 'rspec/core' 3 | require 'rspec/core/rake_task' 4 | 5 | namespace :spec do 6 | desc "Run the code examples in spec/ except those in spec/features" 7 | RSpec::Core::RakeTask.new('without_features' => 'db:test:prepare') do |t| 8 | file_list = FileList['spec/**/*_spec.rb'].exclude('spec/features/**/*_spec.rb') 9 | 10 | t.pattern = file_list 11 | end 12 | end 13 | 14 | rescue LoadError 15 | namespace :spec do 16 | task :without_requests do 17 | end 18 | end 19 | end 20 | 21 | begin 22 | require 'guard/jasmine/task' 23 | 24 | namespace :spec do 25 | desc "Run all javascript specs" 26 | task :javascripts do 27 | begin 28 | ::Guard::Jasmine::CLI.start([]) 29 | 30 | rescue SystemExit => e 31 | case e.status 32 | when 1 33 | fail "Some specs have failed." 34 | when 2 35 | fail "The spec couldn't be run: #{e.message}." 36 | end 37 | end 38 | end 39 | 40 | desc 'Runs specs with coverage and cane checks' 41 | task cane: ['spec:enable_coverage', 'spec:coverage', 'quality'] 42 | end 43 | 44 | Rake::Task['spec'].enhance do 45 | Rake::Task['spec:javascripts'].invoke 46 | end 47 | 48 | rescue LoadError 49 | namespace :spec do 50 | task :javascripts do 51 | puts "Guard is not available in this environment: #{Rails.env}." 52 | end 53 | end 54 | end 55 | 56 | 57 | Rake::Task['spec'].clear_actions 58 | 59 | desc 'Runs all specs' 60 | task spec: ['spec:without_features', 'spec:features', 'spec:javascripts'] 61 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 48 | 49 | 50 | 51 | 52 |
53 |

The page you were looking for doesn't exist.

54 |

You may have mistyped the address or the page may have moved.

55 |
56 |

If you are the application owner check the logs for more information.

57 | 58 | 59 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module Pushertc 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | 15 | # Disable unwanted generators. 16 | config.generators do |generate| 17 | generate.stylesheets false 18 | #generate.helper false 19 | generate.routing_specs false 20 | #generate.view_specs false 21 | generate.request_specs false 22 | end 23 | 24 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 25 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 26 | # config.time_zone = 'Central Time (US & Canada)' 27 | 28 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 29 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 30 | # config.i18n.default_locale = :de 31 | 32 | # Don't initialize the application when precompiling assets. Doing so on Heroku problematic 33 | # since the environment config is not available during slug completions (see user-env-compile). 34 | config.assets.initialize_on_precompile = false 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations. 23 | config.active_record.migration_error = :page_load 24 | 25 | # Debug mode disables concatenation and preprocessing of assets. 26 | # This option may cause significant delays in view rendering with a large 27 | # number of complex assets. 28 | config.assets.debug = true 29 | 30 | # Adds additional error checking when serving assets at runtime. 31 | # Checks for improperly declared sprockets dependencies. 32 | # Raises helpful error messages. 33 | config.assets.raise_runtime_errors = true 34 | 35 | # Raises error for missing translations 36 | # config.action_view.raise_on_missing_translations = true 37 | 38 | config.action_mailer.default_url_options = { host: 'localhost:3000' } 39 | 40 | end 41 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static asset server for tests with Cache-Control for performance. 16 | config.serve_static_assets = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | 37 | # Raises error for missing translations 38 | # config.action_view.raise_on_missing_translations = true 39 | 40 | config.action_mailer.default_url_options = { host: 'example.com' } 41 | end 42 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.slim: -------------------------------------------------------------------------------- 1 | doctype 5 2 | html 3 | head 4 | title PusherTC 5 | = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true 6 | = javascript_include_tag 'application', 'data-turbolinks-track' => true 7 | = csrf_meta_tag 8 | meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" 9 | 10 | body id=(controller.controller_name) class=(controller.action_name) 11 | .wrapper 12 | nav.navbar.navbar-default.navbar-fixed-top role='navigation' 13 | .container 14 | .navbar-header 15 | button.button.navbar-toggle data-toggle='collapse' data-target='.navbar-collapse' 16 | span.icon-bar 17 | span.icon-bar 18 | span.icon-bar 19 | a.navbar-brand href='/' PusherTC 20 | .collapse.navbar-collapse 21 | form#send-message.navbar-form.navbar-right 22 | .form-group 23 | input.form-control#message 24 | ' 25 | button.btn.btn-success type='submit' Send Message 26 | 27 | .container 28 | #name-prompt.modal.fade 29 | .modal-dialog 30 | form 31 | .modal-content 32 | .modal-header 33 | button.close type="button" data-dismiss="modal" 34 | span aria-hidden="true" × 35 | span.sr-only Close 36 | h4.modal-title What's your name? 37 | .modal-body 38 | input.form-control autofocus=true 39 | .modal-footer 40 | button.btn.btn-success type='submit' Ok 41 | 42 | #chat data-api-key=Pusher.key data-auth-endpoint=pusher_auth_path 43 | br 44 | 45 | #remoteVideos 46 | 47 | ul#allVideos.list-inline 48 | li 49 | video#localVideo autoplay=true muted="muted" 50 | 51 | dl.dl-horizontal#messages 52 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | ENV['RAILS_ENV'] ||= 'test' 3 | require 'spec_helper' 4 | require File.expand_path('../../config/environment', __FILE__) 5 | require 'rspec/rails' 6 | 7 | # Requires supporting ruby files with custom matchers and macros, etc, in 8 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 9 | # run as spec files by default. This means that files in spec/support that end 10 | # in _spec.rb will both be required and run as specs, causing the specs to be 11 | # run twice. It is recommended that you do not name files matching this glob to 12 | # end with _spec.rb. You can configure this pattern with the --pattern 13 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 14 | Dir[Rails.root.join('spec/support/**/*.rb')].sort.each { |f| require f } 15 | 16 | # Checks for pending migrations before tests are run. 17 | # If you are not using ActiveRecord, you can remove this line. 18 | ActiveRecord::Migration.maintain_test_schema! 19 | 20 | RSpec.configure do |config| 21 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 22 | #config.fixture_path = "#{::Rails.root}/spec/fixtures" 23 | 24 | # See database_cleaner.rb for database cleanup details. 25 | config.use_transactional_fixtures = false 26 | 27 | # RSpec Rails can automatically mix in different behaviours to your tests 28 | # based on their file location, for example enabling you to call `get` and 29 | # `post` in specs under `spec/controllers`. 30 | # 31 | # You can disable this behaviour by removing the line below, and instead 32 | # explicitly tag your specs with their type, e.g.: 33 | # 34 | # RSpec.describe UsersController, :type => :controller do 35 | # # ... 36 | # end 37 | # 38 | # The different available types are documented in the features, such as in 39 | # https://relishapp.com/rspec/rspec-rails/docs 40 | config.infer_spec_type_from_file_location! 41 | end 42 | -------------------------------------------------------------------------------- /lib/templates/rails/scaffold_controller/controller.rb: -------------------------------------------------------------------------------- 1 | <% if namespaced? -%> 2 | require_dependency "<%= namespaced_file_path %>/application_controller" 3 | 4 | <% end -%> 5 | <% module_namespacing do -%> 6 | class <%= controller_class_name %>Controller < ApplicationController 7 | before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy] 8 | 9 | def index 10 | @<%= plural_table_name %> = <%= orm_class.all(class_name) %> 11 | end 12 | 13 | def show 14 | end 15 | 16 | def new 17 | @<%= singular_table_name %> = <%= orm_class.build(class_name) %> 18 | end 19 | 20 | def edit 21 | end 22 | 23 | def create 24 | @<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %> 25 | 26 | if @<%= orm_instance.save %> 27 | redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully created.'" %> 28 | else 29 | render action: 'new' 30 | end 31 | end 32 | 33 | def update 34 | if @<%= orm_instance.update("#{singular_table_name}_params") %> 35 | redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %> 36 | else 37 | render action: 'edit' 38 | end 39 | end 40 | 41 | def destroy 42 | @<%= orm_instance.destroy %> 43 | redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %> 44 | end 45 | 46 | private 47 | # Use callbacks to share common setup or constraints between actions. 48 | def set_<%= singular_table_name %> 49 | @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %> 50 | end 51 | 52 | # Only allow a trusted parameter "white list" through. 53 | def <%= "#{singular_table_name}_params" %> 54 | <%- if attributes_names.empty? -%> 55 | params[<%= ":#{singular_table_name}" %>] 56 | <%- else -%> 57 | params.require(<%= ":#{singular_table_name}" %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>) 58 | <%- end -%> 59 | end 60 | end 61 | <% end -%> 62 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both thread web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. 20 | # config.action_dispatch.rack_cache = true 21 | 22 | # When deploying to Heroku, the app must serve static assets (or serve them from a CDN). 23 | config.serve_static_assets = true 24 | 25 | # Compress JavaScripts and CSS. 26 | config.assets.js_compressor = :uglifier 27 | # config.assets.css_compressor = :sass 28 | 29 | # Do not fallback to assets pipeline if a precompiled asset is missed. 30 | config.assets.compile = false 31 | 32 | # Generate digests for assets URLs. 33 | config.assets.digest = true 34 | 35 | # Specifies the header that your server uses for sending files. 36 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for apache 37 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 38 | 39 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 40 | # config.force_ssl = true 41 | 42 | # Set to :debug to see everything in the log. 43 | config.log_level = :info 44 | 45 | # Prepend all log lines with the following tags. 46 | # config.log_tags = [ :subdomain, :uuid ] 47 | 48 | # Use a different logger for distributed setups. 49 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 50 | 51 | # Use a different cache store in production. 52 | # config.cache_store = :mem_cache_store 53 | 54 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 55 | # config.action_controller.asset_host = "http://assets.example.com" 56 | 57 | # Precompile additional assets. 58 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 59 | # config.assets.precompile += %w( search.js ) 60 | 61 | # Ignore bad email addresses and do not raise email delivery errors. 62 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 63 | # config.action_mailer.raise_delivery_errors = false 64 | 65 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 66 | # the I18n.default_locale when a translation cannot be found). 67 | config.i18n.fallbacks = true 68 | 69 | # Send deprecation notices to registered listeners. 70 | config.active_support.deprecation = :notify 71 | 72 | # Disable automatic flushing of the log to improve performance. 73 | # config.autoflush_log = false 74 | 75 | # Use default logging formatter so that PID and timestamp are not suppressed. 76 | config.log_formatter = ::Logger::Formatter.new 77 | 78 | # Do not dump schema after migrations. 79 | config.active_record.dump_schema_after_migration = false 80 | 81 | config.action_mailer.default_url_options = { host: 'pushertc.herokuapp.com' } 82 | end 83 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # Coverage must be enabled before the application is loaded. 2 | if ENV['COVERAGE'] 3 | require 'simplecov' 4 | 5 | # Writes the coverage stat to a file to be used by Cane. 6 | class SimpleCov::Formatter::QualityFormatter 7 | def format(result) 8 | SimpleCov::Formatter::HTMLFormatter.new.format(result) 9 | File.open('coverage/covered_percent', 'w') do |f| 10 | f.puts result.source_files.covered_percent.to_f 11 | end 12 | end 13 | end 14 | SimpleCov.formatter = SimpleCov::Formatter::QualityFormatter 15 | 16 | SimpleCov.start do 17 | add_filter '/spec/' 18 | add_filter '/config/' 19 | add_filter '/vendor/' 20 | add_group 'Models', 'app/models' 21 | add_group 'Controllers', 'app/controllers' 22 | add_group 'Helpers', 'app/helpers' 23 | add_group 'Views', 'app/views' 24 | add_group 'Mailers', 'app/mailers' 25 | end 26 | end 27 | 28 | # Given that it is always loaded, you are encouraged to keep this file as 29 | # light-weight as possible. Requiring heavyweight dependencies from this file 30 | # will add to the boot time of your test suite on EVERY test run, even for an 31 | # individual file that may not need all of that loaded. Instead, make a 32 | # separate helper file that requires this one and then use it only in the specs 33 | # that actually need it. 34 | # 35 | # The `.rspec` file also contains a few flags that are not defaults but that 36 | # users commonly want. 37 | # 38 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 39 | RSpec.configure do |config| 40 | # The settings below are suggested to provide a good initial experience 41 | # with RSpec, but feel free to customize to your heart's content. 42 | 43 | # These two settings work together to allow you to limit a spec run 44 | # to individual examples or groups you care about by tagging them with 45 | # `:focus` metadata. When nothing is tagged with `:focus`, all examples 46 | # get run. 47 | config.filter_run :focus 48 | config.run_all_when_everything_filtered = true 49 | 50 | # Many RSpec users commonly either run the entire suite or an individual 51 | # file, and it's useful to allow more verbose output when running an 52 | # individual spec file. 53 | if config.files_to_run.one? 54 | # Use the documentation formatter for detailed output, 55 | # unless a formatter has already been configured 56 | # (e.g. via a command-line flag). 57 | config.default_formatter = 'doc' 58 | end 59 | 60 | # Print the 10 slowest examples and example groups at the 61 | # end of the spec run, to help surface which specs are running 62 | # particularly slow. 63 | # config.profile_examples = 10 64 | 65 | # Run specs in random order to surface order dependencies. If you find an 66 | # order dependency and want to debug it, you can fix the order by providing 67 | # the seed, which is printed after each run. 68 | # --seed 1234 69 | # config.order = :random 70 | 71 | # Run non-feature specs (shuffled) before feature specs. 72 | config.register_ordering(:global) do |items| 73 | features, others = items.partition { |g| g.metadata[:type] == :feature } 74 | others.shuffle + features 75 | end 76 | 77 | # Seed global randomization in this process using the `--seed` CLI option. 78 | # Setting this allows you to use `--seed` to deterministically reproduce 79 | # test failures related to randomization by passing the same `--seed` value 80 | # as the one that triggered the failure. 81 | Kernel.srand config.seed 82 | 83 | # rspec-expectations config goes here. You can use an alternate 84 | # assertion/expectation library such as wrong or the stdlib/minitest 85 | # assertions if you prefer. 86 | config.expect_with :rspec do |expectations| 87 | # Enable only the newer, non-monkey-patching expect syntax. 88 | # For more details, see: 89 | # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax 90 | expectations.syntax = :expect 91 | end 92 | 93 | # rspec-mocks config goes here. You can use an alternate test double 94 | # library (such as bogus or mocha) by changing the `mock_with` option here. 95 | config.mock_with :rspec do |mocks| 96 | # Enable only the newer, non-monkey-patching expect syntax. 97 | # For more details, see: 98 | # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 99 | mocks.syntax = :expect 100 | 101 | # Prevents you from mocking or stubbing a method that does not exist on 102 | # a real object. This is generally recommended. 103 | mocks.verify_partial_doubles = true 104 | end 105 | end 106 | -------------------------------------------------------------------------------- /config/initializers/simple_form_bootstrap.rb: -------------------------------------------------------------------------------- 1 | # Use this setup block to configure all options available in SimpleForm. 2 | SimpleForm.setup do |config| 3 | config.error_notification_class = 'alert alert-danger' 4 | config.button_class = 'btn btn-default' 5 | config.boolean_label_class = nil 6 | 7 | config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 8 | b.use :html5 9 | b.use :placeholder 10 | b.optional :maxlength 11 | b.optional :pattern 12 | b.optional :min_max 13 | b.optional :readonly 14 | b.use :label, class: 'control-label' 15 | 16 | b.use :input, class: 'form-control' 17 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' } 18 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 19 | end 20 | 21 | config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 22 | b.use :html5 23 | b.use :placeholder 24 | b.optional :maxlength 25 | b.optional :readonly 26 | b.use :label, class: 'control-label' 27 | 28 | b.use :input 29 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' } 30 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 31 | end 32 | 33 | config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 34 | b.use :html5 35 | b.optional :readonly 36 | 37 | b.wrapper tag: 'div', class: 'checkbox' do |ba| 38 | ba.use :label_input 39 | end 40 | 41 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' } 42 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 43 | end 44 | 45 | config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 46 | b.use :html5 47 | b.optional :readonly 48 | b.use :label, class: 'control-label' 49 | b.use :input 50 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' } 51 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 52 | end 53 | 54 | config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 55 | b.use :html5 56 | b.use :placeholder 57 | b.optional :maxlength 58 | b.optional :pattern 59 | b.optional :min_max 60 | b.optional :readonly 61 | b.use :label, class: 'col-sm-3 control-label' 62 | 63 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba| 64 | ba.use :input, class: 'form-control' 65 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } 66 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 67 | end 68 | end 69 | 70 | config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 71 | b.use :html5 72 | b.use :placeholder 73 | b.optional :maxlength 74 | b.optional :readonly 75 | b.use :label, class: 'col-sm-3 control-label' 76 | 77 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba| 78 | ba.use :input 79 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } 80 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 81 | end 82 | end 83 | 84 | config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 85 | b.use :html5 86 | b.optional :readonly 87 | 88 | b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr| 89 | wr.wrapper tag: 'div', class: 'checkbox' do |ba| 90 | ba.use :label_input, class: 'col-sm-9' 91 | end 92 | 93 | wr.use :error, wrap_with: { tag: 'span', class: 'help-block' } 94 | wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 95 | end 96 | end 97 | 98 | config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 99 | b.use :html5 100 | b.optional :readonly 101 | 102 | b.use :label, class: 'col-sm-3 control-label' 103 | 104 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba| 105 | ba.use :input 106 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } 107 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 108 | end 109 | end 110 | 111 | config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 112 | b.use :html5 113 | b.use :placeholder 114 | b.optional :maxlength 115 | b.optional :pattern 116 | b.optional :min_max 117 | b.optional :readonly 118 | b.use :label, class: 'sr-only' 119 | 120 | b.use :input, class: 'form-control' 121 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' } 122 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 123 | end 124 | 125 | # Wrappers for forms and inputs using the Bootstrap toolkit. 126 | # Check the Bootstrap docs (http://getbootstrap.com) 127 | # to learn about the different styles for forms and inputs, 128 | # buttons and other elements. 129 | config.default_wrapper = :vertical_form 130 | end 131 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. 9 | // 10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD 11 | // GO AFTER THE REQUIRES BELOW. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require bootstrap 16 | //= require pusher 17 | //= require simplepeer 18 | //= require hark 19 | 20 | // not a real GUID, but it will do 21 | // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript 22 | var guid = (function() { 23 | function s4() { 24 | return Math.floor((1 + Math.random()) * 0x10000) 25 | .toString(16) 26 | .substring(1); 27 | } 28 | return function() { 29 | return s4() + s4() + '-' + s4() + '-' + s4() + '-' + 30 | s4() + '-' + s4() + s4() + s4(); 31 | }; 32 | })(); 33 | 34 | navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; 35 | 36 | var mediaOptions = { 37 | audio: true, 38 | video: { 39 | mandatory: { 40 | minWidth: 1280, 41 | minHeight: 720 42 | } 43 | } 44 | }; 45 | 46 | $(function() { 47 | var $messages = $('#messages'), 48 | $modal = $('#name-prompt').modal({ backdrop: 'static' }) 49 | 50 | $modal.find('button').click(function(e) { 51 | e.preventDefault(); 52 | name = $modal.find('input').val().trim(); 53 | 54 | if (name === '') return; 55 | 56 | $modal.modal('hide'); 57 | 58 | var currentUser = { 59 | name: name, 60 | id: guid(), 61 | stream: undefined 62 | }; 63 | 64 | navigator.getUserMedia(mediaOptions, function(stream) { 65 | currentUser.stream = stream; 66 | var video = $('#localVideo')[0]; 67 | video.src = window.URL.createObjectURL(stream); 68 | 69 | start(); 70 | }, function() {}); 71 | 72 | 73 | function start() { 74 | var pusher = new Pusher($('#chat').data().apiKey, { 75 | authEndpoint: '/pusher/auth', 76 | auth: { 77 | params: currentUser 78 | } 79 | }); 80 | 81 | var channel = pusher.subscribe('presence-chat'); 82 | var peers = {}; 83 | 84 | function lookForPeers() { 85 | for (var userId in channel.members.members) { 86 | if (userId != currentUser.id) { 87 | var member = channel.members.members[userId]; 88 | 89 | peers[userId] = initiateConnection(userId, member.name) 90 | } 91 | } 92 | } 93 | 94 | channel.bind('pusher:subscription_succeeded', lookForPeers); 95 | 96 | function gotRemoteVideo(userId, userName, stream) { 97 | var video = $("