├── log └── .gitkeep ├── lib ├── tasks │ └── .gitkeep └── assets │ └── .gitkeep ├── public ├── favicon.ico ├── robots.txt ├── 500.html ├── 422.html ├── 404.html └── index.html ├── test ├── unit │ ├── .gitkeep │ ├── helpers │ │ └── panels_helper_test.rb │ ├── panel_test.rb │ ├── favicon_test.rb │ └── favicon_panel_test.rb ├── fixtures │ ├── .gitkeep │ ├── panels.yml │ ├── favicon_panels.yml │ └── favicons.yml ├── functional │ ├── .gitkeep │ └── panels_controller_test.rb ├── integration │ └── .gitkeep ├── performance │ └── browsing_test.rb └── test_helper.rb ├── app ├── mailers │ └── .gitkeep ├── models │ ├── .gitkeep │ ├── favicon_panel.rb │ ├── favicon.rb │ ├── panel.rb │ ├── favicon_downloader.rb │ └── favicon_finder.rb ├── views │ ├── panels │ │ └── show.css.erb │ ├── layouts │ │ └── application.html.erb │ └── favicons │ │ └── _favicon.css.erb ├── helpers │ ├── application_helper.rb │ ├── panels_helper.rb │ └── favicons_helper.rb ├── assets │ ├── images │ │ └── rails.png │ ├── stylesheets │ │ ├── panels.css.scss │ │ ├── application.css │ │ └── scaffolds.css.scss │ └── javascripts │ │ ├── panels.js.coffee │ │ └── application.js ├── workers │ ├── panel_completer.rb │ └── favicon_creator.rb └── controllers │ ├── application_controller.rb │ └── panels_controller.rb ├── vendor ├── plugins │ └── .gitkeep └── assets │ ├── javascripts │ └── .gitkeep │ └── stylesheets │ └── .gitkeep ├── Procfile ├── config ├── environment.rb ├── boot.rb ├── locales │ └── en.yml ├── routes.rb ├── initializers │ ├── mime_types.rb │ ├── cookie_filter.rb │ ├── backtrace_silencers.rb │ ├── database_connection.rb │ ├── session_store.rb │ ├── secret_token.rb │ ├── wrap_parameters.rb │ ├── inflections.rb │ └── sidekiq.rb ├── database.yml ├── unicorn.rb ├── environments │ ├── development.rb │ ├── test.rb │ └── production.rb ├── application.rb └── newrelic.yml ├── db ├── migrate │ ├── 20121109225645_add_complete_to_panels.rb │ ├── 20121116160636_add_favicon_count_to_panels.rb │ ├── 20121106145312_create_panels.rb │ ├── 20121120032355_remove_favicon_count_from_panels.rb │ ├── 20121106144403_create_favicons.rb │ ├── 20121106153545_fix_hash_name.rb │ └── 20121106151039_create_favicon_panels.rb ├── schema.rb └── seeds.rb ├── doc └── README_FOR_APP ├── Rakefile ├── config.ru ├── script └── rails ├── Gemfile ├── .gitignore ├── README.md └── Gemfile.lock /log/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/unit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/mailers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/plugins/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/functional/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/panels/show.css.erb: -------------------------------------------------------------------------------- 1 | <%= compress_css render(@favicons) %> -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb 2 | worker: DB_POOL=10 bundle exec sidekiq -c 10 -------------------------------------------------------------------------------- /app/assets/images/rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feedbin/polyptych/master/app/assets/images/rails.png -------------------------------------------------------------------------------- /test/unit/helpers/panels_helper_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PanelsHelperTest < ActionView::TestCase 4 | end 5 | -------------------------------------------------------------------------------- /test/unit/panel_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PanelTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/unit/favicon_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class FaviconTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/fixtures/panels.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html 2 | 3 | one: 4 | hash: MyString 5 | 6 | two: 7 | hash: MyString 8 | -------------------------------------------------------------------------------- /test/unit/favicon_panel_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class FaviconPanelTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /app/models/favicon_panel.rb: -------------------------------------------------------------------------------- 1 | class FaviconPanel < ActiveRecord::Base 2 | attr_accessible :favicon_id, :panel_id 3 | 4 | belongs_to :favicon 5 | belongs_to :panel, touch: true 6 | end 7 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | Polyptych::Application.initialize! 6 | -------------------------------------------------------------------------------- /app/workers/panel_completer.rb: -------------------------------------------------------------------------------- 1 | class PanelCompleter 2 | 3 | def self.perform(panel_id) 4 | panel = Panel.find(panel_id) 5 | panel.update_attribute(:complete, true) 6 | end 7 | 8 | end -------------------------------------------------------------------------------- /db/migrate/20121109225645_add_complete_to_panels.rb: -------------------------------------------------------------------------------- 1 | class AddCompleteToPanels < ActiveRecord::Migration 2 | def change 3 | add_column :panels, :complete, :boolean, default: false 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/helpers/panels_helper.rb: -------------------------------------------------------------------------------- 1 | module PanelsHelper 2 | def compress_css(css) 3 | compressed_css = Sass::Engine.new(css, syntax: :scss, style: :compressed); 4 | compressed_css.render 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/models/favicon.rb: -------------------------------------------------------------------------------- 1 | class Favicon < ActiveRecord::Base 2 | attr_accessible :content_type, :favicon, :hostname 3 | 4 | has_many :favicon_panels 5 | has_many :panels, through: :favicon_panels 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20121116160636_add_favicon_count_to_panels.rb: -------------------------------------------------------------------------------- 1 | class AddFaviconCountToPanels < ActiveRecord::Migration 2 | def change 3 | add_column :panels, :favicon_count, :integer, default: 0 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/assets/stylesheets/panels.css.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the Panels controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | # Set up gems listed in the Gemfile. 4 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 5 | 6 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) 7 | -------------------------------------------------------------------------------- /app/helpers/favicons_helper.rb: -------------------------------------------------------------------------------- 1 | module FaviconsHelper 2 | def favicon_content_type(content_type) 3 | if /image/ =~ content_type 4 | content_type 5 | else 6 | 'image/x-icon' 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /doc/README_FOR_APP: -------------------------------------------------------------------------------- 1 | Use this README file to introduce your application and point to useful places in the API for learning more. 2 | Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. 3 | -------------------------------------------------------------------------------- /test/fixtures/favicon_panels.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html 2 | 3 | one: 4 | favicon_id: 1 5 | panel_id: 1 6 | 7 | two: 8 | favicon_id: 1 9 | panel_id: 1 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | hello: "Hello world" 6 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | require 'sidekiq/web' 2 | 3 | Polyptych::Application.routes.draw do 4 | 5 | resources :panels, only: [:show, :create] do 6 | member do 7 | get :status 8 | end 9 | end 10 | 11 | mount Sidekiq::Web => '/sidekiq' 12 | end 13 | -------------------------------------------------------------------------------- /app/assets/javascripts/panels.js.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ 4 | -------------------------------------------------------------------------------- /db/migrate/20121106145312_create_panels.rb: -------------------------------------------------------------------------------- 1 | class CreatePanels < ActiveRecord::Migration 2 | def change 3 | create_table :panels do |t| 4 | t.string :hash 5 | t.timestamps 6 | end 7 | add_index :panels, :hash, unique: true 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Polyptych 5 | <%= stylesheet_link_tag "application", :media => "all" %> 6 | <%= csrf_meta_tags %> 7 | 8 | 9 | 10 | <%= yield %> 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /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 | # Mime::Type.register_alias "text/html", :iphone 6 | Mime::Type.register "text/css", :css -------------------------------------------------------------------------------- /app/models/panel.rb: -------------------------------------------------------------------------------- 1 | class Panel < ActiveRecord::Base 2 | 3 | validates_uniqueness_of :name 4 | 5 | attr_accessible :name 6 | 7 | has_many :favicon_panels 8 | has_many :favicons, through: :favicon_panels 9 | 10 | def to_param 11 | name 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /db/migrate/20121120032355_remove_favicon_count_from_panels.rb: -------------------------------------------------------------------------------- 1 | class RemoveFaviconCountFromPanels < ActiveRecord::Migration 2 | def up 3 | remove_column :panels, :favicon_count 4 | end 5 | 6 | def down 7 | add_column :panels, :favicon_count, :integer, default: 0 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /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 | Polyptych::Application.load_tasks 8 | -------------------------------------------------------------------------------- /test/fixtures/favicons.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html 2 | 3 | one: 4 | hostname: MyString 5 | content_type: MyString 6 | favicon: MyText 7 | 8 | two: 9 | hostname: MyString 10 | content_type: MyString 11 | favicon: MyText 12 | -------------------------------------------------------------------------------- /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 | run Polyptych::Application 5 | 6 | app = Rack::Builder.new { 7 | map "/" do 8 | run Polyptych::Application 9 | end 10 | }.to_app 11 | 12 | run app -------------------------------------------------------------------------------- /script/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 3 | 4 | APP_PATH = File.expand_path('../../config/application', __FILE__) 5 | require File.expand_path('../../config/boot', __FILE__) 6 | require 'rails/commands' 7 | -------------------------------------------------------------------------------- /db/migrate/20121106144403_create_favicons.rb: -------------------------------------------------------------------------------- 1 | class CreateFavicons < ActiveRecord::Migration 2 | def change 3 | create_table :favicons do |t| 4 | t.string :hostname 5 | t.string :content_type 6 | t.text :favicon 7 | t.timestamps 8 | end 9 | add_index :favicons, :hostname, unique: true 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | ruby '2.0.0' 3 | 4 | gem 'rails', '3.2.11' 5 | gem 'pg' 6 | gem 'sass-rails', '~> 3.2.3' 7 | gem 'mechanize' 8 | gem 'sprockets' 9 | gem 'slim' 10 | gem 'sinatra', require: nil 11 | gem 'sidekiq' 12 | gem 'foreman' 13 | gem 'rack-cors', require: 'rack/cors' 14 | gem 'autoscaler' 15 | gem 'unicorn' 16 | 17 | -------------------------------------------------------------------------------- /app/views/favicons/_favicon.css.erb: -------------------------------------------------------------------------------- 1 | .favicon-<%= favicon.hostname.parameterize %> { 2 | <% unless favicon.favicon.nil? %> 3 | background-image: url(data:<%= favicon_content_type(favicon.content_type) %>;base64,<%= favicon.favicon %>); 4 | background-repeat: no-repeat; 5 | background-position: left center; 6 | background-size: 16px 16px; 7 | <% end %> 8 | } 9 | -------------------------------------------------------------------------------- /config/initializers/cookie_filter.rb: -------------------------------------------------------------------------------- 1 | class CookieFilter 2 | def initialize(app) 3 | @app = app 4 | end 5 | 6 | def call(env) 7 | status, headers, body = @app.call(env) 8 | headers.delete 'Set-Cookie' 9 | [status, headers, body] 10 | end 11 | end 12 | 13 | Rails.application.config.middleware.insert_before ::ActionDispatch::Cookies, ::CookieFilter -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery 3 | 4 | def generate_name(hostnames) 5 | hostnames = hostnames.sort.join 6 | logger.info { hostnames } 7 | Digest::SHA1.hexdigest hostnames 8 | end 9 | 10 | def not_found 11 | render file: "public/404.html", status: 404 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /db/migrate/20121106153545_fix_hash_name.rb: -------------------------------------------------------------------------------- 1 | class FixHashName < ActiveRecord::Migration 2 | def self.up 3 | remove_index :panels, :hash 4 | rename_column :panels, :hash, :name 5 | add_index :panels, :name, unique: true 6 | end 7 | 8 | def self.down 9 | remove_index :panels, :name 10 | rename_column :panels, :name, :hash 11 | add_index :panels, :hash, unique: true 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /db/migrate/20121106151039_create_favicon_panels.rb: -------------------------------------------------------------------------------- 1 | class CreateFaviconPanels < ActiveRecord::Migration 2 | def change 3 | create_table :favicon_panels do |t| 4 | t.integer :favicon_id 5 | t.integer :panel_id 6 | 7 | t.timestamps 8 | end 9 | add_index :favicon_panels, :favicon_id 10 | add_index :favicon_panels, :panel_id 11 | add_index :favicon_panels, [:favicon_id, :panel_id], unique: true 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/performance/browsing_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'rails/performance_test_help' 3 | 4 | class BrowsingTest < ActionDispatch::PerformanceTest 5 | # Refer to the documentation for all available options 6 | # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] 7 | # :output => 'tmp/performance', :formats => [:flat] } 8 | 9 | def test_homepage 10 | get '/' 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /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/database_connection.rb: -------------------------------------------------------------------------------- 1 | Rails.application.config.after_initialize do 2 | ActiveRecord::Base.connection_pool.disconnect! 3 | 4 | ActiveSupport.on_load(:active_record) do 5 | config = Rails.application.config.database_configuration[Rails.env] 6 | config['reaping_frequency'] = ENV['DB_REAP_FREQ'] || 10 # seconds 7 | config['pool'] = ENV['DB_POOL'] || 5 8 | ActiveRecord::Base.establish_connection(config) 9 | end 10 | end -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Polyptych::Application.config.session_store :cookie_store, key: '_polyptych_session' 4 | 5 | # Use the database for sessions instead of the cookie-based default, 6 | # which shouldn't be used to store highly confidential information 7 | # (create the session table with "rails generate session_migration") 8 | # Polyptych::Application.config.session_store :active_record_store 9 | -------------------------------------------------------------------------------- /app/workers/favicon_creator.rb: -------------------------------------------------------------------------------- 1 | class FaviconCreator 2 | include Sidekiq::Worker 3 | 4 | def perform(favicon_id) 5 | favicon = Favicon.find(favicon_id) 6 | 7 | favicon_result = FaviconDownloader.new(favicon.hostname) 8 | favicon_result.download 9 | 10 | if favicon_result.data && favicon_result.data.length > 0 11 | favicon.update_attributes(favicon: favicon_result.data, content_type: favicon_result.content_type) 12 | end 13 | end 14 | 15 | end -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # Postgres 2 | production: 3 | adapter: postgresql 4 | encoding: unicode 5 | database: polyptych_development 6 | pool: 15 7 | username: ben 8 | password: 9 | 10 | development: 11 | adapter: postgresql 12 | encoding: unicode 13 | database: polyptych_development 14 | pool: 15 15 | username: ben 16 | password: 17 | 18 | test: 19 | adapter: postgresql 20 | encoding: unicode 21 | database: polyptych_test 22 | pool: 15 23 | username: ben 24 | password: 25 | -------------------------------------------------------------------------------- /.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 | 13 | # Ignore all logfiles and tempfiles. 14 | /log/*.log 15 | /tmp 16 | /vendor/bundle -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] = "test" 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. 7 | # 8 | # Note: You'll currently still have to declare fixtures explicitly in integration tests 9 | # -- they do not yet inherit this setting 10 | fixtures :all 11 | 12 | # Add more helper methods to be used by all tests here... 13 | end 14 | -------------------------------------------------------------------------------- /config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | # Make sure the secret is at least 30 characters and all random, 6 | # no regular words or you'll be exposed to dictionary attacks. 7 | Polyptych::Application.config.secret_token = '74703453db8a4385635fa3d73eb365cbc7808bed355bd04ce67145c764c37af55c983d1f1289b7b7d8b8beae733b78213c2955b4c492564f55c8356efd9141b7' 8 | -------------------------------------------------------------------------------- /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] 9 | end 10 | 11 | # Disable root element in JSON by default. 12 | ActiveSupport.on_load(:active_record) do 13 | self.include_root_in_json = false 14 | end 15 | -------------------------------------------------------------------------------- /app/models/favicon_downloader.rb: -------------------------------------------------------------------------------- 1 | require 'open-uri' 2 | 3 | class FaviconDownloader 4 | 5 | attr_accessor :url, :hostname, :data, :content_type 6 | 7 | def initialize(hostname) 8 | @hostname = hostname 9 | end 10 | 11 | def download 12 | self.url = FaviconFinder.new(hostname).url 13 | 14 | unless url.nil? 15 | open(url) do |response| 16 | self.content_type = response.content_type 17 | self.data = Base64.encode64(response.read).gsub("\n", '') 18 | end 19 | end 20 | 21 | end 22 | 23 | end 24 | -------------------------------------------------------------------------------- /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 4 | # (all these examples are active by default): 5 | # ActiveSupport::Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | # 12 | # These inflection rules are supported but not enabled by default: 13 | # ActiveSupport::Inflector.inflections do |inflect| 14 | # inflect.acronym 'RESTful' 15 | # end 16 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the top of the 9 | * compiled file, but it's generally better to create a new file per style scope. 10 | * 11 | *= require_self 12 | *= require_tree . 13 | */ 14 | -------------------------------------------------------------------------------- /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 | // the 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_tree . 16 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

