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

Feature/spec #147

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
/notes.txt
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ gem 'haml-rails'
gem 'sass-rails'
gem 'uglifier'
gem 'jquery-rails'
gem 'mysql2', '~> 0.3.16'

group :development do
gem 'sqlite3'
gem 'pry'
gem 'pry-nav'
gem 'thin'
gem "better_errors"
gem "binding_of_caller"
end

Expand All @@ -24,10 +24,12 @@ end

group :test do
gem 'database_cleaner', '1.2.0'
gem 'shoulda-matchers', '~> 2.6.2'
end


group :production do
gem 'pg'
gem 'pg', '~> 0.17.1'
gem 'rails_12factor'
end

13 changes: 7 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ GEM
thread_safe (~> 0.1)
tzinfo (~> 1.1)
arel (5.0.1.20140414130214)
better_errors (1.0.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap-sass (3.1.1.1)
Expand Down Expand Up @@ -71,7 +68,8 @@ GEM
mime-types (1.25.1)
minitest (5.3.4)
multi_json (1.10.1)
pg (0.17.0)
mysql2 (0.3.16)
pg (0.17.1)
polyglot (0.3.5)
pry (0.9.12.3)
coderay (~> 1.0)
Expand Down Expand Up @@ -124,6 +122,8 @@ GEM
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0)
shoulda-matchers (2.6.2)
activesupport (>= 3.0.0)
slop (3.4.7)
sprockets (2.11.0)
hike (~> 1.2)
Expand Down Expand Up @@ -155,20 +155,21 @@ PLATFORMS
ruby

DEPENDENCIES
better_errors
binding_of_caller
bootstrap-sass
coffee-rails
database_cleaner (= 1.2.0)
haml-rails
jquery-rails
pg
mysql2 (~> 0.3.16)
pg (~> 0.17.1)
pry
pry-nav
rails (= 4.1.1)
rails_12factor
rspec-rails (= 2.99)
sass-rails
shoulda-matchers (~> 2.6.2)
sqlite3
thin
uglifier
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
*= require whitespace-reset
*= require_tree .
*/

4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
class ApplicationController < ActionController::Base
protect_from_forgery




end
5 changes: 5 additions & 0 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class CategoriesController < ApplicationController
def show
@category = Category.find(params[:id])
end
end
11 changes: 11 additions & 0 deletions app/controllers/videos_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class VideosController < ApplicationController

def index
@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 , -> {order("created_at DESC")}
validates_presence_of :name
end
8 changes: 8 additions & 0 deletions app/models/video.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Video < ActiveRecord::Base
belongs_to :category

validates :title, presence: true
validates :description, presence: true


end
8 changes: 8 additions & 0 deletions app/views/categories/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%article.video_category
%header
%h3= @category.name
.videos.row
[email protected] do |video|
.video.col-sm-2
=link_to video do
%img(src="#{video.small_cover_url}")
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
= stylesheet_link_tag "application"
= javascript_include_tag "application"
%body

%header
= render 'shared/header'
%section.content.clearfix
= render 'shared/messages'
= yield
%footer
&copy 2013 MyFLiX

10 changes: 10 additions & 0 deletions app/views/videos/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- @categories.each do |category|
%article.video_category
%header
%h3= link_to category.name, category
.videos.row
- category.videos.each do |video|
.video.col-sm-2
= link_to video do
%img(src="#{video.small_cover_url}")

17 changes: 17 additions & 0 deletions app/views/videos/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
%article.video
.container
.row
.video_large_cover.col-sm-7.col-sm-offset-1
-if @video.large_cover_url.blank?
%img(src="http://dummyimage.com/665x375/000000/00a2ff")
-else
%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

2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require(:default, Rails.env)

module Myflix
Expand Down
50 changes: 37 additions & 13 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
default: &default
adapter: mysql2
encoding: utf8
pool: 5
timeout: 5000
username: root
password: theone881
socket: /tmp/mysql.sock

development:
<<: *default
database: movie_development

# 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
<<: *default
database: movie_test

# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: movie_production
username: biller
password: <%= ENV['BILLER_DATABASE_PASSWORD'] %>
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Myflix::Application.routes.draw do
get 'ui(/:action)', controller: 'ui'
resources :videos, only: [:index, :show]
resources :categories, only:[:show]
get 'home', to: 'videos#index'
end
11 changes: 11 additions & 0 deletions db/migrate/20140817051347_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
end
end
end
7 changes: 7 additions & 0 deletions db/migrate/20140818062252_add_category_to_video.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddCategoryToVideo < ActiveRecord::Migration
def change
change_table :videos do |t|
t.integer :category_id
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/20140818062506_create_categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateCategories < ActiveRecord::Migration
def change
create_table :categories do |t|

