about summary refs log tree commit diff
path: root/app/views
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-05 22:43:05 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-05 22:43:05 +0100
commit6045b6cb1880b27e8b21799b9501a794a5f5b88b (patch)
tree415169b028c44d15da6a4ddaf152175ff8f1fcc0 /app/views
parent7e93da3f8d31041034ba4eece5ee7a2cec5cfd2b (diff)
Customizing devise views and controllers
Diffstat (limited to 'app/views')
-rw-r--r--app/views/auth/mailer/password_change.html.erb3
-rw-r--r--app/views/auth/mailer/reset_password_instructions.html.erb8
-rw-r--r--app/views/auth/passwords/edit.html.erb25
-rw-r--r--app/views/auth/passwords/new.html.haml9
-rw-r--r--app/views/auth/registrations/edit.html.haml11
-rw-r--r--app/views/auth/registrations/new.html.haml17
-rw-r--r--app/views/auth/sessions/new.html.haml9
-rw-r--r--app/views/auth/shared/_links.html.haml19
-rw-r--r--app/views/home/index.html.haml2
-rw-r--r--app/views/layouts/application.html.haml5
-rw-r--r--app/views/layouts/auth.html.haml10
11 files changed, 114 insertions, 4 deletions
diff --git a/app/views/auth/mailer/password_change.html.erb b/app/views/auth/mailer/password_change.html.erb
new file mode 100644
index 000000000..b41daf476
--- /dev/null
+++ b/app/views/auth/mailer/password_change.html.erb
@@ -0,0 +1,3 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>We're contacting you to notify you that your password has been changed.</p>
diff --git a/app/views/auth/mailer/reset_password_instructions.html.erb b/app/views/auth/mailer/reset_password_instructions.html.erb
new file mode 100644
index 000000000..f667dc12f
--- /dev/null
+++ b/app/views/auth/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
+<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: @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>
diff --git a/app/views/auth/passwords/edit.html.erb b/app/views/auth/passwords/edit.html.erb
new file mode 100644
index 000000000..6a796b050
--- /dev/null
+++ b/app/views/auth/passwords/edit.html.erb
@@ -0,0 +1,25 @@
+<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="field">
+    <%= f.label :password, "New password" %><br />
+    <% if @minimum_password_length %>
+      <em>(<%= @minimum_password_length %> characters minimum)</em><br />
+    <% end %>
+    <%= f.password_field :password, autofocus: true, autocomplete: "off" %>
+  </div>
+
+  <div class="field">
+    <%= f.label :password_confirmation, "Confirm new password" %><br />
+    <%= f.password_field :password_confirmation, autocomplete: "off" %>
+  </div>
+
+  <div class="actions">
+    <%= f.submit "Change my password" %>
+  </div>
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/auth/passwords/new.html.haml b/app/views/auth/passwords/new.html.haml
new file mode 100644
index 000000000..2677feea0
--- /dev/null
+++ b/app/views/auth/passwords/new.html.haml
@@ -0,0 +1,9 @@
+= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
+  = devise_error_messages!
+
+  .field
+    = f.email_field :email, autofocus: true, required: true, placeholder: 'E-mail address'
+  .actions
+    = f.button "Reset password", type: 'submit'
+
+.form-footer= render "auth/shared/links"
diff --git a/app/views/auth/registrations/edit.html.haml b/app/views/auth/registrations/edit.html.haml
new file mode 100644
index 000000000..943230b34
--- /dev/null
+++ b/app/views/auth/registrations/edit.html.haml
@@ -0,0 +1,11 @@
+= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
+  = devise_error_messages!
+
+  .field
+    = f.password_field :password, autocomplete: "off", placeholder: 'New password'
+  .field
+    = f.password_field :password_confirmation, autocomplete: "off", placeholder: 'Confirm new password'
+  .field
+    = f.password_field :current_password, autocomplete: "off", placeholder: 'Current password'
+  .actions
+    = f.button "Save changes", type: 'submit'
diff --git a/app/views/auth/registrations/new.html.haml b/app/views/auth/registrations/new.html.haml
new file mode 100644
index 000000000..c8532ec38
--- /dev/null
+++ b/app/views/auth/registrations/new.html.haml
@@ -0,0 +1,17 @@
+= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
+  = devise_error_messages!
+
+  = f.fields_for :account do |ff|
+    .field
+      = ff.text_field :username, autofocus: true, placeholder: 'Username', required: true
+
+  .field
+    = f.email_field :email, placeholder: 'E-mail address', required: true
+  .field
+    = f.password_field :password, autocomplete: "off", placeholder: 'Password', required: true
+  .field
+    = f.password_field :password_confirmation, autocomplete: "off", placeholder: 'Confirm password', required: true
+  .actions
+    = f.button "Sign up", type: 'submit'
+
+.form-footer= render "auth/shared/links"
diff --git a/app/views/auth/sessions/new.html.haml b/app/views/auth/sessions/new.html.haml
new file mode 100644
index 000000000..220d0ec79
--- /dev/null
+++ b/app/views/auth/sessions/new.html.haml
@@ -0,0 +1,9 @@
+= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
+  .field
+    = f.email_field :email, autofocus: true, placeholder: 'E-mail address', required: true
+  .field
+    = f.password_field :password, autocomplete: "off", placeholder: 'Password', required: true
+  .actions
+    = f.button "Log in", type: 'submit'
+
+.form-footer= render "auth/shared/links"
diff --git a/app/views/auth/shared/_links.html.haml b/app/views/auth/shared/_links.html.haml
new file mode 100644
index 000000000..6f89eed75
--- /dev/null
+++ b/app/views/auth/shared/_links.html.haml
@@ -0,0 +1,19 @@
+%ul.no-list
+  - if controller_name != 'sessions'
+    %li= link_to "Log in", new_session_path(resource_name)
+
+  - if devise_mapping.registerable? && controller_name != 'registrations'
+    %li= link_to "Sign up", new_registration_path(resource_name)
+
+  - if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations'
+    %li= link_to "Forgot your password?", new_password_path(resource_name)
+
+  - if devise_mapping.confirmable? && controller_name != 'confirmations'
+    %li= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name)
+
+  - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
+    %li= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name)
+
+  - if devise_mapping.omniauthable?
+    - resource_class.omniauth_providers.each do |provider|
+      %li= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider)
diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml
index 862374a98..11894d72c 100644
--- a/app/views/home/index.html.haml
+++ b/app/views/home/index.html.haml
@@ -1 +1,3 @@
 Mastodon
+
+= link_to 'Logout', destroy_user_session_path, method: :delete
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index f15217203..25b3b5b49 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -9,7 +9,4 @@
     = yield :header_tags
   %body
     .container
-      = yield
-    .footer
-      Powered by
-      = link_to 'Mastodon', 'https://github.com/Gargron/mastodon', class: 'mastodon-link'
+      = content_for?(:content) ? yield(:content) : yield
diff --git a/app/views/layouts/auth.html.haml b/app/views/layouts/auth.html.haml
new file mode 100644
index 000000000..dd0e7f166
--- /dev/null
+++ b/app/views/layouts/auth.html.haml
@@ -0,0 +1,10 @@
+- content_for :content do
+  .logo-container
+    %h1
+      Mastodon
+      %small= Rails.configuration.x.local_domain
+
+  .form-container
+    = yield
+
+= render template: "layouts/application"