We're sorry, but something went wrong.

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The change you wanted was rejected.

23 |

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

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The page you were looking for doesn't exist.

23 |

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

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /config/unicorn.rb: -------------------------------------------------------------------------------- 1 | worker_processes 3 2 | timeout 30 3 | preload_app true 4 | 5 | before_fork do |server, worker| 6 | # Replace with MongoDB or whatever 7 | if defined?(ActiveRecord::Base) 8 | ActiveRecord::Base.connection.disconnect! 9 | Rails.logger.info('Disconnected from ActiveRecord') 10 | end 11 | 12 | # If you are using Redis but not Resque, change this 13 | if defined?(Resque) 14 | Resque.redis.quit 15 | Rails.logger.info('Disconnected from Redis') 16 | end 17 | 18 | sleep 1 19 | end 20 | 21 | after_fork do |server, worker| 22 | # Replace with MongoDB or whatever 23 | if defined?(ActiveRecord::Base) 24 | ActiveRecord::Base.establish_connection 25 | Rails.logger.info('Connected to ActiveRecord') 26 | end 27 | 28 | # If you are using Redis but not Resque, change this 29 | if defined?(Resque) 30 | Resque.redis = ENV['REDIS_URI'] 31 | Rails.logger.info('Connected to Redis') 32 | end 33 | end -------------------------------------------------------------------------------- /config/initializers/sidekiq.rb: -------------------------------------------------------------------------------- 1 | require 'securerandom' # bug in Sidekiq as of 2.2.1 2 | require 'sidekiq' 3 | require 'sidekiq/web' 4 | require 'autoscaler/sidekiq' 5 | require 'autoscaler/heroku_scaler' 6 | 7 | Sidekiq::Web.use Rack::Auth::Basic do |username, password| 8 | web_password = ENV['SIDEKIQ_PASSWORD'] || 'secret' 9 | username == 'admin' && password == web_password 10 | end 11 | 12 | heroku = nil 13 | if ENV['HEROKU_APP'] 14 | heroku = Autoscaler::HerokuScaler.new 15 | end 16 | 17 | Sidekiq.configure_client do |config| 18 | if heroku 19 | config.client_middleware do |chain| 20 | chain.add Autoscaler::Sidekiq::Client, 'default' => heroku 21 | end 22 | end 23 | end 24 | 25 | Sidekiq.configure_server do |config| 26 | config.server_middleware do |chain| 27 | if heroku 28 | p "Setting up auto-scaledown" 29 | chain.add(Autoscaler::Sidekiq::Server, heroku, 60) 30 | else 31 | p "Not scaleable" 32 | end 33 | end 34 | end -------------------------------------------------------------------------------- /test/functional/panels_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PanelsControllerTest < ActionController::TestCase 4 | setup do 5 | @panel = panels(:one) 6 | end 7 | 8 | test "should get index" do 9 | get :index 10 | assert_response :success 11 | assert_not_nil assigns(:panels) 12 | end 13 | 14 | test "should get new" do 15 | get :new 16 | assert_response :success 17 | end 18 | 19 | test "should create panel" do 20 | assert_difference('Panel.count') do 21 | post :create, panel: { hash: @panel.hash } 22 | end 23 | 24 | assert_redirected_to panel_path(assigns(:panel)) 25 | end 26 | 27 | test "should show panel" do 28 | get :show, id: @panel 29 | assert_response :success 30 | end 31 | 32 | test "should get edit" do 33 | get :edit, id: @panel 34 | assert_response :success 35 | end 36 | 37 | test "should update panel" do 38 | put :update, id: @panel, panel: { hash: @panel.hash } 39 | assert_redirected_to panel_path(assigns(:panel)) 40 | end 41 | 42 | test "should destroy panel" do 43 | assert_difference('Panel.count', -1) do 44 | delete :destroy, id: @panel 45 | end 46 | 47 | assert_redirected_to panels_path 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /app/assets/stylesheets/scaffolds.css.scss: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #fff; 3 | color: #333; 4 | font-family: verdana, arial, helvetica, sans-serif; 5 | font-size: 13px; 6 | line-height: 18px; 7 | } 8 | 9 | p, ol, ul, td { 10 | font-family: verdana, arial, helvetica, sans-serif; 11 | font-size: 13px; 12 | line-height: 18px; 13 | } 14 | 15 | pre { 16 | background-color: #eee; 17 | padding: 10px; 18 | font-size: 11px; 19 | } 20 | 21 | a { 22 | color: #000; 23 | &:visited { 24 | color: #666; 25 | } 26 | &:hover { 27 | color: #fff; 28 | background-color: #000; 29 | } 30 | } 31 | 32 | div { 33 | &.field, &.actions { 34 | margin-bottom: 10px; 35 | } 36 | } 37 | 38 | #notice { 39 | color: green; 40 | } 41 | 42 | .field_with_errors { 43 | padding: 2px; 44 | background-color: red; 45 | display: table; 46 | } 47 | 48 | #error_explanation { 49 | width: 450px; 50 | border: 2px solid red; 51 | padding: 7px; 52 | padding-bottom: 0; 53 | margin-bottom: 20px; 54 | background-color: #f0f0f0; 55 | h2 { 56 | text-align: left; 57 | font-weight: bold; 58 | padding: 5px 5px 5px 15px; 59 | font-size: 12px; 60 | margin: -7px; 61 | margin-bottom: 0px; 62 | background-color: #c00; 63 | color: #fff; 64 | } 65 | ul li { 66 | font-size: 12px; 67 | list-style: square; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Polyptych::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 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 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 | # Only use best-standards-support built into browsers 23 | config.action_dispatch.best_standards_support = :builtin 24 | 25 | # Raise exception on mass assignment protection for Active Record models 26 | config.active_record.mass_assignment_sanitizer = :strict 27 | 28 | # Log the query plan for queries taking more than this (works 29 | # with SQLite, MySQL, and PostgreSQL) 30 | config.active_record.auto_explain_threshold_in_seconds = 0.5 31 | 32 | # Do not compress assets 33 | config.assets.compress = false 34 | 35 | # Expands the lines which load the assets 36 | config.assets.debug = true 37 | end 38 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Polyptych::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 | # Configure static asset server for tests with Cache-Control for performance 11 | config.serve_static_assets = true 12 | config.static_cache_control = "public, max-age=3600" 13 | 14 | # Log error messages when you accidentally call methods on nil 15 | config.whiny_nils = true 16 | 17 | # Show full error reports and disable caching 18 | config.consider_all_requests_local = true 19 | config.action_controller.perform_caching = false 20 | 21 | # Raise exceptions instead of rendering exception templates 22 | config.action_dispatch.show_exceptions = false 23 | 24 | # Disable request forgery protection in test environment 25 | config.action_controller.allow_forgery_protection = false 26 | 27 | # Tell Action Mailer not to deliver emails to the real world. 28 | # The :test delivery method accumulates sent emails in the 29 | # ActionMailer::Base.deliveries array. 30 | config.action_mailer.delivery_method = :test 31 | 32 | # Raise exception on mass assignment protection for Active Record models 33 | config.active_record.mass_assignment_sanitizer = :strict 34 | 35 | # Print deprecation notices to the stderr 36 | config.active_support.deprecation = :stderr 37 | end 38 | -------------------------------------------------------------------------------- /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 to check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(:version => 20121120032355) do 15 | 16 | create_table "favicon_panels", :force => true do |t| 17 | t.integer "favicon_id" 18 | t.integer "panel_id" 19 | t.datetime "created_at", :null => false 20 | t.datetime "updated_at", :null => false 21 | end 22 | 23 | add_index "favicon_panels", ["favicon_id", "panel_id"], :name => "index_favicon_panels_on_favicon_id_and_panel_id", :unique => true 24 | add_index "favicon_panels", ["favicon_id"], :name => "index_favicon_panels_on_favicon_id" 25 | add_index "favicon_panels", ["panel_id"], :name => "index_favicon_panels_on_panel_id" 26 | 27 | create_table "favicons", :force => true do |t| 28 | t.string "hostname" 29 | t.string "content_type" 30 | t.text "favicon" 31 | t.datetime "created_at", :null => false 32 | t.datetime "updated_at", :null => false 33 | end 34 | 35 | add_index "favicons", ["hostname"], :name => "index_favicons_on_hostname", :unique => true 36 | 37 | create_table "panels", :force => true do |t| 38 | t.string "name" 39 | t.datetime "created_at", :null => false 40 | t.datetime "updated_at", :null => false 41 | t.boolean "complete", :default => false 42 | end 43 | 44 | add_index "panels", ["name"], :name => "index_panels_on_name", :unique => true 45 | 46 | end 47 | -------------------------------------------------------------------------------- /app/controllers/panels_controller.rb: -------------------------------------------------------------------------------- 1 | class PanelsController < ApplicationController 2 | 3 | skip_before_filter :verify_authenticity_token 4 | 5 | # GET /panels/1.css 6 | def show 7 | panel = Panel.find_by_name(params[:id]) 8 | if panel 9 | @favicons = panel.favicons 10 | 11 | if panel.complete 12 | expires_in 1.year, public: true 13 | else 14 | expires_now 15 | end 16 | 17 | respond_to do |format| 18 | format.css 19 | end 20 | else 21 | not_found 22 | end 23 | end 24 | 25 | # POST /panels.json 26 | def create 27 | name = generate_name(params[:hostnames]) 28 | @panel = Panel.where(name: name).first 29 | 30 | if @panel.nil? 31 | @panel = Panel.create(name: name) 32 | favicon_ids = [] 33 | 34 | params[:hostnames].each do |hostname| 35 | favicon = Favicon.where(hostname: hostname).first_or_create 36 | favicon.favicon_panels.create(panel_id: @panel.id) 37 | unless favicon.favicon 38 | favicon_ids << favicon.id 39 | end 40 | end 41 | 42 | if favicon_ids.any? 43 | favicon_count = favicon_ids.length 44 | favicon_ids.each { |favicon_id| FaviconCreator.perform_async(favicon_id) } 45 | end 46 | 47 | PanelCompleter.delay_for(1.minute).perform(@panel.id) 48 | 49 | end 50 | 51 | respond_to do |format| 52 | if @panel 53 | format.json { render json: {name: @panel.name}, status: :ok } 54 | else 55 | format.json { render json: @panel.errors, status: :unprocessable_entity } 56 | end 57 | end 58 | 59 | end 60 | 61 | def status 62 | @panel = Panel.find_by_name(params[:id]) 63 | respond_to do |format| 64 | if @panel 65 | format.json { render json: {complete: @panel.complete, exists: true}, status: :ok } 66 | elsif @panel.nil? 67 | format.json { render json: {complete: false, exists: false}, status: :ok } 68 | else 69 | format.json { render json: @panel.errors, status: :unprocessable_entity } 70 | end 71 | end 72 | end 73 | 74 | end 75 | -------------------------------------------------------------------------------- /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 | 9 | favicon = Favicon.create content_type: 'image/x-icon', hostname: 'benubois.com', favicon: 'AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAAA=' 10 | panel = Panel.create name: Digest::SHA1.hexdigest(favicon.hostname) 11 | panel.favicon_panels.create(favicon_id: favicon.id) 12 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Polyptych::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 | # Full error reports are disabled and caching is turned on 8 | config.consider_all_requests_local = false 9 | config.action_controller.perform_caching = true 10 | 11 | # Disable Rails's static asset server (Apache or nginx will already do this) 12 | config.serve_static_assets = false 13 | 14 | # Compress JavaScripts and CSS 15 | config.assets.compress = true 16 | 17 | # Don't fallback to assets pipeline if a precompiled asset is missed 18 | config.assets.compile = false 19 | 20 | # Generate digests for assets URLs 21 | config.assets.digest = true 22 | 23 | # Defaults to nil and saved in location specified by config.assets.prefix 24 | # config.assets.manifest = YOUR_PATH 25 | 26 | # Specifies the header that your server uses for sending files 27 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 28 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 29 | 30 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 31 | # config.force_ssl = true 32 | 33 | # See everything in the log (default is :info) 34 | # config.log_level = :debug 35 | 36 | # Prepend all log lines with the following tags 37 | # config.log_tags = [ :subdomain, :uuid ] 38 | 39 | # Use a different logger for distributed setups 40 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 41 | 42 | # Use a different cache store in production 43 | # config.cache_store = :mem_cache_store 44 | 45 | # Enable serving of images, stylesheets, and JavaScripts from an asset server 46 | # config.action_controller.asset_host = "http://assets.example.com" 47 | 48 | # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) 49 | # config.assets.precompile += %w( search.js ) 50 | 51 | # Disable delivery errors, bad email addresses will be ignored 52 | # config.action_mailer.raise_delivery_errors = false 53 | 54 | # Enable threaded mode 55 | # config.threadsafe! 56 | 57 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 58 | # the I18n.default_locale when a translation can not be found) 59 | config.i18n.fallbacks = true 60 | 61 | # Send deprecation notices to registered listeners 62 | config.active_support.deprecation = :notify 63 | 64 | # Log the query plan for queries taking more than this (works 65 | # with SQLite, MySQL, and PostgreSQL) 66 | # config.active_record.auto_explain_threshold_in_seconds = 0.5 67 | end 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | polyptych 2 | ========= 3 | 4 | A favicon stylesheet api. 5 | 6 | Getting a Stylesheet 7 | -------------------- 8 | Generate the sha1 of a concatenated sorted list of hostnames 9 | 10 | ```ruby 11 | require 'digest/sha1' 12 | 13 | hostnames = %w{daringfireball.net benubois.com} 14 | # > ['daringfireball.net', 'benubois.com'] 15 | 16 | hostnames = hostnames.sort 17 | # > ['benubois.com', 'daringfireball.net'] 18 | 19 | hostnames = hostnames.join 20 | # > "benubois.comdaringfireball.net" 21 | 22 | hash = Digest::SHA1.hexdigest(hostnames) 23 | # > "9cf135321116c70e88b361409ea02cf75c46face" 24 | ``` 25 | 26 | Now that you have a hash you can get the stylesheet like 27 | 28 | ```ruby 29 | require 'httparty' 30 | HTTParty.get("http://polyptych.dev/panels/#{hash}.css") 31 | ``` 32 | 33 | or using curl 34 | 35 | ```shell 36 | $ curl -v http://polyptych.dev/panels/9cf135321116c70e88b361409ea02cf75c46face.css 37 | ``` 38 | 39 | If no stylesheet is found a 404 will be returned. In which case you'll want to create a stylesheet 40 | 41 | Creating a Stylesheet 42 | --------------------- 43 | 44 | ```ruby 45 | require 'httparty' 46 | require 'json' 47 | 48 | result = HTTParty.post( 49 | 'http://polyptych.dev/panels.json', 50 | body: { 51 | hostnames: ['benubois.com', 'daringfireball.net'] 52 | }.to_json, 53 | headers: { 54 | 'Accept': 'application/json', 55 | 'Content-Type': 'application/json' 56 | } 57 | ) 58 | ``` 59 | 60 | Or using curl 61 | 62 | ```shell 63 | $ curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"hostnames": ["benubois.com", "daringfireball.net"]}' http://polyptych.dev/panels.json 64 | ``` 65 | 66 | The response should return 201 Created or 302 Found if it already exists. 67 | 68 | The response should look like 69 | 70 | ```shell 71 | * About to connect() to polyptych.dev port 80 (#0) 72 | * Trying 127.0.0.1... 73 | * connected 74 | * Connected to polyptych.dev (127.0.0.1) port 80 (#0) 75 | > POST /panels.json HTTP/1.1 76 | > User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5 77 | > Host: polyptych.dev 78 | > Accept: application/json 79 | > Content-type: application/json 80 | > Content-Length: 54 81 | > 82 | * upload completely sent off: 54 out of 54 bytes 83 | < HTTP/1.1 302 Moved Temporarily 84 | < Date: Fri, 09 Nov 2012 21:10:26 GMT 85 | < Location: http://polyptych.dev/panels/9cf135321116c70e88b361409ea02cf75c46face.css 86 | < Content-Type: application/json; charset=utf-8 87 | < Cache-Control: max-age=2592000, public 88 | < X-UA-Compatible: IE=Edge 89 | < X-Request-Id: 518334c0827e8240b73e8f8405a4c731 90 | < X-Runtime: 0.679689 91 | < Transfer-Encoding: chunked 92 | < 93 | * Connection #0 to host polyptych.dev left intact 94 | {"name":"9cf135321116c70e88b361409ea02cf75c46face"}* Closing connection #0 95 | ``` -------------------------------------------------------------------------------- /app/models/favicon_finder.rb: -------------------------------------------------------------------------------- 1 | class FaviconFinder 2 | # Try to parse the given document URL. 3 | # Return nil in case parsing fails (malformatted input URL). 4 | def initialize(source_url) 5 | begin 6 | @source_url = URI.parse(source_url) 7 | if @source_url.scheme == nil 8 | @source_url = URI.parse("http://" + source_url) 9 | end 10 | rescue 11 | return nil 12 | end 13 | 14 | @agent = Mechanize.new 15 | 16 | # TODO: fix mechanize meta refresh sleep bug! 17 | @agent.follow_meta_refresh = true 18 | @agent.keep_alive = false 19 | @agent.open_timeout = 15 20 | @agent.read_timeout = 15 21 | @agent.redirection_limit=10 22 | 23 | @agent.user_agent = "Friendly favicon fetcher (favicon.heroku.com)" 24 | end 25 | 26 | # Get the URL of the favicon.ico file. 27 | # First try to get it from the document source, if that fails try the default location. 28 | def url 29 | # Can we get the source of the document? 30 | begin 31 | # ugly workaround for broken mechanize follow_meta_refresh 32 | Timeout.timeout(15) { @page = @agent.get(@source_url.to_s) } 33 | rescue Timeout::Error => e 34 | return nil 35 | rescue => e 36 | return nil 37 | end 38 | 39 | 40 | 41 | # Get the first favicon link (in case there are many). 42 | # There can be many rel types for favicons: http://en.wikipedia.org/wiki/Favicon 43 | # Xpath doesn't have case insensitive match, so we use translate for that. 44 | favicon_href = @page.search("//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'icon']/@href |" + 45 | "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'shortcut icon']/@href")[0].to_s 46 | 47 | # Try default location: http://domain.tld/favicon.ico 48 | # Before returning URL, check if the icon really exists. 49 | if favicon_href.empty? 50 | default_favicon_url = @page.uri.scheme + '://' + @page.uri.host + '/favicon.ico' 51 | if favicon_exists?(default_favicon_url) 52 | return default_favicon_url 53 | else 54 | return nil 55 | end 56 | end 57 | 58 | if URI.parse(favicon_href).relative? 59 | favicon_url = @page.uri.scheme + '://' + @page.uri.host + favicon_href 60 | else 61 | favicon_url = favicon_href 62 | end 63 | 64 | if favicon_exists?(favicon_url) 65 | return favicon_url 66 | else 67 | return nil 68 | end 69 | end 70 | 71 | private 72 | 73 | # Check if a favicon.ico file exists by downloading it and checking the file type 74 | def favicon_exists?(favicon_url) 75 | begin 76 | favicon = @agent.get(favicon_url) 77 | rescue 78 | return false 79 | end 80 | 81 | # check if it's a icon/gif/png file by looking at magic bytes 82 | if favicon.body =~ /^\x00\x00\x01\x00/ or 83 | favicon.body =~ /^\x47\x49\x46\x38/ 84 | return true 85 | else 86 | return false 87 | end 88 | end 89 | end -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | if defined?(Bundler) 6 | # If you precompile assets before deploying to production, use this line 7 | Bundler.require(*Rails.groups(:assets => %w(development test))) 8 | # If you want your assets lazily compiled in production, use this line 9 | # Bundler.require(:default, :assets, Rails.env) 10 | end 11 | 12 | module Polyptych 13 | class Application < Rails::Application 14 | # Settings in config/environments/* take precedence over those specified here. 15 | # Application configuration should go into files in config/initializers 16 | # -- all .rb files in that directory are automatically loaded. 17 | 18 | # Custom directories with classes and modules you want to be autoloadable. 19 | # config.autoload_paths += %W(#{config.root}/extras) 20 | 21 | # Only load the plugins named here, in the order given (default is alphabetical). 22 | # :all can be used as a placeholder for all plugins not explicitly named. 23 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 24 | 25 | # Activate observers that should always be running. 26 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer 27 | 28 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 29 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 30 | # config.time_zone = 'Central Time (US & Canada)' 31 | 32 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 33 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 34 | # config.i18n.default_locale = :de 35 | 36 | # Configure the default encoding used in templates for Ruby 1.9. 37 | config.encoding = "utf-8" 38 | 39 | # Configure sensitive parameters which will be filtered from the log file. 40 | config.filter_parameters += [:password] 41 | 42 | # Enable escaping HTML in JSON. 43 | config.active_support.escape_html_entities_in_json = true 44 | 45 | # Use SQL instead of Active Record's schema dumper when creating the database. 46 | # This is necessary if your schema can't be completely dumped by the schema dumper, 47 | # like if you have constraints or database-specific column types 48 | # config.active_record.schema_format = :sql 49 | 50 | # Enforce whitelist mode for mass assignment. 51 | # This will create an empty whitelist of attributes available for mass-assignment for all models 52 | # in your app. As such, your models will need to explicitly whitelist or blacklist accessible 53 | # parameters by using an attr_accessible or attr_protected declaration. 54 | config.active_record.whitelist_attributes = true 55 | 56 | # Enable the asset pipeline 57 | config.assets.enabled = true 58 | 59 | # Version of your assets, change this if you want to expire all your assets 60 | config.assets.version = '1.0' 61 | 62 | config.middleware.use Rack::Deflater 63 | 64 | config.middleware.use Rack::Cors do 65 | allow do 66 | origins '*' 67 | resource '*', headers: :any, methods: [:get, :post, :options] 68 | end 69 | end 70 | 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (3.2.11) 5 | actionpack (= 3.2.11) 6 | mail (~> 2.4.4) 7 | actionpack (3.2.11) 8 | activemodel (= 3.2.11) 9 | activesupport (= 3.2.11) 10 | builder (~> 3.0.0) 11 | erubis (~> 2.7.0) 12 | journey (~> 1.0.4) 13 | rack (~> 1.4.0) 14 | rack-cache (~> 1.2) 15 | rack-test (~> 0.6.1) 16 | sprockets (~> 2.2.1) 17 | activemodel (3.2.11) 18 | activesupport (= 3.2.11) 19 | builder (~> 3.0.0) 20 | activerecord (3.2.11) 21 | activemodel (= 3.2.11) 22 | activesupport (= 3.2.11) 23 | arel (~> 3.0.2) 24 | tzinfo (~> 0.3.29) 25 | activeresource (3.2.11) 26 | activemodel (= 3.2.11) 27 | activesupport (= 3.2.11) 28 | activesupport (3.2.11) 29 | i18n (~> 0.6) 30 | multi_json (~> 1.0) 31 | arel (3.0.2) 32 | autoscaler (0.2.0) 33 | heroku-api 34 | sidekiq (>= 2.6.1, < 3.0) 35 | builder (3.0.4) 36 | celluloid (0.12.4) 37 | facter (>= 1.6.12) 38 | timers (>= 1.0.0) 39 | connection_pool (1.0.0) 40 | domain_name (0.5.7) 41 | unf (~> 0.0.3) 42 | erubis (2.7.0) 43 | excon (0.16.10) 44 | facter (1.6.17) 45 | foreman (0.61.0) 46 | thor (>= 0.13.6) 47 | heroku-api (0.3.7) 48 | excon (~> 0.16.10) 49 | hike (1.2.1) 50 | i18n (0.6.1) 51 | journey (1.0.4) 52 | json (1.7.6) 53 | kgio (2.8.0) 54 | mail (2.4.4) 55 | i18n (>= 0.4.0) 56 | mime-types (~> 1.16) 57 | treetop (~> 1.4.8) 58 | mechanize (2.5.1) 59 | domain_name (~> 0.5, >= 0.5.1) 60 | mime-types (~> 1.17, >= 1.17.2) 61 | net-http-digest_auth (~> 1.1, >= 1.1.1) 62 | net-http-persistent (~> 2.5, >= 2.5.2) 63 | nokogiri (~> 1.4) 64 | ntlm-http (~> 0.1, >= 0.1.1) 65 | webrobots (~> 0.0, >= 0.0.9) 66 | mime-types (1.21) 67 | multi_json (1.5.0) 68 | net-http-digest_auth (1.2.1) 69 | net-http-persistent (2.8) 70 | nokogiri (1.5.6) 71 | ntlm-http (0.1.1) 72 | pg (0.14.1) 73 | polyglot (0.3.3) 74 | rack (1.4.5) 75 | rack-cache (1.2) 76 | rack (>= 0.4) 77 | rack-cors (0.2.7) 78 | rack 79 | rack-protection (1.3.2) 80 | rack 81 | rack-ssl (1.3.3) 82 | rack 83 | rack-test (0.6.2) 84 | rack (>= 1.0) 85 | rails (3.2.11) 86 | actionmailer (= 3.2.11) 87 | actionpack (= 3.2.11) 88 | activerecord (= 3.2.11) 89 | activeresource (= 3.2.11) 90 | activesupport (= 3.2.11) 91 | bundler (~> 1.0) 92 | railties (= 3.2.11) 93 | railties (3.2.11) 94 | actionpack (= 3.2.11) 95 | activesupport (= 3.2.11) 96 | rack-ssl (~> 1.3.2) 97 | rake (>= 0.8.7) 98 | rdoc (~> 3.4) 99 | thor (>= 0.14.6, < 2.0) 100 | raindrops (0.10.0) 101 | rake (10.0.3) 102 | rdoc (3.12.1) 103 | json (~> 1.4) 104 | redis (3.0.2) 105 | redis-namespace (1.2.1) 106 | redis (~> 3.0.0) 107 | sass (3.2.5) 108 | sass-rails (3.2.6) 109 | railties (~> 3.2.0) 110 | sass (>= 3.1.10) 111 | tilt (~> 1.3) 112 | sidekiq (2.7.2) 113 | celluloid (~> 0.12.0) 114 | connection_pool (~> 1.0) 115 | multi_json (~> 1) 116 | redis (~> 3) 117 | redis-namespace 118 | sinatra (1.3.4) 119 | rack (~> 1.4) 120 | rack-protection (~> 1.3) 121 | tilt (~> 1.3, >= 1.3.3) 122 | slim (1.3.6) 123 | temple (~> 0.5.5) 124 | tilt (~> 1.3.3) 125 | sprockets (2.2.2) 126 | hike (~> 1.2) 127 | multi_json (~> 1.0) 128 | rack (~> 1.0) 129 | tilt (~> 1.1, != 1.3.0) 130 | temple (0.5.5) 131 | thor (0.17.0) 132 | tilt (1.3.3) 133 | timers (1.1.0) 134 | treetop (1.4.12) 135 | polyglot 136 | polyglot (>= 0.3.1) 137 | tzinfo (0.3.35) 138 | unf (0.0.5) 139 | unf_ext 140 | unf_ext (0.0.5) 141 | unicorn (4.6.0) 142 | kgio (~> 2.6) 143 | rack 144 | raindrops (~> 0.7) 145 | webrobots (0.0.13) 146 | 147 | PLATFORMS 148 | ruby 149 | 150 | DEPENDENCIES 151 | autoscaler 152 | foreman 153 | mechanize 154 | pg 155 | rack-cors 156 | rails (= 3.2.11) 157 | sass-rails (~> 3.2.3) 158 | sidekiq 159 | sinatra 160 | slim 161 | sprockets 162 | unicorn 163 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ruby on Rails: Welcome aboard 5 | 174 | 187 | 188 | 189 |
190 | 203 | 204 |
205 | 209 | 210 | 214 | 215 |
216 |

