Skip to content

Commit

Permalink
Fix if else statements for images & change navbar look
Browse files Browse the repository at this point in the history
  • Loading branch information
Muncken87 committed Sep 25, 2016
1 parent 3c7d826 commit 4a459d1
Show file tree
Hide file tree
Showing 47 changed files with 304 additions and 30 deletions.
Binary file modified .DS_Store
Binary file not shown.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

Expand All @@ -34,9 +34,9 @@ gem 'rmagick'
gem "animate-rails"
gem 'best_in_place', '~> 3.0.1'
gem 'simple_form'
gem 'carrierwave'
gem "fog-aws"
gem "figaro"
gem 'cancancan', '~> 1.10'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
Expand All @@ -51,6 +51,7 @@ group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
gem "better_errors"
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
Expand Down
12 changes: 11 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,20 @@ GEM
best_in_place (3.0.3)
actionpack (>= 3.2)
railties (>= 3.2)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
builder (3.2.2)
byebug (9.0.5)
cancancan (1.15.0)
carrierwave (0.11.2)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
mimemagic (>= 0.3.0)
coderay (1.1.1)
coffee-rails (4.2.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.2.x)
Expand Down Expand Up @@ -158,6 +164,7 @@ GEM
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
redis (3.3.1)
responders (2.3.0)
railties (>= 4.2.0, < 5.1)
rmagick (2.16.0)
Expand Down Expand Up @@ -210,7 +217,9 @@ PLATFORMS
DEPENDENCIES
animate-rails
best_in_place (~> 3.0.1)
better_errors
byebug
cancancan (~> 1.10)
carrierwave
coffee-rails (~> 4.2)
devise
Expand All @@ -224,6 +233,7 @@ DEPENDENCIES
pg
puma (~> 3.0)
rails (~> 5.0.0)
redis (~> 3.0)
rmagick
sass-rails (~> 5.0)
simple_form
Expand All @@ -236,4 +246,4 @@ DEPENDENCIES
web-console

BUNDLED WITH
1.12.5
1.13.1
Binary file modified app/.DS_Store
Binary file not shown.
Binary file modified app/assets/.DS_Store
Binary file not shown.
Binary file added app/assets/images/.DS_Store
Binary file not shown.
Binary file removed app/assets/images/empty.jpg
Binary file not shown.
Binary file added app/assets/images/fallback/empty.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//= require jquery
//= require best_in_place
//= require jquery-ui
//= require socket.io
//= require jquery_ujs
//= require turbolinks
//= require_tree .
Expand Down
4 changes: 4 additions & 0 deletions app/assets/javascripts/channels/channel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
4 changes: 4 additions & 0 deletions app/assets/javascripts/channels/connection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
3 changes: 3 additions & 0 deletions app/assets/javascripts/messages.coffee
Original file line number Diff line number Diff line change
@@ -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/
4 changes: 4 additions & 0 deletions app/assets/javascripts/socket.io.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions app/assets/stylesheets/application.sass
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
@import "sections/post-form"
@import "sections/user-show"
@import "sections/user_login"
@import "sections/user-form"
// @import "sections/chatbar"
Expand All @@ -46,3 +48,7 @@ body

a
color: #365899

img
max-width: 100%
max-height: 100%
9 changes: 9 additions & 0 deletions app/assets/stylesheets/sections/_chatbar.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.chatbar
background-color: #f4f4f4
position: fixed
height: 100vh
padding: 3em
margin-top: 57.5px
right: 0
top: 0
border-left: 1px solid #d6d7da
21 changes: 11 additions & 10 deletions 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: 1em 0em
padding: 0.75em 0em
background-color: $fb-blue

.logo
Expand All @@ -9,17 +9,17 @@
color: $white
margin-right: 2em
text-decoration: none
line-height: 26px
line-height: 35px

@media (max-width: 662px)
margin-bottom: 0.5em

input[type="search"],input[type="submit"]
margin: 5px 0px 0px
border: none
height: 24px
line-height: 24px
margin-top: 2px
height: 35px
line-height: 35px
margin-top: 0px

@media (max-width: 662px)
display: block
Expand Down Expand Up @@ -64,27 +64,28 @@
color: $white

a
line-height: 23px
line-height: 32px

.login
&:after
content: '/'
margin: 0px 5px

img
height: 24px
width: 24px
height: 35px
width: 35px
border-radius: 4px
vertical-align: middle
margin-right: 0.5em
margin-bottom: 2px


span
vertical-align: middle
color: $white
height: 26px
height: 35px
padding: 0px 10px 0px 0px
line-height: 27px
line-height: 34px

@media (max-width: 1020px)
display: none
5 changes: 5 additions & 0 deletions app/assets/stylesheets/sections/_post-form.sass
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ input[type="submit"]
height: auto
color: white
letter-spacing: -0.24px

