Skip to content

Commit f64f12d

Browse files
committedAug 17, 2011
Continue developing
1 parent a3c09ec commit f64f12d

17 files changed

+193
-20
lines changed
 

‎Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ gem 'coffee-script'
2222
# To use debugger
2323
# gem 'ruby-debug'
2424

25+
group :development do
26+
gem 'guard-livereload'
27+
end
28+
2529
# Bundle gems for the local environment. Make sure to
2630
# put test-only gems in this group so their generators
2731
# and rake tasks are available in development mode:

‎Gemfile.lock

+11
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,24 @@ GEM
6262
orm_adapter (~> 0.0.3)
6363
warden (~> 1.0.3)
6464
diff-lcs (1.1.2)
65+
em-websocket (0.3.1)
66+
addressable (>= 2.1.1)
67+
eventmachine (>= 0.12.9)
6568
erubis (2.7.0)
69+
eventmachine (0.12.10)
6670
execjs (1.2.4)
6771
multi_json (~> 1.0)
6872
factory_girl (2.0.4)
6973
factory_girl_rails (1.1.0)
7074
factory_girl (~> 2.0.0)
7175
railties (>= 3.0.0)
7276
ffi (1.0.9)
77+
guard (0.6.2)
78+
thor (~> 0.14.6)
79+
guard-livereload (0.3.0)
80+
em-websocket (>= 0.2.0)
81+
guard (>= 0.4.0)
82+
multi_json (~> 1.0.3)
7383
hike (1.2.0)
7484
i18n (0.6.0)
7585
jquery-rails (1.0.13)
@@ -174,6 +184,7 @@ DEPENDENCIES
174184
default_value_for
175185
devise
176186
factory_girl_rails
187+
guard-livereload
177188
jquery-rails (>= 1.0.12)
178189
launchy
179190
rails (= 3.1.0.rc5)

‎Guardfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# A sample Guardfile
2+
# More info at https://github.com/guard/guard#readme
3+
4+
guard 'livereload' do
5+
watch(%r{app/.+\.(erb|js)})
6+
watch(%r{app/helpers/.+\.rb})
7+
watch(%r{(public/|app/assets).+\.(css|js|html)})
8+
watch(%r{(app/assets/.+\.css)\.s[ac]ss}) { |m| m[1] }
9+
watch(%r{(app/assets/.+\.js)\.coffee}) { |m| m[1] }
10+
watch(%r{config/locales/.+\.yml})
11+
end

‎app/assets/stylesheets/application.css.scss

+51
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,28 @@ textarea {
4545
height: 200px;
4646
}
4747

48+
input[type="text"] {
49+
background: rgb(232,232,232); /* Old browsers */
50+
background: -moz-linear-gradient(top, rgba(232,232,232,1) 0%, rgba(255,255,255,1) 40%, rgba(255,255,255,1) 100%); /* FF3.6+ */
51+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(232,232,232,1)), color-stop(40%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,1))); /* Chrome,Safari4+ */
52+
background: -webkit-linear-gradient(top, rgba(232,232,232,1) 0%,rgba(255,255,255,1) 40%,rgba(255,255,255,1) 100%); /* Chrome10+,Safari5.1+ */
53+
background: -o-linear-gradient(top, rgba(232,232,232,1) 0%,rgba(255,255,255,1) 40%,rgba(255,255,255,1) 100%); /* Opera11.10+ */
54+
background: -ms-linear-gradient(top, rgba(232,232,232,1) 0%,rgba(255,255,255,1) 40%,rgba(255,255,255,1) 100%); /* IE10+ */
55+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e8e8e8', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */
56+
background: linear-gradient(top, rgba(232,232,232,1) 0%,rgba(255,255,255,1) 40%,rgba(255,255,255,1) 100%); /* W3C */
57+
58+
border: 1px solid #aaaaaa;
59+
padding: 4px;
60+
font-size: 0.85em;
61+
@include BorderRadius(4px);
62+
@include BoxShadow(0px 0px 1px gray);
63+
}
64+
65+
input[type="submit"] {
66+
font-size: 0.85em;
67+
padding: 6px 12px 6px 12px;
68+
}
69+
4870

4971
#sections_bar {
5072
margin: 20px;
@@ -245,6 +267,35 @@ form.comment {
245267
}
246268
}
247269