Getting started

217 |

Here’s how to get rolling:

218 | 219 |
    220 |
  1. 221 |

    Use rails generate to create your models and controllers

    222 |

    To see all available options, run it without parameters.

    223 |
  2. 224 | 225 |
  3. 226 |

    Set up a default route and remove public/index.html

    227 |

    Routes are set up in config/routes.rb.

    228 |
  4. 229 | 230 |
  5. 231 |

    Create your database

    232 |

    Run rake db:create to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.

    233 |
  6. 234 |
235 |
236 |
237 | 238 | 239 |
240 | 241 | 242 | -------------------------------------------------------------------------------- /config/newrelic.yml: -------------------------------------------------------------------------------- 1 | # Here are the settings that are common to all environments 2 | common: &default_settings 3 | # ============================== LICENSE KEY =============================== 4 | 5 | # You must specify the license key associated with your New Relic 6 | # account. This key binds your Agent's data to your account in the 7 | # New Relic service. 8 | license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>' 9 | 10 | # Agent Enabled (Rails Only) 11 | # Use this setting to force the agent to run or not run. 12 | # Default is 'auto' which means the agent will install and run only 13 | # if a valid dispatcher such as Mongrel is running. This prevents 14 | # it from running with Rake or the console. Set to false to 15 | # completely turn the agent off regardless of the other settings. 16 | # Valid values are true, false and auto. 17 | # 18 | # agent_enabled: auto 19 | 20 | # Application Name Set this to be the name of your application as 21 | # you'd like it show up in New Relic. The service will then auto-map 22 | # instances of your application into an "application" on your 23 | # dashboard page. If you want to map this instance into multiple 24 | # apps, like "AJAX Requests" and "All UI" then specify a semicolon 25 | # separated list of up to three distinct names, or a yaml list. 26 | # Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e., 27 | # Production, Staging, etc) 28 | # 29 | # Example: 30 | # 31 | # app_name: 32 | # - Ajax Service 33 | # - All Services 34 | # 35 | app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> 36 | 37 | # When "true", the agent collects performance data about your 38 | # application and reports this data to the New Relic service at 39 | # newrelic.com. This global switch is normally overridden for each 40 | # environment below. (formerly called 'enabled') 41 | monitor_mode: true 42 | 43 | # Developer mode should be off in every environment but 44 | # development as it has very high overhead in memory. 45 | developer_mode: false 46 | 47 | # The newrelic agent generates its own log file to keep its logging 48 | # information separate from that of your application. Specify its 49 | # log level here. 50 | log_level: info 51 | 52 | # Optionally set the path to the log file This is expanded from the 53 | # root directory (may be relative or absolute, e.g. 'log/' or 54 | # '/var/log/') The agent will attempt to create this directory if it 55 | # does not exist. 56 | # log_file_path: 'log' 57 | 58 | # Optionally set the name of the log file, defaults to 'newrelic_agent.log' 59 | # log_file_name: 'newrelic_agent.log' 60 | 61 | # The newrelic agent communicates with the service via http by 62 | # default. If you want to communicate via https to increase 63 | # security, then turn on SSL by setting this value to true. Note, 64 | # this will result in increased CPU overhead to perform the 65 | # encryption involved in SSL communication, but this work is done 66 | # asynchronously to the threads that process your application code, 67 | # so it should not impact response times. 68 | ssl: false 69 | 70 | # EXPERIMENTAL: enable verification of the SSL certificate sent by 71 | # the server. This setting has no effect unless SSL is enabled 72 | # above. This may block your application. Only enable it if the data 73 | # you send us needs end-to-end verified certificates. 74 | # 75 | # This means we cannot cache the DNS lookup, so each request to the 76 | # service will perform a lookup. It also means that we cannot 77 | # use a non-blocking lookup, so in a worst case, if you have DNS 78 | # problems, your app may block indefinitely. 79 | # verify_certificate: true 80 | 81 | # Set your application's Apdex threshold value with the 'apdex_t' 82 | # setting, in seconds. The apdex_t value determines the buckets used 83 | # to compute your overall Apdex score. 84 | # Requests that take less than apdex_t seconds to process will be 85 | # classified as Satisfying transactions; more than apdex_t seconds 86 | # as Tolerating transactions; and more than four times the apdex_t 87 | # value as Frustrating transactions. 88 | # For more about the Apdex standard, see 89 | # http://newrelic.com/docs/general/apdex 90 | 91 | apdex_t: 0.5 92 | 93 | #============================== Browser Monitoring =============================== 94 | # New Relic Real User Monitoring gives you insight into the performance real users are 95 | # experiencing with your website. This is accomplished by measuring the time it takes for 96 | # your users' browsers to download and render your web pages by injecting a small amount 97 | # of JavaScript code into the header and footer of each page. 98 | browser_monitoring: 99 | # By default the agent automatically injects the monitoring JavaScript 100 | # into web pages. Set this attribute to false to turn off this behavior. 101 | auto_instrument: true 102 | 103 | # Proxy settings for connecting to the service. 104 | # 105 | # If a proxy is used, the host setting is required. Other settings 106 | # are optional. Default port is 8080. 107 | # 108 | # proxy_host: hostname 109 | # proxy_port: 8080 110 | # proxy_user: 111 | # proxy_pass: 112 | 113 | 114 | # Tells transaction tracer and error collector (when enabled) 115 | # whether or not to capture HTTP params. When true, frameworks can 116 | # exclude HTTP parameters from being captured. 117 | # Rails: the RoR filter_parameter_logging excludes parameters 118 | # Java: create a config setting called "ignored_params" and set it to 119 | # a comma separated list of HTTP parameter names. 120 | # ex: ignored_params: credit_card, ssn, password 121 | capture_params: false 122 | 123 | 124 | # Transaction tracer captures deep information about slow 125 | # transactions and sends this to the service once a 126 | # minute. Included in the transaction is the exact call sequence of 127 | # the transactions including any SQL statements issued. 128 | transaction_tracer: 129 | 130 | # Transaction tracer is enabled by default. Set this to false to 131 | # turn it off. This feature is only available at the Professional 132 | # and above product levels. 133 | enabled: true 134 | 135 | # Threshold in seconds for when to collect a transaction 136 | # trace. When the response time of a controller action exceeds 137 | # this threshold, a transaction trace will be recorded and sent to 138 | # the service. Valid values are any float value, or (default) 139 | # "apdex_f", which will use the threshold for an dissatisfying 140 | # Apdex controller action - four times the Apdex T value. 141 | transaction_threshold: apdex_f 142 | 143 | # When transaction tracer is on, SQL statements can optionally be 144 | # recorded. The recorder has three modes, "off" which sends no 145 | # SQL, "raw" which sends the SQL statement in its original form, 146 | # and "obfuscated", which strips out numeric and string literals 147 | record_sql: obfuscated 148 | 149 | # Threshold in seconds for when to collect stack trace for a SQL 150 | # call. In other words, when SQL statements exceed this threshold, 151 | # then capture and send the current stack trace. This is 152 | # helpful for pinpointing where long SQL calls originate from 153 | stack_trace_threshold: 0.500 154 | 155 | # Determines whether the agent will capture query plans for slow 156 | # SQL queries. Only supported in mysql and postgres. Should be 157 | # set to false when using other adapters. 158 | # explain_enabled: true 159 | 160 | # Threshold for query execution time below which query plans will not 161 | # not be captured. Relevant only when `explain_enabled` is true. 162 | # explain_threshold: 0.5 163 | 164 | # Error collector captures information about uncaught exceptions and 165 | # sends them to the service for viewing 166 | error_collector: 167 | 168 | # Error collector is enabled by default. Set this to false to turn 169 | # it off. This feature is only available at the Professional and above 170 | # product levels 171 | enabled: true 172 | 173 | # Rails Only - tells error collector whether or not to capture a 174 | # source snippet around the place of the error when errors are View 175 | # related. 176 | capture_source: true 177 | 178 | # To stop specific errors from reporting to New Relic, set this property 179 | # to comma separated values. Default is to ignore routing errors 180 | # which are how 404's get triggered. 181 | # 182 | ignore_errors: ActionController::RoutingError 183 | 184 | # (Advanced) Uncomment this to ensure the cpu and memory samplers 185 | # won't run. Useful when you are using the agent to monitor an 186 | # external resource 187 | # disable_samplers: true 188 | 189 | # If you aren't interested in visibility in these areas, you can 190 | # disable the instrumentation to reduce overhead. 191 | # 192 | # disable_view_instrumentation: true 193 | # disable_activerecord_instrumentation: true 194 | # disable_memcache_instrumentation: true 195 | # disable_dj: true 196 | 197 | # If you're interested in capturing memcache keys as though they 198 | # were SQL uncomment this flag. Note that this does increase 199 | # overhead slightly on every memcached call, and can have security 200 | # implications if your memcached keys are sensitive 201 | # capture_memcache_keys: true 202 | 203 | # Certain types of instrumentation such as GC stats will not work if 204 | # you are running multi-threaded. Please let us know. 205 | # multi_threaded = false 206 | 207 | # Application Environments 208 | # ------------------------------------------ 209 | # Environment specific settings are in this section. 210 | # For Rails applications, RAILS_ENV is used to determine the environment 211 | # For Java applications, pass -Dnewrelic.environment to set 212 | # the environment 213 | 214 | # NOTE if your application has other named environments, you should 215 | # provide newrelic configuration settings for these environments here. 216 | 217 | development: 218 | <<: *default_settings 219 | # Turn off communication to New Relic service in development mode (also 220 | # 'enabled'). 221 | # NOTE: for initial evaluation purposes, you may want to temporarily 222 | # turn the agent on in development mode. 223 | monitor_mode: false 224 | 225 | # Rails Only - when running in Developer Mode, the New Relic Agent will 226 | # present performance information on the last 100 transactions you have 227 | # executed since starting the mongrel. 228 | # NOTE: There is substantial overhead when running in developer mode. 229 | # Do not use for production or load testing. 230 | developer_mode: true 231 | 232 | # Enable textmate links 233 | # textmate: true 234 | 235 | test: 236 | <<: *default_settings 237 | # It almost never makes sense to turn on the agent when running 238 | # unit, functional or integration tests or the like. 239 | monitor_mode: false 240 | 241 | # Turn on the agent in production for 24x7 monitoring. NewRelic 242 | # testing shows an average performance impact of < 5 ms per 243 | # transaction, you you can leave this on all the time without 244 | # incurring any user-visible performance degradation. 245 | production: 246 | <<: *default_settings 247 | monitor_mode: true 248 | 249 | # Many applications have a staging environment which behaves 250 | # identically to production. Support for that environment is provided 251 | # here. By default, the staging environment has the agent turned on. 252 | staging: 253 | <<: *default_settings 254 | monitor_mode: true 255 | app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> (Staging) --------------------------------------------------------------------------------