&:hover
color: white
background-color: darken(#4267b2, 5)
border-color: darken(#4267b2, 5)
3 changes: 3 additions & 0 deletions app/assets/stylesheets/sections/_user-form.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.user-form
img
height: 320px
6 changes: 4 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?

def index
end
include SessionsHelper

# Confirms a logged-in user.


protected

Expand Down
27 changes: 27 additions & 0 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class MessagesController < ApplicationController
before_action :get_messages

def index
@messages = Message.all
end

def create
message = current_user.messages.build(message_params)
if message.save
redirect_to messages_url
else
render 'index'
end
end

private

def get_messages
@messages = Message.for_display
@message = current_user.messages.build
end

def message_params
params.require(:message).permit(:content)
end
end
6 changes: 3 additions & 3 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
def index
@user = User.all
@users = User.all
end

def show
Expand Down Expand Up @@ -47,7 +47,7 @@ def update
def destroy
@user.destroy
respond_to do |format|
format.html { redirect_to @wall, notice: 'Post was successfully destroyed.' }
format.html { redirect_to @user, notice: 'Post was successfully destroyed.' }
format.json { head :no_content }
end
end
Expand All @@ -61,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,:cover_photo)
params.require(:user).permit(:first_name, :last_name, :avatar,:avatar_cache,:cover_photo,:email)
end
end
2 changes: 2 additions & 0 deletions app/helpers/messages_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module MessagesHelper
end
22 changes: 22 additions & 0 deletions app/helpers/sessions_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module SessionsHelper

# # Logs in the given user.
# def log_in(user)
# cookies.signed[:user_id] = user.id
# end
#
# def log_out
# cookies.delete(:user_id)
# @current_user = nil
# end
#
# # Returns the current logged-in user (if any).
# def current_user
# @current_user ||= User.find_by(id: cookies.signed[:user_id])
# end
#
# # Returns true if the user is logged in, false otherwise.
# def logged_in?
# !current_user.nil?
# end
end
15 changes: 15 additions & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Ability
include CanCan::Ability

def initialize(user)
user ||= User.new # guest user (not logged in)
if user.admin?
can :manage, :all
else
can :manage, User, id: user.id
can [:index, :show], Wall
cannot [:create], User

end
end
end
5 changes: 5 additions & 0 deletions app/models/message.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Message < ApplicationRecord
belongs_to :user
validates :content, presence: true
scope :for_display, -> { order(:created_at).limit(50)}
end
3 changes: 3 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class User < ApplicationRecord

has_many :posts, dependent: :delete_all
has_many :comments, dependent: :delete_all
validates :username, presence: true, uniqueness: true
has_many :messages

attr_accessor :login

validates :username,
Expand Down
1 change: 1 addition & 0 deletions app/models/wall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Wall < ApplicationRecord
has_many :post
has_many :users
has_many :comments
has_many :messages, dependent: :destroy

delegate :username, :username=,:avatar, :avatar=, :email, :email=, :to => :user, allow_nil: true
devise :database_authenticatable, :registerable,
Expand Down
2 changes: 1 addition & 1 deletion app/uploaders/avatar_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def store_dir
end

def default_url
ActionController::Base.helpers.asset_path([version_name, "empty.jpg"].compact.join('_'))
ActionController::Base.helpers.asset_path("fallback/" + [version_name, "empty.jpg"].compact.join('_'))
end

version :slider do
Expand Down
3 changes: 3 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

<body>
<%= render partial: "shared/navbar" %>
<!-- <%= render partial: "shared/chatbar" %> -->


<% if notice %>
<p id="notice" class="alert alert-notice"><%= notice %></p>
<% end %>
Expand Down
8 changes: 8 additions & 0 deletions app/views/messages/_message.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="message">
<div class="message-user">
<%= message.user.username %>:
</div>
<div class="message-content">
<%= message.content %>
</div>
</div>
7 changes: 7 additions & 0 deletions app/views/messages/_messages.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="messages" class="messages">
<div id="messages-table" class="messages-table">
<% if @messages.any? %>
<%= render @messages %>
<% end %>
</div>
</div>
6 changes: 6 additions & 0 deletions app/views/messages/_messages_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="message-input">
<%= form_for(@message) do |f| %>
<%= f.text_area :content %>
<%= f.submit "Send" %>
<% end %>
</div>
4 changes: 4 additions & 0 deletions app/views/messages/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="message-wr">
<%= render 'messages' %>
<%= render 'message_form' %>
</div>
4 changes: 4 additions & 0 deletions app/views/posts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
<hr>
<div class=" content-area">
<div class="content-profile-img">
<% if @post.avatar.present? %>
<%= image_tag current_user.avatar.mini %>
<% else %>
<%= image_tag current_user.avatar %>
<% end %>
</div>
<div class="content-text">
<%= f.text_area :content, placeholder: "What are you doing right now?" %>
Expand Down
Loading

0 comments on commit 4a459d1

Please sign in to comment.