diff --git a/Gemfile b/Gemfile index 704d5009..f8ec0ef8 100644 --- a/Gemfile +++ b/Gemfile @@ -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: diff --git a/Gemfile.lock b/Gemfile.lock index f90762ff..1bdd3329 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,7 +62,11 @@ 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) @@ -70,6 +74,12 @@ GEM 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) @@ -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) diff --git a/Guardfile b/Guardfile new file mode 100644 index 00000000..2e2fa4ed --- /dev/null +++ b/Guardfile @@ -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 diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index d0e3d6c8..091d8a2c 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -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; @@ -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; + } +} + /* _______________________________ diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 9602b05b..8fba58ea 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -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 diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index 9179f600..bdaed386 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -1,7 +1,6 @@ class Admin::SitesController < ApplicationController layout 'admin' - before_filter :require_admin! before_filter :set_navigation_ids # GET /admin/sites @@ -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 @@ -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 @@ -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 diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb new file mode 100644 index 00000000..04a1f3c3 --- /dev/null +++ b/app/controllers/test_controller.rb @@ -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? diff --git a/app/helpers/test_helper.rb b/app/helpers/test_helper.rb new file mode 100644 index 00000000..09b6d50b --- /dev/null +++ b/app/helpers/test_helper.rb @@ -0,0 +1,2 @@ +module TestHelper +end diff --git a/app/views/admin/dashboard/new_site.html.erb b/app/views/admin/dashboard/new_site.html.erb index 3d049a36..cb24f9ba 100644 --- a/app/views/admin/dashboard/new_site.html.erb +++ b/app/views/admin/dashboard/new_site.html.erb @@ -2,6 +2,30 @@
So you want to embed comments on a bunch of web pages.
-What's your site's name? Just enter one. If you have more you can add them later.
- -How do you want to moderate new comments?
+<%= form_for([:admin, @site], :class => 'new_site') do |f| %> +Enter just one. If you have more you can add them later.
+ <%= f.text_field :name %> +How do you want to moderate new comments?
+ +