t.string :name
t.timestamps
end
end
end
7 changes: 7 additions & 0 deletions db/migrate/20140818102620_add_timestamps_to_video.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddTimestampsToVideo < ActiveRecord::Migration
def change
change_table :videos do |t|
t.timestamps
end
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: 20140818102620) 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.integer "category_id"
t.datetime "created_at"
t.datetime "updated_at"
end

end
33 changes: 33 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,36 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Category.create([{ name: 'TV Commedies' }, { name: 'TV Dramas' }, { name: 'Reality TV' }])
Video.create(title: 'Monk', description: 'Adrian Monk is a brilliant San Francisco detective, whose obsessive compulsive disorder just happens to get in the way.', small_cover_url: '/tmp/monk.jpg', large_cover_url: '/tmp/monk_large.jpg', category_id: 2 )
Video.create(title: 'Family Guy', description: 'In a wacky Rhode Island town, a dysfunctional family strive to cope with everyday life as they are thrown from one crazy scenario to another.', small_cover_url: '/tmp/family_guy.jpg', large_cover_url: '', category_id: 1 )
Video.create(title: 'Futurama', description: "Fry, a pizza guy is accidentally frozen in 999 and thawed out New Year's Eve 999.", small_cover_url: '/tmp/futurama.jpg', large_cover_url: '', category_id: 1)
Video.create(title: 'South Park', description: 'Follows the misadventures of four irreverent grade-schoolers in the quiet, dysfunctional town of South Park, Colorado.', small_cover_url: '/tmp/south_park.jpg', large_cover_url: '', category_id: 1)
Video.create(title: 'Monk', description: 'Adrian Monk is a brilliant San Francisco detective, whose obsessive compulsive disorder just happens to get in the way.', small_cover_url: '/tmp/monk.jpg', large_cover_url: '/tmp/monk_large.jpg', category_id: 2)
Video.create(title: 'Family Guy', description: 'In a wacky Rhode Island town, a dysfunctional family strive to cope with everyday life as they are thrown from one crazy scenario to another.', small_cover_url: '/tmp/family_guy.jpg', large_cover_url: '', category_id: 1)
#Video.create(title: 'Futurama', description: "Fry, a pizza guy is accidentally frozen in 999 and thawed out New Year's Eve 999.", small_cover_url: '/tmp/futurama.jpg', large_cover_url: '', )
#Video.create(title: 'South Park', description: 'Follows the misadventures of four irreverent grade-schoolers in the quiet, dysfunctional town of South Park, Colorado.', small_cover_url: '/tmp/south_park.jpg', large_cover_url: '', )
#Video.create(title: 'Monk', description: 'Adrian Monk is a brilliant San Francisco detective, whose obsessive compulsive disorder just happens to get in the way.', small_cover_url: '/tmp/monk.jpg', large_cover_url: '/tmp/monk_large.jpg', )
#Video.create(title: 'Family Guy', description: 'In a wacky Rhode Island town, a dysfunctional family strive to cope with everyday life as they are thrown from one crazy scenario to another.', small_cover_url: '/tmp/family_guy.jpg', large_cover_url: '', )
#Video.create(title: 'Futurama', description: "Fry, a pizza guy is accidentally frozen in 999 and thawed out New Year's Eve 999.", small_cover_url: '/tmp/futurama.jpg', large_cover_url: '', )
#Video.create(title: 'South Park', description: 'Follows the misadventures of four irreverent grade-schoolers in the quiet, dysfunctional town of South Park, Colorado.', small_cover_url: '/tmp/south_park.jpg', large_cover_url: '', )
#Video.create(title: 'Monk', description: 'Adrian Monk is a brilliant San Francisco detective, whose obsessive compulsive disorder just happens to get in the way.', small_cover_url: '/tmp/monk.jpg', large_cover_url: '/tmp/monk_large.jpg', )
#Video.create(title: 'Family Guy', description: 'In a wacky Rhode Island town, a dysfunctional family strive to cope with everyday life as they are thrown from one crazy scenario to another.', small_cover_url: '/tmp/family_guy.jpg', large_cover_url: '', )
#Video.create(title: 'Futurama', description: "Fry, a pizza guy is accidentally frozen in 999 and thawed out New Year's Eve 999.", small_cover_url: '/tmp/futurama.jpg', large_cover_url: '', )
#Video.create(title: 'South Park', description: 'Follows the misadventures of four irreverent grade-schoolers in the quiet, dysfunctional town of South Park, Colorado.', small_cover_url: '/tmp/south_park.jpg', large_cover_url: '', )
#Video.create(title: 'Monk', description: 'Adrian Monk is a brilliant San Francisco detective, whose obsessive compulsive disorder just happens to get in the way.', small_cover_url: '/tmp/monk.jpg', large_cover_url: '/tmp/monk_large.jpg', )
#Video.create(title: 'Family Guy', description: 'In a wacky Rhode Island town, a dysfunctional family strive to cope with everyday life as they are thrown from one crazy scenario to another.', small_cover_url: '/tmp/family_guy.jpg', large_cover_url: '', )
#Video.create(title: 'Futurama', description: "Fry, a pizza guy is accidentally frozen in 999 and thawed out New Year's Eve 999.", small_cover_url: '/tmp/futurama.jpg', large_cover_url: '', )
#Video.create(title: 'South Park', description: 'Follows the misadventures of four irreverent grade-schoolers in the quiet, dysfunctional town of South Park, Colorado.', small_cover_url: '/tmp/south_park.jpg', large_cover_url: '', )
#Video.create(title: 'Monk', description: 'Adrian Monk is a brilliant San Francisco detective, whose obsessive compulsive disorder just happens to get in the way.', small_cover_url: '/tmp/monk.jpg', large_cover_url: '/tmp/monk_large.jpg', )
#Video.create(title: 'Family Guy', description: 'In a wacky Rhode Island town, a dysfunctional family strive to cope with everyday life as they are thrown from one crazy scenario to another.', small_cover_url: '/tmp/family_guy.jpg', large_cover_url: '', )
#Video.create(title: 'Futurama', description: "Fry, a pizza guy is accidentally frozen in 999 and thawed out New Year's Eve 999.", small_cover_url: '/tmp/futurama.jpg', large_cover_url: '', )
#Video.create(title: 'South Park', description: 'Follows the misadventures of four irreverent grade-schoolers in the quiet, dysfunctional town of South Park, Colorado.', small_cover_url: '/tmp/south_park.jpg', large_cover_url: '', )
#Video.create(title: 'Monk', description: 'Adrian Monk is a brilliant San Francisco detective, whose obsessive compulsive disorder just happens to get in the way.', small_cover_url: '/tmp/monk.jpg', large_cover_url: '/tmp/monk_large.jpg', )
#Video.create(title: 'Family Guy', description: 'In a wacky Rhode Island town, a dysfunctional family strive to cope with everyday life as they are thrown from one crazy scenario to another.', small_cover_url: '/tmp/family_guy.jpg', large_cover_url: '', )
#Video.create(title: 'Futurama', description: "Fry, a pizza guy is accidentally frozen in 999 and thawed out New Year's Eve 999.", small_cover_url: '/tmp/futurama.jpg', large_cover_url: '', )
#Video.create(title: 'South Park', description: 'Follows the misadventures of four irreverent grade-schoolers in the quiet, dysfunctional town of South Park, Colorado.', small_cover_url: '/tmp/south_park.jpg', large_cover_url: '', )
#Video.create(title: 'Monk', description: 'Adrian Monk is a brilliant San Francisco detective, whose obsessive compulsive disorder just happens to get in the way.', small_cover_url: '/tmp/monk.jpg', large_cover_url: '/tmp/monk_large.jpg', )
#Video.create(title: 'Family Guy', description: 'In a wacky Rhode Island town, a dysfunctional family strive to cope with everyday life as they are thrown from one crazy scenario to another.', small_cover_url: '/tmp/family_guy.jpg', large_cover_url: '', )
#Video.create(title: 'Futurama', description: "Fry, a pizza guy is accidentally frozen in 999 and thawed out New Year's Eve 999.", small_cover_url: '/tmp/futurama.jpg', large_cover_url: '', )
#Video.create(title: 'South Park', description: 'Follows the misadventures of four irreverent grade-schoolers in the quiet, dysfunctional town of South Park, Colorado.', small_cover_url: '/tmp/south_park.jpg', large_cover_url: '', )
5 changes: 5 additions & 0 deletions notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
small_cover_url.string
large_cover_url.string
title.string
desctiption.text

Loading