From 14d7aa9772acc315e57ea0f43fa9cdd67e2ae799 Mon Sep 17 00:00:00 2001 From: Mike Kelley Date: Sat, 27 Aug 2011 02:34:18 -0600 Subject: [PATCH] fixed some bugs, added seed data, changed login to use username + styled login/register page --- README.rdoc | 16 ++++++- app/models/user.rb | 2 +- app/views/devise/registrations/new.html.erb | 50 +++++++++++-------- app/views/devise/sessions/new.html.erb | 53 ++++++++++++++------- app/views/layouts/application.html.erb | 5 +- config/initializers/devise.rb | 2 +- db/seeds.rb | 25 ++++++++++ public/stylesheets/application.css | 2 +- 8 files changed, 111 insertions(+), 44 deletions(-) diff --git a/README.rdoc b/README.rdoc index 8b4cd8e..daae94f 100644 --- a/README.rdoc +++ b/README.rdoc @@ -3,6 +3,9 @@ Demo for Forum Monster Forum Gem https://github.com/gitt/forum_monster +Live demo available here +http://forum_monster.dev.codezombie.org/ + Just download, bundle, and run. git clone git@github.com:gitt/forum_monster_demo.git @@ -10,4 +13,15 @@ Just download, bundle, and run. cd forum_monster_demo bundle install - rails s \ No newline at end of file + rake db:create + rake db:migrate + rake db:seed + + rails s + +2 Logins, 2 categories, and 5 forums are already setup for you to play with. You can create more as well + +The admin login is admin/forum_admin +The user login is user/forum_user + +In addition to the 2 above users, you can use the registration process as normal. \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index e7f5ca5..aa2be83 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,6 +16,6 @@ class User < ActiveRecord::Base has_many :posts, :dependent => :destroy def admin? - true if self.username == 'codezombie' + true if self.username == 'admin' end end diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index e39b74e..99a3809 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,21 +1,29 @@ -

Sign up

- -<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> - <%= devise_error_messages! %> - -

<%= f.label :username %>
- <%= f.text_field :username %>

- -

<%= f.label :email %>
- <%= f.email_field :email %>

- -

<%= f.label :password %>
- <%= f.password_field :password %>

- -

<%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation %>

- -

<%= f.submit "Sign up" %>

-<% end %> - -<%= render :partial => "devise/shared/links" %> +
+
+

Welcome to Forum Monster

+

Forum Monster is a simple forum generator written in rails 3. The goal of Forum Monster, is to provide a simple, and easy to setup forum application without having to dictate how your site it setup.

+

The email field is required, but none of the data is saved for more than a day. Feel free to put in a fake address.

+
+
+ <%= form_for("user", :as => resource_name, :url => registration_path("user")) do |f| %> +

+ Username:
+ <%= f.text_field :username, :style => "font-size:2.2em", :autocomplete => "off" %>
+

+

+ Email Address:
+ <%= f.text_field :email, :style => "font-size:2.2em", :autocomplete => "off" %>
+

+

+ Password:
+ <%= f.password_field :password, :style => "font-size:2.2em", :autocomplete => "off" %>
+

+

+ Confirm Password:
+ <%= f.password_field :password_confirmation, :style => "font-size:2.2em", :autocomplete => "off" %>
+

+

<%= f.submit "Sign up" %>

+ <% end %> +
+
+
\ No newline at end of file diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index d03def8..83752f4 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,17 +1,38 @@ -

Sign in

+ + -<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> -

<%= f.label :email %>
- <%= f.email_field :email %>

- -

<%= f.label :password %>
- <%= f.password_field :password %>

- - <% if devise_mapping.rememberable? -%> -

<%= f.check_box :remember_me %> <%= f.label :remember_me %>

- <% end -%> - -

<%= f.submit "Sign in" %>

-<% end %> - -<%= render :partial => "devise/shared/links" %> \ No newline at end of file +
+
+

Welcome to Forum Monster

+

+ Forum Monster is a simple forum generator written in rails 3. The goal of Forum Monster, is to provide a simple, and easy to setup forum application without having to dictate how your site it setup. +

You can login with the following information:

+

Admin Demo: admin/forum_admin

+

User Demo: user/forum_user

+

+
+
+ <%= form_for("user", :url => user_session_path) do |f| %> +

<%= f.text_field :username , :value => "username", :style => "font-size:2.2em;" %>

+

<%= f.password_field :password, :value => "password", :style => "font-size:2.2em" %>

+ <%= f.submit 'Sign in' %> + <% end %> +
+
+
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 032e019..53dbfc3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -45,13 +45,12 @@ <%= yield %> - <% if %w(categories forums topics posts).include? controller_name %>

Total number of registered users: <%= User.count %>
- Newest registered user: <%= link_to User.last.username %> + Newest registered user: <%= link_to User.last.username unless User.last.nil? %>

- <% end %> + diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 22cb644..c83ea51 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -22,7 +22,7 @@ Devise.setup do |config| # session. If you need permissions, you should implement that in a before filter. # You can also supply a hash where the value is a boolean determining whether # or not authentication should be aborted when the value is not present. - # config.authentication_keys = [ :email ] + config.authentication_keys = [ :username ] # Configure parameters from the request object used for authentication. Each entry # given should be a request method and it will automatically be passed to the diff --git a/db/seeds.rb b/db/seeds.rb index 664d8c7..a28522e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,28 @@ # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name => 'Daley', :city => cities.first) + +User.create!( + [ + { :username => "admin", :email => "admin@forum.com", :password => "forum_admin", :password_confirmation => "forum_admin" }, + { :username => "user", :email => "user@forum.com", :password => "forum_user", :password_confirmation => "forum_user" } + ] +) + +Category.create!( + [ + { :title => "General Discussion", :position => 0 }, + { :title => "Programming Discussions", :position => 1 } + ] +) + +Forum.create!( + [ + { :title => "General Discussion", :description => "Discuss any topic in this forum.", :category_id => Category.find_by_title("General Discussion").id, :position => 0 }, + { :title => "Ruby on Rails", :description => "Discuss Ruby on Rails.", :category_id => Category.find_by_title("Programming Discussions").id, :position => 0 }, + { :title => "PHP", :description => "Discuss PHP.", :category_id => Category.find_by_title("Programming Discussions").id, :position => 1 }, + { :title => "Javascript", :description => "Discuss Javascript.", :category_id => Category.find_by_title("Programming Discussions").id, :position => 2 }, + { :title => "CSS", :description => "Discuss CSS.", :category_id => Category.find_by_title("Programming Discussions").id, :position => 3 } + ] +) + diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 9047a70..92eac54 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -71,7 +71,7 @@ table a { font-weight:bold; } #info_box { width:1024px; - margin:0 auto; + margin:5px auto; background:#fff; border:1px solid #e2e2e2; }