-
Notifications
You must be signed in to change notification settings - Fork 47
UPDATED README #85
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
base: master
Are you sure you want to change the base?
UPDATED README #85
Changes from 3 commits
2aad47f
ee29483
fbcef37
c42cc24
56278ad
9ea1ef3
b00d9db
9e112e0
3682bdf
20e3ca9
424d144
19e366d
7cc6331
06d069f
e352e82
9a50203
05e22e7
821b582
83234c7
66d8d51
8155bd0
94e485b
b9dc8fd
f8cf55e
9676305
02ae263
695f4dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,10 @@ | ||
| class RecipeController < ApplicationController | ||
| def new | ||
| end | ||
|
|
||
| def update | ||
| def index | ||
| end | ||
|
|
||
| def show | ||
|
|
||
| end | ||
|
|
||
| def destroy | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,27 @@ | ||
| class ResultsController < ApplicationController | ||
|
|
||
| # https://developer.edamam.com/edamam-docs-recipe-api | ||
| # from Edamam q = query text, r = return of recipe based on it's id | ||
| attr_reader :q, :uri | ||
|
|
||
| # def initialize(q, uri) | ||
| # # @q = q | ||
| # # @uri = uri | ||
| # end | ||
|
|
||
| # attr_reader :query, :uri | ||
| def index | ||
| end | ||
|
|
||
| def new | ||
| end | ||
|
|
||
| def create | ||
| @page = '/' | ||
| end | ||
|
|
||
| def show | ||
| end | ||
|
|
||
| def edit | ||
| end | ||
|
|
||
| def update | ||
| end | ||
|
|
||
| def destroy | ||
| # @page = "/" | ||
| # @results = ApiMuncherWrapper.search(params[:query], params[:from]) | ||
| # @count = ApiMuncherWrapper.results(params[:query]) | ||
| # @query = params[:query] | ||
|
|
||
| # # expect user to be redirected to new search | ||
| # if @results == false | ||
| # redirect_to results_index_path | ||
| # flash[:notice] = "Recipe not found. Try Again Please!" | ||
| # else # expect user to be shown serach results | ||
| # @results_start = params[:from].to_i + 1 | ||
| # @results_end = @results_start + @results.length - 1 | ||
| # # do I need to reset query here, should I clear the field? | ||
|
|
||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| <h1>See your Recipes here!</h1> | ||
| <% @results.each do |recipe|%> | ||
| <%= recipe[:name] %> | ||
| <%= image_tag(recipe[:pic]) %> | ||
| <%= link_to recipe[:uri] do %> | ||
| <%= recipe[:name] %><br> | ||
| <%= image_tag(recipe[:pic]) %> | ||
| <!-- <%# recipe[:uri] %> --> | ||
| <% end %> | ||
| <br><br><br> | ||
| <% end %> | ||
| <!-- turn this into a partial --> | ||
| <footer><p class="attribute"> Powered by Edamam <img src="../edamam_logo.svg" alt="Edamam Logo"><p></footer> | ||
| <footer> | ||
| <p class="attribute"> Powered by Edamam | ||
| <img src="/assets/edamam_logo.png" alt="Edamam Logo"> | ||
| <p> | ||
| </footer> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,21 @@ | ||
| require 'httparty' | ||
| # did you change this ? Then restart the server! | ||
| class ApiMuncherWrapper | ||
|
|
||
| BASE_URL = "https://api.edamam.com/search" | ||
| # should this be listed as Token/ id instead/ | ||
| APP_ID = ENV['app_id'] | ||
| APP_KEY = ENV['app_key'] | ||
|
|
||
| # https://developer.edamam.com/edamam-docs-recipe-api | ||
| # from Edamam q = query text, r = return of recipe based on it's id | ||
| # attr_reader :recipe, :q, :url, :image, :returns, :r | ||
| # def initialize(recipe, q, url, image, returns, r) | ||
| # @recipe = recipe | ||
| # @q = q | ||
| # @url = url | ||
| # @image = image | ||
| # end | ||
|
|
||
| def self.get_recipe | ||
| url = BASE_URL + "?q=bacon&from=0&to=10" + "&app_id=#{APP_ID}" + "&app_key=#{APP_KEY}" | ||
|
|
||
| def self.get_recipes(query, from=nil) | ||
|
|
||
| url = BASE_URL + "?q=#{query}" + "&app_id=#{APP_ID}" + "&app_key=#{APP_KEY}" + "#{from}" | ||
|
|
||
| puts "*******" + url + "*******" | ||
|
|
||
| # url = BASE_URL + "?q=bacon&from=0&to=10" + "&app_id=#{APP_ID}" + "&app_key=#{APP_KEY}" | ||
|
|
||
| data = HTTParty.get(url) | ||
| # return data['hits'][0]['recipe']['label'] | ||
| recipes = [] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might want to put in some checks in for if the API responds with something unexpected, like if 'hits' is null. I would also probably setup a recipe class and return either a specific recipe or an array of them. That way you would separate the implementation of the Recipe API from it's use. It would let you switch APIs or other sources of the recipes easier. |
||
|
|
@@ -26,14 +24,20 @@ def self.get_recipe | |
| data['hits'].each do |recipe| | ||
| label = recipe["recipe"]["label"] | ||
| image = recipe["recipe"]["image"] | ||
| uri = recipe["recipe"]["uri"] | ||
| recipes << { | ||
| name: label, | ||
| pic: image | ||
| pic: image, | ||
| uri: uri | ||
| } | ||
| end | ||
| end | ||
| return recipes | ||
| end | ||
|
|
||
| def self.get_one_recipe | ||
|
|
||
| end | ||
| end | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This footer could be abstracted into the layout or as a partial.