Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Muncher - Angela - Octos #31

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d053b29
run rails new
knockknockhusthere May 2, 2018
21f69c0
created recipe controller and routes
knockknockhusthere May 2, 2018
c3cc13d
added httparty and figaro to gemfile
knockknockhusthere May 2, 2018
18cc73a
added env files
knockknockhusthere May 2, 2018
7dfc014
added env file and added api wrapper
knockknockhusthere May 2, 2018
9413df4
recipe model tests and api wrapper tests
knockknockhusthere May 2, 2018
748d0e9
wrote list_recipes and added edamam attribute
knockknockhusthere May 3, 2018
13c66c1
testing output for pesto chicken in index views page
knockknockhusthere May 4, 2018
0acd604
linked show page for recipes, editted controller actions
knockknockhusthere May 4, 2018
bdef4a9
FIXED THE SHOW PAGE YAY
knockknockhusthere May 4, 2018
cfe6f11
eager load addition to config/application
knockknockhusthere May 4, 2018
ba06229
added enable dependencies
knockknockhusthere May 4, 2018
2e7de85
remove pry
knockknockhusthere May 4, 2018
ace3624
circular reference fix
knockknockhusthere May 4, 2018
f1b90c9
hid pry gem
knockknockhusthere May 4, 2018
ce7b87a
added paginate
knockknockhusthere May 5, 2018
3590ffa
recipes controller testing for index
knockknockhusthere May 6, 2018
0f6a93d
controller tests for show
knockknockhusthere May 6, 2018
9d1aa69
test added and passing
knockknockhusthere May 6, 2018
5eece16
added a background image
knockknockhusthere May 7, 2018
fdf8717
css changes
knockknockhusthere May 7, 2018
873f692
css for index and show
knockknockhusthere May 7, 2018
bf01469
getting heroku to compile assets
knockknockhusthere May 7, 2018
63d54f4
created footer
knockknockhusthere May 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added paginate
  • Loading branch information
knockknockhusthere committed May 5, 2018
commit ce7b87a79adeb60e134e4c453796b7ef74eb571f
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ gem 'bootsnap', '>= 1.1.0', require: false
gem 'httparty'
gem 'figaro'

gem 'will_paginate', '~> 3.1.0'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ GEM
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
will_paginate (3.1.6)
xpath (3.0.0)
nokogiri (~> 1.8)

Expand Down Expand Up @@ -273,6 +274,7 @@ DEPENDENCIES
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
webmock
will_paginate (~> 3.1.0)

RUBY VERSION
ruby 2.5.0p0
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/recipes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class RecipesController < ApplicationController
def index
@query = params[:query]
@recipes = RecipeApiWrapper.list_recipes(@query)
@recipes = RecipeApiWrapper.list_recipes(@query).paginate(:page => params[:page], :per_page => 12)
# @recipe = RecipeApiWrapper.show_recipe("http%3A%2F%2Fwww.edamam.com%2Fontologies%2Fedamam.owl%23recipe_48c52ac3bd8c16720a7cb8ef34cd5e5b")
end

Expand Down
2 changes: 2 additions & 0 deletions app/views/recipes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
<h3><%= link_to recipe.label, recipe_path(:uri => recipe.uri, :label => recipe.label) %></h3>
<img src=" <%= recipe.image %>" alt="recipe photo">
<% end %>

<%= will_paginate @recipes, id: "paginate-index"%>
1 change: 1 addition & 0 deletions config/initializers/array_paginate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'will_paginate/array'
4 changes: 2 additions & 2 deletions lib/recipe_api_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class RecipeError < StandardError; end
search_results = []
def self.list_recipes(query)

url = "https://api.edamam.com/search?app_id=#{API_ID}&app_key=#{API_KEY}&q=#{query}"
url = "https://api.edamam.com/search?app_id=#{API_ID}&app_key=#{API_KEY}&q=#{query}&to=120"

encoded_uri = URI.encode(url)

response = HTTParty.get(url).parsed_response
#ALWAYS CHECK YOUR ERROR CODES
# ALWAYS CHECK YOUR ERROR CODES
# unless response.success?
# raise StandardError.new(response["error"])
# end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# ALWAYS CHECK YOUR ERROR CODES

ಠ_ಠ

Expand Down