Skip to content

Commit

Permalink
Continue developing
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Aug 17, 2011
1 parent a3c09ec commit f64f12d
Show file tree
Hide file tree
Showing 17 changed files with 193 additions and 20 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ gem 'coffee-script'
# To use debugger
# gem 'ruby-debug'

group :development do
gem 'guard-livereload'
end

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
Expand Down
11 changes: 11 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,24 @@ GEM
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
diff-lcs (1.1.2)
em-websocket (0.3.1)
addressable (>= 2.1.1)
eventmachine (>= 0.12.9)
erubis (2.7.0)
eventmachine (0.12.10)
execjs (1.2.4)
multi_json (~> 1.0)
factory_girl (2.0.4)
factory_girl_rails (1.1.0)
factory_girl (~> 2.0.0)
railties (>= 3.0.0)
ffi (1.0.9)
guard (0.6.2)
thor (~> 0.14.6)
guard-livereload (0.3.0)
em-websocket (>= 0.2.0)
guard (>= 0.4.0)
multi_json (~> 1.0.3)
hike (1.2.0)
i18n (0.6.0)
jquery-rails (1.0.13)
Expand Down Expand Up @@ -174,6 +184,7 @@ DEPENDENCIES
default_value_for
devise
factory_girl_rails
guard-livereload
jquery-rails (>= 1.0.12)
launchy
rails (= 3.1.0.rc5)
Expand Down
11 changes: 11 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'livereload' do
watch(%r{app/.+\.(erb|js)})
watch(%r{app/helpers/.+\.rb})
watch(%r{(public/|app/assets).+\.(css|js|html)})
watch(%r{(app/assets/.+\.css)\.s[ac]ss}) { |m| m[1] }
watch(%r{(app/assets/.+\.js)\.coffee}) { |m| m[1] }
watch(%r{config/locales/.+\.yml})
end
51 changes: 51 additions & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ textarea {
height: 200px;
}

input[type="text"] {
background: rgb(232,232,232); /* Old browsers */
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+ */
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+ */
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+ */
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+ */
background: -ms-linear-gradient(top, rgba(232,232,232,1) 0%,rgba(255,255,255,1) 40%,rgba(255,255,255,1) 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e8e8e8', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, rgba(232,232,232,1) 0%,rgba(255,255,255,1) 40%,rgba(255,255,255,1) 100%); /* W3C */

border: 1px solid #aaaaaa;
padding: 4px;
font-size: 0.85em;
@include BorderRadius(4px);
@include BoxShadow(0px 0px 1px gray);
}

input[type="submit"] {
font-size: 0.85em;
padding: 6px 12px 6px 12px;
}


#sections_bar {
margin: 20px;
Expand Down Expand Up @@ -245,6 +267,35 @@ form.comment {
}
}

form.new_site {
p {
margin-top: 0.25em;
margin-bottom: 0.25em;
}

label {
display: block;
}

input[type="text"] {
width: 30em;
}

.field {
margin-top: 1em;
margin-bottom: 1em;
}

.desc {
font-size: 120%;
font-weight: bold;
}

.radio_buttons {
margin-left: 8px;
}
}


