Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit c8a7e0379cbc5f8020222129242637ce23ad5dee 0 parents
@twe4ked authored
Showing with 784 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +1 −0  .rvmrc
  3. +34 −0 Gemfile
  4. +96 −0 Gemfile.lock
  5. +29 −0 README.textile
  6. +7 −0 Rakefile
  7. +3 −0  app/controllers/application_controller.rb
  8. +10 −0 app/controllers/shots_controller.rb
  9. +2 −0  app/helpers/application_helper.rb
  10. +2 −0  app/helpers/shots_helper.rb
  11. +14 −0 app/views/layouts/application.html.haml
  12. +2 −0  app/views/shots/index.html.haml
  13. +4 −0 config.ru
  14. +42 −0 config/application.rb
  15. +6 −0 config/boot.rb
  16. +22 −0 config/database.yml
  17. +5 −0 config/environment.rb
  18. +26 −0 config/environments/development.rb
  19. +49 −0 config/environments/production.rb
  20. +35 −0 config/environments/test.rb
  21. +7 −0 config/initializers/backtrace_silencers.rb
  22. +10 −0 config/initializers/inflections.rb
  23. +5 −0 config/initializers/mime_types.rb
  24. +7 −0 config/initializers/secret_token.rb
  25. +8 −0 config/initializers/session_store.rb
  26. +5 −0 config/locales/en.yml
  27. +4 −0 config/routes.rb
  28. +7 −0 db/seeds.rb
  29. +2 −0  doc/README_FOR_APP
  30. 0  lib/tasks/.gitkeep
  31. +26 −0 public/404.html
  32. +26 −0 public/422.html
  33. +26 −0 public/500.html
  34. BIN  public/images/loading.gif
  35. +16 −0 public/javascripts/application.js
  36. +59 −0 public/javascripts/jquery.infinitescroll.js
  37. +5 −0 public/robots.txt
  38. 0  public/stylesheets/.gitkeep
  39. +35 −0 public/stylesheets/sass/style.scss
  40. +102 −0 public/stylesheets/style.css
  41. +6 −0 script/rails
  42. +9 −0 test/functional/shots_controller_test.rb
  43. +9 −0 test/performance/browsing_test.rb
  44. +13 −0 test/test_helper.rb
  45. +4 −0 test/unit/helpers/shots_helper_test.rb
  46. 0  vendor/plugins/.gitkeep
