Skip to content

Commit

Permalink
merge conflicts commit
Browse files Browse the repository at this point in the history
  • Loading branch information
github username committed Jun 22, 2017
2 parents dbcdc0b + 1d4264e commit 024d684
Show file tree
Hide file tree
Showing 40 changed files with 201 additions and 6 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ gem 'pry'
gem 'carrierwave', '~> 1.1.0'
gem 'mini_magick'
gem 'paperclip', git: 'git://github.com/thoughtbot/paperclip.git'
gem 'rails4-autocomplete'
# gem 'rmagick'
gem 'jquery-rails'

Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails4-autocomplete (1.1.1)
rails (>= 3.0)
railties (5.1.1)
actionpack (= 5.1.1)
activesupport (= 5.1.1)
Expand Down Expand Up @@ -215,6 +217,7 @@ DEPENDENCIES
pry
puma (~> 3.7)
rails (~> 5.1.1)
rails4-autocomplete
sass-rails (~> 5.0)
selenium-webdriver
spring
Expand Down
15 changes: 14 additions & 1 deletion app/controllers/recipes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ def update
render :edit
end
end

def search
end

def find
@searched_recipes = Recipe.select(name: params[:search])
name = params[:search].split(" ").join("_")
redirect_to found_path(name)
end

def found
name = params[:name].split("_").join(" ")
@searched_recipes = Recipe.where(name: name)
end

def destroy
@recipe = Recipe.find(params[:id])
Expand All @@ -51,7 +65,6 @@ def destroy
flash[:notice] = "Successfully deleted #{@recipe.name}"
end


private

def recipe_params
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
class WelcomeController < ApplicationController

def index
end

end
42 changes: 40 additions & 2 deletions app/models/recipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,51 @@ class Recipe < ApplicationRecord
belongs_to :author, :class_name => "User", :foreign_key => :author_id
has_many :recipe_ingredients
has_many :ingredients, through: :recipe_ingredients
has_attached_file :image, styles: { medium: '300x300>', thumb: '100x100>' }, default_url: "/images/:style/missing.png"
has_attached_file :image, styles: { medium: '300x300>', thumb: '50x50>' }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/

validates :name, presence: true
validates :prep_time, presence: true
validates :cook_time, presence: true
validates :instructions, presence: true

#alias_method :saved_recipe_id, :id
def self.published
Recipe.all.find_all{|r| r.published}
end

def self.featured
@weekly_recipes = Recipe.where(:created_at => 7.days.ago..Time.now).where(published: true)
@weekly_recipes.sort_by{|r| r.savers.length}.reverse.first(5)
end

def self.top_users
Recipe.published.sort_by{|r| r.savers.length}.reverse.map do |r|
User.find(r.author_id)
end.uniq.first(5)
end

def self.top_recipes
Recipe.published.sort_by{|r| r.savers.length}.reverse.first(5)
end

def self.fast_food
Recipe.published.sort_by{|r| r.prep_time + r.cook_time}.first(5)
end

def self.top_vegan
Recipe.published.find_all{|r| r.vegan}.sort_by{|r| r.savers.length}.reverse.first(5)
end

def self.top_low_carb
Recipe.published.find_all{|r| r.low_carb}.sort_by{|r| r.savers.length}.reverse.first(5)
end

def self.top_kosher
Recipe.published.find_all{|r| r.kosher}.sort_by{|r| r.savers.length}.reverse.first(5)
end

def self.top_halal
Recipe.published.find_all{|r| r.halal}.sort_by{|r| r.savers.length}.reverse.first(5)
end

end
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<div class="nav-wrapper yellow darken-3">
<a href="<%= root_url %>" class="brand-logo left">RecipeSharingApp</a>
<ul class="right">
<li><a href="/search"><i class="material-icons">search</i></a></li>
<li class="hide-on-small-only"><a href="<%= users_path %>">All Users</a></li>
<li class="hide-on-small-only"><a href="<%= recipes_path %>">All Recipes</a></li>

Expand Down
9 changes: 9 additions & 0 deletions app/views/recipes/found.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>Searched Recipes</h1>

<% @searched_recipes.each do |recipe| %>

<ul>
<li><%= link_to recipe.name, recipe_path(recipe) %></li>
</ul>

<% end %>
15 changes: 15 additions & 0 deletions app/views/recipes/index.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<div class="row">
<form class="col s12" action="/search" method="post">
<div class="row">
<br>
<div class="input-field col s12">
<i class="material-icons prefix">search</i>
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>">
<input id="icon_prefix" type="text" class="validate" name="search">
<label for="icon_prefix">Search</label>
</div>
</div>
</form>
</div>