/*
_______________________________
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/admin/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def new_admin
def create_admin
#raise if User.where(:admin => true).count > 0
end

def new_site
@site = Site.new
end

private
def set_navigation_ids
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/admin/sites_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class Admin::SitesController < ApplicationController
layout 'admin'

before_filter :require_admin!
before_filter :set_navigation_ids

# GET /admin/sites
Expand Down Expand Up @@ -45,14 +44,15 @@ def edit
# POST /admin/sites
# POST /admin/sites.json
def create
@site = Site.new(params[:admin_site])
@site = Site.new(params[:site])
@site.user = current_user

respond_to do |format|
if @site.save
format.html { redirect_to @site, :notice => 'Site was successfully created.' }
format.html { redirect_to created_admin_site_path(@site) }
format.json { render :json => @site, :status => :created, :location => @site }
else
format.html { render action: "new" }
format.html { render :action => "new" }
format.json { render :json => @site.errors, :status => :unprocessable_entity }
end
end
Expand All @@ -64,11 +64,11 @@ def update
@site = Site.find(params[:id])

respond_to do |format|
if @site.update_attributes(params[:admin_site])
format.html { redirect_to @site, :notice => 'Site was successfully updated.' }
if @site.update_attributes(params[:site])
format.html { redirect_to [:admin, @site], :notice => 'Site was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.html { render :action => "edit" }
format.json { render :json => @site.errors, :status => :unprocessable_entity }
end
end
Expand All @@ -81,7 +81,7 @@ def destroy
@site.destroy

respond_to do |format|
format.html { redirect_to admin_sites_url }
format.html { redirect_to admin_sites_path }
format.json { head :ok }
end
end
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/test_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class TestController < ApplicationController
layout nil

skip_before_filter :verify_authenticity_token
skip_before_filter :authenticate_user!

def login
sign_in(User.find(params[:user_id]))
render :text => 'ok'
end
end if Rails.env.test?
2 changes: 2 additions & 0 deletions app/helpers/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module TestHelper
end
30 changes: 27 additions & 3 deletions app/views/admin/dashboard/new_site.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
<h1>Let's get started!</h1>
<p>So you want to embed comments on a bunch of web pages.</p>

<p>What's your site's name? Just enter one. If you have more you can add them later.</p>

<p>How do you want to moderate new comments?</p>
<%= form_for([:admin, @site], :class => 'new_site') do |f| %>
<div class="field">
<p class="desc"><label for="site_name">What's your site's name?</label></p>
<p>Enter just one. If you have more you can add them later.</p>
<%= f.text_field :name %>
</div>

<div class="field">
<p class="desc">How do you want to moderate new comments?</p>
<div class="radio_buttons">
<label>
<%= f.radio_button :moderation_method, :none %>
Don't moderate, approve all comments automatically.
</label>
<label>
<%= f.radio_button :moderation_method, :akismet %>
Check spam with Akismet, approve automatically if no spam detected.
</label>
<label>
<%= f.radio_button :moderation_method, :manual %>
Manually approve all comments.
</label>
</div>
</div>

<%= f.submit 'Next step &raquo;'.html_safe %>
<% end %>
2 changes: 2 additions & 0 deletions app/views/admin/sites/created.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Your site has been created!</h1>
Here's how you embed comments in your web pages.
8 changes: 7 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@
get :preview
end
end
resources :sites
resources :sites do
member do
get :created
get :install
end
end
resources :users do
get :comments
get :sites
end
end

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

# The priority is based upon order of creation:
# first created -> highest priority.
Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/test_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe TestController do

end
6 changes: 5 additions & 1 deletion spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
email '[email protected]'
password 123456
password_confirmation 123456
is_admin true
admin true
end

factory :kotori, :class => User do
Expand Down Expand Up @@ -58,6 +58,10 @@
end

module FactoryHelpers
def admin(attrs = {})
@admin ||= FactoryGirl.create(:admin, attrs)
end

def kotori(attrs = {})
@kotori ||= FactoryGirl.create(:kotori, attrs)
end
Expand Down
15 changes: 15 additions & 0 deletions spec/helpers/test_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'spec_helper'

# Specs in this file have access to a helper object that includes
# the TestHelper. For example:
#
# describe TestHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe TestHelper do
pending "add some examples to (or delete) #{__FILE__}"
end
15 changes: 10 additions & 5 deletions spec/requests/admin/dashboard_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")

describe "Admin::Dashboard" do
Expand All @@ -12,18 +13,22 @@
end

describe "setting up a site" do
it "works" do
before :each do
login(admin)
visit '/admin/dashboard/new_site'
end

it "works" do
page.should have_content("So you want to embed comments on a bunch of web pages")
fill_in 'site[name]', :with => 'Foo'
fill_in 'site[moderation_type]'
click_button 'Next step &raquo;'
page.should have_content("Your site has been created. Here's how you embed comments in your web pages.")
choose 'Manually approve all comments.'
click_button 'Next step »'
page.should have_content("Your site has been created! Here's how you embed comments in your web pages.")
Site.find_by_name('Foo').should_not be_nil
end

it "refuses to create the site upon errors" do
click_button 'Next step &raquo;'
click_button 'Next step »'
page.should have_content("prohibited this site from being created")
page.should have_content("So you want to embed comments on a bunch of web pages")
end
Expand Down
19 changes: 18 additions & 1 deletion spec/requests/admin/sites_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")

describe "Admin::Sites" do
describe "GET /admin/sites" do
describe "/admin/sites" do
it "shows all sites that the current user can access"
it "shows the sites alphabetically"
end

describe "/admin/sites/:id" do
it "shows the most recent comments"
end

describe "/admin/sites/:id/topics" do
it "shows the most recent topics"
end

describe "installation page" do
it "shows installation instructions"
end

describe "settings page" do
it "shows the site settings"
it "allows updating the site settings"
end
end
3 changes: 2 additions & 1 deletion spec/support/spec_support.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module SpecSupport
def login(user)
if example.metadata[:type] == :request
raise "Not yet implemented"
visit("/test/login?user_id=#{user.id}")
page.should have_content("ok")
elsif example.metadata[:type] == :controller
raise "Please use sign_in instead in controller specs"
else
Expand Down

0 comments on commit f64f12d

Please sign in to comment.