Skip to content

Commit fa4fac8

Browse files
committed
Base code for start of the pull request lab
0 parents  commit fa4fac8

File tree

153 files changed

+30217
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+30217
-0
lines changed

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile ~/.gitignore_global
6+
7+
# Ignore bundler config
8+
/.bundle
9+
10+
# Include the SQLite database this time.
11+
# /db/*.sqlite3*/
12+
13+
# Ignore all logfiles and tempfiles.
14+
/log/*.log
15+
/tmp
16+
17+
# Ignore the .DS_Store files from Mac OS X
18+
.DS_Store

Gemfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'rails', '3.2.1'
4+
gem 'sqlite3'
5+
gem 'simple_form'
6+
gem 'carrierwave'
7+
gem 'will_paginate'
8+
gem 'jquery-rails'
9+
10+
# Gems used only for assets and not required
11+
# in production environments by default.
12+
group :assets do
13+
gem 'sass-rails', '~> 3.2.3'
14+
gem 'coffee-rails', '~> 3.2.1'
15+
gem 'uglifier', '>= 1.0.3'
16+
end
17+
18+
# Gems used only in development
19+
group :development do
20+
gem 'populator3'
21+
gem 'faker'
22+
gem 'hirb'
23+
gem 'wirble'
24+
end

Gemfile.lock

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actionmailer (3.2.1)
5+
actionpack (= 3.2.1)
6+
mail (~> 2.4.0)
7+
actionpack (3.2.1)
8+
activemodel (= 3.2.1)
9+
activesupport (= 3.2.1)
10+
builder (~> 3.0.0)
11+
erubis (~> 2.7.0)
12+
journey (~> 1.0.1)
13+
rack (~> 1.4.0)
14+
rack-cache (~> 1.1)
15+
rack-test (~> 0.6.1)
16+
sprockets (~> 2.1.2)
17+
activemodel (3.2.1)
18+
activesupport (= 3.2.1)
19+
builder (~> 3.0.0)
20+
activerecord (3.2.1)
21+
activemodel (= 3.2.1)
22+
activesupport (= 3.2.1)
23+
arel (~> 3.0.0)
24+
tzinfo (~> 0.3.29)
25+
activeresource (3.2.1)
26+
activemodel (= 3.2.1)
27+
activesupport (= 3.2.1)
28+
activesupport (3.2.1)
29+
i18n (~> 0.6)
30+
multi_json (~> 1.0)
31+
arel (3.0.2)
32+
builder (3.0.0)
33+
carrierwave (0.6.2)
34+
activemodel (>= 3.2.0)
35+
activesupport (>= 3.2.0)
36+
coffee-rails (3.2.2)
37+
coffee-script (>= 2.2.0)
38+
railties (~> 3.2.0)
39+
coffee-script (2.2.0)
40+
coffee-script-source
41+
execjs
42+
coffee-script-source (1.3.1)
43+
erubis (2.7.0)
44+
execjs (1.3.0)
45+
multi_json (~> 1.0)
46+
faker (1.0.1)
47+
i18n (~> 0.4)
48+
hike (1.2.1)
49+
hirb (0.6.2)
50+
i18n (0.6.0)
51+
journey (1.0.3)
52+
jquery-rails (2.0.2)
53+
railties (>= 3.2.0, < 5.0)
54+
thor (~> 0.14)
55+
json (1.6.6)
56+
mail (2.4.4)
57+
i18n (>= 0.4.0)
58+
mime-types (~> 1.16)
59+
treetop (~> 1.4.8)
60+
mime-types (1.18)
61+
multi_json (1.3.2)
62+
polyglot (0.3.3)
63+
populator3 (0.2.7)
64+
rack (1.4.1)
65+
rack-cache (1.2)
66+
rack (>= 0.4)
67+
rack-ssl (1.3.2)
68+
rack
69+
rack-test (0.6.1)
70+
rack (>= 1.0)
71+
rails (3.2.1)
72+
actionmailer (= 3.2.1)
73+
actionpack (= 3.2.1)
74+
activerecord (= 3.2.1)
75+
activeresource (= 3.2.1)
76+
activesupport (= 3.2.1)
77+
bundler (~> 1.0)
78+
railties (= 3.2.1)
79+
railties (3.2.1)
80+
actionpack (= 3.2.1)
81+
activesupport (= 3.2.1)
82+
rack-ssl (~> 1.3.2)
83+
rake (>= 0.8.7)
84+
rdoc (~> 3.4)
85+
thor (~> 0.14.6)
86+
rake (0.9.2.2)
87+
rdoc (3.12)
88+
json (~> 1.4)
89+
sass (3.1.15)
90+
sass-rails (3.2.5)
91+
railties (~> 3.2.0)
92+
sass (>= 3.1.10)
93+
tilt (~> 1.3)
94+
simple_form (2.0.1)
95+
actionpack (~> 3.0)
96+
activemodel (~> 3.0)
97+
sprockets (2.1.2)
98+
hike (~> 1.2)
99+
rack (~> 1.0)
100+
tilt (~> 1.1, != 1.3.0)
101+
sqlite3 (1.3.6)
102+
thor (0.14.6)
103+
tilt (1.3.3)
104+
treetop (1.4.10)
105+
polyglot
106+
polyglot (>= 0.3.1)
107+
tzinfo (0.3.33)
108+
uglifier (1.2.4)
109+
execjs (>= 0.3.0)
110+
multi_json (>= 1.0.2)
111+
will_paginate (3.0.3)
112+
wirble (0.1.3)
113+
114+
PLATFORMS
115+
ruby
116+
117+
DEPENDENCIES
118+
carrierwave
119+
coffee-rails (~> 3.2.1)
120+
faker
121+
hirb
122+
jquery-rails
123+
populator3
124+
rails (= 3.2.1)
125+
sass-rails (~> 3.2.3)
126+
simple_form
127+
sqlite3
128+
uglifier (>= 1.0.3)
129+
will_paginate
130+
wirble

README.rdoc

Whitespace-only changes.

Rakefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env rake
2+
# Add your own tasks in files placed in lib/tasks ending in .rake,
3+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4+
5+
require File.expand_path('../config/application', __FILE__)
6+
7+
KcwWorld::Application.load_tasks
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ApplicationController < ActionController::Base
2+
protect_from_forgery
3+
end
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
class CategoriesController < ApplicationController
2+
3+
def index
4+
@categories = Category.alphabetical.paginate(:page => params[:page]).per_page(10)
5+
end
6+
7+
8+
def show
9+
@category = Category.find(params[:id])
10+
end
11+
12+
13+
def new
14+
@category = Category.new
15+
end
16+
17+
18+
def edit
19+
@category = Category.find(params[:id])
20+
end
21+
22+
23+
def create
24+
@category = Category.new(params[:category])
25+
if @category.save
26+
flash[:notice] = 'Category was successfully created.'
27+
redirect_to category_path(@category)
28+
else
29+
render :action => "new"
30+
end
31+
end
32+
33+
34+
def update
35+
@category = Category.find(params[:id])
36+
if @category.update_attributes(params[:category])
37+
flash[:notice] = 'Category was successfully updated.'
38+
redirect_to category_path(@category)
39+
else
40+
render :action => "edit"
41+
end
42+
end
43+
44+
45+
def destroy
46+
@category = Category.find(params[:id])
47+
@category.destroy
48+
redirect_to categories_path
49+
end
50+
end

app/controllers/home_controller.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class HomeController < ApplicationController
2+
def index
3+
@proverb = Proverb.get_random_quote
4+
end
5+
end

app/controllers/photos_controller.rb

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
class PhotosController < ApplicationController
2+
3+
def index
4+
@photos = Photo.alphabetical.paginate(:page => params[:page]).per_page(5)
5+
end
6+
7+
8+
def show
9+
@photo = Photo.find(params[:id])
10+
end
11+
12+
13+
def new
14+
@photo = Photo.new
15+
end
16+
17+
18+
def edit
19+
@photo = Photo.find(params[:id])
20+
end
21+
22+
23+
def create
24+
@photo = Photo.new(params[:photo])
25+
if @photo.save
26+
flash[:notice] = 'Photo was successfully created.'
27+
redirect_to photo_path(@photo)
28+
else
29+
render :action => "new"
30+
end
31+
end
32+
33+
34+
def update
35+
@photo = Photo.find(params[:id])
36+
if @photo.update_attributes(params[:photo])
37+
flash[:notice] = 'Photo was successfully updated.'
38+
redirect_to photo_path(@photo)
39+
else
40+
render :action => "edit"
41+
end
42+
end
43+
44+
45+
def destroy
46+
@photo = Photo.find(params[:id])
47+
@photo.destroy
48+
redirect_to photos_path
49+
end
50+
end
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
class ProverbsController < ApplicationController
2+
3+
def index
4+
@proverbs = Proverb.alphabetical.paginate(:page => params[:page]).per_page(10)
5+
end
6+
7+
8+
def show
9+
@proverb = Proverb.find(params[:id])
10+
end
11+
12+
13+
def new
14+
@proverb = Proverb.new
15+
end
16+
17+
18+
def edit
19+
@proverb = Proverb.find(params[:id])
20+
flash[:notice] = 'Revise proverbs only if there is a typo; altering its meaning will cost you your life.'
21+
end
22+
23+
24+
def create
25+
@proverb = Proverb.new(params[:proverb])
26+
if @proverb.save
27+
flash[:notice] = 'A new proverb was successfully created.'
28+
redirect_to proverb_path(@proverb)
29+
else
30+
render :action => "new"
31+
end
32+
end
33+
34+
35+
def update
36+
@proverb = Proverb.find(params[:id])
37+
if @proverb.update_attributes(params[:proverb])
38+
flash[:notice] = 'Proverb was successfully updated ...and for your sake it better be correct.'
39+
redirect_to proverb_path(@proverb)
40+
else
41+
render :action => "edit"
42+
end
43+
end
44+
45+
46+
def destroy
47+
@proverb = Proverb.find(params[:id])
48+
flash[:error] = 'petaQ! You cannot destroy a hallowed Klingon proverb. '
49+
redirect_to proverbs_path
50+
end
51+
end

app/helpers/application_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ApplicationHelper
2+
end

app/mailers/.gitkeep

Whitespace-only changes.

app/models/.gitkeep

Whitespace-only changes.

app/models/category.rb

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Category < ActiveRecord::Base
2+
has_many :photos
3+
4+
scope :active, where('active = ?', true)
5+
scope :alphabetical, order('name')
6+
end

app/models/photo.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Photo < ActiveRecord::Base
2+
# Carrierwave
3+
mount_uploader :image, ImageUploader
4+
5+
# Relationships
6+
belongs_to :category
7+
8+
# Validations
9+
validates_presence_of :caption
10+
11+
# Scopes
12+
scope :active, where('active = ?', true)
13+
scope :alphabetical, order('caption')
14+
end

app/models/proverb.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Proverb < ActiveRecord::Base
2+
# Method to get a random quote for home page
3+
def self.get_random_quote
4+
find(:first, :order => 'Random()')
5+
end
6+
7+
# Make sure that both klingon phrase and translation included
8+
validates_presence_of :klingon, :translation
9+
10+
# Alphabetical by translation
11+
scope :alphabetical, order('translation')
12+
scope :active, where('active = ?', true)
13+
14+
end

0 commit comments

Comments
 (0)