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

Carets- Julia Meier- API Muncher #25

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
43689ef
initial setup. copied lib and lib_test files from previous project. m…
julmeier Nov 1, 2017
b2d35cc
added recipes_controller
julmeier Nov 1, 2017
86dde1e
added config.autoload_paths line to the config/application.rb file
julmeier Nov 1, 2017
b3d54f1
continued testing of edamam_api_wrapper. Found some leftover text aft…
julmeier Nov 1, 2017
17fea3b
created controller methods and made index and search html pages. Was …
julmeier Nov 2, 2017
7b7cb33
made show controller, route and view
julmeier Nov 2, 2017
96a423f
created show_recipe method. modified list_recipes method to take in t…
julmeier Nov 2, 2017
86d29f0
save of number_of_recipes/10 loop in the search view. experimenting w…
julmeier Nov 3, 2017
5d36257
figured out how to pass the from/to parameters to the controller. Abo…
julmeier Nov 3, 2017
a7e2304
some nuggets of wisdom from dee about how to inject from/to into the …
julmeier Nov 3, 2017
48e4dd3
got help from dee to finish with pagination. found out that the API o…
julmeier Nov 3, 2017
b81cdc9
added additional elements to show page. will start to refactor contro…
julmeier Nov 3, 2017
cb93b6f
added logic to search view to display the pagination correctly when t…
julmeier Nov 3, 2017
d9a40cf
additional refactoring
julmeier Nov 3, 2017
8484a07
commented out require stuff at the top of controllers
julmeier Nov 3, 2017
2a57fd1
changed line 12 in search.html to consider nil class based on heroku …
julmeier Nov 3, 2017
dae937d
added required lines to the application.rb and production.rb based on…
julmeier Nov 3, 2017
737276d
changed line 12 in search view to be &&
julmeier Nov 3, 2017
a533fe2
removed the portion of the view page that displays the pagination bec…
julmeier Nov 3, 2017
6e27d54
added back in the pagination view code. Took it out to see if it was …
julmeier Nov 3, 2017
2401968
added require dependency to the API controller too
julmeier Nov 3, 2017
cf5b4c4
added styling to the form and search pages. having issue oissue of wr…
julmeier Nov 5, 2017
f0208ef
continued styling on show and search pages. The Health Information da…
julmeier Nov 5, 2017
2a3f897
can't get the photo captions to wrap
julmeier Nov 5, 2017
a5b9107
fixed columns on the show page so that all content lines up correctly
julmeier Nov 5, 2017
86650bd
heroku is not uploading my background image for the search headers. a…
julmeier Nov 5, 2017
fc33205
removed config.assets.compile = false from production.rb
julmeier Nov 5, 2017
b236ded
finished all required styling
julmeier Nov 5, 2017
823c83a
centered grid on results page. on an xlarge screen, the home page has…
julmeier Nov 5, 2017
3fda7b6
tried to fix gap between footer and image on home page- no go
julmeier Nov 5, 2017
868b12d
changed name to What's Cookin'?
julmeier Nov 5, 2017
d628354
fixed CSS mistakes that were preventing upload to heroku
julmeier Nov 6, 2017
5f1550b
controller testing ongoing. saving because computer is getting blippy
julmeier Nov 6, 2017
f5fe8d5
changed failure case from @keywords.nil? to @keywords.blank? after te…
julmeier Nov 6, 2017
29bbac7
additional controller tests
julmeier Nov 6, 2017
f4f1af7
additional model and controller testing
julmeier Nov 6, 2017
d86e89f
Chris helped me get lib tests to work by recreating postgres. Fixed l…
julmeier Nov 6, 2017
25d67ab
changed CSS body to 100% height which fixed smartphone issues with la…
julmeier Nov 14, 2017
8d869b2
changed footer CSS on results page so that it's fixed to the bottom (…
julmeier Nov 14, 2017
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 styling to the form and search pages. having issue oissue of wr…
…apping header background image
julmeier committed Nov 5, 2017
commit cf5b4c4620c4a7debfdf4b9eb812ecf0f0bb6d3b
Binary file added app/assets/images/cutting-board-header.png
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 app/assets/images/fruit-1323080.jpg
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 app/assets/images/fruits-863072.jpg
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 app/assets/images/italian-cuisine-2378729.jpg
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 app/assets/images/mushroom_assortment.jpg
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 app/assets/images/salad-2068220.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11,729 changes: 11,729 additions & 0 deletions app/assets/javascripts/foundation.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions app/assets/javascripts/foundation.min.js

