| |   |
| 1 | 1 | class ProjectsController < ApplicationController |
| 2 | before_filter :login_required |
| 3 | |
| 2 | 4 | layout "standard" |
| 3 | 5 | |
| 4 | 6 | undoable_methods |
| … | … | |
| 8 | 8 | # GET /projects |
| 9 | 9 | # GET /projects.xml |
| 10 | 10 | def index |
| 11 | | @projects = Project.find(:all) |
| 11 | @projects = current_user.projects.find(:all) |
| 12 | 12 | |
| 13 | 13 | respond_to do |format| |
| 14 | 14 | format.html # index.html.erb |
| … | … | |
| 19 | 19 | # GET /projects/1 |
| 20 | 20 | # GET /projects/1.xml |
| 21 | 21 | def show |
| 22 | | @project = Project.find(params[:id]) |
| 22 | @project = current_user.projects.find(params[:id]) |
| 23 | 23 | |
| 24 | 24 | respond_to do |format| |
| 25 | 25 | format.html # show.html.erb |
| … | … | |
| 30 | 30 | # GET /projects/new |
| 31 | 31 | # GET /projects/new.xml |
| 32 | 32 | def new |
| 33 | | @project = Project.new |
| 33 | @project = current_user.projects.new |
| 34 | 34 | |
| 35 | 35 | respond_to do |format| |
| 36 | 36 | format.html # new.html.erb |
| … | … | |
| 40 | 40 | |
| 41 | 41 | # GET /projects/1/edit |
| 42 | 42 | def edit |
| 43 | | @project = Project.find(params[:id]) |
| 43 | @project = current_user.projects.find(params[:id]) |
| 44 | 44 | end |
| 45 | 45 | |
| 46 | 46 | # POST /projects |
| 47 | 47 | # POST /projects.xml |
| 48 | 48 | def create |
| 49 | | @project = Project.new(params[:project]) |
| 49 | @project = current_user.projects.new(params[:project]) |
| 50 | 50 | |
| 51 | 51 | respond_to do |format| |
| 52 | 52 | change("create project #{@project.title}", projects_path, projects_path) do |
| … | … | |
| 65 | 65 | # PUT /projects/1 |
| 66 | 66 | # PUT /projects/1.xml |
| 67 | 67 | def update |
| 68 | | @project = Project.find(params[:id]) |
| 68 | @project = current_user.projects.find(params[:id]) |
| 69 | 69 | |
| 70 | 70 | respond_to do |format| |
| 71 | 71 | change("update project #{@project.title}", edit_project_path(@project), project_path(@project)) do |
| … | … | |
| 84 | 84 | # DELETE /projects/1 |
| 85 | 85 | # DELETE /projects/1.xml |
| 86 | 86 | def destroy |
| 87 | | @project = Project.find(params[:id]) |
| 87 | @project = current_user.projects.find(params[:id]) |
| 88 | 88 | change("delete project #{@project.title}", project_path(@project), projects_path) do |
| 89 | 89 | @project.destroy |
| 90 | 90 | end |
| toggle raw diff |
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -1,4 +1,6 @@
class ProjectsController < ApplicationController
+ before_filter :login_required
+
layout "standard"
undoable_methods
@@ -6,7 +8,7 @@ class ProjectsController < ApplicationController
# GET /projects
# GET /projects.xml
def index
- @projects = Project.find(:all)
+ @projects = current_user.projects.find(:all)
respond_to do |format|
format.html # index.html.erb
@@ -17,7 +19,7 @@ class ProjectsController < ApplicationController
# GET /projects/1
# GET /projects/1.xml
def show
- @project = Project.find(params[:id])
+ @project = current_user.projects.find(params[:id])
respond_to do |format|
format.html # show.html.erb
@@ -28,7 +30,7 @@ class ProjectsController < ApplicationController
# GET /projects/new
# GET /projects/new.xml
def new
- @project = Project.new
+ @project = current_user.projects.new
respond_to do |format|
format.html # new.html.erb
@@ -38,13 +40,13 @@ class ProjectsController < ApplicationController
# GET /projects/1/edit
def edit
- @project = Project.find(params[:id])
+ @project = current_user.projects.find(params[:id])
end
# POST /projects
# POST /projects.xml
def create
- @project = Project.new(params[:project])
+ @project = current_user.projects.new(params[:project])
respond_to do |format|
change("create project #{@project.title}", projects_path, projects_path) do
@@ -63,7 +65,7 @@ class ProjectsController < ApplicationController
# PUT /projects/1
# PUT /projects/1.xml
def update
- @project = Project.find(params[:id])
+ @project = current_user.projects.find(params[:id])
respond_to do |format|
change("update project #{@project.title}", edit_project_path(@project), project_path(@project)) do
@@ -82,7 +84,7 @@ class ProjectsController < ApplicationController
# DELETE /projects/1
# DELETE /projects/1.xml
def destroy
- @project = Project.find(params[:id])
+ @project = current_user.projects.find(params[:id])
change("delete project #{@project.title}", project_path(@project), projects_path) do
@project.destroy
end |
| |   |
| 1 | # This controller handles the login/logout function of the site. |
| 2 | class SessionsController < ApplicationController |
| 3 | |
| 4 | layout "standard" |
| 5 | |
| 6 | # render new.rhtml |
| 7 | def new |
| 8 | end |
| 9 | |
| 10 | def create |
| 11 | self.current_user = User.authenticate(params[:login], params[:password]) |
| 12 | if logged_in? |
| 13 | if params[:remember_me] == "1" |
| 14 | self.current_user.remember_me |
| 15 | cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } |
| 16 | end |
| 17 | redirect_back_or_default('/') |
| 18 | flash[:notice] = "Logged in successfully" |
| 19 | else |
| 20 | render :action => 'new' |
| 21 | end |
| 22 | end |
| 23 | |
| 24 | def destroy |
| 25 | self.current_user.forget_me if logged_in? |
| 26 | cookies.delete :auth_token |
| 27 | reset_session |
| 28 | flash[:notice] = "You have been logged out." |
| 29 | redirect_back_or_default('/') |
| 30 | end |
| 31 | end |
| toggle raw diff |
--- /dev/null
+++ b/app/controllers/sessions_controller.rb
@@ -0,0 +1,31 @@
+# This controller handles the login/logout function of the site.
+class SessionsController < ApplicationController
+
+ layout "standard"
+
+ # render new.rhtml
+ def new
+ end
+
+ def create
+ self.current_user = User.authenticate(params[:login], params[:password])
+ if logged_in?
+ if params[:remember_me] == "1"
+ self.current_user.remember_me
+ cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
+ end
+ redirect_back_or_default('/')
+ flash[:notice] = "Logged in successfully"
+ else
+ render :action => 'new'
+ end
+ end
+
+ def destroy
+ self.current_user.forget_me if logged_in?
+ cookies.delete :auth_token
+ reset_session
+ flash[:notice] = "You have been logged out."
+ redirect_back_or_default('/')
+ end
+end |
| |   |
| 1 | class UsersController < ApplicationController |
| 2 | |
| 3 | layout "standard" |
| 4 | |
| 5 | # render new.rhtml |
| 6 | def new |
| 7 | end |
| 8 | |
| 9 | def create |
| 10 | cookies.delete :auth_token |
| 11 | # protects against session fixation attacks, wreaks havoc with |
| 12 | # request forgery protection. |
| 13 | # uncomment at your own risk |
| 14 | # reset_session |
| 15 | @user = User.new(params[:user]) |
| 16 | @user.save |
| 17 | if @user.errors.empty? |
| 18 | self.current_user = @user |
| 19 | redirect_back_or_default('/') |
| 20 | flash[:notice] = "Thanks for signing up!" |
| 21 | else |
| 22 | render :action => 'new' |
| 23 | end |
| 24 | end |
| 25 | |
| 26 | end |
| toggle raw diff |
--- /dev/null
+++ b/app/controllers/users_controller.rb
@@ -0,0 +1,26 @@
+class UsersController < ApplicationController
+
+ layout "standard"
+
+ # render new.rhtml
+ def new
+ end
+
+ def create
+ cookies.delete :auth_token
+ # protects against session fixation attacks, wreaks havoc with
+ # request forgery protection.
+ # uncomment at your own risk
+ # reset_session
+ @user = User.new(params[:user])
+ @user.save
+ if @user.errors.empty?
+ self.current_user = @user
+ redirect_back_or_default('/')
+ flash[:notice] = "Thanks for signing up!"
+ else
+ render :action => 'new'
+ end
+ end
+
+end |
| |   |
| 1 | require 'digest/sha1' |
| 2 | class User < ActiveRecord::Base |
| 3 | # Virtual attribute for the unencrypted password |
| 4 | attr_accessor :password |
| 5 | |
| 6 | validates_presence_of :login |
| 7 | validates_presence_of :password, :if => :password_required? |
| 8 | validates_presence_of :password_confirmation, :if => :password_required? |
| 9 | validates_length_of :password, :within => 3..40, :if => :password_required? |
| 10 | validates_confirmation_of :password, :if => :password_required? |
| 11 | validates_length_of :login, :within => 3..40 |
| 12 | validates_uniqueness_of :login, :case_sensitive => false |
| 13 | before_save :encrypt_password |
| 14 | |
| 15 | # prevents a user from submitting a crafted form that bypasses activation |
| 16 | # anything else you want your user to change should be added here. |
| 17 | attr_accessible :login, :password, :password_confirmation |
| 18 | |
| 19 | has_many :projects |
| 20 | |
| 21 | # Authenticates a user by their login name and unencrypted password. Returns the user or nil. |
| 22 | def self.authenticate(login, password) |
| 23 | u = find_by_login(login) # need to get the salt |
| 24 | u && u.authenticated?(password) ? u : nil |
| 25 | end |
| 26 | |
| 27 | # Encrypts some data with the salt. |
| 28 | def self.encrypt(password, salt) |
| 29 | Digest::SHA1.hexdigest("--#{salt}--#{password}--") |
| 30 | end |
| 31 | |
| 32 | # Encrypts the password with the user salt |
| 33 | def encrypt(password) |
| 34 | self.class.encrypt(password, salt) |
| 35 | end |
| 36 | |
| 37 | def authenticated?(password) |
| 38 | crypted_password == encrypt(password) |
| 39 | end |
| 40 | |
| 41 | def remember_token? |
| 42 | remember_token_expires_at && Time.now.utc < remember_token_expires_at |
| 43 | end |
| 44 | |
| 45 | # These create and unset the fields required for remembering users between browser closes |
| 46 | def remember_me |
| 47 | remember_me_for 2.weeks |
| 48 | end |
| 49 | |
| 50 | def remember_me_for(time) |
| 51 | remember_me_until time.from_now.utc |
| 52 | end |
| 53 | |
| 54 | def remember_me_until(time) |
| 55 | self.remember_token_expires_at = time |
| 56 | self.remember_token = encrypt("#{login}--#{remember_token_expires_at}") |
| 57 | save(false) |
| 58 | end |
| 59 | |
| 60 | def forget_me |
| 61 | self.remember_token_expires_at = nil |
| 62 | self.remember_token = nil |
| 63 | save(false) |
| 64 | end |
| 65 | |
| 66 | protected |
| 67 | # before filter |
| 68 | def encrypt_password |
| 69 | return if password.blank? |
| 70 | self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? |
| 71 | self.crypted_password = encrypt(password) |
| 72 | end |
| 73 | |
| 74 | def password_required? |
| 75 | crypted_password.blank? || !password.blank? |
| 76 | end |
| 77 | |
| 78 | end |
| toggle raw diff |
--- /dev/null
+++ b/app/models/user.rb
@@ -0,0 +1,78 @@
+require 'digest/sha1'
+class User < ActiveRecord::Base
+ # Virtual attribute for the unencrypted password
+ attr_accessor :password
+
+ validates_presence_of :login
+ validates_presence_of :password, :if => :password_required?
+ validates_presence_of :password_confirmation, :if => :password_required?
+ validates_length_of :password, :within => 3..40, :if => :password_required?
+ validates_confirmation_of :password, :if => :password_required?
+ validates_length_of :login, :within => 3..40
+ validates_uniqueness_of :login, :case_sensitive => false
+ before_save :encrypt_password
+
+ # prevents a user from submitting a crafted form that bypasses activation
+ # anything else you want your user to change should be added here.
+ attr_accessible :login, :password, :password_confirmation
+
+ has_many :projects
+
+ # Authenticates a user by their login name and unencrypted password. Returns the user or nil.
+ def self.authenticate(login, password)
+ u = find_by_login(login) # need to get the salt
+ u && u.authenticated?(password) ? u : nil
+ end
+
+ # Encrypts some data with the salt.
+ def self.encrypt(password, salt)
+ Digest::SHA1.hexdigest("--#{salt}--#{password}--")
+ end
+
+ # Encrypts the password with the user salt
+ def encrypt(password)
+ self.class.encrypt(password, salt)
+ end
+
+ def authenticated?(password)
+ crypted_password == encrypt(password)
+ end
+
+ def remember_token?
+ remember_token_expires_at && Time.now.utc < remember_token_expires_at
+ end
+
+ # These create and unset the fields required for remembering users between browser closes
+ def remember_me
+ remember_me_for 2.weeks
+ end
+
+ def remember_me_for(time)
+ remember_me_until time.from_now.utc
+ end
+
+ def remember_me_until(time)
+ self.remember_token_expires_at = time
+ self.remember_token = encrypt("#{login}--#{remember_token_expires_at}")
+ save(false)
+ end
+
+ def forget_me
+ self.remember_token_expires_at = nil
+ self.remember_token = nil
+ save(false)
+ end
+
+ protected
+ # before filter
+ def encrypt_password
+ return if password.blank?
+ self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
+ self.crypted_password = encrypt(password)
+ end
+
+ def password_required?
+ crypted_password.blank? || !password.blank?
+ end
+
+end |
| |   |
| 13 | 13 | <h2>Showing off RUR (<a href="http://blog.nanorails.com/rails-undo-redo">Rails Undo Redo</a>)</h2> |
| 14 | 14 | </div> |
| 15 | 15 | |
| 16 | <% if flash[:notice] %> |
| 17 | <p class="message undo"><%= flash[:notice] %></p> |
| 18 | <% end %> |
| 19 | |
| 16 | 20 | <%= @content_for_layout %> |
| 17 | 21 | |
| 18 | 22 | <div id="clear"></div> |
| … | … | |
| 27 | 27 | <p class="message"><%= undo_redo_links %></p> |
| 28 | 28 | <% end %> |
| 29 | 29 | |
| 30 | | <% if flash["notice"] %> |
| 31 | | <p class="message"><%= flash["notice"] %></p> |
| 32 | | <% end %> |
| 33 | | |
| 34 | 30 | <div id="footer"> |
| 35 | 31 | Copyright 2008 <a href="http://blog.nanorails.com">nano RAILS</a> | Design by <a href="http://www.minimalistic-design.net">Minimalistic Design</a> |
| 36 | 32 | </div> |
| 33 | <!-- Start of StatCounter Code --> |
| 34 | <script type="text/javascript"> |
| 35 | var sc_project=3439485; |
| 36 | var sc_invisible=1; |
| 37 | var sc_partition=38; |
| 38 | var sc_security="bab9070d"; |
| 39 | </script> |
| 40 | |
| 41 | <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/free_hit_counter.html"><img class="statcounter" src="http://c39.statcounter.com/3439485/0/bab9070d/1/" alt="counter" /></a></div></noscript> |
| 42 | <!-- End of StatCounter Code --> |
| 37 | 43 | </body> |
| 38 | 44 | </html> |
| toggle raw diff |
--- a/app/views/layouts/standard.html.erb
+++ b/app/views/layouts/standard.html.erb
@@ -13,6 +13,10 @@
<h2>Showing off RUR (<a href="http://blog.nanorails.com/rails-undo-redo">Rails Undo Redo</a>)</h2>
</div>
+ <% if flash[:notice] %>
+ <p class="message undo"><%= flash[:notice] %></p>
+ <% end %>
+
<%= @content_for_layout %>
<div id="clear"></div>
@@ -23,12 +27,18 @@
<p class="message"><%= undo_redo_links %></p>
<% end %>
-<% if flash["notice"] %>
-<p class="message"><%= flash["notice"] %></p>
-<% end %>
-
<div id="footer">
Copyright 2008 <a href="http://blog.nanorails.com">nano RAILS</a> | Design by <a href="http://www.minimalistic-design.net">Minimalistic Design</a>
</div>
+<!-- Start of StatCounter Code -->
+<script type="text/javascript">
+var sc_project=3439485;
+var sc_invisible=1;
+var sc_partition=38;
+var sc_security="bab9070d";
+</script>
+
+<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/free_hit_counter.html"><img class="statcounter" src="http://c39.statcounter.com/3439485/0/bab9070d/1/" alt="counter" /></a></div></noscript>
+<!-- End of StatCounter Code -->
</body>
</html>
\ No newline at end of file |
| |   |
| 29 | 29 | <ul> |
| 30 | 30 | <li><%= link_to 'Home', root_path %></li> |
| 31 | 31 | <li><%= link_to 'About', about_path %></li> |
| 32 | <% if logged_in? %> |
| 33 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 34 | <% end %> |
| 32 | 35 | <li><%= link_to 'Project List', projects_path %></li> |
| 33 | 36 | <li><%= link_to 'Show', @project %></li> |
| 34 | 37 | <li><%= link_to 'New task', new_project_task_path(@project) %></li> |
| toggle raw diff |
--- a/app/views/projects/edit.html.erb
+++ b/app/views/projects/edit.html.erb
@@ -29,6 +29,9 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
<li><%= link_to 'Show', @project %></li>
<li><%= link_to 'New task', new_project_task_path(@project) %></li> |
| |   |
| 26 | 26 | <ul> |
| 27 | 27 | <li><%= link_to 'Home', root_path %></li> |
| 28 | 28 | <li><%= link_to 'About', about_path %></li> |
| 29 | <% if logged_in? %> |
| 30 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 31 | <% end %> |
| 29 | 32 | <li><%= link_to 'Project List', projects_path %></li> |
| 30 | 33 | <li><%= link_to 'New project', new_project_path %></li> |
| 31 | 34 | </ul> |
| toggle raw diff |
--- a/app/views/projects/index.html.erb
+++ b/app/views/projects/index.html.erb
@@ -26,6 +26,9 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
<li><%= link_to 'New project', new_project_path %></li>
</ul> |
| |   |
| 29 | 29 | <ul> |
| 30 | 30 | <li><%= link_to 'Home', root_path %></li> |
| 31 | 31 | <li><%= link_to 'About', about_path %></li> |
| 32 | <% if logged_in? %> |
| 33 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 34 | <% end %> |
| 32 | 35 | <li><%= link_to 'Project List', projects_path %></li> |
| 33 | 36 | </ul> |
| 34 | 37 | </div> |
| toggle raw diff |
--- a/app/views/projects/new.html.erb
+++ b/app/views/projects/new.html.erb
@@ -29,6 +29,9 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
</ul>
</div> |
| |   |
| 25 | 25 | <ul> |
| 26 | 26 | <li><%= link_to 'Home', root_path %></li> |
| 27 | 27 | <li><%= link_to 'About', about_path %></li> |
| 28 | <% if logged_in? %> |
| 29 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 30 | <% end %> |
| 28 | 31 | <li><%= link_to 'Project List', projects_path %></li> |
| 29 | 32 | <li><%= link_to 'Edit', edit_project_path(@project) %></li> |
| 30 | 33 | <li><%= link_to 'New task', new_project_task_path(@project) %></li> |
| toggle raw diff |
--- a/app/views/projects/show.html.erb
+++ b/app/views/projects/show.html.erb
@@ -25,6 +25,9 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
<li><%= link_to 'Edit', edit_project_path(@project) %></li>
<li><%= link_to 'New task', new_project_task_path(@project) %></li> |
| |   |
| 1 | <div class="middle"> |
| 2 | <h2>Login to your account</h2> |
| 3 | <% form_tag session_path do -%> |
| 4 | <p> |
| 5 | <b>Login</b><br/> |
| 6 | <%= text_field_tag 'login' %> |
| 7 | </p> |
| 8 | |
| 9 | <p> |
| 10 | <b>Password</b><br/> |
| 11 | <%= password_field_tag 'password' %> |
| 12 | </p> |
| 13 | |
| 14 | <p> |
| 15 | <b>Remember me</b> |
| 16 | <%= check_box_tag 'remember_me' %> |
| 17 | </p> |
| 18 | |
| 19 | <p><%= submit_tag 'Log in' %></p> |
| 20 | <% end -%> |
| 21 | </div> |
| 22 | <div class="right"> |
| 23 | <h2>Navigation</h2> |
| 24 | <ul> |
| 25 | <li><%= link_to 'Home', root_path %></li> |
| 26 | <li><%= link_to 'About', about_path %></li> |
| 27 | <% if logged_in? %> |
| 28 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 29 | <% else %> |
| 30 | <li><%= link_to 'Login', login_path %></li> |
| 31 | <li><%= link_to 'Sign Up', signup_path %></li> |
| 32 | <% end %> |
| 33 | </ul> |
| 34 | </div> |
| toggle raw diff |
--- /dev/null
+++ b/app/views/sessions/new.html.erb
@@ -0,0 +1,34 @@
+<div class="middle">
+ <h2>Login to your account</h2>
+ <% form_tag session_path do -%>
+ <p>
+ <b>Login</b><br/>
+ <%= text_field_tag 'login' %>
+ </p>
+
+ <p>
+ <b>Password</b><br/>
+ <%= password_field_tag 'password' %>
+ </p>
+
+ <p>
+ <b>Remember me</b>
+ <%= check_box_tag 'remember_me' %>
+ </p>
+
+ <p><%= submit_tag 'Log in' %></p>
+ <% end -%>
+</div>
+<div class="right">
+ <h2>Navigation</h2>
+ <ul>
+ <li><%= link_to 'Home', root_path %></li>
+ <li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% else %>
+ <li><%= link_to 'Login', login_path %></li>
+ <li><%= link_to 'Sign Up', signup_path %></li>
+ <% end %>
+ </ul>
+</div> |
| |   |
| 29 | 29 | <ul> |
| 30 | 30 | <li><%= link_to 'Home', root_path %></li> |
| 31 | 31 | <li><%= link_to 'About', about_path %></li> |
| 32 | <% if logged_in? %> |
| 33 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 34 | <% end %> |
| 32 | 35 | <li><%= link_to 'Project List', projects_path %></li> |
| 33 | 36 | <li><%= link_to 'Show', project_task_path(@project, @task) %></li> |
| 37 | <li><%= link_to 'New task', new_project_task_path(@project) %></li> |
| 34 | 38 | <li><%= link_to 'Tasks', project_tasks_path(@project) %></li> |
| 35 | 39 | <li><%= link_to 'Project', project_path(@project) %></li> |
| 36 | 40 | </ul> |
| toggle raw diff |
--- a/app/views/tasks/edit.html.erb
+++ b/app/views/tasks/edit.html.erb
@@ -29,8 +29,12 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
<li><%= link_to 'Show', project_task_path(@project, @task) %></li>
+ <li><%= link_to 'New task', new_project_task_path(@project) %></li>
<li><%= link_to 'Tasks', project_tasks_path(@project) %></li>
<li><%= link_to 'Project', project_path(@project) %></li>
</ul> |
| |   |
| 26 | 26 | <ul> |
| 27 | 27 | <li><%= link_to 'Home', root_path %></li> |
| 28 | 28 | <li><%= link_to 'About', about_path %></li> |
| 29 | <% if logged_in? %> |
| 30 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 31 | <% end %> |
| 29 | 32 | <li><%= link_to 'Project List', projects_path %></li> |
| 30 | 33 | <li><%= link_to 'New task', new_project_task_path(@project) %></li> |
| 31 | 34 | <li><%= link_to 'Project', project_path(@project) %></li> |
| toggle raw diff |
--- a/app/views/tasks/index.html.erb
+++ b/app/views/tasks/index.html.erb
@@ -26,6 +26,9 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
<li><%= link_to 'New task', new_project_task_path(@project) %></li>
<li><%= link_to 'Project', project_path(@project) %></li> |
| |   |
| 19 | 19 | <ul> |
| 20 | 20 | <li><%= link_to 'Home', root_path %></li> |
| 21 | 21 | <li><%= link_to 'About', about_path %></li> |
| 22 | <% if logged_in? %> |
| 23 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 24 | <% end %> |
| 22 | 25 | <li><%= link_to 'Project List', projects_path %></li> |
| 23 | 26 | <li><%= link_to 'Show', project_task_path(@project, @task) %></li> |
| 27 | <li><%= link_to 'New task', new_project_task_path(@project) %></li> |
| 24 | 28 | <li><%= link_to 'Tasks', project_tasks_path(@project) %></li> |
| 25 | 29 | <li><%= link_to 'Project', project_path(@project) %></li> |
| 26 | 30 | </ul> |
| toggle raw diff |
--- a/app/views/tasks/move.html.erb
+++ b/app/views/tasks/move.html.erb
@@ -19,8 +19,12 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
<li><%= link_to 'Show', project_task_path(@project, @task) %></li>
+ <li><%= link_to 'New task', new_project_task_path(@project) %></li>
<li><%= link_to 'Tasks', project_tasks_path(@project) %></li>
<li><%= link_to 'Project', project_path(@project) %></li>
</ul> |
| |   |
| 29 | 29 | <ul> |
| 30 | 30 | <li><%= link_to 'Home', root_path %></li> |
| 31 | 31 | <li><%= link_to 'About', about_path %></li> |
| 32 | <% if logged_in? %> |
| 33 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 34 | <% end %> |
| 32 | 35 | <li><%= link_to 'Project List', projects_path %></li> |
| 33 | 36 | <li><%= link_to 'Tasks', project_tasks_path(@project) %></li> |
| 34 | 37 | <li><%= link_to 'Project', project_path(@project) %></li> |
| toggle raw diff |
--- a/app/views/tasks/new.html.erb
+++ b/app/views/tasks/new.html.erb
@@ -29,6 +29,9 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
<li><%= link_to 'Tasks', project_tasks_path(@project) %></li>
<li><%= link_to 'Project', project_path(@project) %></li> |
| |   |
| 26 | 26 | <ul> |
| 27 | 27 | <li><%= link_to 'Home', root_path %></li> |
| 28 | 28 | <li><%= link_to 'About', about_path %></li> |
| 29 | <% if logged_in? %> |
| 30 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 31 | <% end %> |
| 29 | 32 | <li><%= link_to 'Project List', projects_path %></li> |
| 30 | 33 | <li><%= link_to 'Edit', edit_project_task_path(@project, @task) %></li> |
| 31 | 34 | <li><%= link_to 'Move', move_project_task_path(@project, @task) %></li> |
| 35 | <li><%= link_to 'New task', new_project_task_path(@project) %></li> |
| 32 | 36 | <li><%= link_to 'Tasks', project_tasks_path(@project) %></li> |
| 33 | 37 | <li><%= link_to 'Project', project_path(@project) %></li> |
| 34 | 38 | </ul> |
| toggle raw diff |
--- a/app/views/tasks/show.html.erb
+++ b/app/views/tasks/show.html.erb
@@ -26,9 +26,13 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
<li><%= link_to 'Edit', edit_project_task_path(@project, @task) %></li>
<li><%= link_to 'Move', move_project_task_path(@project, @task) %></li>
+ <li><%= link_to 'New task', new_project_task_path(@project) %></li>
<li><%= link_to 'Tasks', project_tasks_path(@project) %></li>
<li><%= link_to 'Project', project_path(@project) %></li>
</ul> |
| |   |
| 1 | <div class="middle"> |
| 2 | <h2>Register for a new account</h2> |
| 3 | <%= error_messages_for :user %> |
| 4 | <% form_for :user, :url => users_path do |f| -%> |
| 5 | <p><label for="login">Login</label><br/> |
| 6 | <%= f.text_field :login %></p> |
| 7 | |
| 8 | <p><label for="email">Email</label><br/> |
| 9 | <%= f.text_field :email %></p> |
| 10 | |
| 11 | <p><label for="password">Password</label><br/> |
| 12 | <%= f.password_field :password %></p> |
| 13 | |
| 14 | <p><label for="password_confirmation">Confirm Password</label><br/> |
| 15 | <%= f.password_field :password_confirmation %></p> |
| 16 | |
| 17 | <p><%= submit_tag 'Sign up' %></p> |
| 18 | <% end -%> |
| 19 | </div> |
| 20 | |
| 21 | <div class="right"> |
| 22 | <h2>Navigation</h2> |
| 23 | <ul> |
| 24 | <li><%= link_to 'Home', root_path %></li> |
| 25 | <li><%= link_to 'About', about_path %></li> |
| 26 | <% if logged_in? %> |
| 27 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 28 | <% else %> |
| 29 | <li><%= link_to 'Login', login_path %></li> |
| 30 | <li><%= link_to 'Sign Up', signup_path %></li> |
| 31 | <% end %> |
| 32 | </ul> |
| 33 | </div> |
| toggle raw diff |
--- /dev/null
+++ b/app/views/users/new.html.erb
@@ -0,0 +1,33 @@
+<div class="middle">
+ <h2>Register for a new account</h2>
+ <%= error_messages_for :user %>
+ <% form_for :user, :url => users_path do |f| -%>
+ <p><label for="login">Login</label><br/>
+ <%= f.text_field :login %></p>
+
+ <p><label for="email">Email</label><br/>
+ <%= f.text_field :email %></p>
+
+ <p><label for="password">Password</label><br/>
+ <%= f.password_field :password %></p>
+
+ <p><label for="password_confirmation">Confirm Password</label><br/>
+ <%= f.password_field :password_confirmation %></p>
+
+ <p><%= submit_tag 'Sign up' %></p>
+ <% end -%>
+</div>
+
+<div class="right">
+ <h2>Navigation</h2>
+ <ul>
+ <li><%= link_to 'Home', root_path %></li>
+ <li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% else %>
+ <li><%= link_to 'Login', login_path %></li>
+ <li><%= link_to 'Sign Up', signup_path %></li>
+ <% end %>
+ </ul>
+</div>
\ No newline at end of file |
| |   |
| 1 | 1 | <div class="middle"> |
| 2 | 2 | <h2>About Rails Undo Redo</h2> |
| 3 | | <p>Just to fill out empty space in the template I decided to write this and to add one of my previous templates |
| 4 | | here. There are direct links to view one of my previous templates live and live link to download it also ;) |
| 5 | | Anyway hope you like both this one and previous one. You can see all of my templates at |
| 6 | | <a href="http://www.minimalistic-design.net">Minimalistic design</a> live.</p> |
| 3 | <p>To learn more about how you can easily implement undo/redo for Active Record and your Ruby and Rails app, visit the Rails Undo Redo (RUR) <a href="http://blog.nanorails.com/rails-undo-redo">Project Page</a>.</p> |
| 7 | 4 | </div> |
| 8 | 5 | |
| 9 | 6 | <div class="right"> |
| … | … | |
| 8 | 8 | <ul> |
| 9 | 9 | <li><%= link_to 'Home', root_path %></li> |
| 10 | 10 | <li><%= link_to 'About', about_path %></li> |
| 11 | <% if logged_in? %> |
| 12 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 13 | <% else %> |
| 14 | <li><%= link_to 'Login', login_path %></li> |
| 15 | <li><%= link_to 'Sign Up', signup_path %></li> |
| 16 | <% end %> |
| 11 | 17 | <li><%= link_to 'Project List', projects_path %></li> |
| 12 | 18 | <li><%= link_to 'New project', new_project_path %></li> |
| 13 | 19 | </ul> |
| toggle raw diff |
--- a/app/views/welcome/about.html.erb
+++ b/app/views/welcome/about.html.erb
@@ -1,9 +1,6 @@
<div class="middle">
<h2>About Rails Undo Redo</h2>
- <p>Just to fill out empty space in the template I decided to write this and to add one of my previous templates
- here. There are direct links to view one of my previous templates live and live link to download it also ;)
- Anyway hope you like both this one and previous one. You can see all of my templates at
- <a href="http://www.minimalistic-design.net">Minimalistic design</a> live.</p>
+ <p>To learn more about how you can easily implement undo/redo for Active Record and your Ruby and Rails app, visit the Rails Undo Redo (RUR) <a href="http://blog.nanorails.com/rails-undo-redo">Project Page</a>.</p>
</div>
<div class="right">
@@ -11,6 +8,12 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% else %>
+ <li><%= link_to 'Login', login_path %></li>
+ <li><%= link_to 'Sign Up', signup_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
<li><%= link_to 'New project', new_project_path %></li>
</ul> |
| |   |
| 1 | 1 | <div class="middle"> |
| 2 | 2 | <h2>Home</h2> |
| 3 | | <p>Just to fill out empty space in the template I decided to write this and to add one of my previous templates |
| 4 | | here. There are direct links to view one of my previous templates live and live link to download it also ;) |
| 5 | | Anyway hope you like both this one and previous one. You can see all of my templates at |
| 6 | | <a href="http://www.minimalistic-design.net">Minimalistic design</a> live.</p> |
| 3 | <p>This web application is an experiment to test a few ideas on how to implement Undo Redo for Rails. Give it a <%= link_to("test drive", signup_path) %>.</p> |
| 4 | <h2>Key ideas</h2> |
| 5 | <ul> |
| 6 | <li>Works across all models</li> |
| 7 | <li>Capture the list of changed objects (UndoRecord)</li> |
| 8 | <li>Group these UndoRecords per User Action (UndoAction)</li> |
| 9 | <li>undo and redo are just a simple matter or replaying the UndoRecord in the right order</li> |
| 10 | </ul> |
| 11 | <p>By using a Rails plugin (or very soon a gem as well), you can very easily transform any Rails Application using Active Record into a full fledged multi level undo/redo application like most desktop application.<p> |
| 12 | <br/> |
| 13 | <p>Notice: This is a demo application, and as such, do not use to store any data you would not want to lose</p> |
| 7 | 14 | </div> |
| 8 | 15 | |
| 9 | 16 | <div class="right"> |
| … | … | |
| 18 | 18 | <ul> |
| 19 | 19 | <li><%= link_to 'Home', root_path %></li> |
| 20 | 20 | <li><%= link_to 'About', about_path %></li> |
| 21 | <% if logged_in? %> |
| 22 | <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li> |
| 23 | <% else %> |
| 24 | <li><%= link_to 'Login', login_path %></li> |
| 25 | <li><%= link_to 'Sign Up', signup_path %></li> |
| 26 | <% end %> |
| 21 | 27 | <li><%= link_to 'Project List', projects_path %></li> |
| 22 | 28 | <li><%= link_to 'New project', new_project_path %></li> |
| 23 | 29 | </ul> |
| toggle raw diff |
--- a/app/views/welcome/index.html.erb
+++ b/app/views/welcome/index.html.erb
@@ -1,9 +1,16 @@
<div class="middle">
<h2>Home</h2>
- <p>Just to fill out empty space in the template I decided to write this and to add one of my previous templates
- here. There are direct links to view one of my previous templates live and live link to download it also ;)
- Anyway hope you like both this one and previous one. You can see all of my templates at
- <a href="http://www.minimalistic-design.net">Minimalistic design</a> live.</p>
+ <p>This web application is an experiment to test a few ideas on how to implement Undo Redo for Rails. Give it a <%= link_to("test drive", signup_path) %>.</p>
+ <h2>Key ideas</h2>
+ <ul>
+ <li>Works across all models</li>
+ <li>Capture the list of changed objects (UndoRecord)</li>
+ <li>Group these UndoRecords per User Action (UndoAction)</li>
+ <li>undo and redo are just a simple matter or replaying the UndoRecord in the right order</li>
+ </ul>
+ <p>By using a Rails plugin (or very soon a gem as well), you can very easily transform any Rails Application using Active Record into a full fledged multi level undo/redo application like most desktop application.<p>
+ <br/>
+ <p>Notice: This is a demo application, and as such, do not use to store any data you would not want to lose</p>
</div>
<div class="right">
@@ -11,6 +18,12 @@
<ul>
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
+ <% if logged_in? %>
+ <li><%= link_to "Logout (#{h current_user.login})", logout_path %></li>
+ <% else %>
+ <li><%= link_to 'Login', login_path %></li>
+ <li><%= link_to 'Sign Up', signup_path %></li>
+ <% end %>
<li><%= link_to 'Project List', projects_path %></li>
<li><%= link_to 'New project', new_project_path %></li>
</ul> |
| |   |
| 1 | 1 | ActionController::Routing::Routes.draw do |map| |
| 2 | map.resources :users |
| 3 | |
| 4 | map.resource :session |
| 5 | |
| 2 | 6 | map.resources :projects do |task| |
| 3 | 7 | task.resources :tasks, :member => { :move => :get, :move_to => :post } |
| 4 | 8 | end |
| … | … | |
| 40 | 40 | map.undo 'undo', :controller => "welcome", :action => "undo" |
| 41 | 41 | map.redo 'redo', :controller => "welcome", :action => "redo" |
| 42 | 42 | |
| 43 | # authentication |
| 44 | map.signup '/signup', :controller => 'users', :action => 'new' |
| 45 | map.login '/login', :controller => 'sessions', :action => 'new' |
| 46 | map.logout '/logout', :controller => 'sessions', :action => 'destroy' |
| 47 | |
| 43 | 48 | |
| 44 | 49 | # Install the default routes as the lowest priority. |
| 45 | 50 | map.connect ':controller/:action/:id' |
| toggle raw diff |
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,8 @@
ActionController::Routing::Routes.draw do |map|
+ map.resources :users
+
+ map.resource :session
+
map.resources :projects do |task|
task.resources :tasks, :member => { :move => :get, :move_to => :post }
end
@@ -36,6 +40,11 @@ ActionController::Routing::Routes.draw do |map|
map.undo 'undo', :controller => "welcome", :action => "undo"
map.redo 'redo', :controller => "welcome", :action => "redo"
+ # authentication
+ map.signup '/signup', :controller => 'users', :action => 'new'
+ map.login '/login', :controller => 'sessions', :action => 'new'
+ map.logout '/logout', :controller => 'sessions', :action => 'destroy'
+
# Install the default routes as the lowest priority.
map.connect ':controller/:action/:id' |