Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mod0 #107

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Mod0 #107

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ group :development do
gem 'thin'
gem "better_errors"
gem "binding_of_caller"
gem 'rspec-rails'
end

group :production do
Expand Down
14 changes: 14 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ GEM
coffee-script-source (1.6.3)
daemons (1.1.9)
debug_inspector (0.0.2)
diff-lcs (1.2.5)
erubis (2.7.0)
eventmachine (1.0.0)
execjs (2.0.2)
Expand Down Expand Up @@ -98,6 +99,18 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.1.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
sass (3.2.12)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
Expand Down Expand Up @@ -145,6 +158,7 @@ DEPENDENCIES
pry-nav
rails
rails_12factor
rspec-rails
sass-rails
sqlite3
thin
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CategoriesController < ApplicationController

def index
@categories = Category.all
end

def show
@category = Category.find(params[:id])

end
end
12 changes: 12 additions & 0 deletions app/controllers/videos_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class VideosController < ApplicationController

def index
@videos = Video.all
@categories = Category.all

end

def show
@video = Video.find(params[:id])
end
end
4 changes: 4 additions & 0 deletions app/models/category.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Category < ActiveRecord::Base
has_many :videos

end
5 changes: 5 additions & 0 deletions app/models/video.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Video < ActiveRecord::Base
belongs_to :category
#test

end
14 changes: 14 additions & 0 deletions app/views/categories/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
%section.genre
%header.clearfix
%h1= @category.name
.genre_sorting
Sort by:
%select(name="")
%option(value="a-z") Title: A - Z
%option(value="z-a") Title: Z - A
%option(value="rating") Rating
%article.row
- @category.videos.each do |video|
.video.col-md-2
= link_to video_path(video) do
%img(src="#{video.small_cover_url}")
9 changes: 9 additions & 0 deletions app/views/videos/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- @categories.each do |category|
%article.video_category
%header
%h3= link_to "TV #{category.name}", category_path(category)
.videos.row
- category.videos.each do |video|
.video.col-sm-2
= link_to video_path(video) do
%img(src="#{video.small_cover_url}")
13 changes: 13 additions & 0 deletions app/views/videos/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
%article.video
.container
.row
.video_large_cover.col-sm-7.col-sm-offset-1
%img(src="#{@video.large_cover_url}")
.video_info.col-sm-3
%header
%h3= @video.title
%span Rating: 4.5/5.0
%p= @video.description
.actions
%a.btn.btn-primary(href="") Watch Now
%a.btn.btn-default(href="") + My Queue
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Myflix::Application.routes.draw do
get 'ui(/:action)', controller: 'ui'

get '/home', to: 'videos#index'

resources :videos, only: [:index, :show]
resources :categories, only: [:show]
end
11 changes: 11 additions & 0 deletions db/migrate/20140519141833_create_videos.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateVideos < ActiveRecord::Migration
def change
create_table :videos do |t|
t.string :title
t.text :description
t.string :small_cover_url
t.string :large_cover_url
t.timestamps
end
end
end
8 changes: 8 additions & 0 deletions db/migrate/20140519181338_create_categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CreateCategories < ActiveRecord::Migration
def change
create_table :categories do |t|
t.string :name
t.timestamps
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20140519190153_add_categoryid_to_videos.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCategoryidToVideos < ActiveRecord::Migration
def change
add_column :videos, :category_id, :integer
end
end
32 changes: 32 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20140519190153) do

create_table "categories", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "videos", force: true do |t|
t.string "title"
t.text "description"
t.string "small_cover_url"
t.string "large_cover_url"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "category_id"
end

end
9 changes: 9 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)

Video.create(title: "Futurama", description: "Pizza boy Philip J. Fry awakens in the 31st century after 1,000 years of cryogenic preservation in this animated series.", small_cover_url: "/tmp/futurama.jpg", large_cover_url: "/tmp/futurama.jpg")
Video.create(title: "Family Guy", description: "Story about a family", small_cover_url: "/tmp/family_guy.jpg", large_cover_url: "/tmp/family_guy")
Video.create(title: "South Park", description: "Kids in a park", small_cover_url: "/tmp/south_park.jpg", large_cover_url: "/tmp/south_park.jpg")
Video.create(title: "Monk", description: "Story about a monk detetctive", small_cover_url: "/tmp/monk.jpg", large_cover_url: "/tmp/monk_large")

Category.create(name: "Comedy")
Category.create(name: "Drama")
Category.create(name: "Reality")
42 changes: 42 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)

RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr

# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true

# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
end