270+
form.new_site {
271+
p {
272+
margin-top: 0.25em;
273+
margin-bottom: 0.25em;
274+
}
275+
276+
label {
277+
display: block;
278+
}
279+
280+
input[type="text"] {
281+
width: 30em;
282+
}
283+
284+
.field {
285+
margin-top: 1em;
286+
margin-bottom: 1em;
287+
}
288+
289+
.desc {
290+
font-size: 120%;
291+
font-weight: bold;
292+
}
293+
294+
.radio_buttons {
295+
margin-left: 8px;
296+
}
297+
}
298+
248299

249300
/*
250301
_______________________________

‎app/controllers/admin/dashboard_controller.rb

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def new_admin
2323
def create_admin
2424
#raise if User.where(:admin => true).count > 0
2525
end
26+
27+
def new_site
28+
@site = Site.new
29+
end
2630

2731
private
2832
def set_navigation_ids

‎app/controllers/admin/sites_controller.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
class Admin::SitesController < ApplicationController
22
layout 'admin'
33

4-
before_filter :require_admin!
54
before_filter :set_navigation_ids
65

76
# GET /admin/sites
@@ -45,14 +44,15 @@ def edit
4544
# POST /admin/sites
4645
# POST /admin/sites.json
4746
def create
48-
@site = Site.new(params[:admin_site])
47+
@site = Site.new(params[:site])
48+
@site.user = current_user
4949

5050
respond_to do |format|
5151
if @site.save
52-
format.html { redirect_to @site, :notice => 'Site was successfully created.' }
52+
format.html { redirect_to created_admin_site_path(@site) }
5353
format.json { render :json => @site, :status => :created, :location => @site }
5454
else
55-
format.html { render action: "new" }
55+
format.html { render :action => "new" }
5656
format.json { render :json => @site.errors, :status => :unprocessable_entity }
5757
end
5858
end
@@ -64,11 +64,11 @@ def update
6464
@site = Site.find(params[:id])
6565

6666
respond_to do |format|
67-
if @site.update_attributes(params[:admin_site])
68-
format.html { redirect_to @site, :notice => 'Site was successfully updated.' }
67+
if @site.update_attributes(params[:site])
68+
format.html { redirect_to [:admin, @site], :notice => 'Site was successfully updated.' }
6969
format.json { head :ok }
7070
else
71-
format.html { render action: "edit" }
71+
format.html { render :action => "edit" }
7272
format.json { render :json => @site.errors, :status => :unprocessable_entity }
7373
end
7474
end
@@ -81,7 +81,7 @@ def destroy
8181
@site.destroy
8282

8383
respond_to do |format|
84-
format.html { redirect_to admin_sites_url }
84+
format.html { redirect_to admin_sites_path }
8585
format.json { head :ok }
8686
end
8787
end

‎app/controllers/test_controller.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class TestController < ApplicationController
2+
layout nil
3+
4+
skip_before_filter :verify_authenticity_token
5+
skip_before_filter :authenticate_user!
6+
7+
def login
8+
sign_in(User.find(params[:user_id]))
9+
render :text => 'ok'
10+
end
11+
end if Rails.env.test?

‎app/helpers/test_helper.rb

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

‎app/views/admin/dashboard/new_site.html.erb

+27-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22
<h1>Let's get started!</h1>
33
<p>So you want to embed comments on a bunch of web pages.</p>
44

5-
<p>What's your site's name? Just enter one. If you have more you can add them later.</p>
6-
7-
<p>How do you want to moderate new comments?</p>
5+
<%= form_for([:admin, @site], :class => 'new_site') do |f| %>
6+
<div class="field">
7+
<p class="desc"><label for="site_name">What's your site's name?</label></p>
8+
<p>Enter just one. If you have more you can add them later.</p>
9+
<%= f.text_field :name %>
10+
</div>
11+
12+
<div class="field">
13+
<p class="desc">How do you want to moderate new comments?</p>
14+
<div class="radio_buttons">
15+
<label>
16+
<%= f.radio_button :moderation_method, :none %>
17+
Don't moderate, approve all comments automatically.
18+
</label>
19+
<label>
20+
<%= f.radio_button :moderation_method, :akismet %>
21+
Check spam with Akismet, approve automatically if no spam detected.
22+
</label>
23+
<label>
24+
<%= f.radio_button :moderation_method, :manual %>
25+
Manually approve all comments.
26+
</label>
27+
</div>
28+
</div>
29+
30+
<%= f.submit 'Next step &raquo;'.html_safe %>
31+
<% end %>
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Your site has been created!</h1>
2+
Here's how you embed comments in your web pages.

‎config/routes.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@
1010
get :preview
1111
end
1212
end
13-
resources :sites
13+
resources :sites do
14+
member do
15+
get :created
16+
get :install
17+
end
18+
end
1419
resources :users do
1520
get :comments
1621
get :sites
1722
end
1823
end
1924

2025
match 'admin/dashboard(/:action)', :to => 'admin/dashboard', :as => :dashboard
26+
match 'test/:action', :to => 'test' if Rails.env.test?
2127

2228
# The priority is based upon order of creation:
2329
# first created -> highest priority.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'spec_helper'
2+
3+
describe TestController do
4+
5+
end

‎spec/factories.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
email 'admin@admin.com'
44
password 123456
55
password_confirmation 123456
6-
is_admin true
6+
admin true
77
end
88

99
factory :kotori, :class => User do
@@ -58,6 +58,10 @@
5858
end
5959

6060
module FactoryHelpers
61+
def admin(attrs = {})
62+
@admin ||= FactoryGirl.create(:admin, attrs)
63+
end
64+
6165
def kotori(attrs = {})
6266
@kotori ||= FactoryGirl.create(:kotori, attrs)
6367
end

‎spec/helpers/test_helper_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'spec_helper'
2+
3+
# Specs in this file have access to a helper object that includes
4+
# the TestHelper. For example:
5+
#
6+
# describe TestHelper do
7+
# describe "string concat" do
8+
# it "concats two strings with spaces" do
9+
# helper.concat_strings("this","that").should == "this that"
10+
# end
11+
# end
12+
# end
13+
describe TestHelper do
14+
pending "add some examples to (or delete) #{__FILE__}"
15+
end

‎spec/requests/admin/dashboard_spec.rb

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# encoding: utf-8
12
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
23

34
describe "Admin::Dashboard" do
@@ -12,18 +13,22 @@
1213
end
1314

1415
describe "setting up a site" do
15-
it "works" do
16+
before :each do
17+
login(admin)
1618
visit '/admin/dashboard/new_site'
19+
end
20+
21+
it "works" do
1722
page.should have_content("So you want to embed comments on a bunch of web pages")
1823
fill_in 'site[name]', :with => 'Foo'
19-
fill_in 'site[moderation_type]'
20-
click_button 'Next step &raquo;'
21-
page.should have_content("Your site has been created. Here's how you embed comments in your web pages.")
24+
choose 'Manually approve all comments.'
25+
click_button 'Next step »'
26+
page.should have_content("Your site has been created! Here's how you embed comments in your web pages.")
2227
Site.find_by_name('Foo').should_not be_nil
2328
end
2429

2530
it "refuses to create the site upon errors" do
26-
click_button 'Next step &raquo;'
31+
click_button 'Next step »'
2732
page.should have_content("prohibited this site from being created")
2833
page.should have_content("So you want to embed comments on a bunch of web pages")
2934
end

‎spec/requests/admin/sites_spec.rb

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
22

33
describe "Admin::Sites" do
4-
describe "GET /admin/sites" do
4+
describe "/admin/sites" do
55
it "shows all sites that the current user can access"
66
it "shows the sites alphabetically"
77
end
8+
9+
describe "/admin/sites/:id" do
10+
it "shows the most recent comments"
11+
end
12+
13+
describe "/admin/sites/:id/topics" do
14+
it "shows the most recent topics"
15+
end
16+
17+
describe "installation page" do
18+
it "shows installation instructions"
19+
end
20+
21+
describe "settings page" do
22+
it "shows the site settings"
23+
it "allows updating the site settings"
24+
end
825
end

‎spec/support/spec_support.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module SpecSupport
22
def login(user)
33
if example.metadata[:type] == :request
4-
raise "Not yet implemented"
4+
visit("/test/login?user_id=#{user.id}")
5+
page.should have_content("ok")
56
elsif example.metadata[:type] == :controller
67
raise "Please use sign_in instead in controller specs"
78
else

0 commit comments

Comments
 (0)
Please sign in to comment.