fixed some bugs, added seed data, changed login to use username + styled login/register page

This commit is contained in:
Mike Kelley
2011-08-27 02:34:18 -06:00
parent 17fee3c6d5
commit 14d7aa9772
8 changed files with 111 additions and 44 deletions

View File

@@ -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
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.

View File

@@ -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

View File

@@ -1,21 +1,29 @@
<h2>Sign up</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :username %><br />
<%= f.text_field :username %></p>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
<p><%= f.label :password %><br />
<%= f.password_field :password %></p>
<p><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></p>
<p><%= f.submit "Sign up" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>
<div class="module" style="padding:15px 25px 0px 25px;">
<div style="float:left; width:50%; height:330px; padding-right:10px;">
<h1>Welcome to Forum Monster</h1>
<p>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.</p>
<p style="font-size:1.2em;"><strong>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.</strong></p>
</div>
<div style="float:right; width:45%; padding-left:30px; border-left:1px solid #e2e2e2;">
<%= form_for("user", :as => resource_name, :url => registration_path("user")) do |f| %>
<p>
Username: <br />
<%= f.text_field :username, :style => "font-size:2.2em", :autocomplete => "off" %><br />
</p>
<p>
Email Address: <br />
<%= f.text_field :email, :style => "font-size:2.2em", :autocomplete => "off" %><br />
</p>
<p>
Password:<br />
<%= f.password_field :password, :style => "font-size:2.2em", :autocomplete => "off" %><br />
</p>
<p>
Confirm Password:<br />
<%= f.password_field :password_confirmation, :style => "font-size:2.2em", :autocomplete => "off" %><br />
</p>
<p><%= f.submit "Sign up" %></p>
<% end %>
</div>
<div class="clear"></div>
</div>

View File

@@ -1,17 +1,38 @@
<h2>Sign in</h2>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$().ready(function() {
$('#user_username, #user_password').click(function() {
$(this).val('');
});
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
$('#user_username, #user_password').blur(function() {
if ( $(this).val() == '' ) {
if ( $(this).is('#user_username') ) {
$(this).val('username');
}else{
$(this).val('password');
}
}
});
});
</script>
<p><%= f.label :password %><br />
<%= f.password_field :password %></p>
<% if devise_mapping.rememberable? -%>
<p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
<% end -%>
<p><%= f.submit "Sign in" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>
<div class="module" style="padding:15px 25px 0px 25px;">
<div style="float:left; width:50%; height:210px; padding-right:10px;">
<h1>Welcome to Forum Monster</h1>
<p>
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.
<p>You can login with the following information:</p>
<p><strong>Admin Demo:</strong> admin/forum_admin</p>
<p><strong>User Demo:</strong> user/forum_user</p>
</p>
</div>
<div style="float:right; width:45%; height:195px; padding-left:30px; border-left:1px solid #e2e2e2;">
<%= form_for("user", :url => user_session_path) do |f| %>
<p><%= f.text_field :username , :value => "username", :style => "font-size:2.2em;" %></p>
<p><%= f.password_field :password, :value => "password", :style => "font-size:2.2em" %></p>
<%= f.submit 'Sign in' %>
<% end %>
</div>
<div class="clear"></div>
</div>

View File

@@ -45,13 +45,12 @@
<%= yield %>
</div>
<% if %w(categories forums topics posts).include? controller_name %>
<div id="info_box">
<p>
Total number of registered users: <strong><%= User.count %></strong><br />
Newest registered user: <%= link_to User.last.username %>
Newest registered user: <%= link_to User.last.username unless User.last.nil? %>
</p>
</div>
<% end %>
</body>
</html>

View File

@@ -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

View File

@@ -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 }
]
)

View File

@@ -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;
}