Large diffs are not rendered by default.

10,253 changes: 10,253 additions & 0 deletions app/assets/javascripts/jquery.js

Large diffs are not rendered by default.

361 changes: 361 additions & 0 deletions app/assets/javascripts/what-input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,361 @@
/**
* what-input - A global utility for tracking the current input method (mouse, keyboard or touch).
* @version v4.2.0
* @link https://github.com/ten1seven/what-input
* @license MIT
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("whatInput", [], factory);
else if(typeof exports === 'object')
exports["whatInput"] = factory();
else
root["whatInput"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};

/******/ // The require function
/******/ function __webpack_require__(moduleId) {

/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;

/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };

/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ // Flag the module as loaded
/******/ module.loaded = true;

/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }


/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;

/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;

/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";

/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {

'use strict';

module.exports = function () {
/*
* variables
*/

// last used input type
var currentInput = 'initial';

// last used input intent
var currentIntent = null;

// cache document.documentElement
var doc = document.documentElement;

// form input types
var formInputs = ['input', 'select', 'textarea'];

var functionList = [];

// list of modifier keys commonly used with the mouse and
// can be safely ignored to prevent false keyboard detection
var ignoreMap = [16, // shift
17, // control
18, // alt
91, // Windows key / left Apple cmd
93 // Windows menu / right Apple cmd
];

// list of keys for which we change intent even for form inputs
var changeIntentMap = [9 // tab
];

// mapping of events to input types
var inputMap = {
keydown: 'keyboard',
mousedown: 'mouse',
mousemove: 'mouse',
MSPointerDown: 'pointer',
MSPointerMove: 'pointer',
pointerdown: 'pointer',
pointermove: 'pointer',
touchstart: 'touch'
};

// array of all used input types
var inputTypes = [];

// boolean: true if touch buffer is active
var isBuffering = false;

// boolean: true if the page is being scrolled
var isScrolling = false;

// store current mouse position
var mousePos = {
x: null,
y: null
};

// map of IE 10 pointer events
var pointerMap = {
2: 'touch',
3: 'touch', // treat pen like touch
4: 'mouse'
};

var supportsPassive = false;

try {
var opts = Object.defineProperty({}, 'passive', {
get: function get() {
supportsPassive = true;
}
});

window.addEventListener('test', null, opts);
} catch (e) {}

/*
* set up
*/

var setUp = function setUp() {
// add correct mouse wheel event mapping to `inputMap`
inputMap[detectWheel()] = 'mouse';

addListeners();
setInput();
};

/*
* events
*/

var addListeners = function addListeners() {
// `pointermove`, `MSPointerMove`, `mousemove` and mouse wheel event binding
// can only demonstrate potential, but not actual, interaction
// and are treated separately

// pointer events (mouse, pen, touch)
if (window.PointerEvent) {
doc.addEventListener('pointerdown', updateInput);
doc.addEventListener('pointermove', setIntent);
} else if (window.MSPointerEvent) {
doc.addEventListener('MSPointerDown', updateInput);
doc.addEventListener('MSPointerMove', setIntent);
} else {
// mouse events
doc.addEventListener('mousedown', updateInput);
doc.addEventListener('mousemove', setIntent);

// touch events
if ('ontouchstart' in window) {
doc.addEventListener('touchstart', touchBuffer);
doc.addEventListener('touchend', touchBuffer);
}
}

// mouse wheel
doc.addEventListener(detectWheel(), setIntent, supportsPassive ? { passive: true } : false);

// keyboard events
doc.addEventListener('keydown', updateInput);
};

// checks conditions before updating new input
var updateInput = function updateInput(event) {
// only execute if the touch buffer timer isn't running
if (!isBuffering) {
var eventKey = event.which;
var value = inputMap[event.type];
if (value === 'pointer') value = pointerType(event);

if (currentInput !== value || currentIntent !== value) {
var activeElem = document.activeElement;
var activeInput = false;
var notFormInput = activeElem && activeElem.nodeName && formInputs.indexOf(activeElem.nodeName.toLowerCase()) === -1;

if (notFormInput || changeIntentMap.indexOf(eventKey) !== -1) {
activeInput = true;
}

if (value === 'touch' ||
// ignore mouse modifier keys
value === 'mouse' ||
// don't switch if the current element is a form input
value === 'keyboard' && eventKey && activeInput && ignoreMap.indexOf(eventKey) === -1) {
// set the current and catch-all variable
currentInput = currentIntent = value;

setInput();
}
}
}
};

// updates the doc and `inputTypes` array with new input
var setInput = function setInput() {
doc.setAttribute('data-whatinput', currentInput);
doc.setAttribute('data-whatintent', currentInput);

if (inputTypes.indexOf(currentInput) === -1) {
inputTypes.push(currentInput);
doc.className += ' whatinput-types-' + currentInput;
}

fireFunctions('input');
};

// updates input intent for `mousemove` and `pointermove`
var setIntent = function setIntent(event) {
// test to see if `mousemove` happened relative to the screen
// to detect scrolling versus mousemove
if (mousePos['x'] !== event.screenX || mousePos['y'] !== event.screenY) {
isScrolling = false;

mousePos['x'] = event.screenX;
mousePos['y'] = event.screenY;
} else {
isScrolling = true;
}

// only execute if the touch buffer timer isn't running
// or scrolling isn't happening
if (!isBuffering && !isScrolling) {
var value = inputMap[event.type];
if (value === 'pointer') value = pointerType(event);

if (currentIntent !== value) {
currentIntent = value;

doc.setAttribute('data-whatintent', currentIntent);

fireFunctions('intent');
}
}
};

// buffers touch events because they frequently also fire mouse events
var touchBuffer = function touchBuffer(event) {
if (event.type === 'touchstart') {
isBuffering = false;

// set the current input
updateInput(event);
} else {
isBuffering = true;
}
};

var fireFunctions = function fireFunctions(type) {
for (var i = 0, len = functionList.length; i < len; i++) {
if (functionList[i].type === type) {
functionList[i].function.call(undefined, currentIntent);
}
}
};

/*
* utilities
*/

var pointerType = function pointerType(event) {
if (typeof event.pointerType === 'number') {
return pointerMap[event.pointerType];
} else {
// treat pen like touch
return event.pointerType === 'pen' ? 'touch' : event.pointerType;
}
};

// detect version of mouse wheel event to use
// via https://developer.mozilla.org/en-US/docs/Web/Events/wheel
var detectWheel = function detectWheel() {
var wheelType = void 0;

// Modern browsers support "wheel"
if ('onwheel' in document.createElement('div')) {
wheelType = 'wheel';
} else {
// Webkit and IE support at least "mousewheel"
// or assume that remaining browsers are older Firefox
wheelType = document.onmousewheel !== undefined ? 'mousewheel' : 'DOMMouseScroll';
}

return wheelType;
};

/*
* init
*/

// don't start script unless browser cuts the mustard
// (also passes if polyfills are used)
if ('addEventListener' in window && Array.prototype.indexOf) {
setUp();
}

/*
* api
*/

return {
// returns string: the current input type
// opt: 'loose'|'strict'
// 'strict' (default): returns the same value as the `data-whatinput` attribute
// 'loose': includes `data-whatintent` value if it's more current than `data-whatinput`
ask: function ask(opt) {
return opt === 'loose' ? currentIntent : currentInput;
},

// returns array: all the detected input types
types: function types() {
return inputTypes;
},

// overwrites ignored keys with provided array
ignoreKeys: function ignoreKeys(arr) {
ignoreMap = arr;
},

// attach functions to input and intent "events"
// funct: function to fire on change
// eventType: 'input'|'intent'
onChange: function onChange(funct, eventType) {
functionList.push({
function: funct,
type: eventType
});
}
};
}();

/***/ })
/******/ ])
});
;
Empty file added app/assets/stylesheets/app.css
Empty file.
91 changes: 91 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -13,3 +13,94 @@
*= require_tree .
*= require_self
*/

