Skip to content

Commit

Permalink
Change Shout to Snapby
Browse files Browse the repository at this point in the history
  • Loading branch information
bastienbeurier committed Apr 16, 2014
1 parent 652e046 commit 3766304
Show file tree
Hide file tree
Showing 119 changed files with 769 additions and 799 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require File.expand_path('../config/application', __FILE__)

StreetShout::Application.load_tasks
Snapby::Application.load_tasks
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file removed app/assets/images/topappli-logo.png
Binary file not shown.
Binary file removed app/assets/images/webzeen-logo.jpg
Binary file not shown.
26 changes: 13 additions & 13 deletions app/assets/stylesheets/home.css.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/* Constant
-------------------------------------*/
$shout_blue : #7A9ED3;
$snapby_blue : #7A9ED3;



Expand Down Expand Up @@ -356,11 +356,11 @@ a {
margin: -15px 0 -15px 0;
line-height: 1.25em;
text-align: center;
color: $shout_blue;}
color: $snapby_blue;}
#title_blue .container h2 {
font-size: 24px;
text-align: center;
color: $shout_blue; }
color: $snapby_blue; }
#title_blue .container .logo img{
display: block;
max-width: 70px;
Expand All @@ -382,7 +382,7 @@ a {
z-index: 1000;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
border: 1.5px solid $shout_blue ;
border: 1.5px solid $snapby_blue ;
border-bottom-style:none;
}
.footer a, .footer p {
Expand Down Expand Up @@ -415,7 +415,7 @@ a {
.footer .container #footer-right .footer-link {
height:100%;
padding-right: 30px;
color: $shout_blue ;
color: $snapby_blue ;
font-weight: 600;}
.footer .container #footer-phone-left {
float: left;
Expand Down Expand Up @@ -447,21 +447,21 @@ a {
max-width: 600px;
padding: 10px;
color: #000;
border-top: 2px solid $shout_blue;}
border-top: 2px solid $snapby_blue;}
#standard-text .container h1 {
font-weight: 800;
font-size: 24px;
margin-bottom: 20px;
margin-top: 15px;
line-height:200%;
color: $shout_blue;}
color: $snapby_blue;}
#standard-text .container h2 {
font-weight: 800;
font-size: 18px;
margin-bottom: 10px;
margin-top: 20px;
line-height:150%;
color: $shout_blue; }
color: $snapby_blue; }
#standard-text .container h3 {
font-weight:bold;
margin-top: 10px;
Expand All @@ -475,27 +475,27 @@ a {
margin-bottom: 5px; }


/* Display_shout
/* Display_snapby
-------------------------------------*/
#display_shout {
#display_snapby {
width: 90%;
position: relative;
top: 5%;
left:5%;
height: auto;
padding-bottom: 30px;}
#display_shout img {
#display_snapby img {
display: block;
width: 100%;
margin-top: 5px;
height: auto;}
#display_shout h2{
#display_snapby h2{
position: absolute;
margin: 5%;
top: 5%%;
text-align: center;
width: 90%;}
#display_shout h2 span {
#display_snapby h2 span {
border-radius: 10px;
color: white;
font-size: 40px;
Expand Down
6 changes: 3 additions & 3 deletions app/assets/stylesheets/media-queries.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
text-align: center;
}

/* DISPLAY_SHOUT */
#display_shout {
/* DISPLAY_SNAPBY */
#display_snapby {
padding-bottom: 10px;}
#display_shout h2 span {
#display_snapby h2 span {
font-size: 18px;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/activities_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Api::V1::ActivitiesController < Api::V1::ApiController

#Display likes for a shout
#Display likes for a snapby
def index
Rails.logger.debug "BAB index activies index params: #{params}"

Expand Down
16 changes: 8 additions & 8 deletions app/controllers/api/v1/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ def create
comment = Comment.new(comment_params)

if comment.save
shout = Shout.find(params[:shout_id])
shout.update_attributes(comment_count: shout.comment_count + 1)
render json: { result: { comments: shout.comments.reverse } }, status: 201
snapby = Snapby.find(params[:snapby_id])
snapby.update_attributes(comment_count: snapby.comment_count + 1)
render json: { result: { comments: snapby.comments.reverse } }, status: 201
else
render json: { errors: { internal: comment.errors } }, :status => 500
end
end

#Display comments for a shout
#Display comments for a snapby
def index
Rails.logger.debug "BAB comment index params: #{params}"

if !params[:shout_id]
if !params[:snapby_id]
render json: { errors: {incomplete: ["Incomplete comment information"] } }, :status => 406
return
end

shout = Shout.find(params[:shout_id])
snapby = Snapby.find(params[:snapby_id])

#TODO: handle when there is a lot of comments (not for now)
render json: {result: {comments: shout.comments.reverse } }, status: 200
render json: {result: {comments: snapby.comments.reverse } }, status: 200
end

private

def comment_params
params.permit(:shout_id, :shouter_id, :description, :commenter_id, :commenter_username, :lat, :lng)
params.permit(:snapby_id, :snapbyer_id, :description, :commenter_id, :commenter_username, :lat, :lng)
end