4 .gitignore
@@ -0,0 +1,4 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
1  .rvmrc
@@ -0,0 +1 @@
+rvm --create 1.9.2-p180@inspiredshots
34 Gemfile
@@ -0,0 +1,34 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.0.5'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3'
+gem 'haml'
+gem 'swish'
+gem 'httparty'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
+# gem 'ruby-debug'
+# gem 'ruby-debug19', :require => 'ruby-debug'
+
+# Bundle the extra gems:
+# gem 'bj'
+# gem 'nokogiri'
+# gem 'sqlite3-ruby', :require => 'sqlite3'
+# gem 'aws-s3', :require => 'aws/s3'
+
+# Bundle gems for the local environment. Make sure to
+# put test-only gems in this group so their generators
+# and rake tasks are available in development mode:
+group :development, :test do
+ gem 'ruby-debug19', :require => 'ruby-debug'
+end
96 Gemfile.lock
@@ -0,0 +1,96 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ actionmailer (3.0.5)
+ actionpack (= 3.0.5)
+ mail (~> 2.2.15)
+ actionpack (3.0.5)
+ activemodel (= 3.0.5)
+ activesupport (= 3.0.5)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.4)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.13)
+ rack-test (~> 0.5.7)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.5)
+ activesupport (= 3.0.5)
+ builder (~> 2.1.2)
+ i18n (~> 0.4)
+ activerecord (3.0.5)
+ activemodel (= 3.0.5)
+ activesupport (= 3.0.5)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.5)
+ activemodel (= 3.0.5)
+ activesupport (= 3.0.5)
+ activesupport (3.0.5)
+ archive-tar-minitar (0.5.2)
+ arel (2.0.9)
+ builder (2.1.2)
+ columnize (0.3.2)
+ crack (0.1.8)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ haml (3.0.25)
+ httparty (0.7.4)
+ crack (= 0.1.8)
+ i18n (0.5.0)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
+ mail (2.2.15)
+ activesupport (>= 2.3.6)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ polyglot (0.3.1)
+ rack (1.2.2)
+ rack-mount (0.6.13)
+ rack (>= 1.0.0)
+ rack-test (0.5.7)
+ rack (>= 1.0)
+ rails (3.0.5)
+ actionmailer (= 3.0.5)
+ actionpack (= 3.0.5)
+ activerecord (= 3.0.5)
+ activeresource (= 3.0.5)
+ activesupport (= 3.0.5)
+ bundler (~> 1.0)
+ railties (= 3.0.5)
+ railties (3.0.5)
+ actionpack (= 3.0.5)
+ activesupport (= 3.0.5)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
+ rake (0.8.7)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+ sqlite3 (1.3.3)
+ swish (0.8.0)
+ thor (0.14.6)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.25)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ haml
+ httparty
+ rails (= 3.0.5)
+ ruby-debug19
+ sqlite3
+ swish
29 README.textile
@@ -0,0 +1,29 @@
+h1. Infinitely scrolling Dribbble feed
+
+h2. Thanks
+
+"Swish":http://github.com/jeremyw/swish - Ruby Dribbble API wrapper by Jeremy Weiskotten
+"jQuery infinite scroll plugin":http://github.com/brianmario/jquery-infinite-scroll by Brian Lopez
+
+h2. Licence:
+
+Copyright (c) 2011 Odin Dutton
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7 Rakefile
@@ -0,0 +1,7 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+require 'rake'
+
+Inspiredshots::Application.load_tasks
3  app/controllers/application_controller.rb
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
10 app/controllers/shots_controller.rb
@@ -0,0 +1,10 @@
+class ShotsController < ApplicationController
+ def index
+ @page = params[:page]
+ @shots = Dribbble::Shot.popular(:page => @page, :per_page => 10)
+
+ if request.xhr?
+ render :layout => false
+ end
+ end
+end
2  app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
2  app/helpers/shots_helper.rb
@@ -0,0 +1,2 @@
+module ShotsHelper
+end
14 app/views/layouts/application.html.haml
@@ -0,0 +1,14 @@
+!!! 5
+%html
+%head
+ %title InspiredShots
+ = stylesheet_link_tag :all
+ = javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js', 'jquery.infinitescroll.js', 'application'
+%body
+ %h1 InspiredShots
+ %p Infinitely scrolling dribbble.
+ %ul= yield
+ %footer
+ Created by #{link_to 'Odin Dutton', 'http://odindutton.com/'}.
+/ Ruby Dribbble API wrapper by Jeremy Weiskotten (http://github.com/jeremyw/swish)
+/ jQuery infinite scroll plugin by Brian Lopez (http://github.com/brianmario/jquery-infinite-scroll)
2  app/views/shots/index.html.haml
@@ -0,0 +1,2 @@
+- @shots.each do |shot|
+ %li= link_to (image_tag shot.image_url), shot.url, :title => shot.player.name
4 config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Inspiredshots::Application
42 config/application.rb
@@ -0,0 +1,42 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+module Inspiredshots
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # JavaScript files you want as :defaults (application.js is always included).
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+ end
+end
6 config/boot.rb
@@ -0,0 +1,6 @@
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+
+require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
22 config/database.yml
@@ -0,0 +1,22 @@
+# SQLite version 3.x
+# gem install sqlite3
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
5 config/environment.rb
@@ -0,0 +1,5 @@
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+Inspiredshots::Application.initialize!
26 config/environments/development.rb
@@ -0,0 +1,26 @@
+Inspiredshots::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the webserver when you make code changes.
+ config.cache_classes = false
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_view.debug_rjs = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+end
+
49 config/environments/production.rb
@@ -0,0 +1,49 @@
+Inspiredshots::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # The production environment is meant for finished, "live" apps.
+ # Code is not reloaded between requests
+ config.cache_classes = true
+
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Specifies the header that your server uses for sending files
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
+
+ # For nginx:
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
+
+ # If you have no front-end server that supports something like X-Sendfile,
+ # just comment this out and Rails will serve the files
+
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Disable Rails's static asset server
+ # In production, Apache or nginx will already do this
+ config.serve_static_assets = false
+
+ # Enable serving of images, stylesheets, and javascripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable threaded mode
+ # config.threadsafe!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
35 config/environments/test.rb
@@ -0,0 +1,35 @@
+Inspiredshots::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
7 config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
10 config/initializers/inflections.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
5 config/initializers/mime_types.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
7 config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+Inspiredshots::Application.config.secret_token = '2fbd65b618ded42c420230f4e0e59935d30c976a1d7857ab85fe06480ef9a5095831e6c9f5f997f204e95aeee0e76bfadfa00c08dc81095e53f8c7cf8d7a5d1e'
8 config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+Inspiredshots::Application.config.session_store :cookie_store, :key => '_inspiredshots_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rails generate session_migration")
+# Inspiredshots::Application.config.session_store :active_record_store
5 config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
4 config/routes.rb
@@ -0,0 +1,4 @@
+Inspiredshots::Application.routes.draw do
+ get "shots/index"
+ root :to => "shots#index"
+end
7 db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
+# Mayor.create(:name => 'Daley', :city => cities.first)
2  doc/README_FOR_APP
@@ -0,0 +1,2 @@
+Use this README file to introduce your application and point to useful places in the API for learning more.
+Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
0  lib/tasks/.gitkeep
No changes.
26 public/404.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The page you were looking for doesn't exist (404)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/404.html -->
+ <div class="dialog">
+ <h1>The page you were looking for doesn't exist.</h1>
+ <p>You may have mistyped the address or the page may have moved.</p>
+ </div>
+</body>
+</html>
26 public/422.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The change you wanted was rejected (422)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/422.html -->
+ <div class="dialog">
+ <h1>The change you wanted was rejected.</h1>
+ <p>Maybe you tried to change something you didn't have access to.</p>
+ </div>
+</body>
+</html>
26 public/500.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>We're sorry, but something went wrong (500)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/500.html -->
+ <div class="dialog">
+ <h1>We're sorry, but something went wrong.</h1>
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
+ </div>
+</body>
+</html>
BIN  public/images/loading.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 public/javascripts/application.js
@@ -0,0 +1,16 @@
+jQuery(document).ready(function($) {
+ $(window).infinitescroll({
+ url: window.location.href,
+ appendTo: 'ul'
+ });
+
+ $('ul').bind('infinitescroll.beforesend', function(e) {
+ console.log('beforesend');
+ $(this).append('<li class="loading"></li>');
+ });
+
+ $('ul').bind('infinitescroll.finish', function(e) {
+ console.log('finish');
+ $('li.loading').hide();
+ });
+});
59 public/javascripts/jquery.infinitescroll.js
@@ -0,0 +1,59 @@
+// Infinite Scroll
+(function($) {
+ $.fn.infinitescroll = function(options) {
+ return $(this).each(function() {
+ var el = $(this);
+ var settings = $.extend({
+ url: null,
+ triggerAt: 300,
+ page: 2,
+ appendTo: '.list tbody',
+ container: $(document)
+ }, options);
+ var req = null;
+ var maxReached = false;
+
+ var infinityRunner = function() {
+ if (settings.url !== null) {
+ if (settings.force || (settings.triggerAt >= (settings.container.height() - el.height() - el.scrollTop()))) {
+ settings.force = false;
+ // if the request is in progress, exit and wait for it to finish
+ if (req && req.readyState < 4 && req.readyState > 0) {
+ return;
+ }
+ $(settings.appendTo).trigger('infinitescroll.beforesend');
+ req = $.get(settings.url, 'page='+settings.page, function(data) {
+ if (data !== '') {
+ if (settings.page > 1) {
+ $(settings.appendTo).append(data);
+ } else {
+ $(settings.appendTo).html(data);
+ }
+ settings.page++;
+ $(settings.appendTo).trigger('infinitescroll.finish');
+ } else {
+ maxReached = true;
+ $(settings.appendTo).trigger('infinitescroll.maxreached');
+ }
+ }, 'html');
+ }
+ }
+ };
+
+ el.bind('infinitescroll.scrollpage', function(e, page) {
+ settings.page = page;
+ settings.force = true;
+ infinityRunner();
+ });
+
+ el.scroll(function(e) {
+ if (!maxReached) {
+ infinityRunner();
+ }
+ });
+
+ // Test initial page layout for trigger
+ infinityRunner();
+ });
+ };
+})(jQuery);
5 public/robots.txt
@@ -0,0 +1,5 @@
+# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
+#
+# To ban all spiders from the entire site uncomment the next two lines:
+# User-Agent: *
+# Disallow: /
0  public/stylesheets/.gitkeep
No changes.
35 public/stylesheets/sass/style.scss
@@ -0,0 +1,35 @@
+// -- Reset --------------------------------------------------------------------
+body,div,dl,dt,dd,ul,ol,li,h1,h2,h4,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td{margin:0;padding:0}
+table{border-collapse:collapse;border-spacing:0}
+fieldset,img{border:0}
+address,caption,cite,code,dfn,em,strong,th,var,optgroup{font-style:inherit;font-weight:inherit}
+del,ins{text-decoration:none}
+li{list-style:none}
+caption,th{text-align:left}
+h1,h2,h3,h4,h4,h5,h6{font-size:100%;font-weight:400}
+q:before,q:after{content:''}
+abbr,acronym{border:0;font-variant:normal}
+legend{color:#000}
+input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit}
+input,button,textarea,select{font-size:100%}
+.clearfix:after{content:".";display:block;clear:both;visibility:hidden;line-height:0;height:0}
+.clearfix{display:inline-block}
+html[xmlns] .clearfix{display:block}
+* html .clearfix{height:1%}
+sup,sub{vertical-align:baseline}
+
+header, nav, section, article, footer{display:block;}
+
+// -- Global -------------------------------------------------------------------
+body{color:#666;background:#111;width:400px;margin:20px auto;font:12px/140% 'Helvetica Neue', Arial, Sans-Serif;}
+h1{font-size:20px;margin-bottom:10px;color:#ea4c89;}
+p{magin-bottom:20px;}
+ul{
+ li{margin:20px 0;background:#000;text-align:center;width:400px;height:300px;line-height:300px;
+ img{margin:0 auto;}
+ &.loading{background:url('../images/loading.gif') 50% 50% no-repeat;height:16px;}
+ }
+}
+footer{text-align:center;
+ a{color:#999;}
+}
102 public/stylesheets/style.css
@@ -0,0 +1,102 @@
+body, div, dl, dt, dd, ul, ol, li, h1, h2, h4, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td {
+ margin: 0;
+ padding: 0; }
+
+table {
+ border-collapse: collapse;
+ border-spacing: 0; }
+
+fieldset, img {
+ border: 0; }
+
+address, caption, cite, code, dfn, em, strong, th, var, optgroup {
+ font-style: inherit;
+ font-weight: inherit; }
+
+del, ins {
+ text-decoration: none; }
+
+li {
+ list-style: none; }
+
+caption, th {
+ text-align: left; }
+
+h1, h2, h3, h4, h4, h5, h6 {
+ font-size: 100%;
+ font-weight: 400; }
+
+q:before, q:after {
+ content: ''; }
+
+abbr, acronym {
+ border: 0;
+ font-variant: normal; }
+
+legend {
+ color: #000; }
+
+input, button, textarea, select, optgroup, option {
+ font-family: inherit;
+ font-size: inherit;
+ font-style: inherit;
+ font-weight: inherit; }
+
+input, button, textarea, select {
+ font-size: 100%; }
+
+.clearfix:after {
+ content: ".";
+ display: block;
+ clear: both;
+ visibility: hidden;
+ line-height: 0;
+ height: 0; }
+
+.clearfix {
+ display: inline-block; }
+
+html[xmlns] .clearfix {
+ display: block; }
+
+* html .clearfix {
+ height: 1%; }
+
+sup, sub {
+ vertical-align: baseline; }
+
+header, nav, section, article, footer {
+ display: block; }
+
+body {
+ color: #666;
+ background: #111;
+ width: 400px;
+ margin: 20px auto;
+ font: 12px/140% "Helvetica Neue", Arial, Sans-Serif; }
+
+h1 {
+ font-size: 20px;
+ margin-bottom: 10px;
+ color: #ea4c89; }
+
+p {
+ magin-bottom: 20px; }
+
+ul li {
+ margin: 20px 0;
+ background: #000;
+ text-align: center;
+ width: 400px;
+ height: 300px;
+ line-height: 300px; }
+ ul li img {
+ margin: 0 auto; }
+ ul li.loading {
+ background: url("../images/loading.gif") 50% 50% no-repeat;
+ height: 16px; }
+
+footer {
+ text-align: center; }
+ footer a {
+ color: #999; }
6 script/rails
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require 'rails/commands'
9 test/functional/shots_controller_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class ShotsControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ end
+
+end
9 test/performance/browsing_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+require 'rails/performance_test_help'
+
+# Profiling results for each test method are written to tmp/performance.
+class BrowsingTest < ActionDispatch::PerformanceTest
+ def test_homepage
+ get '/'
+ end
+end
13 test/test_helper.rb
@@ -0,0 +1,13 @@
+ENV["RAILS_ENV"] = "test"
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
+ #
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
+ # -- they do not yet inherit this setting
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end
4 test/unit/helpers/shots_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class ShotsHelperTest < ActionView::TestCase
+end
0  vendor/plugins/.gitkeep
No changes.

0 comments on commit c8a7e03

Please sign in to comment.
Something went wrong with that request. Please try again.