summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-11-22 21:35:54 -0700
committermo khan <mo@mokhan.ca>2014-11-22 21:35:54 -0700
commit93d22d876deded6f7453dafef151db8d4582c8f5 (patch)
tree140922d286f1fdffebcc241073f73b6d0aaf4e18
parent84d4bc964b9f5e1eb93819087af564655a8cabef (diff)
parent7620674929c024a7279dfa116deab8805f2fb2ec (diff)
Merge branch 'master' of bitbucket.org:cakeside/cakeside
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock4
-rw-r--r--app/assets/javascripts/application.js1
-rw-r--r--app/assets/javascripts/backbone/cakeside.js.coffee12
-rw-r--r--app/assets/javascripts/backbone/controllers/cakes_controller.js.coffee8
-rw-r--r--app/assets/javascripts/backbone/controllers/dashboard_controller.js.coffee4
-rw-r--r--app/assets/javascripts/backbone/controllers/profile_controller.js.coffee4
-rw-r--r--app/assets/javascripts/backbone/controllers/tutorials_controller.js.coffee14
-rw-r--r--app/assets/javascripts/backbone/templates/cakes/cake.jst.ejs22
-rw-r--r--app/assets/javascripts/backbone/templates/cakes/edit.jst.ejs7
-rw-r--r--app/assets/javascripts/backbone/templates/photos/new-modal.jst.ejs4
-rw-r--r--app/controllers/api/v1/cakes_controller.rb16
-rw-r--r--app/controllers/api/v1/tutorials_controller.rb5
-rw-r--r--app/controllers/my/dashboard_controller.rb3
-rw-r--r--app/controllers/my/kitchens_controller.rb7
-rw-r--r--app/controllers/products_controller.rb3
-rw-r--r--app/controllers/registrations_controller.rb2
-rw-r--r--app/controllers/sessions_controller.rb4
-rw-r--r--app/helpers/application_helper.rb6
-rw-r--r--app/mailers/notification_mailer.rb5
-rw-r--r--app/models/activity.rb9
-rw-r--r--app/models/comment.rb5
-rw-r--r--app/models/favorite.rb5
-rw-r--r--app/models/tag.rb9
-rw-r--r--app/models/user.rb6
-rw-r--r--app/services/application/update_cake_command.rb18
-rw-r--r--app/services/application/upload_photo.rb8
-rw-r--r--app/views/admin/jobs/index.html.erb8
-rw-r--r--app/views/admin/jobs/show.html.erb1
-rw-r--r--app/views/admin/sessions/index.html.erb6
-rw-r--r--app/views/admin/users/_index.html.erb2
-rw-r--r--app/views/api/v1/cakes/_cake.json.jbuilder48
-rw-r--r--app/views/api/v1/categories/_category.json.jbuilder8
-rw-r--r--app/views/api/v1/photos/_photo.json.jbuilder20
-rw-r--r--app/views/api/v1/profiles/_profile.json.jbuilder18
-rw-r--r--app/views/api/v1/tutorials/_tutorial.json.jbuilder24
-rw-r--r--app/views/api/v1/tutorials/create.json.jbuilder3
-rw-r--r--app/views/cakes/index.html.erb1
-rw-r--r--app/views/layouts/_header.html.erb16
-rw-r--r--app/views/layouts/application.html.erb2
-rw-r--r--app/views/my/dashboard/_comment.html.erb6
-rw-r--r--app/views/my/dashboard/_creation.html.erb3
-rw-r--r--app/views/my/dashboard/_favorite.html.erb7
-rw-r--r--app/views/my/dashboard/_tutorial.html.erb6
-rw-r--r--app/views/my/dashboard/index.html.erb67
-rw-r--r--app/views/my/favorites/index.html.erb4
-rw-r--r--app/views/my/kitchens/show.html.erb25
-rw-r--r--app/views/my/shared/_my_nav.html.erb29
-rw-r--r--app/views/notification_mailer/notification_email.text.erb1
-rw-r--r--app/views/products/index.html.erb6
-rw-r--r--app/views/profiles/index.html.erb1
-rw-r--r--app/views/tutorials/index.html.erb1
-rw-r--r--config/routes.rb3
-rw-r--r--db/migrate/20141102040612_recreate_all_activities.rb13
-rw-r--r--db/schema.rb26
-rw-r--r--spec/controllers/api/v1/tutorials_controller_spec.rb5
-rw-r--r--spec/controllers/registrations_controller_spec.rb2
-rw-r--r--spec/controllers/sessions_controller_spec.rb4
-rw-r--r--spec/factories.rb8
-rw-r--r--spec/features/change_password_spec.rb4
-rw-r--r--spec/features/registration_spec.rb2
-rw-r--r--spec/mailers/notification_mailer_spec.rb8
-rw-r--r--spec/mailers/previews/notification_mailer_preview.rb2
-rw-r--r--spec/models/favorite_spec.rb2
64 files changed, 305 insertions, 279 deletions
diff --git a/Gemfile b/Gemfile
index b3e01215..96cd584d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -17,6 +17,7 @@ end
gem 'acts-as-taggable-on'
gem 'jquery-ui-rails', '~> 4.0.0'
+gem 'jquery-turbolinks'
gem 'mini_magick'
gem "kaminari"
gem 'bootstrap-sass', '~> 2.3.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index 0e4dabb8..3fea6bef 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -197,6 +197,9 @@ GEM
jquery-rails (3.1.2)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
+ jquery-turbolinks (2.1.0)
+ railties (>= 3.1.0)
+ turbolinks
jquery-ui-rails (4.0.5)
railties (>= 3.1.0)
js-routes (0.9.9)
@@ -403,6 +406,7 @@ DEPENDENCIES
groupdate
jbuilder
jquery-rails
+ jquery-turbolinks
jquery-ui-rails (~> 4.0.0)
js-routes
kaminari
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index fc002f2d..d973d0cc 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -11,6 +11,7 @@
// about supported directives.
//
//= require jquery
+//= require jquery.turbolinks
//= require jquery-migrate
//= require jquery_ujs
//= require turbolinks
diff --git a/app/assets/javascripts/backbone/cakeside.js.coffee b/app/assets/javascripts/backbone/cakeside.js.coffee
index e55bb348..6f468e52 100644
--- a/app/assets/javascripts/backbone/cakeside.js.coffee
+++ b/app/assets/javascripts/backbone/cakeside.js.coffee
@@ -37,14 +37,12 @@ window.CakeSide =
@cakes = new CakeSide.Collections.CakesCollection()
@categories = new CakeSide.Collections.CategoriesCollection()
- @categories.fetch(reset: true)
@tutorials = new CakeSide.Collections.TutorialsCollection()
- @tutorials.fetch(reset: true)
- @disqus_view = new CakeSide.Views.DisqusView
- disqus_shortname: data.disqus_shortname
- CakeSide.Application.reqres.setHandler 'CommentView', =>
- @disqus_view
+ #@disqus_view = new CakeSide.Views.DisqusView
+ #disqus_shortname: data.disqus_shortname
+ #CakeSide.Application.reqres.setHandler 'CommentView', =>
+ #@disqus_view
CakeSide.Application.reqres.setHandler 'CakesRepository', =>
@cakes
CakeSide.Application.reqres.setHandler 'CategoriesRepository', =>
@@ -63,5 +61,7 @@ window.CakeSide =
CakeSide.Application.reqres.setHandler 'ProfilesRepository', =>
@profiles ||= new CakeSide.Collections.ProfilesCollection()
+ @categories.fetch(reset: true)
+ @tutorials.fetch(reset: true)
@cakes.fetch(reset: true).done ->
CakeSide.Application.start()
diff --git a/app/assets/javascripts/backbone/controllers/cakes_controller.js.coffee b/app/assets/javascripts/backbone/controllers/cakes_controller.js.coffee
index c9fe5579..70d99253 100644
--- a/app/assets/javascripts/backbone/controllers/cakes_controller.js.coffee
+++ b/app/assets/javascripts/backbone/controllers/cakes_controller.js.coffee
@@ -3,11 +3,11 @@ class CakeSide.Controllers.CakesController extends Marionette.Controller
initialize: (options) ->
@content_region = CakeSide.Application.content_region
@cakes = CakeSide.Application.request('CakesRepository')
- @comment_view = CakeSide.Application.request('CommentView')
+ #@comment_view = CakeSide.Application.request('CommentView')
index: ->
@selectTab()
- @comment_view.hide()
+ #@comment_view.hide()
@content_region.show(new @views.IndexView(collection: @cakes))
show: (id, photo_id) ->
@@ -21,13 +21,13 @@ class CakeSide.Controllers.CakesController extends Marionette.Controller
newCake: ->
@selectTab()
- @comment_view.hide()
+ #@comment_view.hide()
@content_region.show(new @views.NewView(collection: @cakes))
edit: (id) ->
@selectTab()
@content_region.show(new @views.EditView(model: @cakes.get(id)))
- @comment_view.hide()
+ #@comment_view.hide()
selectTab: ->
$('.nav-list').children().removeClass('active')
diff --git a/app/assets/javascripts/backbone/controllers/dashboard_controller.js.coffee b/app/assets/javascripts/backbone/controllers/dashboard_controller.js.coffee
index 45e7196c..23169914 100644
--- a/app/assets/javascripts/backbone/controllers/dashboard_controller.js.coffee
+++ b/app/assets/javascripts/backbone/controllers/dashboard_controller.js.coffee
@@ -1,6 +1,6 @@
class CakeSide.Controllers.DashboardController extends Marionette.Controller
initialize: (options) ->
- @comment_view = CakeSide.Application.request('CommentView')
+ #@comment_view = CakeSide.Application.request('CommentView')
index: ->
- @comment_view.hide()
+ #@comment_view.hide()
diff --git a/app/assets/javascripts/backbone/controllers/profile_controller.js.coffee b/app/assets/javascripts/backbone/controllers/profile_controller.js.coffee
index e0306805..984cf4d7 100644
--- a/app/assets/javascripts/backbone/controllers/profile_controller.js.coffee
+++ b/app/assets/javascripts/backbone/controllers/profile_controller.js.coffee
@@ -2,11 +2,11 @@ class CakeSide.Controllers.ProfileController extends Marionette.Controller
views: CakeSide.Views.Profiles
initialize: (options) ->
@content_region = CakeSide.Application.content_region
- @comment_view = CakeSide.Application.request('CommentView')
+ #@comment_view = CakeSide.Application.request('CommentView')
show: (id) ->
@selectTab()
- @comment_view.hide()
+ #@comment_view.hide()
profile = new CakeSide.Models.Profile
id: id
profile.fetch
diff --git a/app/assets/javascripts/backbone/controllers/tutorials_controller.js.coffee b/app/assets/javascripts/backbone/controllers/tutorials_controller.js.coffee
index ae1a626f..5f1997c4 100644
--- a/app/assets/javascripts/backbone/controllers/tutorials_controller.js.coffee
+++ b/app/assets/javascripts/backbone/controllers/tutorials_controller.js.coffee
@@ -3,26 +3,26 @@ class CakeSide.Controllers.TutorialsController extends Marionette.Controller
initialize: (options) ->
@content_region = CakeSide.Application.content_region
@tutorials = CakeSide.Application.request('TutorialsRepository')
- @comment_view = CakeSide.Application.request('CommentView')
+ #@comment_view = CakeSide.Application.request('CommentView')
index: ->
@selectTab()
- @comment_view.hide()
+ #@comment_view.hide()
@content_region.show(new @views.IndexView(collection: @tutorials))
new: ->
@selectTab()
- @comment_view.hide()
+ #@comment_view.hide()
@content_region.show(new @views.NewView(collection: @tutorials))
show: (id) ->
@selectTab()
tutorial = @tutorials.get(id)
@content_region.show(new @views.ShowView(model: tutorial))
- @comment_view.render
- identifier: "t-#{tutorial.id}"
- title: tutorial.get('name')
- url: tutorial.public_url()
+ #@comment_view.render
+ #identifier: "t-#{tutorial.id}"
+ #title: tutorial.get('heading')
+ #url: tutorial.get('url')
selectTab: ->
$('.nav-list').children().removeClass('active')
diff --git a/app/assets/javascripts/backbone/templates/cakes/cake.jst.ejs b/app/assets/javascripts/backbone/templates/cakes/cake.jst.ejs
index c20138b5..e9800ad5 100644
--- a/app/assets/javascripts/backbone/templates/cakes/cake.jst.ejs
+++ b/app/assets/javascripts/backbone/templates/cakes/cake.jst.ejs
@@ -4,18 +4,10 @@
<img class="media-object" data-src="<%= photo.thumb_url %>" alt="64x64" style="width: 64px; height: 64px;" src="<%= photo.thumb_url %>">
</a>
<% } %>
- <div class="media-body">
- <h4 class="media-heading"><%= name %></h4>
- <%= story %>
- <p>
- <a href="#cakes/<%= id %>/edit">
- <i class="fa fa-edit"></i> edit
- </a>
- <a href="<%= Routes.cake_favorites_path(id) %>">
- <i class="fa fa-heart"></i> fanclub
- </a>
- <span class="badge badge-warning">
- <i class="fa fa-comment"> </i> <a href="/creations/<%= id %>#disqus_thread" data-disqus-identifier="c-<%= id %>"></a>
- </span>
- </p>
- </div>
+<div class="media-body">
+ <h4 class="media-heading"><a href="#cakes/<%= id %>"><%= name %></a></h4>
+ <p>
+ <a href="#cakes/<%= id %>/edit"><i class="fa fa-edit"></i>edit</a>
+ <a href="<%= Routes.cake_favorites_path(id) %>"><i class="fa fa-heart"></i>fanclub</a>
+ </p>
+</div>
diff --git a/app/assets/javascripts/backbone/templates/cakes/edit.jst.ejs b/app/assets/javascripts/backbone/templates/cakes/edit.jst.ejs
index d462642f..e589075f 100644
--- a/app/assets/javascripts/backbone/templates/cakes/edit.jst.ejs
+++ b/app/assets/javascripts/backbone/templates/cakes/edit.jst.ejs
@@ -1,11 +1,16 @@
<div class="row-fluid">
<div class="span12">
- <p class="pull-right"> <a class="btn btn-primary add-photo">Add Photo...</a> </p>
<h1><small>Edit</small> <%= cake.name %></h1>
<hr />
<form id="edit-cake" name="cake" class="form-horizontal">
<fieldset>
<div class="control-group">
+ <label class="control-label"></label>
+ <div class="controls">
+ <a class="btn btn-primary add-photo">Upload Photo...</a>
+ </div>
+ </div>
+ <div class="control-group">
<label class="control-label" for="cake_name">Name*</label>
<div class="controls">
<input class="input-xxlarge" id="cake_name" name="name" type="text" value="<%= cake.name %>" />
diff --git a/app/assets/javascripts/backbone/templates/photos/new-modal.jst.ejs b/app/assets/javascripts/backbone/templates/photos/new-modal.jst.ejs
index 66bbe946..7f7a7dfb 100644
--- a/app/assets/javascripts/backbone/templates/photos/new-modal.jst.ejs
+++ b/app/assets/javascripts/backbone/templates/photos/new-modal.jst.ejs
@@ -3,14 +3,14 @@
<h4>Upload Photo</h4>
</div>
<div class="modal-body">
- <img id="preview-image" src="#" alt="your image" class="hide hidden-phone" />
<span class="btn btn-default btn-file">
+ Browse... <input id="photo-attachment" name="attachment" type="file" accept="image/*">
</span>
- <p>
+ <p class='pull-right'>
<input id="watermark" name="watermark" maxlength="30" size="30" type="text" placeholder="watermark" /> on CakeSide.com
<a class="tooltip-item" data-placement="right" rel="tooltip" href="#" data-original-title="Watermark your name or company on each uploaded image" data-animation="true"><i class="icon-question-sign"></i></a>
</p>
+ <img id="preview-image" src="#" alt="your image" class="hide hidden-phone" />
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Cancel</a>
diff --git a/app/controllers/api/v1/cakes_controller.rb b/app/controllers/api/v1/cakes_controller.rb
index 7dc46473..1f03e8ee 100644
--- a/app/controllers/api/v1/cakes_controller.rb
+++ b/app/controllers/api/v1/cakes_controller.rb
@@ -24,15 +24,13 @@ module Api
end
def update
- UpdateCakeCommand.new(self).run(params[:id], params[:cake][:tags], cake_params)
- end
-
- def update_cake_succeeded(cake)
- respond_with(@cake = cake)
- end
-
- def update_cake_failed(cake)
- respond_with(@cake = cake)
+ @cake = current_user.creations.find(params[:id])
+ current_user.tag(@cake, with: params[:cake][:tags], on: :tags)
+ if @cake.update(cake_params.reject { |key, value| key == "tags" })
+ respond_with @cake
+ else
+ respond_with @cake
+ end
end
def destroy
diff --git a/app/controllers/api/v1/tutorials_controller.rb b/app/controllers/api/v1/tutorials_controller.rb
index c257f707..8c75dbf0 100644
--- a/app/controllers/api/v1/tutorials_controller.rb
+++ b/app/controllers/api/v1/tutorials_controller.rb
@@ -1,16 +1,13 @@
module Api
module V1
class TutorialsController < ApiController
- respond_to :json
-
def index
- respond_with(@tutorials = current_user.tutorials)
+ @tutorials = current_user.tutorials.page(page).per(per_page)
end
def create
@tutorial = current_user.tutorials.create!(tutorial_params)
current_user.tag(@tutorial, with: params[:tutorial][:tags], on: :tags)
- respond_with(@tutorial)
end
private
diff --git a/app/controllers/my/dashboard_controller.rb b/app/controllers/my/dashboard_controller.rb
index 006a55a7..158dc91c 100644
--- a/app/controllers/my/dashboard_controller.rb
+++ b/app/controllers/my/dashboard_controller.rb
@@ -1,7 +1,8 @@
module My
class DashboardController < BaseController
def index
- @items = (current_user.creations.includes(:photos) + current_user.tutorials).sort_by! { |x| x.created_at }.reverse
+ @cakes = current_user.creations.includes(:photos)
+ @tutorials = current_user.tutorials.limit(10)
@activities = current_user.recent_activities
end
end
diff --git a/app/controllers/my/kitchens_controller.rb b/app/controllers/my/kitchens_controller.rb
new file mode 100644
index 00000000..33b14e2e
--- /dev/null
+++ b/app/controllers/my/kitchens_controller.rb
@@ -0,0 +1,7 @@
+module My
+ class KitchensController < BaseController
+ def show
+ @tags = Tag.unique_tags
+ end
+ end
+end
diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb
index 82a5bc9c..ea4906f2 100644
--- a/app/controllers/products_controller.rb
+++ b/app/controllers/products_controller.rb
@@ -6,6 +6,9 @@ class ProductsController < ApplicationController
def index
@products = @product_api.search(params[:q])
+ if @products.count == 1
+ redirect_to product_path(@products.first.asin)
+ end
end
def show
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb
index c85879fa..0054424a 100644
--- a/app/controllers/registrations_controller.rb
+++ b/app/controllers/registrations_controller.rb
@@ -3,7 +3,7 @@ class RegistrationsController < ApplicationController
user = User.create(secure_params)
if user.save
cookies.signed[:raphael] = User.login(secure_params[:email], secure_params[:password]).access(request)
- redirect_to my_root_path
+ redirect_to my_dashboard_path
else
flash[:error] = user.errors.full_messages
redirect_to new_session_path
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index a971916e..577cd777 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,13 +1,13 @@
class SessionsController < ApplicationController
def new
- redirect_to my_root_path if user_signed_in?
+ redirect_to my_dashboard_path if user_signed_in?
@session = UserSession.new
end
def create
if @session = User.login(session_params[:username], session_params[:password])
cookies.signed[:raphael] = @session.access(request)
- redirect_to my_root_path
+ redirect_to my_dashboard_path
else
flash[:error] = "Ooops... invalid email or password."
redirect_to login_path
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 631b03ae..78f36467 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -23,11 +23,15 @@ module ApplicationHelper
end
def controller?(name)
- params[:controller].include?(name)
+ params[:controller].include?(name.to_s)
end
def render_markdown(content)
return "" if content.nil?
GitHub::Markdown.render_gfm(content)
end
+
+ def configuration_for(key, default)
+ content_for(key) || default
+ end
end
diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb
index 9f125d8d..021ea994 100644
--- a/app/mailers/notification_mailer.rb
+++ b/app/mailers/notification_mailer.rb
@@ -1,9 +1,8 @@
class NotificationMailer < ActionMailer::Base
default from: "noreply@cakeside.com"
- def notification_email(activity)
- @user = activity.user
- @activity = activity
+ def notification_email(user)
+ @user = user
mail(to: @user.email, subject: "New Activity on CakeSide")
end
end
diff --git a/app/models/activity.rb b/app/models/activity.rb
index 24e5ebb0..0e3047cd 100644
--- a/app/models/activity.rb
+++ b/app/models/activity.rb
@@ -1,9 +1,4 @@
class Activity < ActiveRecord::Base
- belongs_to :subject, polymorphic: true
- belongs_to :user
- after_create :send_notification_email
-
- def send_notification_email
- NotificationMailer.delay.notification_email(self)
- end
+ belongs_to :subject, polymorphic: true # favorite, comment
+ belongs_to :user # user to notify
end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 464d05f9..f85bc343 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -7,6 +7,9 @@ class Comment < ActiveRecord::Base
private
def create_activity
- Activity.create(user: user, subject: self)
+ transaction do
+ Activity.create(user: creation.author, subject: self)
+ creation.author.notify_of_activity
+ end
end
end
diff --git a/app/models/favorite.rb b/app/models/favorite.rb
index 2a6e900d..289d83ad 100644
--- a/app/models/favorite.rb
+++ b/app/models/favorite.rb
@@ -4,6 +4,9 @@ class Favorite < ActiveRecord::Base
after_create :create_activity
def create_activity
- Activity.create(user: creation.author, subject: self)
+ transaction do
+ Activity.create(user: creation.author, subject: self)
+ creation.author.notify_of_activity
+ end
end
end
diff --git a/app/models/tag.rb b/app/models/tag.rb
new file mode 100644
index 00000000..1f8309e5
--- /dev/null
+++ b/app/models/tag.rb
@@ -0,0 +1,9 @@
+class Tag
+ def self.unique_tags
+ ActsAsTaggableOn::Tag
+ .joins(:taggings)
+ .where(taggings: { context: 'tags' })
+ .order(:name)
+ .uniq
+ end
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 6b152a84..6bb6b95b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -50,7 +50,7 @@ class User < ActiveRecord::Base
end
def recent_activities(limit = 20)
- activities.includes(:subject).order(created_at: :desc).limit(limit)
+ activities.includes(subject: [{user: :avatar}, :creation]).order(created_at: :desc).limit(limit)
end
def comment_on(creation, text, disqus_id)
@@ -65,6 +65,10 @@ class User < ActiveRecord::Base
creations.create(name: name, category_id: category.id)
end
+ def notify_of_activity
+ NotificationMailer.delay.notification_email(self)
+ end
+
class << self
def login(username, password)
user = User.find_by(email: username)
diff --git a/app/services/application/update_cake_command.rb b/app/services/application/update_cake_command.rb
deleted file mode 100644
index 829a87dc..00000000
--- a/app/services/application/update_cake_command.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class UpdateCakeCommand
- def initialize(context)
- @context = context
- end
-
- def run(id, tags, creation_params)
- current_user = @context.current_user
-
- cake = current_user.creations.find(id)
- current_user.tag(cake, with: tags, on: :tags)
-
- if cake.update(creation_params.reject { |key, value| key == "tags" })
- @context.update_cake_succeeded(cake)
- else
- @context.update_cake_failed(cake)
- end
- end
-end
diff --git a/app/services/application/upload_photo.rb b/app/services/application/upload_photo.rb
index 1fde1a50..0465154a 100644
--- a/app/services/application/upload_photo.rb
+++ b/app/services/application/upload_photo.rb
@@ -5,9 +5,11 @@ class UploadPhoto
end
def run(cake_id, params)
- photo = @cakes.find(cake_id).photos.create!(image_processing: true, watermark: params[:watermark])
- @command_bus.publish(:upload_photo, create_message_from(cake_id, params, photo))
- photo
+ ActiveRecord::Base.transaction do
+ photo = @cakes.find(cake_id).photos.create!(image_processing: true, watermark: params[:watermark])
+ @command_bus.publish(:upload_photo, create_message_from(cake_id, params, photo))
+ photo
+ end
end
private
diff --git a/app/views/admin/jobs/index.html.erb b/app/views/admin/jobs/index.html.erb
index 4f17d882..cf287015 100644
--- a/app/views/admin/jobs/index.html.erb
+++ b/app/views/admin/jobs/index.html.erb
@@ -26,10 +26,10 @@
<td><%= job.last_error.present? ? link_to('FAILED', admin_job_path(job)) : '' %></td>
<td><%= job.locked_by %> </td>
<td><%= job.queue %></td>
- <td><%= time_ago_in_words(job.run_at) if job.run_at %></td>
- <td><%= time_ago_in_words(job.locked_at) if job.locked_at %></td>
- <td><%= time_ago_in_words(job.created_at) %></td>
- <td><%= time_ago_in_words(job.updated_at) %></td>
+ <td><%= job.run_at.try(:to_formatted_s, :short) %></td>
+ <td><%= job.locked_at.try(:to_formatted_s, :short) %></td>
+ <td><%= job.created_at.try(:to_formatted_s, :short) %></td>
+ <td><%= job.updated_at.try(:to_formatted_s, :short) %></td>
<td>
<%= link_to "Retry", admin_job_path(job), method: :put, class: 'btn', disable_with: 'Retrying...' %>
<%= link_to "Destroy", admin_job_path(job), method: :delete, class: 'btn btn-danger', disable_with: 'Deleting...' %>
diff --git a/app/views/admin/jobs/show.html.erb b/app/views/admin/jobs/show.html.erb
index 201d0d79..f20106cf 100644
--- a/app/views/admin/jobs/show.html.erb
+++ b/app/views/admin/jobs/show.html.erb
@@ -1,3 +1,4 @@
+<% provide(:container_class, 'container-fluid') %>
<div class="row-fluid">
<div class="span2">
<%= render partial: "my/shared/my_nav" %>
diff --git a/app/views/admin/sessions/index.html.erb b/app/views/admin/sessions/index.html.erb
index ff38368d..2d7ee574 100644
--- a/app/views/admin/sessions/index.html.erb
+++ b/app/views/admin/sessions/index.html.erb
@@ -10,7 +10,6 @@
<td>user</td>
<td><%= link_to "ip", admin_sessions_path(sort: 'ip', direction: @direction) %></td>
<td><%= link_to "city", admin_sessions_path(sort: 'city', direction: @direction) %></td>
- <td><%= link_to "user agent", admin_sessions_path(sort: 'ua', direction: @direction) %></td>
<td>device</td>
<td>browser</td>
<td>os</td>
@@ -26,13 +25,12 @@
<td><%= link_to user_session.user.name, admin_user_path(user_session.user) %></td>
<td><%= user_session.ip %></td>
<td><%= user_session.location.try(:city) %></td>
- <td><%= user_session.user_agent %></td>
<td><%= user_session.browser.form_factor %></td>
<td><%= user_session.browser.browser %></td>
<td><%= user_session.browser.os %></td>
<td><%= user_session.browser.os_version %></td>
- <td><%= user_session.accessed_at %></td>
- <td><%= user_session.revoked_at %></td>
+ <td><%= user_session.accessed_at.try(:to_formatted_s, :short) %></td>
+ <td><%= user_session.revoked_at.try(:to_formatted_s, :short) %></td>
<td><%= link_to "Revoke", admin_session_path(user_session), method: :delete, class: 'btn btn-danger' %></td>
</tr>
<% end %>
diff --git a/app/views/admin/users/_index.html.erb b/app/views/admin/users/_index.html.erb
index 5825cc60..823199e2 100644
--- a/app/views/admin/users/_index.html.erb
+++ b/app/views/admin/users/_index.html.erb
@@ -32,7 +32,7 @@
<%= "<li>#{user.facebook}</li>".html_safe unless user.facebook.blank? %>
</ul>
</td>
- <td><%= user.created_at.strftime("%Y-%m-%d") %></td>
+ <td><%= user.created_at.to_formatted_s(:short) %></td>
</tr>
<% end %>
</tbody>
diff --git a/app/views/api/v1/cakes/_cake.json.jbuilder b/app/views/api/v1/cakes/_cake.json.jbuilder
index 4e71e524..cd84dc1c 100644
--- a/app/views/api/v1/cakes/_cake.json.jbuilder
+++ b/app/views/api/v1/cakes/_cake.json.jbuilder
@@ -1,24 +1,26 @@
-json.id cake.id
-json.name cake.name
-json.slug cake.to_param
-json.story cake.story
-json.category do
- json.id cake.category.id
- json.name cake.category.name
-end
-json.user do
- json.id cake.user.id
- json.name cake.user.name
-end
-json.created_at cake.created_at
-json.updated_at cake.updated_at
-json.photos cake.photos do |photo|
- json.id photo.id
- json.large_url "https:#{photo.url_for(:large)}"
- json.thumb_url "https:#{photo.url_for(:thumb)}"
- json.created_at photo.created_at
- json.updated_at photo.updated_at
-end
-json.tags cake.tags do |tag|
- json.name tag.name
+json.cache! ['v1', cake] do
+ json.id cake.id
+ json.name cake.name
+ json.slug cake.to_param
+ json.story cake.story
+ json.created_at cake.created_at
+ json.updated_at cake.updated_at
+ json.category do
+ json.id cake.category.id
+ json.name cake.category.name
+ end
+ json.user do
+ json.id cake.user.id
+ json.name cake.user.name
+ end
+ json.photos cake.photos do |photo|
+ json.id photo.id
+ json.large_url "https:#{photo.url_for(:large)}"
+ json.thumb_url "https:#{photo.url_for(:thumb)}"
+ json.created_at photo.created_at
+ json.updated_at photo.updated_at
+ end
+ json.tags cake.tags do |tag|
+ json.name tag.name
+ end
end
diff --git a/app/views/api/v1/categories/_category.json.jbuilder b/app/views/api/v1/categories/_category.json.jbuilder
index 9d7d1c83..da651e96 100644
--- a/app/views/api/v1/categories/_category.json.jbuilder
+++ b/app/views/api/v1/categories/_category.json.jbuilder
@@ -1,3 +1,5 @@
-json.id category.id
-json.name category.name
-json.slug category.slug
+json.cache! ['v1', category] do
+ json.id category.id
+ json.name category.name
+ json.slug category.slug
+end
diff --git a/app/views/api/v1/photos/_photo.json.jbuilder b/app/views/api/v1/photos/_photo.json.jbuilder
index 00bceb3e..abc71501 100644
--- a/app/views/api/v1/photos/_photo.json.jbuilder
+++ b/app/views/api/v1/photos/_photo.json.jbuilder
@@ -1,9 +1,11 @@
-json.id photo.id
-json.cake_id photo.imageable_id
-json.content_type photo.content_type
-json.original_filename photo.original_filename
-json.thumb_url photo.url_for(:thumb)
-json.large_url photo.url_for(:large)
-json.original_url photo.url_for(:original)
-json.created_at photo.created_at
-json.updated_at photo.updated_at
+json.cache! ['v1', photo] do
+ json.id photo.id
+ json.cake_id photo.imageable_id
+ json.content_type photo.content_type
+ json.original_filename photo.original_filename
+ json.thumb_url photo.url_for(:thumb)
+ json.large_url photo.url_for(:large)
+ json.original_url photo.url_for(:original)
+ json.created_at photo.created_at
+ json.updated_at photo.updated_at
+end
diff --git a/app/views/api/v1/profiles/_profile.json.jbuilder b/app/views/api/v1/profiles/_profile.json.jbuilder
index 3d416cf8..a2b30992 100644
--- a/app/views/api/v1/profiles/_profile.json.jbuilder
+++ b/app/views/api/v1/profiles/_profile.json.jbuilder
@@ -1,8 +1,10 @@
-json.id profile.id
-json.email profile.email
-json.name profile.name
-json.website profile.website
-json.twitter profile.twitter
-json.facebook profile.facebook
-json.city profile.city
-json.errors profile.errors
+json.cache! ['v1', profile] do
+ json.id profile.id
+ json.email profile.email
+ json.name profile.name
+ json.website profile.website
+ json.twitter profile.twitter
+ json.facebook profile.facebook
+ json.city profile.city
+ json.errors profile.errors
+end
diff --git a/app/views/api/v1/tutorials/_tutorial.json.jbuilder b/app/views/api/v1/tutorials/_tutorial.json.jbuilder
index 6bfdbc1a..dbfe2974 100644
--- a/app/views/api/v1/tutorials/_tutorial.json.jbuilder
+++ b/app/views/api/v1/tutorials/_tutorial.json.jbuilder
@@ -1,12 +1,14 @@
-json.id tutorial.id
-json.heading tutorial.heading
-json.description tutorial.description
-json.url tutorial.url
-json.image_url tutorial.image_url
-json.author tutorial.author
-json.author_url tutorial.author_url
-json.created_at tutorial.created_at
-json.updated_at tutorial.updated_at
-json.tags tutorial.tags do |tag|
- json.name tag.name
+json.cache! ['v1', tutorial] do
+ json.id tutorial.id
+ json.heading tutorial.heading
+ json.description tutorial.description
+ json.url tutorial.url
+ json.image_url tutorial.image_url
+ json.author tutorial.author
+ json.author_url tutorial.author_url
+ json.created_at tutorial.created_at
+ json.updated_at tutorial.updated_at
+ json.tags tutorial.tags do |tag|
+ json.name tag.name
+ end
end
diff --git a/app/views/api/v1/tutorials/create.json.jbuilder b/app/views/api/v1/tutorials/create.json.jbuilder
new file mode 100644
index 00000000..cfc0f35b
--- /dev/null
+++ b/app/views/api/v1/tutorials/create.json.jbuilder
@@ -0,0 +1,3 @@
+json.tutorial do
+ json.partial! 'tutorial', tutorial: tutorial
+end
diff --git a/app/views/cakes/index.html.erb b/app/views/cakes/index.html.erb
index 1e6fc6db..0ee67e86 100644
--- a/app/views/cakes/index.html.erb
+++ b/app/views/cakes/index.html.erb
@@ -1,5 +1,6 @@
<% provide(:description, "CakeSide is a free site to share your cake creations and ideas with other cake fanatics like yourself") -%>
<% provide(:search_path, request.env['PATH_INFO'] || cakes_path) %>
+<% provide(:container_class, 'container-fluid') %>
<% unless user_signed_in? -%>
<div class="row-fluid">
<div class="span6">
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb
index 4a500c3b..5e31d54c 100644
--- a/app/views/layouts/_header.html.erb
+++ b/app/views/layouts/_header.html.erb
@@ -1,6 +1,6 @@
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
- <div class="container-fluid">
+ <div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
@@ -10,7 +10,7 @@
<div class="nav-collapse collapse">
<ul class="nav">
<li>
- <%= form_tag(yield(:search_path).blank? ? search_path : yield(:search_path), method: :get, name: "search", class: "navbar-search pull-left") do %>
+ <%= form_tag(configuration_for(:search_path, search_path), method: :get, name: "search", class: "navbar-search pull-left") do %>
<%= text_field_tag :q, params[:q], class: 'search-query', placeholder: 'Search' %>
<% end %>
</li>
@@ -21,7 +21,7 @@
<% if user_signed_in? %>
<ul class="nav pull-right" data-no-turbolink>
<li>
- <%= link_to my_root_path do %>
+ <%= link_to my_dashboard_path do %>
<%= avatar_for(current_user, size: 24) %> <%= current_user.name %>
<% end %>
</li>
@@ -30,24 +30,24 @@
<i class="fa fa-plus"></i> <b class="caret"></b>
</a>
<ul class="dropdown-menu">
- <li>
+ <li data-no-turbolink>
<%= link_to my_root_path(anchor: 'cakes/new') do %>
<i class="fa fa-upload"></i> New Cake
<% end %>
</li>
- <li>
+ <li data-no-turbolink>
<%= link_to my_root_path(anchor: 'tutorials/new') do %>
<i class="fa fa-pencil-square"></i> New Tutorial
<% end %>
</li>
</ul>
</li>
- <li>
- <%= link_to my_root_path do %>
+ <li data-no-turbolink>
+ <%= link_to my_dashboard_path do %>
<i class="fa fa-inbox"></i>
<% end %>
</li>
- <li>
+ <li data-no-turbolink>
<%= link_to my_root_path(anchor: 'profile/me') do %>
<i class="fa fa-cog"></i>
<% end %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 774579af..e741b60f 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -32,7 +32,7 @@
</head>
<body>
<%= render "layouts/header" %>
-<div class="container-fluid">
+<div class="<%= configuration_for(:container_class, 'container') %>">
<%= render "layouts/messages" %>
<%= yield %>
</div> <!-- /container -->
diff --git a/app/views/my/dashboard/_comment.html.erb b/app/views/my/dashboard/_comment.html.erb
index 7b15845a..88c21462 100644
--- a/app/views/my/dashboard/_comment.html.erb
+++ b/app/views/my/dashboard/_comment.html.erb
@@ -1,9 +1,7 @@
<div>
- <i class="fa fa-comment fa-large"></i>
- <%= avatar_for(subject.user, size: 24) %>
- <%= link_to subject.user.name, profile_path(subject.user) %> commented on <%= link_to subject.creation.name, my_root_path(anchor: "cakes/#{subject.creation.id}") %>
- <small><%= time_ago_in_words(subject.created_at) %> ago.</small>
+ <i class="fa fa-comment fa-large"></i> <%= link_to subject.creation.name, my_root_path(anchor: "cakes/#{subject.creation.id}") %>
<blockquote>
<%= subject.text %>
+ - <%= avatar_for(subject.user, size: 24) %> <%= link_to subject.user.name, profile_path(subject.user) %>
</blockquote>
</div>
diff --git a/app/views/my/dashboard/_creation.html.erb b/app/views/my/dashboard/_creation.html.erb
index 72d1663e..d8a72b00 100644
--- a/app/views/my/dashboard/_creation.html.erb
+++ b/app/views/my/dashboard/_creation.html.erb
@@ -3,8 +3,7 @@
<img class="media-object" data-src="<%= item.primary_image.url_for(:thumb) %>" alt="64x64" style="width: 64px; height: 64px;" src="<%= item.primary_image.url_for(:thumb) %>">
<% end %>
<div class="media-body">
- <h4 class="media-heading"><%= item.name %></h4>
- <%= item.story %>
+ <h4 class="media-heading"><%= link_to item.name, my_root_path(anchor: "cakes/#{item.id}") %></h4>
<p>
<%= link_to my_root_path(anchor: "cakes/#{item.id}/edit") do %>
<i class="fa fa-pencil-square-o"></i> edit
diff --git a/app/views/my/dashboard/_favorite.html.erb b/app/views/my/dashboard/_favorite.html.erb
index 1b48e7fa..70e499f6 100644
--- a/app/views/my/dashboard/_favorite.html.erb
+++ b/app/views/my/dashboard/_favorite.html.erb
@@ -1,9 +1,8 @@
<div>
<p>
- <i class="fa fa-heart fa-large"></i>
+ <i class="fa fa-star fa-large"></i>
<%= avatar_for(subject.user, size: 24) %>
- <%= link_to subject.user.name, profile_path(subject.user) %> added
- <%= link_to subject.creation.name, my_root_path(anchor: "cakes/#{subject.creation.id}") %> to their favorites
- <small><%= time_ago_in_words(subject.created_at) %> ago.</small>
+ <%= link_to subject.user.name, profile_path(subject.user) %> starred
+ <%= link_to subject.creation.name, my_root_path(anchor: "cakes/#{subject.creation.id}") %>
</p>
</div>
diff --git a/app/views/my/dashboard/_tutorial.html.erb b/app/views/my/dashboard/_tutorial.html.erb
index 19802278..0cd22be1 100644
--- a/app/views/my/dashboard/_tutorial.html.erb
+++ b/app/views/my/dashboard/_tutorial.html.erb
@@ -1,9 +1,5 @@
<div class="media">
- <%= link_to my_root_path(anchor: "tutorials/#{item.id}"), class: 'pull-left' do %>
- <img class="media-object" data-src="<%= item.image_url %>" alt="64x64" style="width: 64px; height: 64px;" src="<%= item.image_url %>">
- <% end %>
<div class="media-body">
- <h4 class="media-heading"><%= item.heading %></h4>
- <%= item.description %>
+ <h4 class="media-heading"><%= link_to item.heading, my_root_path(anchor: "tutorials/#{item.id}") %></h4>
</div>
</div>
diff --git a/app/views/my/dashboard/index.html.erb b/app/views/my/dashboard/index.html.erb
index 8a30f4c8..b285830f 100644
--- a/app/views/my/dashboard/index.html.erb
+++ b/app/views/my/dashboard/index.html.erb
@@ -1,49 +1,34 @@
<% provide(:title, "Dashboard") -%>
-<%= content_for :javascript do -%>
- <%= javascript_tag do %>
- var ALL_TAGS = [ <% ActsAsTaggableOn::Tag.pluck(:name).sort!.each { |item| %> '<%= item %>', <% } %> ];
- var disqus_shortname = '<%= ENV['DISQUS_SHORTNAME'] %>';
- var disqus_identifier = 'u-<%= current_user.id %>';
- var disqus_config = function(){
- this.page.remote_auth_s3 = '<%= disqus_auth %>';
- this.page.api_key = '<%= ENV['DISQUS_API_KEY'] %>';
- };
- $(document).ready(function(){
- CakeSide.initialize({
- access_token: '<%= current_user.authentication_token %>',
- disqus_shortname: disqus_shortname,
- });
- });
- $(document).on('page:load', function(){
- Backbone.history.stop();
- CakeSide.initialize({
- access_token: '<%= current_user.authentication_token %>',
- disqus_shortname: disqus_shortname,
- });
- });
- <% end %>
-<% end -%>
-
-<div class="row-fluid">
+<div class="row">
<div class="span2">
<%= render partial: "my/shared/my_nav" %>
</div>
- <div id="backbone-content" class="span10">
- <div class="span5">
- <% @items.each do |item| %>
- <%= render item.class.to_s.downcase, item: item %>
- <% end %>
- </div>
- <div class="span5">
- <% if @activities.empty? %>
- <p>No new activity to report.</p>
- <% else %>
- <% @activities.each do |activity| %>
- <%= render activity.subject.class.to_s.downcase, subject: activity.subject %>
+ <div class="span10" data-no-turbolink>
+ <div class="row">
+ <div class="span5">
+ <h5>My Cakes</h5>
+ <% @cakes.each do |item| %>
+ <%= render item.class.to_s.downcase, item: item %>
+ <% end %>
+ </div>
+ <div class="span5">
+ <div class="well">
+ <h5>My Notifications</h5>
+ <% if @activities.empty? %>
+ <p>No new activity to report.</p>
+ <% else %>
+ <% @activities.each do |activity| %>
+ <%= render activity.subject.class.to_s.downcase, subject: activity.subject %>
+ <% end %>
+ <% end %>
+ </div>
+ <% if @tutorials.any? %>
+ <h5>My Tutorials</h5>
+ <% @tutorials.each do |item| %>
+ <%= render item.class.to_s.downcase, item: item %>
+ <% end %>
<% end %>
- <% end %>
+ </div>
</div>
</div>
</div>
-<div id="disqus_thread" class="row-fluid"></div>
-<div id="modal" class="modal hide fade"></div>
diff --git a/app/views/my/favorites/index.html.erb b/app/views/my/favorites/index.html.erb
index 13bb3d89..4cfd1e5a 100644
--- a/app/views/my/favorites/index.html.erb
+++ b/app/views/my/favorites/index.html.erb
@@ -13,9 +13,7 @@
<%= image_tag creation.primary_image.url_for(:thumb) %>
<% end %>
<div class="caption">
- <h4><%= link_to shrink(creation.name, 12), cake_path(creation) %></h4>
- <p><%= link_to shrink(creation.user.name, 20), profile_path(creation.user) %></p>
- <p><small><%= time_ago_in_words(creation.created_at) %> ago.</small></p>
+ <small><%= link_to shrink(creation.name, 12), cake_path(creation) %></small>
</div>
</div>
</li>
diff --git a/app/views/my/kitchens/show.html.erb b/app/views/my/kitchens/show.html.erb
new file mode 100644
index 00000000..3c076d89
--- /dev/null
+++ b/app/views/my/kitchens/show.html.erb
@@ -0,0 +1,25 @@
+<% provide(:title, "Kitchen") -%>
+<%= content_for :javascript do -%>
+ <%= javascript_tag do %>
+ var ALL_TAGS = <%= raw @tags.pluck(:name) %>;
+ var disqus_shortname = '<%= ENV['DISQUS_SHORTNAME'] %>';
+ var disqus_identifier = 'u-<%= current_user.id %>';
+ var disqus_config = function(){
+ this.page.remote_auth_s3 = '<%= disqus_auth %>';
+ this.page.api_key = '<%= ENV['DISQUS_API_KEY'] %>';
+ };
+ CakeSide.initialize({
+ access_token: '<%= current_user.authentication_token %>',
+ disqus_shortname: disqus_shortname
+ });
+ <% end %>
+<% end %>
+
+<div class="row">
+ <div class="span2">
+ <%= render partial: "my/shared/my_nav" %>
+ </div>
+ <div id="backbone-content" class="span10"></div>
+</div>
+<div id="disqus_thread" class="row-fluid"></div>
+<div id="modal" class="modal hide fade"></div>
diff --git a/app/views/my/shared/_my_nav.html.erb b/app/views/my/shared/_my_nav.html.erb
index 15f65421..5c195037 100644
--- a/app/views/my/shared/_my_nav.html.erb
+++ b/app/views/my/shared/_my_nav.html.erb
@@ -4,34 +4,29 @@
<% end %>
<ul class="nav nav-list" data-no-turbolink>
<li class="nav-header"><%= current_user.name %></li>
- <li class="<%= "active" if controller?("dashboard") %>"><%= link_to "<i class='fa fa-tachometer'></i> Dashboard".html_safe, my_root_path %></li>
- <!--
- <li id="cakes-tab" class="<%= "active" if controller?("cakes") %>"><%= link_to "Creations", my_root_path(anchor: 'cakes') %></li>
- <li id="tutorial-tab"><%= link_to "Tutorials", my_root_path(anchor: 'tutorials') %></li>
- -->
- <!--<li class="<%= 'active' if controller?('settings') %>"><%= link_to "<i class='fa fa-cog'></i> Settings".html_safe, my_settings_path %></li>-->
- <li id='profile-tab'><%= link_to "<i class='fa fa-cog'></i> Profile".html_safe, my_root_path(anchor: 'profile/me') %></li>
- <li class="<%= 'active' if controller?('passwords') %>"><%= link_to "<i class='fa fa-eye'></i> Account Settings".html_safe, my_passwords_path %></li>
- <li class="<%= "active" if controller?("favorites") %>"><%= link_to "<i class='fa fa-star'></i> Favorites".html_safe, my_favorites_path %></li>
- <li class="<%= 'active' if controller?('avatars') %>"><%= link_to "<i class='fa fa-picture-o'></i> Picture".html_safe, new_my_avatar_path %></li>
- <li class="nav-header">Actions</li>
+ <li class="<%= "active" if controller?(:dashboard) %>"><%= link_to "Dashboard", my_dashboard_path %></li>
+ <li id='profile-tab'><%= link_to "Profile", my_root_path(anchor: 'profile/me') %></li>
+ <li class="<%= 'active' if controller?(:passwords) %>"><%= link_to "Account", my_passwords_path %></li>
+ <li class="<%= "active" if controller?(:favorites) %>"><%= link_to "Favorites", my_favorites_path %></li>
+ <li class="<%= 'active' if controller?(:avatars) %>"><%= link_to "Picture", new_my_avatar_path %></li>
+ <li class="nav-header">New</li>
<li>
<%= link_to my_root_path(anchor: 'cakes/new') do %>
- <i class="fa fa-upload"></i> New Cake
+ <i class="fa fa-upload"></i> Cake
<% end %>
</li>
<li>
<%= link_to my_root_path(anchor: 'tutorials/new') do %>
- <i class="fa fa-pencil-square"></i> New Tutorial
+ <i class="fa fa-pencil-square"></i> Tutorial
<% end %>
</li>
<% if current_user.admin? %>
<li class="nav-header">Admin</li>
- <li><%= link_to "<i class='fa fa-users'></i> Users".html_safe, admin_users_path %></li>
- <li><%= link_to "<i class='fa fa-database'></i> Jobs".html_safe, admin_jobs_path %></li>
- <li><%= link_to "<i class='fa fa-cubes'></i> Activity".html_safe, admin_activities_path %></li>
+ <li><%= link_to "Users", admin_users_path %></li>
+ <li><%= link_to "Jobs", admin_jobs_path %></li>
+ <li><%= link_to "Activity", admin_activities_path %></li>
<li><%= link_to "Subscriptions", admin_subscriptions_path %></li>
- <li><%= link_to "<i class='fa fa-photo'></i> Photos".html_safe, admin_photos_path %></li>
+ <li><%= link_to "Photos", admin_photos_path %></li>
<li><%= link_to "Blobs", admin_blobs_path %></li>
<li><%= link_to "Sessions", admin_sessions_path %></li>
<li><%= link_to "Products", admin_products_path %></li>
diff --git a/app/views/notification_mailer/notification_email.text.erb b/app/views/notification_mailer/notification_email.text.erb
index 0276d4b6..04f52c11 100644
--- a/app/views/notification_mailer/notification_email.text.erb
+++ b/app/views/notification_mailer/notification_email.text.erb
@@ -1,4 +1,3 @@
-
Hi <%= @user.name %>,
You have new notification on Cakeside. Click <%= link_to "here", my_dashboard_url(protocol: 'https') %> to see.
diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb
index 53f1dda4..d6b6517d 100644
--- a/app/views/products/index.html.erb
+++ b/app/views/products/index.html.erb
@@ -1,11 +1,7 @@
<%= provide(:search_path, products_path) %>
<div class="row-fluid">
<div class="span12">
- <h1>Product Catalog</h1>
- <%= form_tag products_path(js: true), method: :get, name: 'search', class: 'form-horizontal', remote: true do %>
- <%= text_field_tag :q, params[:q], class: "search-query", placeholder: "Search" %>
- <%= submit_tag 'Search', class: 'btn btn-primary' %>
- <% end %>
+ <%= link_to "back", params[:boomerang] %>
<div id="results-container">
<%= render partial: "index" %>
</div>
diff --git a/app/views/profiles/index.html.erb b/app/views/profiles/index.html.erb
index 54470cee..9409ca3f 100644
--- a/app/views/profiles/index.html.erb
+++ b/app/views/profiles/index.html.erb
@@ -1,4 +1,5 @@
<%= provide(:search_path, profiles_path) %>
+<% provide(:container_class, 'container-fluid') %>
<div id="bakery">
<%= render partial: 'index' %>
</div>
diff --git a/app/views/tutorials/index.html.erb b/app/views/tutorials/index.html.erb
index 0179c9c0..d8f4e225 100644
--- a/app/views/tutorials/index.html.erb
+++ b/app/views/tutorials/index.html.erb
@@ -1,4 +1,5 @@
<%= provide(:search_path, tutorials_path) %>
+<% provide(:container_class, 'container-fluid') %>
<div class="row-fluid">
<% @tutorials.each_slice(6).each do |batch| %>
<ul class='thumbnails'>
diff --git a/config/routes.rb b/config/routes.rb
index 395dcd3f..0e187d38 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -96,6 +96,7 @@ Cake::Application.routes.draw do
resources :settings, only: [:index, :update]
resources :passwords, only: [:index, :update]
resources :avatars, only: [:new, :create]
- root to: "dashboard#index"
+ resource :kitchen, only: [:show]
+ root to: "kitchens#show"
end
end
diff --git a/db/migrate/20141102040612_recreate_all_activities.rb b/db/migrate/20141102040612_recreate_all_activities.rb
new file mode 100644
index 00000000..a401a26a
--- /dev/null
+++ b/db/migrate/20141102040612_recreate_all_activities.rb
@@ -0,0 +1,13 @@
+class RecreateAllActivities < ActiveRecord::Migration
+ def change
+ ActiveRecord::Base.transaction do
+ Activity.destroy_all
+ Favorite.find_each do |favorite|
+ Activity.create(user: favorite.creation.author, subject: favorite, created_at: favorite.created_at, updated_at: favorite.updated_at)
+ end
+ Comment.find_each do |comment|
+ Activity.create(user: comment.creation.author, subject: comment, created_at: comment.created_at, updated_at: comment.updated_at)
+ end
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 86d1dacc..67af9bf6 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20141020045107) do
+ActiveRecord::Schema.define(version: 20141102040612) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -31,8 +31,8 @@ ActiveRecord::Schema.define(version: 20141020045107) do
create_table "avatars", force: true do |t|
t.integer "user_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "avatar"
t.boolean "avatar_processing"
t.string "avatar_tmp"
@@ -85,8 +85,8 @@ ActiveRecord::Schema.define(version: 20141020045107) do
t.datetime "failed_at"
t.string "locked_by"
t.string "queue"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
@@ -103,8 +103,8 @@ ActiveRecord::Schema.define(version: 20141020045107) do
create_table "interests", force: true do |t|
t.string "name"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "locations", id: :uuid, default: "uuid_generate_v4()", force: true do |t|
@@ -157,15 +157,13 @@ ActiveRecord::Schema.define(version: 20141020045107) do
t.integer "taggings_count", default: 0
end
- add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
-
create_table "tutorials", force: true do |t|
t.string "heading"
t.text "description"
t.string "url"
t.integer "user_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "image_url"
t.string "author"
t.string "author_url"
@@ -190,8 +188,8 @@ ActiveRecord::Schema.define(version: 20141020045107) do
add_index "user_sessions", ["user_id"], name: "index_user_sessions_on_user_id", using: :btree
create_table "users", force: true do |t|
- t.string "email", default: "", null: false
- t.string "password_digest", default: "", null: false
+ t.string "email", default: "", null: false
+ t.string "password_digest", limit: 128, default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "created_at"
@@ -203,7 +201,7 @@ ActiveRecord::Schema.define(version: 20141020045107) do
t.string "city"
t.string "authentication_token"
t.string "full_address"
- t.integer "creations_count", default: 0
+ t.integer "creations_count", default: 0
t.boolean "admin"
end
diff --git a/spec/controllers/api/v1/tutorials_controller_spec.rb b/spec/controllers/api/v1/tutorials_controller_spec.rb
index 435e6136..7d7ef5c6 100644
--- a/spec/controllers/api/v1/tutorials_controller_spec.rb
+++ b/spec/controllers/api/v1/tutorials_controller_spec.rb
@@ -11,9 +11,8 @@ describe Api::V1::TutorialsController do
let(:my_tutorial) { create(:tutorial, user: user) }
let(:other_tutorial) { create(:tutorial) }
-
it "returns the users tutorials" do
- get :index, format: :json
+ xhr :get, :index
expect(assigns(:tutorials)).to include(my_tutorial)
expect(assigns(:tutorials)).to_not include(other_tutorial)
end
@@ -28,7 +27,7 @@ describe Api::V1::TutorialsController do
description: "Connect with your friends - and other fascinating people. Get in-the-moment updates on the things that interest you. And watch events unfold, in real time, from every angle.",
tags: "cake,cookie",
}
- post :create, tutorial: attributes, format: :json
+ xhr :post, :create, tutorial: attributes
expect(assigns(:tutorial)).to be_present
expect(assigns(:tutorial).url).to eql(attributes[:url])
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb
index 692500fd..9a9eaf63 100644
--- a/spec/controllers/registrations_controller_spec.rb
+++ b/spec/controllers/registrations_controller_spec.rb
@@ -10,7 +10,7 @@ describe RegistrationsController do
post :create, user: { name: 'mo', email: 'mo@cakeside.com', password: 'password' }
expect(User.count).to eql(1)
- expect(response).to redirect_to(my_root_path)
+ expect(response).to redirect_to(my_dashboard_path)
expect(cookies.signed[:raphael]).to_not be_nil
expect(cookies.signed[:raphael]).to eql(user_session.access)
end
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index 7de183d9..63ca58ca 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -17,7 +17,7 @@ describe SessionsController do
it "redirects to the dashboard" do
get :new
- expect(response).to redirect_to(my_root_path)
+ expect(response).to redirect_to(my_dashboard_path)
end
end
end
@@ -39,7 +39,7 @@ describe SessionsController do
end
it "redirects to the dashboard" do
- expect(response).to redirect_to(my_root_path)
+ expect(response).to redirect_to(my_dashboard_path)
end
end
diff --git a/spec/factories.rb b/spec/factories.rb
index 2f4acaee..e1f30710 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -1,7 +1,7 @@
FactoryGirl.define do
factory :activity, class: Activity do
- user { FactoryGirl.create(:user) }
- subject { FactoryGirl.create(:creation) }
+ user { create(:user) }
+ subject { create(:favorite) }
end
factory :category, class: Category do
@@ -31,8 +31,8 @@ FactoryGirl.define do
end
factory :favorite do
- user { FactoryGirl.create(:user) }
- creation { FactoryGirl.create(:creation) }
+ association :user
+ association :creation
end
factory :photo, class: Photo do
diff --git a/spec/features/change_password_spec.rb b/spec/features/change_password_spec.rb
index 94f4dbb9..39bcaf9f 100644
--- a/spec/features/change_password_spec.rb
+++ b/spec/features/change_password_spec.rb
@@ -11,8 +11,8 @@ describe "changing my password", js: true do
fill_in('session_password', :with => "password")
end
click_button("Sign In")
- visit my_root_path
- click_link("Account Settings")
+ visit my_dashboard_path
+ click_link("Account")
within(".form-horizontal") do
fill_in('user_password', :with => "mopass")
fill_in('user_password_confirmation', :with => "mopass")
diff --git a/spec/features/registration_spec.rb b/spec/features/registration_spec.rb
index 81144517..25bc2724 100644
--- a/spec/features/registration_spec.rb
+++ b/spec/features/registration_spec.rb
@@ -13,7 +13,7 @@ describe "Registration", :js => true do
end
it "should let you register with that email address" do
- expect(page).to have_content("No new activity to report.")
+ expect(page).to have_content("Dashboard")
end
xit "should take you to the settings page" do
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
index fc5c8366..c67ab53e 100644
--- a/spec/mailers/notification_mailer_spec.rb
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -2,15 +2,15 @@ require "rails_helper"
describe NotificationMailer do
context "send welcome email" do
- let(:activity) { build(:activity) }
- let(:mail) { NotificationMailer.notification_email(activity) }
+ let(:user) { build(:user) }
+ let(:mail) { NotificationMailer.notification_email(user) }
it "adds a subject" do
mail.subject.should == "New Activity on CakeSide"
end
it "sends to the users email" do
- mail.to.should include activity.user.email
+ mail.to.should include user.email
end
it "should send from the correct address" do
@@ -18,7 +18,7 @@ describe NotificationMailer do
end
it "includes their name" do
- mail.body.encoded.should match(activity.user.name)
+ mail.body.encoded.should match(user.name)
end
end
end
diff --git a/spec/mailers/previews/notification_mailer_preview.rb b/spec/mailers/previews/notification_mailer_preview.rb
index ca5d236a..c4d0e9be 100644
--- a/spec/mailers/previews/notification_mailer_preview.rb
+++ b/spec/mailers/previews/notification_mailer_preview.rb
@@ -1,5 +1,5 @@
class NotificationMailerPreview < ActionMailer::Preview
def notification_email
- NotificationMailer.notification_email(Activity.last)
+ NotificationMailer.notification_email(User.last)
end
end
diff --git a/spec/models/favorite_spec.rb b/spec/models/favorite_spec.rb
index 36e4031c..523e835e 100644
--- a/spec/models/favorite_spec.rb
+++ b/spec/models/favorite_spec.rb
@@ -7,7 +7,7 @@ describe Favorite do
let(:user) { create(:user) }
it "creates a new activity" do
- creation.favorites.create(:user => user)
+ user.favorites.create(creation: creation)
creation.author.activities.count.should == 1
end
end