html {
height: 100%;
box-sizing: border-box;
}

*,
*:before,
*:after {
box-sizing: inherit;
}

body {
position: relative;
margin: 0;
padding-bottom: 6rem;
min-height: 100%;
font-family: "Helvetica Neue", Arial, sans-serif;
}

.demo {
margin: 0 auto;
padding-top: 64px;
max-width: 640px;
width: 94%;
}

.demo h1 {
margin-top: 0;
}

/**
* Footer Styles
*/

.footer {
position: absolute;
right: 0;
bottom: 0;
left: 0;
padding: 1rem;
background-color: #efefef;
text-align: center;
}

/**********PAGE HEADER*******************/

.page-header {
max-width: 100%;
/*background-color: #B2DFDB;*/
background-image: url(cutting-board-header.png);
/*border-bottom: 1px solid #EEEEEE;*/
margin-bottom: 10px;
padding: 25px 20px 10px 20px;

}

.page-header h2 {
text-align: center;
margin: 25px auto 40px auto;
}

.page-header h2 a {
color: white;
padding-right: 25px;
margin-right: 15px;
}

/*******SEARCH PAGE**********/
/*******SEARCH PAGE**********/
/*******SEARCH PAGE**********/

.results-grid {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.recipe-photo-and-name {
display: flex;
flex-direction: column;
align-items: center;
}

.recipe-photo-and-name li {
list-style: none;
font-size: 1.5em;
}

.recipe-grid {

}
5,749 changes: 5,749 additions & 0 deletions app/assets/stylesheets/foundation.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/assets/stylesheets/foundation.min.css

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions app/controllers/recipes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require_dependency '../../lib/edamam_api_wrapper'
require_dependency '../../lib/recipe'
# require 'pry'

class RecipesController < ApplicationController
@@ -23,7 +22,7 @@ def search_by_page
@keywords = params['keywords']
if @keywords == ""
redirect_to root_path
#add flash message maybe
flash[:failure] = "You did not enter any keywords. Please enter ingredient keywords into the search bar."
else
@number_of_recipes = EdamamApiWrapper.find_number_of_recipes(@keywords)
from = params[:from]
14 changes: 14 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -9,6 +9,20 @@
</head>

<body>
<% if flash[:failure] %>
<section class = "row status success">
<% flash.each do |name, message| %>
<h3><%= message %></h3>
<% end %>
</section>
<% end %>

<%= yield %>

<footer class="footer">
<h4>
Powered by <%= link_to "Edamam", "https://www.edamam.com/" %>
</h4>
</footer>
</body>
</html>
23 changes: 17 additions & 6 deletions app/views/recipes/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<h1>Muncher</h1>

<%= form_tag recipes_search_path, :method => "get" do %>
<%= text_field_tag :keywords%>
<%= submit_tag "Search"%>
<% end %>
<header class = "page-header row">
<h2 class = "grid-x">
<div class = "small-12 cell">
<%= link_to("Muncher", root_path) %>
</div>
</h2>
<nav class = "grid-x">
<div class="small-4 cell"></div>
<div class="small-4">
<%= form_tag recipes_search_path, :method => "get" do %>
<div class = "small-2 cell"><%= text_field_tag :keywords%><div>
<div class = "small-2 cell"><%= submit_tag "Search", :class => "button"%><div>
</div>
<div class="small-4 cell"></div>
<% end %>
</nav>
</header>
23 changes: 14 additions & 9 deletions app/views/recipes/search.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
<section class= "small-12 large-8 cell">

<%= render partial: "form" %>
</section>

<h2>Params:</h2>
<%= params %>
<!-- <h2>Params:</h2>
<%= params %> -->

<% unless params[:keywords] == nil %>
<h1>Results for <%= @keywords %> </h1>
<%end%>

<h2>Number of Recipes: <%=@number_of_recipes%> </h2>
<h3>Number of Recipes: <%=@number_of_recipes%> </h3>
<%if @number_of_recipes != 0 && @number_of_recipes != nil%>
<% @recipes.each do |recipe| %>
<ul>
<li><%=image_tag recipe.image%></li>
<li><%=link_to(recipe.label, recipe_show_path(recipe.find_recipe_id))%></li>
</ul>
<section class="results-grid">
<%if @number_of_recipes != 0 && @number_of_recipes != nil%>
<% @recipes.each do |recipe| %>
<ul class="recipe-photo-and-name">
<li><%=image_tag recipe.image%></li>
<li><%=link_to(recipe.label, recipe_show_path(recipe.find_recipe_id))%></li>
</ul>
<%end%>
</section>
<%if @number_of_recipes > 100%>
<%10.times do |page| %>
1 change: 0 additions & 1 deletion lib/edamam_api_wrapper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# require 'httparty'
# require 'awesome_print'
# require 'pry'
require_dependency '../../lib/edamam_api_wrapper'
require_dependency '../../lib/recipe'

class EdamamApiWrapper