end
28 changes: 14 additions & 14 deletions app/controllers/api/v1/flags_controller.rb
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
class Api::V1::FlagsController < Api::V1::ApiController

#User flags an abusive shout
#User flags an abusive snapby
def create
Rails.logger.debug "BAB report_shout params: #{params}"
Rails.logger.debug "BAB report_snapby params: #{params}"

shout = Shout.find(params[:shout_id])
snapby = Snapby.find(params[:snapby_id])

if !shout or !params[:motive]
render :json => { :errors => { incomplete: ["incomplete information to flag shout"] } }, status: 406
if !snapby or !params[:motive]
render :json => { :errors => { incomplete: ["incomplete information to flag snapby"] } }, status: 406
return
end

existing_flags = Flag.where(shout_id: shout.id)
existing_flags = Flag.where(snapby_id: snapby.id)

#Case where this user already flagged this shout
#Case where this user already flagged this snapby
if existing_flags.collect(&:flagger_id).include?(params[:flagger_id].to_i)
render json: {errors: { duplicate: ["shout already flagged by user"] } }, status: 422
render json: {errors: { duplicate: ["snapby already flagged by user"] } }, status: 422
return
else
flag = Flag.new(flag_params)

if flag.save
#if more than 5 flags, do not display the shout anymore
#if more than 5 flags, do not display the snapby anymore
if existing_flags.count >= 5
shout.update_attributes(removed: true)
snapby.update_attributes(removed: true)
end

#send mail
begin
UserMailer.flagged_shout_email(flag,shout).deliver
UserMailer.flagged_snapby_email(flag,snapby).deliver
rescue Exception => e
Airbrake.notify(e)
end

render json: {result: { messages: ["shout successfully flagged"] } }, status: 200
render json: {result: { messages: ["snapby successfully flagged"] } }, status: 200
else
render json: {errors: { internal: ["Failed to flag shout"] } }, status: 500
render json: {errors: { internal: ["Failed to flag snapby"] } }, status: 500
end
end
end

private

def flag_params
params.permit(:shout_id, :motive, :flagger_id)
params.permit(:snapby_id, :motive, :flagger_id)
end

end
36 changes: 18 additions & 18 deletions app/controllers/api/v1/likes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,70 @@ def create
params[:liker_id] = current_user.id
params[:liker_username] = current_user.username

shout = Shout.find(params[:shout_id])
snapby = Snapby.find(params[:snapby_id])

if shout.likes.collect(&:liker_id).include? current_user.id
render json: { errors: { invalid: ["Shout already liked by user"] } }, :status => 406
if snapby.likes.collect(&:liker_id).include? current_user.id
render json: { errors: { invalid: ["Snapby already liked by user"] } }, :status => 406
return
end

like = Like.new(like_params)

if like.save
# update counter in shout
shout.update_attributes(like_count: shout.like_count + 1)
# update counter in snapby
snapby.update_attributes(like_count: snapby.like_count + 1)

# if 5 likes, mark as trending
if shout.like_count == TRENDING_LIKES_COUNT
shout.make_trending
if snapby.like_count == TRENDING_LIKES_COUNT
snapby.make_trending
end

CreateLikeActivityAndNotificationWorker.perform_async(like.id)

render json: { result: { like_count: shout.like_count } }, status: 201
render json: { result: { like_count: snapby.like_count } }, status: 201
else
render json: { errors: { internal: like.errors } }, :status => 500
end
end

#Display likes for a shout
#Display likes for a snapby
def index
Rails.logger.debug "BAB index likes params: #{params}"

if !params[:shout_id]
if !params[:snapby_id]
render json: { errors: {incomplete: ["Incomplete like information"] } }, :status => 406
return
end

shout = Shout.find(params[:shout_id])
snapby = Snapby.find(params[:snapby_id])

#TODO: handle when there is a lot of likes (not for now)
render json: { result: {likes: shout.likes.reverse } }, status: 200
render json: { result: {likes: snapby.likes.reverse } }, status: 200
end


def destroy
Rails.logger.debug "TRUCHOV remove_likes params: #{params}"

likes = Like.where("liker_id = ? AND shout_id =?", current_user.id, params[:shout_id])
likes = Like.where("liker_id = ? AND snapby_id =?", current_user.id, params[:snapby_id])

if likes.count < 1
render json: { errors: { internal: ["User did not like this shout"] } }, :status => 500
render json: { errors: { internal: ["User did not like this snapby"] } }, :status => 500
return
end

if likes.destroy_all
shout = Shout.find(params[:shout_id])
shout.update_attributes(like_count: shout.like_count - 1)
snapby = Snapby.find(params[:snapby_id])
snapby.update_attributes(like_count: snapby.like_count - 1)
render json: { result: { messages: ["Like successfully destroyed"] } }, status: 200
else
render json: { errors: { internal: ["User did not like this shout"] } }, :status => 500
render json: { errors: { internal: ["User did not like this snapby"] } }, :status => 500
end
end

private

def like_params
params.permit(:shout_id, :liker_id, :liker_username, :lat, :lng)
params.permit(:snapby_id, :liker_id, :liker_username, :lat, :lng)
end
end
Loading

0 comments on commit 3766304

Please sign in to comment.