Skip to content
Browse files

Well, changed A LOT of things

Added HAML, Font Awesome and Paper Clip Gems
Added username to user attributes
Added profile picture upload feature
Create profile page to each user "/username"
  • Loading branch information...
1 parent a0c3294 commit 8e3ae73ca00bddae7c45fb883a679d38bc471819 @hugodias committed Oct 13, 2013
Showing with 449 additions and 354 deletions.
  1. +10 −0 Gemfile
  2. +3 −0 app/assets/javascripts/dashboard.js.coffee
  3. +3 −0 app/assets/javascripts/registrations.js.coffee
  4. +3 −0 app/assets/javascripts/users.js.coffee
  5. +3 −0 app/assets/javascripts/users/registration.js.coffee
  6. +5 −0 app/assets/stylesheets/application.css.scss
  7. +3 −0 app/assets/stylesheets/dashboard.css.scss
  8. +3 −0 app/assets/stylesheets/registrations.css.scss
  9. +3 −0 app/assets/stylesheets/users.css.scss
  10. +3 −0 app/assets/stylesheets/users/registration.css.scss
  11. +3 −0 app/controllers/application_controller.rb
  12. +6 −0 app/controllers/dashboard_controller.rb
  13. +34 −0 app/controllers/registrations_controller.rb
  14. +5 −0 app/controllers/users_controller.rb
  15. +2 −0 app/helpers/dashboard_helper.rb
  16. +2 −0 app/helpers/registrations_helper.rb
  17. +2 −0 app/helpers/users/registrations_helper.rb
  18. +2 −0 app/helpers/users_helper.rb
  19. +9 −1 app/models/user.rb
  20. +0 −3 app/views/admins/index.html.erb
  21. +2 −0 app/views/admins/index.html.haml
  22. 0 app/views/admins/{manage.html.erb → manage.html.haml}
  23. +1 −0 app/views/dashboard/index.html.haml
  24. +0 −22 app/views/devise/confirmations/new.html.erb
  25. +11 −0 app/views/devise/confirmations/new.html.haml
  26. +0 −5 app/views/devise/mailer/confirmation_instructions.html.erb
  27. +4 −0 app/views/devise/mailer/confirmation_instructions.html.haml
  28. +0 −8 app/views/devise/mailer/reset_password_instructions.html.erb
  29. +6 −0 app/views/devise/mailer/reset_password_instructions.html.haml
  30. +0 −7 app/views/devise/mailer/unlock_instructions.html.erb
  31. +5 −0 app/views/devise/mailer/unlock_instructions.html.haml
  32. +0 −26 app/views/devise/passwords/edit.html.erb
  33. +15 −0 app/views/devise/passwords/edit.html.haml
  34. +0 −21 app/views/devise/passwords/new.html.erb
  35. +11 −0 app/views/devise/passwords/new.html.haml
  36. +0 −29 app/views/devise/registrations/edit.html.erb
  37. +45 −0 app/views/devise/registrations/edit.html.haml
  38. +0 −30 app/views/devise/registrations/new.html.erb
  39. +17 −0 app/views/devise/registrations/new.html.haml
  40. +0 −31 app/views/devise/sessions/new.html.erb
  41. +17 −0 app/views/devise/sessions/new.html.haml
  42. +0 −25 app/views/devise/shared/_links.erb
  43. +19 −0 app/views/devise/shared/_links.haml
  44. +0 −21 app/views/devise/unlocks/new.html.erb
  45. +12 −0 app/views/devise/unlocks/new.html.haml
  46. 0 app/views/home/{secret.html.erb → secret.html.haml}
  47. +0 −5 app/views/home/token.html.erb
  48. +4 −0 app/views/home/token.html.haml
  49. +0 −112 app/views/layouts/application.html.erb
  50. +96 −0 app/views/layouts/application.html.haml
  51. +9 −0 app/views/users/show.html.haml
  52. +9 −4 config/routes.rb
  53. +1 −0 db/development.sqlit3
  54. +11 −0 db/migrate/20131012181224_add_attachment_avatar_to_users.rb
  55. +5 −0 db/migrate/20131012235622_add_username_to_users.rb
  56. +1 −4 install.sh
  57. BIN public/system/users/avatars/000/000/001/medium/Startup-ideas.png
  58. BIN public/system/users/avatars/000/000/001/original/Startup-ideas.png
  59. BIN public/system/users/avatars/000/000/001/thumb/Startup-ideas.png
  60. BIN public/system/users/avatars/000/000/002/medium/Startup-ideas.png
  61. BIN public/system/users/avatars/000/000/002/original/Startup-ideas.png
  62. BIN public/system/users/avatars/000/000/002/thumb/Startup-ideas.png
  63. BIN public/system/users/avatars/000/000/003/medium/DSC03196.JPG
  64. BIN public/system/users/avatars/000/000/003/original/DSC03196.JPG
  65. BIN public/system/users/avatars/000/000/003/thumb/DSC03196.JPG
  66. +7 −0 test/controllers/dashboard_controller_test.rb
  67. +7 −0 test/controllers/registrations_controller_test.rb
  68. +7 −0 test/controllers/users/registration_controller_test.rb
  69. +7 −0 test/controllers/users_controller_test.rb
  70. +4 −0 test/helpers/dashboard_helper_test.rb
  71. +4 −0 test/helpers/registrations_helper_test.rb
  72. +4 −0 test/helpers/users/registration_helper_test.rb
  73. +4 −0 test/helpers/users_helper_test.rb
