Skip to content

Commit

Permalink
Add user cover photo
Browse files Browse the repository at this point in the history
  • Loading branch information
Muncken87 committed Aug 27, 2016
1 parent 3f9903c commit 421e78c
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 22 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added app/.DS_Store
Binary file not shown.
Binary file added app/assets/.DS_Store
Binary file not shown.
Binary file added app/assets/images/globe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/globe2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/sections/_navbar.sass
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "variables/colors"
.navbar
padding: 0.5em 0em
padding: 1em 0em
background-color: $fb-blue

.logo
Expand Down
24 changes: 21 additions & 3 deletions app/assets/stylesheets/sections/_user-show.sass
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,36 @@
border-left: 1px solid #e9eaed

.user-show-experience
position: relative
.intro
font-weight: bold
margin: 0

.globe
height: 24px
width: 24px
margin-right: 0.5rem

.edit-user
text-align: right

&:before
+introduction
background-image: image-url('icons2.png')
background-position: 0 -22px
background-position: 0 -141px
background-size: 27px 219px
height: 12px
width: 12px
display: inline-block
float: left
margin-right: 1rem
opacity: .4

// &:hover
// background-color: #3b5998

ul
margin: 0

li
font-size: 12px
text-decoration: none
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/sections/_wall.sass
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
.username
text-decoration: none

.delete
.post-edit
position: absolute
right: 14px
top: 10px
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def new
def create
@user = User.new(user_params)
@user.avatar = params[:avatar]
@user.cover_photo = params[:cover_photo]
@user.save
respond_to do |format|
if @user.save
Expand All @@ -36,7 +37,7 @@ def create
end

def update
if @user.update(params[:user].permit(:first_name,:last_name,:avatar,:email))
if @user.update(params[:user].permit(:first_name,:last_name,:avatar,:email,:cover_photo))
redirect_to @user
else
render 'edit'
Expand All @@ -60,6 +61,6 @@ def set_user

# Never trust parameters from the scary internet, only allow the white list through.
def user_params
params.require(:user).permit(:first_name, :last_name, :avatar,:avatar_cache)
params.require(:user).permit(:first_name, :last_name, :avatar,:avatar_cache,:cover_photo)
end
end
2 changes: 2 additions & 0 deletions app/controllers/walls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ def index
@post = Post.new
@walls = Wall.all.includes(:user, :post).to_json(:include => [{post: {only: %i(username image content youtube_url)}},{:user => {only: %i(id)}}])
respond_with @wall
@user = User.all
end


end
3 changes: 1 addition & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ def display_avatar(user)
#/(https:\/\/w{3}.youtube.com\/watch\?v=\w*)/
#{}/(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/
def embed(string)

text, link = string.partition(/(?:http:\/\/www\.|https:\/\/|www\.)(?:youtube\.com\/watch\?v=(?:\w+)|domain\.com\/image.(?:jpg|png|gif)|domain\.com)/)
text_html = text.empty? ? nil : content_tag(:p, text.gsub("https://", ""))
iframe = link.empty? ? nil : content_tag(:iframe, nil, {src: embed_code(link)})
iframe = link.empty? ? nil : content_tag(:iframe, nil, {src: embed_code(link)},:allowFullScreen => "true")
text_html + iframe
end

Expand Down
3 changes: 2 additions & 1 deletion app/models/wall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ class Wall < ApplicationRecord
has_many :posts
has_many :users
delegate :username, :username=,:avatar, :avatar=, :email, :email=, :to => :user, allow_nil: true

devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
6 changes: 3 additions & 3 deletions app/uploaders/avatar_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def create_slider_version
# end

# Create different versions of your uploaded files:
# version :thumb do
# process :resize_to_fit => [50, 50]
# end
version :avatar do
process :resize_to_fit => [160, 160]
end

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
Expand Down
3 changes: 2 additions & 1 deletion app/views/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="container">

<!-- <a class="logo three columns">Fakebook</a> -->
<%= link_to 'Facebook', root_path, class: 'logo three columns' %>
<%= link_to 'Fakebook', root_path, class: 'logo three columns' %>

<div class="search">
<input type="search" placeholder="Sök efter personer,platser och saker"class="five columns">
Expand All @@ -13,6 +13,7 @@
<%= link_to current_user do %>
<% if user_signed_in? %>
<span>
<%= image_tag current_user.avatar %>
<%= current_user.username %>
</span>
<% else %>
Expand Down
13 changes: 9 additions & 4 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<div class="user-jumbo">
<div class="jumbo-user-details">
<div class="user-avatar-box">
<%= image_tag current_user.avatar %>
<%= image_tag (@user.avatar.avatar) %>
<!-- <%= label(:user, :avatar) %> -->
<div>
<!-- <%= file_field :avatar, @user, id: 'user_avatar' %> -->
</div>
</div>
<h3><%= current_user.username %></h3>
<h3><%= @user.username %></h3>
</div>
</div>
<div class="time-line card">
Expand All @@ -22,9 +22,14 @@
</div>
<!-- <%= link_to 'Show', @user %> |
<%= link_to 'Back', users_path %> -->

<div class="row">
<div class="four columns card user-show-experience">
<p class="intro">Introduction</p>
<%= image_tag 'globe.png', class: 'two columns globe' %>
<p class="intro six columns ">Introduction
</p>
<%= link_to '', edit_user_path(@user), class: 'edit-user four columns' %>
<div class="u-cf"></div>
<hr>
<ul>
<li class="work">Tidigare Ruby on Rails Developer vid CareerFoundry</li>
Expand All @@ -39,7 +44,7 @@
<div class="card">
<!-- <p><%= link_to 'Show', post %></p>
<p><%= link_to 'Edit', edit_post_path(post) %></p>
<p><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></p> -->
<p><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></p> -->
<div class="post-user-info">
<%= image_tag post.avatar %>
<div class="small-box"></div>
Expand Down
9 changes: 6 additions & 3 deletions app/views/walls/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
<%= image_tag post.avatar %>
<%= link_to post.username, user_path(post.user),class: 'username' %>
<small class="post-submitted"> <%= time_ago_in_words(post.created_at).capitalize %> Ago </small>

<%= link_to 'Delete', post, method: :delete, data: { confirm: 'Are you sure?' }, class: "delete" %>
<%= link_to 'Edit', edit_post_path(post)%>
<% if @post.user_id = current_user.id %>
<div class="post-edit">
<%= link_to 'Delete', post, method: :delete, data: { confirm: 'Are you sure?' } %>
<%= link_to 'Edit', edit_post_path(post)%>
</div>
<% end %>
</div>
<div class="post-content">
<p><%= embed post.content %></p>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20160827130450_add_cover_photo_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCoverPhotoToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :cover_photo, :text
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160821193423) do
ActiveRecord::Schema.define(version: 20160827130450) do

create_table "comments", force: :cascade do |t|
t.datetime "created_at", null: false
Expand Down Expand Up @@ -49,6 +49,7 @@
t.string "last_sign_in_ip"
t.string "username"
t.string "avatar"
t.text "cover_photo"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["username"], name: "index_users_on_username", unique: true
Expand Down
Binary file added public/uploads/user/avatar/1/avatar_git2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/uploads/user/avatar/1/git2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/uploads/user/avatar/1/slider_git2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 421e78c

Please sign in to comment.