<h1>All Recipes</h1>

<% Recipe.published.each do |recipe| %>
Expand Down
13 changes: 13 additions & 0 deletions app/views/recipes/search.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="row">
<form class="col s12" action="/search" method="post">
<div class="row">
<br><br><br><br>
<div class="input-field col s12">
<i class="material-icons prefix">search</i>
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>">
<input id="icon_prefix" type="text" class="validate" name="search">
<label for="icon_prefix">Search</label>
</div>
</div>
</form>
</div>
6 changes: 5 additions & 1 deletion app/views/recipes/show.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
</div><br><br>

<div>
<%= image_tag @recipe.image.url(:medium) if @recipe.image? %>
<% if @recipe.image? %>
<%= image_tag @recipe.image.url(:medium) %>
<% else %>
<%= image_tag '/../../public/placeholders/placeholder.jpg' %>
<% end %>
</div>
<div>
<h5>Dietary Compliance</h5>
Expand Down
95 changes: 93 additions & 2 deletions app/views/welcome/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,95 @@
<h2>Welcome to the Recipe Sharing App</h2>
<h2>Welcome to FaceCook!</h2>
<p>
The time is now: <%= Time.now %>
<%= Time.now.strftime("%B %d, %Y") %>
</p>

<div class="container">
<br>
<div class="row">
<p><strong>Featured Recipes of This Week</strong></p>
<% Recipe.featured.each do |recipe| %>
<div class="col s3">
<%= image_tag recipe.image.url(:thumb) %>
<br>
<%= link_to recipe.name, recipe_path(recipe) %>
</div>
<% end %>
<br><br>

<p><strong>Top Users</strong></p>
<% Recipe.top_users.each do |user| %>
<div class="col s3">
<%= image_tag user.image.url(:thumb) %>
<br>
<%= link_to user.first_name, user_path(user) %>
</div>
<% end %>
</div>
<br>

<div class="row">
<p><strong>Top Recipes of All Time</strong></p>
<% Recipe.top_recipes.each do |recipe| %>
<div class="col s3">
<%= image_tag recipe.image.url(:thumb) %>
<br>
<%= link_to recipe.name, recipe_path(recipe) %>
</div>
<% end %>

<p><strong>Fastest Food</strong></p>
<% Recipe.fast_food.each do |recipe| %>
<div class="col s3">
<%= image_tag recipe.image.url(:thumb) %>
<br>
<%= link_to recipe.name, recipe_path(recipe) %>
</div>
<% end %>
</div>

<div class="row">
<p><strong>Best Vegan Recipes</strong></p>
<% Recipe.top_vegan.each do |recipe| %>
<div class="col s3">
<%= image_tag recipe.image.url(:thumb) %>
<br>
<%= link_to recipe.name, recipe_path(recipe) %>
</div>
<% end %>
<br><br>
</div>

<div class="row">
<p><strong>Best Low Carb Recipes</strong></p>
<% Recipe.top_low_carb.each do |recipe| %>
<div class="col s3">
<%= image_tag recipe.image.url(:thumb) %>
<br>
<%= link_to recipe.name, recipe_path(recipe) %>
</div>
<% end %>
</div>
<br>

<div class="row">
<p><strong>Best Kosher Recipes</strong></p>
<% Recipe.top_kosher.each do |recipe| %>
<div class="col s3">
<%= image_tag recipe.image.url(:thumb) %>
<br>
<%= link_to recipe.name, recipe_path(recipe) %>
</div>
<% end %>
</div>

<div class="row">
<p><strong>Best Halaal Recipes</strong></p>
<% Recipe.top_halal.each do |recipe| %>
<div class="col s3">
<%= image_tag recipe.image.url(:thumb) %>
<br>
<%= link_to recipe.name, recipe_path(recipe) %>
</div>
<% end %>
</div>
</div>
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
resources :recipes
resources :users
resources :saver_recipes
get '/search' => 'recipes#search', as: 'search'
post '/search' => 'recipes#find'
get '/found/:name' => 'recipes#found', as: 'found'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'welcome#index'
get '/signin' => 'sessions#new'
Expand Down
Binary file added public/.DS_Store
Binary file not shown.
Binary file added public/system/.DS_Store
Binary file not shown.
Binary file added public/system/recipes/.DS_Store
Binary file not shown.
Binary file added public/system/recipes/images/.DS_Store
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/system/users/.DS_Store
Binary file not shown.
Binary file added public/system/users/images/.DS_Store
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 024d684

Please sign in to comment.