View
10 Gemfile
@@ -11,6 +11,9 @@ gem 'devise', :git => 'git://github.com/plataformatec/devise.git', :ref => '49ae
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
+gem 'haml'
+gem 'haml-rails', :group => :development
+
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
@@ -26,12 +29,19 @@ gem 'coffee-rails', '~> 4.0.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
+# FontAwesome
+gem 'font-awesome-rails'
+
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
+gem 'protected_attributes'
+
+gem 'paperclip', '~> 3.0'
+
# Twitter Bootstrap 3
gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
:github => 'anjlab/bootstrap-rails'
View
3 app/assets/javascripts/dashboard.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
View
3 app/assets/javascripts/registrations.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
View
3 app/assets/javascripts/users.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
View
3 app/assets/javascripts/users/registration.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
View
5 app/assets/stylesheets/application.css.scss
@@ -1 +1,6 @@
+@import "font-awesome";
@import "twitter/bootstrap";
+
+.center{
+ text-align: center;
+}
View
3 app/assets/stylesheets/dashboard.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the dashboard controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
3 app/assets/stylesheets/registrations.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the registrations controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
3 app/assets/stylesheets/users.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the users controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
3 app/assets/stylesheets/users/registration.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the users/registration controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
3 app/controllers/application_controller.rb
@@ -10,4 +10,7 @@ def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit! }
end
+
+
+
end
View
6 app/controllers/dashboard_controller.rb
@@ -0,0 +1,6 @@
+class DashboardController < ApplicationController
+ before_action :authenticate_user!
+
+ def index
+ end
+end
View
34 app/controllers/registrations_controller.rb
@@ -0,0 +1,34 @@
+class RegistrationsController < Devise::RegistrationsController
+ def update
+ @user = User.find(current_user.id)
+
+ successfully_updated = if needs_password?(@user, params)
+ @user.update_with_password(params[:user])
+ else
+ # remove the virtual current_password attribute update_without_password
+ # doesn't know how to ignore it
+ params[:user].delete(:current_password)
+ @user.update_without_password(params[:user])
+ end
+
+ if successfully_updated
+ set_flash_message :notice, :updated
+ # Sign in the user bypassing validation in case his password changed
+ sign_in @user, :bypass => true
+ redirect_to after_update_path_for(@user)
+ else
+ render "edit"
+ end
+ end
+
+ private
+
+ # check if we need password to update user data
+ # ie if password or email was changed
+ # extend this as needed
+ def needs_password?(user, params)
+ user.email != params[:user][:email] ||
+ params[:user][:password].present? ||
+ user.username != params[:user][:username]
+ end
+end
View
5 app/controllers/users_controller.rb
@@ -0,0 +1,5 @@
+class UsersController < ApplicationController
+ def show
+ @user = User.where(:username => params[:username]).first
+ end
+end
View
2 app/helpers/dashboard_helper.rb
@@ -0,0 +1,2 @@
+module DashboardHelper
+end
View
2 app/helpers/registrations_helper.rb
@@ -0,0 +1,2 @@
+module RegistrationsHelper
+end
View
2 app/helpers/users/registrations_helper.rb
@@ -0,0 +1,2 @@
+module Users::RegistrationsHelper
+end
View
2 app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
View
10 app/models/user.rb
@@ -1,7 +1,15 @@
class User < ActiveRecord::Base
+ attr_accessible :avatar, :email, :password, :password_confirmation, :username
+ has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "images/:style/missing.png"
+
+ before_create :set_username
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
- :token_authenticatable, :confirmable, :lockable
+ :token_authenticatable, :lockable
+ private
+ def set_username
+ self.username = self.email[/^[^@]+/]
+ end
end
View
3 app/views/admins/index.html.erb
@@ -1,3 +0,0 @@
-<% title 'Admin' -%>
-
-<p>Welcome to Admin Section.</p>
View
2 app/views/admins/index.html.haml
@@ -0,0 +1,2 @@
+- title 'Admin'
+%p Welcome to Admin Section.
View
0 app/views/admins/manage.html.erb → app/views/admins/manage.html.haml
File renamed without changes.
View
1 app/views/dashboard/index.html.haml
@@ -0,0 +1 @@
+%h2 Hello, #{current_user.username.humanize}!
View
22 app/views/devise/confirmations/new.html.erb
@@ -1,22 +0,0 @@
-<div class="row">
- <div class="col-md-6 col-md-offset-3">
- <h2>Resend confirmation instructions</h2>
- <%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => {:method => :post}) do |f| %>
- <%= devise_error_messages! %>
-
- <div class="form-group">
- <%= f.label :email %>
- <%= f.email_field :email, :autofocus => true, :class => "form-control" %>
- </div>
-
- <div class="form-group">
- <%= f.submit "Resend confirmation instructions", :class => "btn btn-info" %>
- </div>
- <% end %>
-
- <%= render "devise/shared/links" %>
-
- </div>
-</div>
-
-
View
11 app/views/devise/confirmations/new.html.haml
@@ -0,0 +1,11 @@
+.row
+ .col-md-6.col-md-offset-3
+ %h2 Resend confirmation instructions
+ = form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => {:method => :post}) do |f|
+ = devise_error_messages!
+ .form-group
+ = f.label :email
+ = f.email_field :email, :autofocus => true, :class => "form-control"
+ .form-group
+ = f.submit "Resend confirmation instructions", :class => "btn btn-info"
+ = render "devise/shared/links"
View
5 app/views/devise/mailer/confirmation_instructions.html.erb
@@ -1,5 +0,0 @@
-<p>Welcome <%= @email %>!</p>
-
-<p>You can confirm your account email through the link below:</p>
-
-<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
View
4 app/views/devise/mailer/confirmation_instructions.html.haml
@@ -0,0 +1,4 @@
+%p
+ Welcome #{@email}!
+%p You can confirm your account email through the link below:
+%p= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token)
View
8 app/views/devise/mailer/reset_password_instructions.html.erb
@@ -1,8 +0,0 @@
-<p>Hello <%= @resource.email %>!</p>
-
-<p>Someone has requested a link to change your password. You can do this through the link below.</p>
-
-<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
-
-<p>If you didn't request this, please ignore this email.</p>
-<p>Your password won't change until you access the link above and create a new one.</p>
View
6 app/views/devise/mailer/reset_password_instructions.html.haml
@@ -0,0 +1,6 @@
+%p
+ Hello #{@resource.email}!
+%p Someone has requested a link to change your password. You can do this through the link below.
+%p= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token)
+%p If you didn't request this, please ignore this email.
+%p Your password won't change until you access the link above and create a new one.
View
7 app/views/devise/mailer/unlock_instructions.html.erb
@@ -1,7 +0,0 @@
-<p>Hello <%= @resource.email %>!</p>
-
-<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
-
-<p>Click the link below to unlock your account:</p>
-
-<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
View
5 app/views/devise/mailer/unlock_instructions.html.haml
@@ -0,0 +1,5 @@
+%p
+ Hello #{@resource.email}!
+%p Your account has been locked due to an excessive number of unsuccessful sign in attempts.
+%p Click the link below to unlock your account:
+%p= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token)
View
26 app/views/devise/passwords/edit.html.erb
@@ -1,26 +0,0 @@
-<div class="row">
- <div class="col-md-6 col-md-offset-3">
- <h2>Change your password</h2>
-
- <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => {:method => :put}) do |f| %>
- <%= devise_error_messages! %>
- <%= f.hidden_field :reset_password_token %>
-
- <div class="form-group">
- <%= f.label :password, "New password" %>
- <%= f.password_field :password, :autofocus => true, :class => "form-control" %>
- </div>
-
- <div class="form-group">
- <%= f.label :password_confirmation, "Confirm new password" %>
- <%= f.password_field :password_confirmation, :class => "form-control" %>
- </div>
-
- <div class="form-group">
- <%= f.submit "Change my password", :class => "btn btn-info" %>
- </div>
- <% end %>
-
- <%= render "devise/shared/links" %>
- </div>
-</div>
View
15 app/views/devise/passwords/edit.html.haml
@@ -0,0 +1,15 @@
+.row
+ .col-md-6.col-md-offset-3
+ %h2 Change your password
+ = form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => {:method => :put}) do |f|
+ = devise_error_messages!
+ = f.hidden_field :reset_password_token
+ .form-group
+ = f.label :password, "New password"
+ = f.password_field :password, :autofocus => true, :class => "form-control"
+ .form-group
+ = f.label :password_confirmation, "Confirm new password"
+ = f.password_field :password_confirmation, :class => "form-control"
+ .form-group
+ = f.submit "Change my password", :class => "btn btn-info"
+ = render "devise/shared/links"
View
21 app/views/devise/passwords/new.html.erb
@@ -1,21 +0,0 @@
-<div class="row">
- <div class="col-md-6 col-md-offset-3">
- <h2>Forgot your password?</h2>
-
- <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => {:method => :post}) do |f| %>
- <%= devise_error_messages! %>
-
- <div class="form-group">
- <%= f.label :email %>
- <%= f.email_field :email, :autofocus => true, :class => "form-control" %>
- </div>
-
- <div class="form-group">
- <%= f.submit "Send me reset password instructions", :class => "btn btn-info" %>
- </div>
- <% end %>
-
- <%= render "devise/shared/links" %>
-
- </div>
-</div>
View
11 app/views/devise/passwords/new.html.haml
@@ -0,0 +1,11 @@
+.row
+ .col-md-6.col-md-offset-3
+ %h2 Forgot your password?
+ = form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => {:method => :post}) do |f|
+ = devise_error_messages!
+ .form-group
+ = f.label :email
+ = f.email_field :email, :autofocus => true, :class => "form-control"
+ .form-group
+ = f.submit "Send me reset password instructions", :class => "btn btn-info"
+ = render "devise/shared/links"
View
29 app/views/devise/registrations/edit.html.erb
@@ -1,29 +0,0 @@
-<h2>Edit <%= resource_name.to_s.humanize %></h2>
-
-<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
- <%= devise_error_messages! %>
-
- <div><%= f.label :email %><br />
- <%= f.email_field :email, :autofocus => true %></div>
-
- <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
- <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
- <% end %>
-
- <div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
- <%= f.password_field :password, :autocomplete => "off" %></div>
-
- <div><%= f.label :password_confirmation %><br />
- <%= f.password_field :password_confirmation %></div>
-
- <div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
- <%= f.password_field :current_password %></div>
-
- <div><%= f.submit "Update" %></div>
-<% end %>
-
-<h3>Cancel my account</h3>
-
-<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %></p>
-
-<%= link_to "Back", :back %>
View
45 app/views/devise/registrations/edit.html.haml
@@ -0,0 +1,45 @@
+.row
+ .col-md-6.col-md-offset-3
+ %h2
+ Edit your profile
+ %hr
+ = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :multipart => true }) do |f|
+ = devise_error_messages!
+ %div.form-group
+ = f.label :email
+ = f.email_field :email, :autofocus => true, :class => "form-control"
+ - if devise_mapping.confirmable? && resource.pending_reconfirmation?
+ %div
+ Currently waiting confirmation for: #{resource.unconfirmed_email}
+ %div.form-group
+ = f.label :username
+ = f.text_field :username, :class => "form-control"
+ %div.form-group.well
+ .row
+ .col-md-3
+ = image_tag current_user.avatar.url(:thumb)
+ .col-md-9
+ = f.label :avatar
+ = f.file_field :avatar
+ %hr
+ %h4 Change password
+ %div.well
+ %div.form-group
+ = f.label :password
+ %i (leave blank if you don't want to change it)
+ = f.password_field :password, :autocomplete => "off", :class => "form-control"
+ %div.form-group
+ = f.label :password_confirmation
+ = f.password_field :password_confirmation, :class => "form-control"
+ %hr
+ %div.form-group.well
+ = f.label :current_password
+ %i (we need your current password to confirm your changes)
+ = f.password_field :current_password, :class => "form-control"
+ %div.form-group
+ = f.submit "Update", :class => "btn btn-primary"
+ %a{:href => user_profile_path(current_user.username), :class => 'btn btn-default'} View Profile
+ %hr
+ %h3 Cancel my account
+ %p
+ Unhappy? #{button_to "Cancel my account", registration_path(resource_name), :class => "btn btn-danger", :data => { :confirm => "Are you sure?" }, :method => :delete}
View
30 app/views/devise/registrations/new.html.erb
@@ -1,30 +0,0 @@
-<div class="row">
- <div class="col-md-6 col-md-offset-3">
- <h2>Sign up</h2>
-
- <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
- <%= devise_error_messages! %>
- <div class="form-group">
- <%= f.label :email %>
- <%= f.email_field :email, :autofocus => true, :class => "form-control" %>
- </div>
-
- <div class="form-group">
- <%= f.label :password %>
- <%= f.password_field :password, :class => "form-control" %>
- </div>
-
- <div class="form-group">
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, :class => "form-control" %>
- </div>
-
- <div class="form-group">
- <%= f.submit "Sign up", :class => "btn btn-success" %>
- </div>
- <% end %>
-
- <%= render "devise/shared/links" %>
-
- </div>
-</div>
View
17 app/views/devise/registrations/new.html.haml
@@ -0,0 +1,17 @@
+.row
+ .col-md-6.col-md-offset-3
+ %h2 Sign up
+ = form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
+ = devise_error_messages!
+ .form-group
+ = f.label :email
+ = f.email_field :email, :autofocus => true, :class => "form-control"
+ .form-group
+ = f.label :password
+ = f.password_field :password, :class => "form-control"
+ .form-group
+ = f.label :password_confirmation
+ = f.password_field :password_confirmation, :class => "form-control"
+ .form-group
+ = f.submit "Sign up", :class => "btn btn-success"
+ = render "devise/shared/links"
View
31 app/views/devise/sessions/new.html.erb
@@ -1,31 +0,0 @@
-<div class="row">
- <div class="col-md-6 col-md-offset-3">
- <h2>Sign in</h2>
-
- <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
- <div class="form-group">
- <%= f.label :email %>
- <%= f.email_field :email, :autofocus => true, :class => "form-control" %>
- </div>
-
- <div class="form-group">
- <%= f.label :password %>
- <%= f.password_field :password, :class => "form-control" %>
- </div>
-
- <% if devise_mapping.rememberable? -%>
- <div class="form-group">
- <%= f.check_box :remember_me %>
- <%= f.label :remember_me %>
- </div>
- <% end -%>
-
- <div class="form-group">
- <%= f.submit "Sign in", :class => "btn btn-primary" %>
- </div>
- <% end %>
-
- <%= render "devise/shared/links" %>
-
- </div>
-</div>
View
17 app/views/devise/sessions/new.html.haml
@@ -0,0 +1,17 @@
+.row
+ .col-md-6.col-md-offset-3
+ %h2 Sign in
+ = form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
+ .form-group
+ = f.label :email
+ = f.email_field :email, :autofocus => true, :class => "form-control"
+ .form-group
+ = f.label :password
+ = f.password_field :password, :class => "form-control"
+ - if devise_mapping.rememberable?
+ .form-group
+ = f.check_box :remember_me
+ = f.label :remember_me
+ .form-group
+ = f.submit "Sign in", :class => "btn btn-primary"
+ = render "devise/shared/links"
View
25 app/views/devise/shared/_links.erb
@@ -1,25 +0,0 @@
-<%- if controller_name != 'sessions' %>
- <%= link_to "Sign in", new_session_path(resource_name) %><br />
-<% end -%>
-
-<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
- <%= link_to "Sign up", new_registration_path(resource_name) %><br />
-<% end -%>
-
-<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
- <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
-<% end -%>
-
-<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
- <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
-<% end -%>
-
-<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
- <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
-<% end -%>
-
-<%- if devise_mapping.omniauthable? %>
- <%- resource_class.omniauth_providers.each do |provider| %>
- <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
- <% end -%>
-<% end -%>
View
19 app/views/devise/shared/_links.haml
@@ -0,0 +1,19 @@
+- if controller_name != 'sessions'
+ = link_to "Sign in", new_session_path(resource_name)
+ %br/
+- if devise_mapping.registerable? && controller_name != 'registrations'
+ = link_to "Sign up", new_registration_path(resource_name)
+ %br/
+- if devise_mapping.recoverable? && controller_name != 'passwords'
+ = link_to "Forgot your password?", new_password_path(resource_name)
+ %br/
+- if devise_mapping.confirmable? && controller_name != 'confirmations'
+ = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name)
+ %br/
+- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
+ = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name)
+ %br/
+- if devise_mapping.omniauthable?
+ - resource_class.omniauth_providers.each do |provider|
+ = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)
+ %br/
View
21 app/views/devise/unlocks/new.html.erb
@@ -1,21 +0,0 @@
-<div class="row">
- <div class="col-md-6 col-md-offset-3">
- <h2>Resend unlock instructions</h2>
-
- <%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => {:method => :post}) do |f| %>
- <%= devise_error_messages! %>
-
- <div class="form-group">
- <%= f.label :email %>
- <br/>
- <%= f.email_field :email, :autofocus => true, :class => "form-control" %>
- </div>
-
- <div class="form-group">
- <%= f.submit "Resend unlock instructions", :class => "btn btn-info" %>
- </div>
- <% end %>
-
- <%= render "devise/shared/links" %>
- </div>
-</div>
View
12 app/views/devise/unlocks/new.html.haml
@@ -0,0 +1,12 @@
+.row
+ .col-md-6.col-md-offset-3
+ %h2 Resend unlock instructions
+ = form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => {:method => :post}) do |f|
+ = devise_error_messages!
+ .form-group
+ = f.label :email
+ %br/
+ = f.email_field :email, :autofocus => true, :class => "form-control"
+ .form-group
+ = f.submit "Resend unlock instructions", :class => "btn btn-info"
+ = render "devise/shared/links"
View
0 app/views/home/secret.html.erb → app/views/home/secret.html.haml
File renamed without changes.
View
5 app/views/home/token.html.erb
@@ -1,5 +0,0 @@
-<h1>Hello, <%= current_user.email %></h1>
-
-<p>This link (with the auth_token param) will work even if you're not signed in.</p>
-
-<p>Save this link, sign out, and try it!</p>
View
4 app/views/home/token.html.haml
@@ -0,0 +1,4 @@
+%h1
+ Hello, #{current_user.email}
+%p This link (with the auth_token param) will work even if you're not signed in.
+%p Save this link, sign out, and try it!
View
112 app/views/layouts/application.html.erb
@@ -1,112 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
- <head>
- <title><%= h(yield(:title) || RailStrap::Application.config.application_name ) %></title>
- <%= csrf_meta_tag %>
- <%= stylesheet_link_tag "application", media: "all" %>
- <%= javascript_include_tag :application %>
- <%= yield(:head) %>
- <style>
- /* Sticky footer styles
- -------------------------------------------------- */
-
- html,
- body {
- height: 100%;
- /* The html and body elements cannot have any padding or margin. */
- }
-
- /* Wrapper for page content to push down footer */
- #wrap {
- min-height: 100%;
- height: auto !important;
- height: 100%;
- /* Negative indent footer by its height */
- margin: 0 auto -60px;
- /* Pad bottom by footer height */
- padding: 0 0 60px;
- }
-
- /* Set the fixed height of the footer here */
- #footer {
- height: 60px;
- background-color: #f5f5f5;
- }
-
-
- /* Custom page CSS
- -------------------------------------------------- */
- /* Not required for template or sticky footer method. */
-
- #wrap > .container {
- padding: 60px 15px 0;
- }
- .container .credit {
- margin: 20px 0;
- }
-
- #footer > .container {
- padding-left: 15px;
- padding-right: 15px;
- }
-
- code {
- font-size: 80%;
- }
- </style>
- </head>
- <body>
-
- <div id="wrap">
-
- <!-- Fixed navbar -->
- <div class="navbar navbar-default navbar-fixed-top">
- <div class="container">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <%= link_to RailStrap::Application.config.application_name , root_path, :class => 'navbar-brand' %>
- </div>
- <div class="collapse navbar-collapse">
- <ul class="nav navbar-nav">
- <% if user_signed_in? -%>
- <li><%= current_user.email %></li>
- <li><%= link_to 'My info', edit_user_registration_path %></li>
- <li><%= link_to 'Sign out', destroy_user_session_path, method: :delete %></li>
- <% end -%>
- <% if admin_signed_in? -%>
- <li><%= current_admin.email %></li>
- <li><%= link_to 'Admin section', admins_path %></li>
- <li><%= link_to 'Manage users', manage_path %></li>
- <li><%= link_to 'Sign out', destroy_admin_session_path, method: :delete %></li>
- <% end -%>
- </ul>
- </div><!--/.nav-collapse -->
- </div>
- </div>
-
- <!-- Begin page content -->
- <div class="container">
- <%- flash.each do |name, msg| -%>
- <%= content_tag :div, msg, id: "flash_#{name}" if msg.is_a?(String) %>
- <%- end -%>
- <%- if show_title? -%>
- <h1><%=h yield(:title) %></h1>
- <%- end -%>
-
- <%= yield %>
- </div>
- </div>
-
- <div id="footer">
- <div class="container">
- <p class="text-muted credit"><%= RailStrap::Application.config.application_name %> @ <%= Time.now.year %>.</p>
- </div>
- </div>
-
- </body>
-</html>
View
96 app/views/layouts/application.html.haml
@@ -0,0 +1,96 @@
+!!! Strict
+%html
+ %head
+ %title= h(yield(:title) || RailStrap::Application.config.application_name )
+ = csrf_meta_tag
+ = stylesheet_link_tag "application", media: "all"
+ = javascript_include_tag :application
+ = yield(:head)
+ :css
+ /* Sticky footer styles
+ -------------------------------------------------- */
+
+ html,
+ body {
+ height: 100%;
+ /* The html and body elements cannot have any padding or margin. */
+ }
+
+ /* Wrapper for page content to push down footer */
+ #wrap {
+ min-height: 100%;
+ height: auto !important;
+ height: 100%;
+ /* Negative indent footer by its height */
+ margin: 0 auto -60px;
+ /* Pad bottom by footer height */
+ padding: 0 0 60px;
+ }
+
+ /* Set the fixed height of the footer here */
+ #footer {
+ height: 60px;
+ background-color: #f5f5f5;
+ }
+
+
+ /* Custom page CSS
+ -------------------------------------------------- */
+ /* Not required for template or sticky footer method. */
+
+ #wrap > .container {
+ padding: 80px 15px 0;
+ }
+ .container .credit {
+ margin: 20px 0;
+ }
+
+ #footer > .container {
+ padding-left: 15px;
+ padding-right: 15px;
+ }
+
+ code {
+ font-size: 80%;
+ }
+ %body
+ #wrap
+ / Fixed navbar
+ .navbar.navbar-default.navbar-fixed-top
+ .container
+ .navbar-header
+ %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", :type => "button"}
+ %span.icon-bar
+ %span.icon-bar
+ %span.icon-bar
+ = link_to RailStrap::Application.config.application_name , root_path, :class => 'navbar-brand'
+ .collapse.navbar-collapse
+ %ul.nav.navbar-nav.pull-right
+ - if user_signed_in?
+ %li
+ %a{:href => edit_user_registration_path}
+ = fa_icon "cogs"
+ Edit profile
+ %li
+ %a{:href => user_profile_path(current_user.username)}
+ = fa_icon "user"
+ Me
+ %li= link_to 'Sign out', destroy_user_session_path, method: :delete
+ - if admin_signed_in?
+ %li= current_admin.email
+ %li= link_to 'Admin section', admins_path
+ %li= link_to 'Manage users', manage_path
+ %li= link_to 'Sign out', destroy_admin_session_path, method: :delete
+ / /.nav-collapse
+ / Begin page content
+ .container.container-main
+ - flash.each do |name, msg|
+ = content_tag :div, msg, id: "flash_#{name}" if msg.is_a?(String)
+ - if show_title?
+ %h1= h yield(:title)
+ = yield
+ #footer
+ .container
+ %p.text-muted.credit
+ = RailStrap::Application.config.application_name
+ @ #{Time.now.year}.
View
9 app/views/users/show.html.haml
@@ -0,0 +1,9 @@
+.row
+ .col-sm-12.col-md-5.col-md-offset-3
+ .thumbnail
+ %img{alt: "...", :src => @user.avatar.url}/
+ .caption.center
+ %h3 #{@user.username.humanize}
+ = fa_icon "envelope"
+ = @user.email
+ %hr
View
13 config/routes.rb
@@ -1,16 +1,21 @@
RailStrap::Application.routes.draw do
- devise_for :users, :admins
+ devise_for :users, :controllers => { :registrations => :registrations }
+ devise_for :admins
get '/token' => 'home#token', as: :token
get '/admins/manage' => 'admins#manage', as: :manage
+ get '/dashboard' => 'dashboard#index', as: :dashboard
+
+ get ':username', to: 'users#show', as: :user_profile
+
resources :home, only: :index
resources :admins
- devise_scope :user do
- root to: "devise/sessions#new"
- end
+ root to: "dashboard#index"
+
+
end
View
1 db/development.sqlit3
@@ -0,0 +1 @@
+S
View
11 db/migrate/20131012181224_add_attachment_avatar_to_users.rb
@@ -0,0 +1,11 @@
+class AddAttachmentAvatarToUsers < ActiveRecord::Migration
+ def self.up
+ change_table :users do |t|
+ t.attachment :avatar
+ end
+ end
+
+ def self.down
+ drop_attached_file :users, :avatar
+ end
+end
View
5 db/migrate/20131012235622_add_username_to_users.rb
@@ -0,0 +1,5 @@
+class AddUsernameToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :username, :string
+ end
+end
View
5 install.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-echo 'Welcome to RailsStrap v0.3 install'
+echo 'Welcome to RailsStrap v0.4 install'
echo
echo
@@ -10,9 +10,6 @@ echo '... Creating your database ...'
rake db:create
rake db:migrate
-echo '... Creating default admin user ... '
-rake db:seed
-
echo '... Database created... '
echo
echo 'To start your server run: rails s'
View
BIN public/system/users/avatars/000/000/001/medium/Startup-ideas.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/system/users/avatars/000/000/001/original/Startup-ideas.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/system/users/avatars/000/000/001/thumb/Startup-ideas.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/system/users/avatars/000/000/002/medium/Startup-ideas.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/system/users/avatars/000/000/002/original/Startup-ideas.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/system/users/avatars/000/000/002/thumb/Startup-ideas.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/system/users/avatars/000/000/003/medium/DSC03196.JPG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/system/users/avatars/000/000/003/original/DSC03196.JPG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/system/users/avatars/000/000/003/thumb/DSC03196.JPG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
7 test/controllers/dashboard_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class DashboardControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
View
7 test/controllers/registrations_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RegistrationsControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
View
7 test/controllers/users/registration_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class Users::RegistrationControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
View
7 test/controllers/users_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UsersControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
View
4 test/helpers/dashboard_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class DashboardHelperTest < ActionView::TestCase
+end
View
4 test/helpers/registrations_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class RegistrationsHelperTest < ActionView::TestCase
+end
View
4 test/helpers/users/registration_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class Users::RegistrationHelperTest < ActionView::TestCase
+end
View
4 test/helpers/users_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class UsersHelperTest < ActionView::TestCase
+end

0 comments on commit 8e3ae73

Please sign in to comment.
Something went wrong with that request. Please try again.