Adding simple_form, adding profile settings, header image

This commit is contained in:
Eugen Rochko 2016-03-12 20:47:22 +01:00
parent 1aa477ac2f
commit 3441361568
21 changed files with 344 additions and 4 deletions

View file

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

@ -1,10 +1,24 @@
.card {
background: $primary-color image-url('background-photo.jpeg');
background: #282c37;
background-size: cover;
padding: 60px 0;
padding-bottom: 10px;
border-radius: 4px 4px 0 0;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
overflow: hidden;
position: relative;
&:after {
background: rgba(0, 0, 0, 0.5);
display: block;
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.name {
display: block;
@ -13,6 +27,8 @@
color: #fff;
font-weight: 500;
text-align: center;
position: relative;
z-index: 2;
small {
display: block;
@ -26,6 +42,8 @@
width: 120px;
margin: 0 auto;
margin-bottom: 15px;
position: relative;
z-index: 2;
img {
width: 120px;
@ -38,6 +56,8 @@
.details {
display: flex;
margin-top: 30px;
position: relative;
z-index: 2;
}
.counter {

View file

@ -0,0 +1,3 @@
// Place all the styles related to the settings controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -0,0 +1,27 @@
class SettingsController < ApplicationController
layout 'dashboard'
before_action :authenticate_user!
before_action :set_account
def show
end
def update
if @account.update(account_params)
redirect_to settings_path
else
render action: :show
end
end
private
def account_params
params.require(:account).permit(:display_name, :note, :avatar, :header)
end
def set_account
@account = current_user.account
end
end

View file

@ -0,0 +1,2 @@
module SettingsHelper
end

View file

@ -8,6 +8,10 @@ class Account < ActiveRecord::Base
has_attached_file :avatar, styles: { large: '300x300#', medium: '96x96#', small: '48x48#' }, default_url: 'avatars/missing.png'
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
# Header upload
has_attached_file :header, styles: { medium: '700x335#' }
validates_attachment_content_type :header, content_type: /\Aimage\/.*\Z/
# Timelines
has_many :stream_entries, inverse_of: :account
has_many :statuses, inverse_of: :account

View file

@ -2,7 +2,7 @@
%link{ rel: 'salmon', href: api_salmon_url(@account.id) }/
%link{ rel: 'alternate', type: 'application/atom+xml', href: account_url(@account, format: 'atom') }/
.card
.card{ style: "background-image: url(#{@account.header.url(:medium)})" }
.avatar= image_tag @account.avatar.url(:large)
%h1.name
= @account.display_name.blank? ? @account.username : @account.display_name

View file

@ -17,6 +17,10 @@
= link_to oauth_authorized_applications_path do
= fa_icon 'shield'
Authorized apps
%li{ class: active_nav_class(settings_path) }
= link_to settings_path do
= fa_icon 'user'
Edit profile
.dashboard__content
.dashboard__top-bar
= content_for?(:page_title) ? yield(:page_title) : 'Mastodon'

View file

@ -0,0 +1,6 @@
= simple_form_for @account, url: settings_path, method: :put do |f|
= f.input :display_name
= f.input :note
= f.input :avatar
= f.input :header
= f.button :submit