├── log └── .keep ├── app ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── concerns │ │ └── .keep │ └── talk.rb ├── assets │ ├── images │ │ └── .keep │ ├── stylesheets │ │ ├── base.css.scss │ │ └── application.css │ └── javascripts │ │ ├── application.js │ │ ├── base.js │ │ └── highcharts.js ├── controllers │ ├── concerns │ │ └── .keep │ ├── application_controller.rb │ └── talks_controller.rb ├── helpers │ └── application_helper.rb └── views │ ├── layouts │ └── application.html.erb │ └── talks │ └── index.html.erb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── test ├── helpers │ └── .keep ├── mailers │ └── .keep ├── models │ └── .keep ├── controllers │ └── .keep ├── fixtures │ └── .keep ├── integration │ └── .keep └── test_helper.rb ├── vendor └── assets │ ├── javascripts │ └── .keep │ └── stylesheets │ └── .keep ├── config ├── initializers │ ├── timeout.rb │ ├── session_store.rb │ ├── string_extensions.rb │ ├── filter_parameter_logging.rb │ ├── mime_types.rb │ ├── redis.rb │ ├── backtrace_silencers.rb │ ├── wrap_parameters.rb │ ├── inflections.rb │ └── secret_token.rb ├── routes.rb ├── boot.rb ├── environment.rb ├── database.yml ├── locales │ └── en.yml ├── unicorn.rb ├── application.rb └── environments │ ├── development.rb │ ├── test.rb │ └── production.rb ├── Procfile ├── bin ├── rake ├── bundle ├── rails └── delayed_job ├── config.ru ├── Rakefile ├── README.rdoc ├── db ├── seeds.rb ├── migrate │ ├── 20140321160015_create_talks.rb │ └── 20140321185913_create_delayed_jobs.rb └── schema.rb ├── .gitignore ├── Gemfile └── 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 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/initializers/timeout.rb: -------------------------------------------------------------------------------- 1 | Rack::Timeout.timeout = 6 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb 2 | worker: bundle exec rake jobs:work -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Abstractogram::Application.routes.draw do 2 | root 'talks#index' 3 | get 'talks/query' => 'talks#query', as: :query 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery with: :exception 3 | end 4 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /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 Rails.application 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Abstractogram::Application.initialize! 6 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Abstractogram::Application.config.session_store :cookie_store, key: '_abstractogram_session' 4 | -------------------------------------------------------------------------------- /bin/delayed_job: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) 4 | require 'delayed/command' 5 | Delayed::Command.new(ARGV).daemonize 6 | -------------------------------------------------------------------------------- /app/assets/stylesheets/base.css.scss: -------------------------------------------------------------------------------- 1 | @import "bootstrap"; 2 | 3 | .page-header { 4 | a:hover { text-decoration: none; } 5 | } 6 | 7 | #graph-container { 8 | height: 400px; 9 | margin-top: 25px; 10 | } -------------------------------------------------------------------------------- /config/initializers/string_extensions.rb: -------------------------------------------------------------------------------- 1 | class String 2 | def normalize_for_ngrams 3 | downcase.squish.remove_punctuation 4 | end 5 | 6 | def remove_punctuation 7 | gsub(/[^[[:word:]]\s]/, '') 8 | end 9 | end -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Abstractogram::Application.load_tasks 7 | -------------------------------------------------------------------------------- /config/initializers/redis.rb: -------------------------------------------------------------------------------- 1 | Redis.class_eval do 2 | def self.connect_to_redis! 3 | uri = URI.parse(ENV["REDIS_URL"] || "redis://localhost:6379") 4 | $redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) 5 | end 6 | end 7 | 8 | Redis.connect_to_redis! 9 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: postgresql 3 | database: abstractogram-development 4 | pool: 5 5 | timeout: 5000 6 | 7 | test: 8 | adapter: sqlite3 9 | database: db/test.sqlite3 10 | pool: 5 11 | timeout: 5000 12 | 13 | production: 14 | adapter: sqlite3 15 | database: db/production.sqlite3 16 | pool: 5 17 | timeout: 5000 18 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | == README 2 | 3 | See live version at http://abstractogram.herokuapp.com 4 | 5 | Built as a demo app for RailsConf 2014, abstractogram scrapes talk data (title, abstract, speaker, bio) of RailsConf talks from 2007-2014, then allows you to search words and phrases to see how many times they appeared in talk abstracts by year 6 | 7 | Questions? todd@rapgenius.com 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/controllers/talks_controller.rb: -------------------------------------------------------------------------------- 1 | class TalksController < ApplicationController 2 | def query 3 | terms = get_terms_from_params 4 | render :json => {:title => terms.join(", "), :series => Talk.ngram_query(terms)} 5 | end 6 | 7 | private 8 | 9 | def get_terms_from_params 10 | params[:q].to_s.split(",").map{ |t| t.squish.remove_punctuation }.select(&:present?).uniq 11 | end 12 | end -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | def mobile_device? 3 | request.user_agent =~ /Mobile|webOS/ 4 | end 5 | 6 | def submit_text 7 | mobile_device? ? "Search" : "Search RailsConf Abstracts!" 8 | end 9 | 10 | def name_of_site 11 | "Abstractogram" 12 | end 13 | 14 | def github_url 15 | "https://github.com/RapGenius/abstractogram" 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /db/migrate/20140321160015_create_talks.rb: -------------------------------------------------------------------------------- 1 | class CreateTalks < ActiveRecord::Migration 2 | def change 3 | # improvements we could make: 4 | # speakers as an hstore 5 | # separate model for conferences and add a conference_id 6 | create_table :talks do |t| 7 | t.integer :year 8 | t.string :title 9 | t.string :speaker 10 | t.text :abstract 11 | t.text :bio 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |See the code <%= link_to "on GitHub", github_url, :target => :_blank %>
7 |If you are the application owner check the logs for more information.
56 | 57 | 58 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Maybe you tried to change something you didn't have access to.
55 |If you are the application owner check the logs for more information.
57 | 58 | 59 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |You may have mistyped the address or the page may have moved.
55 |If you are the application owner check the logs for more information.
57 | 58 | 59 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Abstractogram::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 | end 37 | -------------------------------------------------------------------------------- /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: 20140321185913) do 15 | 16 | # These are extensions that must be enabled in order to support this database 17 | enable_extension "plpgsql" 18 | 19 | create_table "delayed_jobs", force: true do |t| 20 | t.integer "priority", default: 0, null: false 21 | t.integer "attempts", default: 0, null: false 22 | t.text "handler", null: false 23 | t.text "last_error" 24 | t.datetime "run_at" 25 | t.datetime "locked_at" 26 | t.datetime "failed_at" 27 | t.string "locked_by" 28 | t.string "queue" 29 | t.datetime "created_at" 30 | t.datetime "updated_at" 31 | end 32 | 33 | add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree 34 | 35 | create_table "talks", force: true do |t| 36 | t.integer "year" 37 | t.string "title" 38 | t.string "speaker" 39 | t.text "abstract" 40 | t.text "bio" 41 | end 42 | 43 | end 44 | -------------------------------------------------------------------------------- /app/assets/javascripts/base.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $("#query-form").on({ 3 | 'ajax:error': function() { 4 | alert("WHOOPS! Something went wrong, try again") 5 | }, 6 | 'ajax:success': function(xhr, data, status) { 7 | var $this = $(this) 8 | var query = $this.find("#q").val() 9 | 10 | if (history && history.pushState) { 11 | window.history.pushState(null, null, "/?q=" + encodeURIComponent(query)) 12 | } 13 | 14 | $("#graph-container").highcharts({ 15 | series: data.series, 16 | title: { text: data.title }, 17 | yAxis: { 18 | min: 0, 19 | title: { text: "Word Count" }, 20 | allowDecimals: false 21 | }, 22 | xAxis: { 23 | allowDecimals: false 24 | }, 25 | legend: { borderWidth: 0 }, 26 | plotOptions: { 27 | series: { 28 | animation: false, 29 | marker: { enabled: false } 30 | } 31 | }, 32 | tooltip: { 33 | shared: true, 34 | formatter: function() { 35 | var s = '' + this.x + '' 36 | 37 | var sortedPoints = this.points.sort(function(a, b) { 38 | return ((a.y < b.y) ? 1 : ((a.y > b.y) ? -1 : 0)); 39 | }); 40 | 41 | $.each(sortedPoints, function(i, point) { 42 | s += '