-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Amanda Ren
committed
Mar 1, 2012
1 parent
a1b7b64
commit 7c0d5be
Showing
48 changed files
with
2,466 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// This is a manifest file that'll be compiled into including all the files listed below. | ||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically | ||
// be included in the compiled file accessible from http://example.com/assets/application.js | ||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | ||
// the compiled file. | ||
// | ||
//= require jquery | ||
//= require jquery_ujs | ||
//= require_tree . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
html, body { | ||
margin: 0; | ||
padding: 0; | ||
background: White; | ||
color: DarkSlateGrey; | ||
font-family: Tahoma, Verdana, sans-serif; | ||
font-size: 10pt; | ||
} | ||
div#main { | ||
margin: 0; | ||
padding: 0 20px 20px; | ||
} | ||
a { | ||
background: transparent; | ||
color: maroon; | ||
text-decoration: underline; | ||
font-weight: bold; | ||
} | ||
h1 { | ||
color: maroon; | ||
font-size: 150%; | ||
font-style: italic; | ||
display: block; | ||
width: 100%; | ||
border-bottom: 1px solid DarkSlateGrey; | ||
} | ||
h1.title { | ||
margin: 0 0 1em; | ||
padding: 10px; | ||
background-color: orange; | ||
color: white; | ||
border-bottom: 4px solid gold; | ||
font-size: 2em; | ||
font-style: normal; | ||
} | ||
table#movies { | ||
margin: 10px; | ||
border-collapse: collapse; | ||
width: 100%; | ||
border-bottom: 2px solid black; | ||
} | ||
table#movies th { | ||
border: 2px solid white; | ||
font-weight: bold; | ||
background-color: wheat; | ||
} | ||
table#movies th, table#movies td { | ||
padding: 4px; | ||
text-align: left; | ||
} | ||
table#movies th.hilite { | ||
background-color: yellow; | ||
} | ||
#notice #warning { | ||
background: rosybrown; | ||
margin: 1em 0; | ||
padding: 4px; | ||
} | ||
form label { | ||
display: block; | ||
line-height: 25px; | ||
font-weight: bold; | ||
color: maroon; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
class MoviesController < ApplicationController | ||
|
||
def show | ||
@id = params[:id] # retrieve movie ID from URI route | ||
@movie = Movie.find(@id) # look up movie by unique ID | ||
@director = @movie.director | ||
# will render app/views/movies/show.<extension> by default | ||
end | ||
|
||
def index | ||
sort = params[:sort] || session[:sort] | ||
case sort | ||
when 'title' | ||
ordering,@title_header = {:order => :title}, 'hilite' | ||
when 'release_date' | ||
ordering,@date_header = {:order => :release_date}, 'hilite' | ||
end | ||
@all_ratings = Movie.all_ratings | ||
@selected_ratings = params[:ratings] || session[:ratings] || {} | ||
|
||
if params[:sort] != session[:sort] | ||
session[:sort] = sort | ||
redirect_to :sort => sort, :ratings => @selected_ratings and return | ||
end | ||
|
||
if params[:ratings] != session[:ratings] and @selected_ratings != {} | ||
session[:sort] = sort | ||
session[:ratings] = @selected_ratings | ||
redirect_to :sort => sort, :ratings => @selected_ratings and return | ||
end | ||
@movies = Movie.find_all_by_rating(@selected_ratings.keys, ordering) | ||
end | ||
|
||
def new | ||
# default: render 'new' template | ||
end | ||
|
||
def create | ||
@movie = Movie.create!(params[:movie]) | ||
flash[:notice] = "#{@movie.title} was successfully created." | ||
redirect_to movies_path | ||
end | ||
|
||
def edit | ||
@movie = Movie.find params[:id] | ||
end | ||
|
||
def update | ||
@movie = Movie.find params[:id] | ||
@movie.update_attributes!(params[:movie]) | ||
flash[:notice] = "#{@movie.title} was successfully updated." | ||
redirect_to movie_path(@movie) | ||
end | ||
|
||
def destroy | ||
@movie = Movie.find(params[:id]) | ||
@movie.destroy | ||
flash[:notice] = "Movie '#{@movie.title}' deleted." | ||
redirect_to movies_path | ||
end | ||
|
||
def similar | ||
@id = params[:movie_id] | ||
@movie = Movie.find(@id) | ||
@director = @movie.director | ||
if not @director.blank? | ||
@movies = Movie.similar_directors(@director) | ||
else | ||
flash[:notice] = "'#{@movie.title}' has no director info" | ||
redirect_to movies_path | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ApplicationHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module MoviesHelper | ||
# Checks if a number is odd: | ||
def oddness(count) | ||
count.odd? ? "odd" : "even" | ||
end | ||
end |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Movie < ActiveRecord::Base | ||
def self.all_ratings | ||
%w(G PG PG-13 NC-17 R) | ||
end | ||
|
||
def self.similar_directors(director) | ||
Movie.where(:director => director) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
!!! 5 | ||
%html | ||
%head | ||
%title Rotten Potatoes! | ||
= stylesheet_link_tag 'application' | ||
= javascript_include_tag 'application' | ||
= csrf_meta_tags | ||
|
||
%body | ||
%h1.title Rotten Potatoes! | ||
#main | ||
- if flash[:notice] | ||
#notice.message= flash[:notice] | ||
- elsif flash[:warning] | ||
#warning.message= flash[:warning] | ||
|
||
= yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-# edit.html.haml using partial | ||
%h1 Edit Existing Movie | ||
|
||
= form_tag movie_path(@movie), :method => :put do | ||
|
||
= label :movie, :title, 'Title' | ||
= text_field :movie, 'title' | ||
|
||
= label :movie, :rating, 'Rating' | ||
= select :movie, :rating, ['G','PG','PG-13','R','NC-17'] | ||
|
||
= label :movie, :release_date, 'Released On' | ||
= date_select :movie, :release_date | ||
|
||
= label :movie, :director, 'Director' | ||
= text_field :movie, 'director' | ||
|
||
= submit_tag 'Update Movie Info' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-# This file is app/views/movies/index.html.haml | ||
%h1 All Movies | ||
|
||
= form_tag movies_path, :method => :get, :id => 'ratings_form' do | ||
= hidden_field_tag "title_sort", true if @title_header | ||
= hidden_field_tag ":release_date_sort", true if @date_header | ||
Include: | ||
- @all_ratings.each do |rating| | ||
= rating | ||
= check_box_tag "ratings[#{rating}]", 1, @selected_ratings.include?(rating) | ||
= submit_tag 'Refresh', :id => 'ratings_submit' | ||
|
||
%table#movies | ||
%thead | ||
%tr | ||
%th{:class => @title_header}= link_to 'Movie Title', movies_path(:sort => 'title', :ratings => @selected_ratings), :id => 'title_header' | ||
%th Rating | ||
%th{:class => @date_header}= link_to 'Release Date', movies_path(:sort => 'release_date', :ratings => @selected_ratings), :id => 'release_date_header' | ||
%th Director | ||
%th More Info | ||
%tbody | ||
- @movies.each do |movie| | ||
%tr | ||
%td= movie.title | ||
%td= movie.rating | ||
%td= movie.release_date | ||
%td= movie.director | ||
%td= link_to "More about #{movie.title}", movie_path(movie) | ||
|
||
= link_to 'Add new movie', new_movie_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
%h1 Create New Movie | ||
|
||
= form_tag movies_path do | ||
|
||
= label :movie, :title, 'Title' | ||
= text_field :movie, 'title' | ||
|
||
= label :movie, :rating, 'Rating' | ||
= select :movie, :rating, ['G','PG','PG-13','R','NC-17'] | ||
|
||
= label :movie, :release_date, 'Released On' | ||
= date_select :movie, :release_date | ||
|
||
= submit_tag 'Save Changes' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-# in app/views/movies/show.html.haml | ||
%h2 Details about #{@movie.title} | ||
|
||
%ul#details | ||
%li | ||
Rating: | ||
= @movie.rating | ||
%li | ||
Released on: | ||
= @movie.release_date.strftime("%B %d, %Y") | ||
%li | ||
Director: | ||
= @movie.director | ||
|
||
%h3 Description: | ||
|
||
%p#description= @movie.description | ||
|
||
= link_to 'Edit', edit_movie_path(@movie) | ||
= button_to 'Delete', movie_path(@movie), :method => :delete, :confirm => 'Are you sure?' | ||
= link_to 'Find Movies With Same Director', movie_similar_path(@id) | ||
= link_to 'Back to movie list', movies_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-# in app/views/movies/similar.html.haml | ||
%h2 Movies with Same Director as #{@movie.title} | ||
|
||
%table#movies | ||
%thead | ||
%tr | ||
%th Movie Title | ||
%th Rating | ||
%th Release Date | ||
%th Director | ||
%th More Info | ||
%tbody | ||
- @movies.each do |movie| | ||
%tr | ||
%td= movie.title | ||
%td= movie.rating | ||
%td= movie.release_date | ||
%td= movie.director | ||
%td= link_to "More about #{movie.title}", movie_path(movie) | ||
|
||
= link_to 'Back', movie_path(@movie) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require File.expand_path('../boot', __FILE__) | ||
|
||
# Pick the frameworks you want: | ||
require "active_record/railtie" | ||
require "action_controller/railtie" | ||
require "action_mailer/railtie" | ||
require "active_resource/railtie" | ||
require "sprockets/railtie" | ||
# require "rails/test_unit/railtie" | ||
|
||
if defined?(Bundler) | ||
# If you precompile assets before deploying to production, use this line | ||
Bundler.require *Rails.groups(:assets => %w(development test)) | ||
# If you want your assets lazily compiled in production, use this line | ||
# Bundler.require(:default, :assets, Rails.env) | ||
end | ||
|
||
module Rottenpotatoes | ||
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 | ||
|
||
# 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] | ||
|
||
# Enable the asset pipeline | ||
config.assets.enabled = true | ||
|
||
# Version of your assets, change this if you want to expire all your assets | ||
config.assets.version = '1.0' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% | ||
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" | ||
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" | ||
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" | ||
%> | ||
default: <%= std_opts %> features | ||
wip: --tags @wip:3 --wip features | ||
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip |
Oops, something went wrong.