diff --git a/.DS_Store b/.DS_Store
index 861ce21..797e7a7 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/Gemfile b/Gemfile
index b7d7aab..93debf9 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,10 +1,17 @@
source 'https://rubygems.org'
+group :development, :test do
+ gem 'sqlite3'
+end
+group :production do
+ gem 'pg', '~> 0.18'
+end
+#gem 'jquery-rails'
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.0.2'
# Use sqlite3 as the database for Active Record
-gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
@@ -42,6 +49,7 @@ gem 'draper'
gem 'pundit'
+
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
@@ -54,6 +62,10 @@ gem 'pundit'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
+ #Use RSpec-rails for testing
+ gem 'rspec-rails', '~> 3.8'
+ gem 'capybara'
+
end
group :development do
diff --git a/Gemfile.lock b/Gemfile.lock
index 1ef8616..9dbcc97 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -24,16 +24,16 @@ GEM
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
- activeadmin (1.1.0)
+ activeadmin (1.4.1)
arbre (>= 1.1.1)
coffee-rails
formtastic (~> 3.1)
formtastic_i18n
- inherited_resources (~> 1.7)
- jquery-rails
- kaminari (>= 0.15, < 2.0)
- railties (>= 4.2, < 5.2)
- ransack (~> 1.3)
+ inherited_resources (>= 1.9.0)
+ jquery-rails (>= 4.2.0)
+ kaminari (>= 0.15)
+ railties (>= 4.2, < 5.3)
+ ransack (>= 1.8.7)
sass (~> 3.1)
sprockets (< 4.1)
activejob (5.0.2)
@@ -54,15 +54,26 @@ GEM
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
+ addressable (2.5.2)
+ public_suffix (>= 2.0.2, < 4.0)
arbre (1.1.1)
activesupport (>= 3.0.0)
arel (7.1.4)
- bcrypt (3.1.11)
- binding_of_caller (0.7.2)
+ bcrypt (3.1.12)
+ bcrypt (3.1.12-x86-mingw32)
+ binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
builder (3.2.3)
- byebug (9.1.0)
+ byebug (10.0.2)
cancan (1.6.10)
+ capybara (3.11.1)
+ addressable
+ mini_mime (>= 0.1.3)
+ nokogiri (~> 1.8)
+ rack (>= 1.6.0)
+ rack-test (>= 0.6.3)
+ regexp_parser (~> 1.2)
+ xpath (~> 3.2)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
@@ -70,15 +81,16 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
- concurrent-ruby (1.0.5)
- crass (1.0.2)
+ concurrent-ruby (1.1.3)
+ crass (1.0.4)
debug_inspector (0.0.3)
- devise (4.3.0)
+ devise (4.5.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
- railties (>= 4.1.0, < 5.2)
+ railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
+ diff-lcs (1.3)
draper (3.0.1)
actionpack (~> 5.0)
activemodel (~> 5.0)
@@ -87,7 +99,8 @@ GEM
request_store (~> 1.0)
erubis (2.7.0)
execjs (2.7.0)
- ffi (1.9.18)
+ ffi (1.9.25)
+ ffi (1.9.25-x86-mingw32)
formtastic (3.1.5)
actionpack (>= 3.2.13)
formtastic_i18n (0.6.0)
@@ -96,20 +109,20 @@ GEM
haml (5.0.4)
temple (>= 0.8.0)
tilt
- has_scope (0.7.1)
- actionpack (>= 4.1, < 5.2)
- activesupport (>= 4.1, < 5.2)
- i18n (0.9.1)
+ has_scope (0.7.2)
+ actionpack (>= 4.1)
+ activesupport (>= 4.1)
+ i18n (0.9.5)
concurrent-ruby (~> 1.0)
- inherited_resources (1.7.2)
- actionpack (>= 3.2, < 5.2.x)
+ inherited_resources (1.9.0)
+ actionpack (>= 4.2, < 5.3)
has_scope (~> 0.6)
- railties (>= 3.2, < 5.2.x)
+ railties (>= 4.2, < 5.3)
responders
- jbuilder (2.7.0)
+ jbuilder (2.8.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
- jquery-rails (4.3.1)
+ jquery-rails (4.3.3)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
@@ -126,25 +139,28 @@ GEM
activerecord
kaminari-core (= 1.1.1)
kaminari-core (1.1.1)
- loofah (2.1.1)
+ loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
- mail (2.7.0)
+ mail (2.7.1)
mini_mime (>= 0.1.1)
- method_source (0.9.0)
- mini_mime (0.1.4)
+ method_source (0.9.2)
+ mini_mime (1.0.1)
mini_portile2 (2.3.0)
- minitest (5.10.3)
- multi_json (1.12.1)
- nio4r (2.1.0)
- nokogiri (1.8.1)
+ minitest (5.11.3)
+ multi_json (1.13.1)
+ nio4r (2.3.1)
+ nokogiri (1.8.5)
+ mini_portile2 (~> 2.3.0)
+ nokogiri (1.8.5-x86-mingw32)
mini_portile2 (~> 2.3.0)
orm_adapter (0.5.0)
- polyamorous (1.3.1)
- activerecord (>= 3.0)
- pundit (1.1.0)
+ pg (0.21.0)
+ pg (0.21.0-x86-mingw32)
+ public_suffix (3.0.3)
+ pundit (2.0.0)
activesupport (>= 3.0.0)
- rack (2.0.3)
+ rack (2.0.6)
rack-cors (0.3.1)
rack-test (0.6.3)
rack (>= 1.0)
@@ -163,35 +179,53 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
- rails-html-sanitizer (1.0.3)
- loofah (~> 2.0)
+ rails-html-sanitizer (1.0.4)
+ loofah (~> 2.2, >= 2.2.2)
railties (5.0.2)
actionpack (= 5.0.2)
activesupport (= 5.0.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
- rake (12.2.1)
- ransack (1.8.4)
- actionpack (>= 3.0)
- activerecord (>= 3.0)
- activesupport (>= 3.0)
+ rake (12.3.1)
+ ransack (2.1.0)
+ actionpack (>= 5.0)
+ activerecord (>= 5.0)
+ activesupport (>= 5.0)
i18n
- polyamorous (~> 1.3)
- rb-fsevent (0.10.2)
+ rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rdoc (4.3.0)
- request_store (1.3.2)
+ regexp_parser (1.3.0)
+ request_store (1.4.1)
+ rack (>= 1.4)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
- sass (3.5.1)
+ rspec-core (3.8.0)
+ rspec-support (~> 3.8.0)
+ rspec-expectations (3.8.2)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.8.0)
+ rspec-mocks (3.8.0)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.8.0)
+ rspec-rails (3.8.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec-core (~> 3.8.0)
+ rspec-expectations (~> 3.8.0)
+ rspec-mocks (~> 3.8.0)
+ rspec-support (~> 3.8.0)
+ rspec-support (3.8.0)
+ sass (3.7.2)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
- sass-rails (5.0.6)
+ sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
@@ -200,12 +234,12 @@ GEM
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
- simple_form (3.5.0)
- actionpack (> 4, < 5.2)
- activemodel (> 4, < 5.2)
+ simple_form (4.1.0)
+ actionpack (>= 5.0)
+ activemodel (>= 5.0)
spring (2.0.2)
activesupport (>= 4.2)
- sprockets (3.7.1)
+ sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
@@ -213,19 +247,20 @@ GEM
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
+ sqlite3 (1.3.13-x86-mingw32)
temple (0.8.0)
- thor (0.20.0)
+ thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.8)
- turbolinks (5.0.1)
- turbolinks-source (~> 5)
- turbolinks-source (5.0.3)
- tzinfo (1.2.4)
+ turbolinks (5.2.0)
+ turbolinks-source (~> 5.2)
+ turbolinks-source (5.2.0)
+ tzinfo (1.2.5)
thread_safe (~> 0.1)
- uglifier (3.2.0)
+ uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
- warden (1.2.7)
- rack (>= 1.0)
+ warden (1.2.8)
+ rack (>= 2.0.6)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
@@ -233,24 +268,30 @@ GEM
sprockets-rails (>= 2.0, < 4.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
- websocket-extensions (0.1.2)
+ websocket-extensions (0.1.3)
+ xpath (3.2.0)
+ nokogiri (~> 1.8)
PLATFORMS
ruby
+ x86-mingw32
DEPENDENCIES
activeadmin
byebug
cancan
+ capybara
coffee-rails (~> 4.1.0)
devise
draper
haml
jbuilder (~> 2.0)
jquery-rails
+ pg (~> 0.18)
pundit
rack-cors (~> 0.3.1)
rails (= 5.0.2)
+ rspec-rails (~> 3.8)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
simple_form
@@ -261,4 +302,4 @@ DEPENDENCIES
web-console (~> 2.0)
BUNDLED WITH
- 1.16.0
+ 1.16.1
diff --git a/Instructions and Resources for the Next Team.docx b/Instructions and Resources for the Next Team.docx
new file mode 100644
index 0000000..0b36bb5
Binary files /dev/null and b/Instructions and Resources for the Next Team.docx differ
diff --git a/README.md b/README.md
index 792b0dd..fb1812d 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,88 @@
# LFC_Features
+### Local Food Connection Application
+LFC is a Grinnell farm directory service. It contains basic information of farms that are connected to Local Food Connection Organization. The goal of the app is to allow user to easily search for Grinnell's sustainable food system.
+
+You can obtain the source with the following command:
+```shell
+git clone https://github.com/CSC322-Grinnell/LFC_Features.git
+```
+
+## Authors and Contributors
+
+### Current Builds
+
+- [Joshua Cussen](https://github.com/nomadicTree)
+- [Siyu Zhang](https://github.com/zhangsiyu1103)
+- [Nolan Schoenle](https://github.com/NSchoenle)
+- [Hoang Cao]()
+- [Ryan Rosol]()
+
+
+### Previous Builds
+
+- [Linh Pham](https://github.com/linhpha)
+- [Pratik Karki](https://github.com/karkipra)
+- [Elise Brod](https://github.com/brodelis)
+- [James Msekela]()
+- [Sara Marku](https://github.com/saramarku)
+
+### Project Structure
+
+The view for the main page is in /app/views/ui/view2.html.erb.
+The CSS and JavaScript files are in /app/assets/javascripts/ and /app/assets/stylesheets/ respectively.
+All images and icons are stored in /app/assets/images.
+The admin page is contained in /app/admin folder.
+/app/admin/farm.rb generates the UI of the Edit farm from admin page.
+
+### How to build
+
+The project can be installed on Cloud 9.
+The Heroku website for the previous group's work on the project is http://localfoodsconnection.herokuapp.com
+We do not have access to this Heroku.
+You need to make a new Heroku to deploy the site.
+
+Next, to set up the database, run the commands:
+
+```
+bundle install
+rake db:create
+rake db:migrate
+rake db:seed
+rake db:seed:seed_farm
+rake db:seed:seed_growing_method
+rake db:seed:seed_selling_method
+rake db:seed:seed_operation
+rake db:seed:seed_market
+```
+
+After successfully seeding the database, you can start the app and get to the main page.
+Note: In order to check if the the seeding of farms was successful in the Rails console type: Farm.count and the result should yield 7. The information for all farms will be in the admin page. You can go to this page by clicking the Sign In link of the main website and the credentials of the admin are:
+```
+Email: admin@example.com
+Password: password
+```
+After successfully signing in to the admin page you can navigate to look and edit the farms currently in the database. You can add Operations, Selling Methods, Primary Operation and Growing Methods for each farm and the map on the main page will update accordingly.
+
+To Sign In as a registered farm, you can find the credentials of the registered farms in the /db/seed/seed_farm.
+
+
+### Current state, future tasks, and tips
+Please see `Instructions and Resources for the Next Team.docx`, also located in the Microsoft Teams Team for this project.
+
+
+## License
+```
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+```
diff --git a/app/admin/farm.rb b/app/admin/farm.rb
deleted file mode 100644
index d7dfc50..0000000
--- a/app/admin/farm.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-ActiveAdmin.register Farm do
- # See permitted parameters documentation:
- # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
- #
- # permit_params :list, :of, :attributes, :on, :model
- #
- # or
- #
- # permit_params do
- # permitted = [:permitted, :attributes]
- # permitted << :other if params[:action] == 'create' && current_user.admin?
- # permitted
- # end
-
- controller do
- before_filter :authorize_index, only: :index
- def authorize_index
- # FarmPolicy::Scope.new(current_farm, Farm).resolve
- Farm
- end
-
- # before_filter :authorize_show_edit_destroy, only: [:show, :edit, :destroy]
- # def authorize_show_edit_destroy
- # authorize resource
- # end
- end
-
- # scope_to :current_farm, unless: proc{ :current_farm }
-
- permit_params do
- permitted = [:name, :address, :phone, :email, :url, :facebook, :instagram,
- :password, :password_confirmation, :twitter]
- permitted << :approved if current_farm.admin?
- permitted
- end
-
- index do
- selectable_column
- id_column
- column :name
- column :email
- column :role
- column :created_at
-
- if current_farm.admin?
- column :approved
- end
-
- actions
- end
-
- filter :name
- filter :email
-
- form do |f|
- f.inputs "Farm Details" do
- f.input :name
- f.input :contact_name
- f.input :year
- f.input :address
- f.input :phone
- f.input :email
- f.input :url
- f.input :statement
-
-
- f.input :facebook
- f.input :instagram
- f.input :twitter
- f.input :other_media
-
- @ops = ['Fruit', 'Vegetables', 'Dairy', 'Pork', 'Chicken', 'Turkey', 'Lamb', 'Duck', 'Agitourism', 'Hay', 'Row Crop']
- @grow = ['Certified Natural Grown', 'USDA Certified Organic', '100% Grass Fed', 'Grass Finished', 'Non-GMO', 'Regenerative Organic Certified', 'Integrated Pest Management', 'Pasture Raised', 'Corn Fed', 'Conventional']
- @sell = ['CSA', 'Farmers Market', 'Wholesale', 'Grocery Stores', 'Grinnell Area Local Food Source', 'On-Farm', 'Iowa Food Coop', 'Institutions', 'Restaurants']
- @market = ['Grinnell-Thursday', 'Grinnell-Saturday', "Des Moines Downtown-Saturday", "Cedar Rapids Downtown-Select Saturdays", "Iowa City-Saturday", "Tama-Toledo", "Brooklyn"]
- f.input :operations, as: :check_boxes, collection: @ops
- f.input :growing_methods, as: :check_boxes, collection: @grow
- f.input :link_to_cert
- f.input :selling_methods, as: :check_boxes, collection: @sell
- f.input :markets, as: :check_boxes, collection: @market
-
- f.input :growth_promoter, as: :boolean, checked_value: true, unchecked_value: false
- f.input :antibiotic, as: :boolean, checked_value: true, unchecked_value: false
-
- f.input :fav_activity
- f.input :why_farm
-
-
- #unless current_farm.admin?
- f.input :password
- f.input :password_confirmation
- #end
-
- if current_farm.admin?
- f.input :approved
- end
-
- end
- f.actions
- end
-end
diff --git a/app/admin/farm_admin.rb b/app/admin/farm_admin.rb
new file mode 100644
index 0000000..afcfbcb
--- /dev/null
+++ b/app/admin/farm_admin.rb
@@ -0,0 +1,86 @@
+ActiveAdmin.register Farm do
+ controller do
+ # before_filter :authorize_index, only: :index #Deprecated in Rails 5.1
+ before_action :authorize_index, only: :index #
+ def authorize_index
+ # FarmPolicy::Scope.new(current_farm, Farm).resolve
+ Farm
+ end
+
+ # before_filter :authorize_show_edit_destroy, only: [:show, :edit, :destroy]
+ # def authorize_show_edit_destroy
+ # authorize resource
+ # end
+ end
+
+ # scope_to :current_farm, unless: proc{ :current_farm }
+ ## Add strong parameters for admin to be able to edit these fields
+ permit_params :name, :address, :phone, :email, :url, :facebook, :instagram, :password,
+ :password_confirmation, :primary_operation_id, :growth_promoter, :antibiotic, :why_farm,
+ :fav_activity, :twitter, :approved, operation_ids: [], selling_method_ids: [],
+ growing_method_ids: [], market_ids: []
+ ##Doe not making sense
+###### AAAAAAAAAAAAAAAAAA
+ index do
+ selectable_column
+ id_column
+ column :name
+ column :email
+ column :role
+ column :created_at
+
+ if current_farm.admin?
+ column :approved
+ end
+
+ actions
+ end
+
+ filter :name
+ filter :email
+
+ form do |f|
+ f.inputs "Farm Details" do
+ f.input :name
+ f.input :contact_name #Not sure if we ever do anything with this
+ f.input :year
+ f.input :address
+ f.input :phone
+ f.input :email
+ f.input :url
+ f.input :statement
+
+
+ f.input :facebook
+ f.input :instagram
+ f.input :twitter
+ f.input :other_media
+
+
+ f.input :operations, as: :check_boxes, collection: Operation.all
+ f.input :primary_operation, as: :select, collection: Operation.all
+ f.input :growing_methods, as: :check_boxes, collection: GrowingMethod.all
+ f.input :link_to_cert
+ f.input :selling_methods, as: :check_boxes, collection: SellingMethod.all
+ f.input :markets, as: :check_boxes, collection: Market.all
+
+ f.input :growth_promoter, as: :boolean, checked_value: true, unchecked_value: false
+ f.input :antibiotic, as: :boolean, checked_value: true, unchecked_value: false
+
+ f.input :fav_activity
+ f.input :why_farm
+
+
+ #unless current_farm.admin?
+ f.input :password
+ f.input :password_confirmation
+ #end
+
+ if current_farm.admin?
+ f.input :approved
+ end
+
+ end
+ f.actions
+ end
+end
diff --git a/javascript_app/icons/24apple.png b/app/assets/icons/24apple.png
similarity index 100%
rename from javascript_app/icons/24apple.png
rename to app/assets/icons/24apple.png
diff --git a/javascript_app/icons/24broccoli.png b/app/assets/icons/24broccoli.png
similarity index 100%
rename from javascript_app/icons/24broccoli.png
rename to app/assets/icons/24broccoli.png
diff --git a/javascript_app/icons/24chicken.png b/app/assets/icons/24chicken.png
similarity index 100%
rename from javascript_app/icons/24chicken.png
rename to app/assets/icons/24chicken.png
diff --git a/javascript_app/icons/24cow.png b/app/assets/icons/24cow.png
similarity index 100%
rename from javascript_app/icons/24cow.png
rename to app/assets/icons/24cow.png
diff --git a/javascript_app/icons/24dairy.png b/app/assets/icons/24dairy.png
similarity index 100%
rename from javascript_app/icons/24dairy.png
rename to app/assets/icons/24dairy.png
diff --git a/javascript_app/icons/24pig.png b/app/assets/icons/24pig.png
similarity index 100%
rename from javascript_app/icons/24pig.png
rename to app/assets/icons/24pig.png
diff --git a/javascript_app/icons/24sheep.png b/app/assets/icons/24sheep.png
similarity index 100%
rename from javascript_app/icons/24sheep.png
rename to app/assets/icons/24sheep.png
diff --git a/javascript_app/icons/64cow.png b/app/assets/icons/64cow.png
similarity index 100%
rename from javascript_app/icons/64cow.png
rename to app/assets/icons/64cow.png
diff --git a/app/assets/icons/agricultural.png b/app/assets/icons/agricultural.png
new file mode 100644
index 0000000..a151cff
Binary files /dev/null and b/app/assets/icons/agricultural.png differ
diff --git a/app/assets/icons/carrot.png b/app/assets/icons/carrot.png
new file mode 100644
index 0000000..6b1b1d2
Binary files /dev/null and b/app/assets/icons/carrot.png differ
diff --git a/app/assets/icons/dairy_free.png b/app/assets/icons/dairy_free.png
new file mode 100644
index 0000000..43c9bde
Binary files /dev/null and b/app/assets/icons/dairy_free.png differ
diff --git a/app/assets/icons/egg.png b/app/assets/icons/egg.png
new file mode 100644
index 0000000..df644d8
Binary files /dev/null and b/app/assets/icons/egg.png differ
diff --git a/app/assets/icons/gluten_free.png b/app/assets/icons/gluten_free.png
new file mode 100644
index 0000000..558d955
Binary files /dev/null and b/app/assets/icons/gluten_free.png differ
diff --git a/app/assets/icons/kosher.png b/app/assets/icons/kosher.png
new file mode 100644
index 0000000..30b07b7
Binary files /dev/null and b/app/assets/icons/kosher.png differ
diff --git a/app/assets/icons/peanut_free.jpg b/app/assets/icons/peanut_free.jpg
new file mode 100644
index 0000000..ca38b82
Binary files /dev/null and b/app/assets/icons/peanut_free.jpg differ
diff --git a/app/assets/icons/steak-512.png b/app/assets/icons/steak-512.png
new file mode 100644
index 0000000..c5182d0
Binary files /dev/null and b/app/assets/icons/steak-512.png differ
diff --git a/app/assets/icons/tree_nut_free.jpg b/app/assets/icons/tree_nut_free.jpg
new file mode 100644
index 0000000..5eda7af
Binary files /dev/null and b/app/assets/icons/tree_nut_free.jpg differ
diff --git a/app/assets/icons/vegetarian.jpg b/app/assets/icons/vegetarian.jpg
new file mode 100644
index 0000000..e78c81c
Binary files /dev/null and b/app/assets/icons/vegetarian.jpg differ
diff --git a/app/assets/images/favicon.png b/app/assets/images/favicon.png
new file mode 100644
index 0000000..6b1b1d2
Binary files /dev/null and b/app/assets/images/favicon.png differ
diff --git a/app/assets/images/hero.jpg b/app/assets/images/hero.jpg
new file mode 100644
index 0000000..144d061
Binary files /dev/null and b/app/assets/images/hero.jpg differ
diff --git a/app/assets/images/logo.png b/app/assets/images/logo.png
new file mode 100644
index 0000000..640bc00
Binary files /dev/null and b/app/assets/images/logo.png differ
diff --git a/app/assets/javascripts/active_admin.js.coffee b/app/assets/javascripts/active_admin.js.coffee
new file mode 100644
index 0000000..3752dce
--- /dev/null
+++ b/app/assets/javascripts/active_admin.js.coffee
@@ -0,0 +1 @@
+#= require active_admin/base
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index e07c5a8..f9302db 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -1,16 +1,35 @@
-// This is a manifest file that'll be compiled into application.js, which will include all the files
-// listed below.
-//
-// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
-// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
-//
-// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
-// compiled file.
-//
-// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
-// about supported directives.
-//
+// To enable jquery for rails
//= require jquery
//= require jquery_ujs
-//= require turbolinks
//= require_tree .
+var map;
+var geocoder;
+
+/***********
+ * API_KEYS *
+ ***********/
+var edemam_app_id = "0649d198";
+var edemam_app_key = "77bd12dd099e7f2c02338006ef659724";
+var lfc_key = "YAS0sY2rbi";
+
+/********
+ * INIT *
+ ********/
+ $(window).on('load',function() {
+ if(window.location.pathname == '/') {
+ set_up_search();
+ initialize_farms();
+ }
+});
+
+/**
+ Set up farm cards
+ **/
+function initialize_farms() {
+ var call_url = "/farms/farm_json";
+ callIndexApi(call_url, Visualize_Farm)
+}
+
+
+
+
diff --git a/app/assets/javascripts/farm_api.js b/app/assets/javascripts/farm_api.js
new file mode 100644
index 0000000..0701543
--- /dev/null
+++ b/app/assets/javascripts/farm_api.js
@@ -0,0 +1,33 @@
+/****************************************
+ * API CALLS functions
+ * **************************************/
+/**
+ make a api call
+ @param
+ call_url: the url to retrieve messages from
+ callback: a callback function for the returned message
+ params: other parameters may be included in the callback functions
+ **/
+function callIndexApi(call_url, callback,params) {
+ $.ajax({
+ type: "GET",
+ url: call_url,
+ headers: {
+ 'X-Auth-Token': lfc_key
+ },
+ dataType: 'json',
+ contentType: 'application/json',
+ crossDomain: true,
+ async: false,
+ success: function(result) {
+ if (result != null || result.length > 0) {
+ callback(result,params);
+ }
+ },
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
+ console.log("Status: " + textStatus);
+ console.log("Error: " + errorThrown);
+ }
+ });
+
+}
\ No newline at end of file
diff --git a/app/assets/javascripts/map.js b/app/assets/javascripts/map.js
new file mode 100644
index 0000000..6dd2606
--- /dev/null
+++ b/app/assets/javascripts/map.js
@@ -0,0 +1,98 @@
+/****************************************
+ * GEOCODING AND ADDING MARKERS FUNCTIONS
+ * **************************************/
+/**
+ positioning farm and add markers
+ @param
+ farm: a json object of farm
+ **/
+function geocodeAddressAndAddMarker(farm) {
+ var address = farm.address;
+ geocoder.geocode({
+ 'address': address
+ }, function(results, status) {
+ // if OK/200 status, add marker to map, else throw alert.
+ if (status === 'OK') {
+ addMarker(farm, results);
+ } else {
+ alert('Geocode was not successful for the following reason: ' + status);
+ }
+ });
+}
+
+var markers = []
+/**
+ add markers to the map
+ @param
+ farm: a json object of farm
+ results: the return value of geocode function
+ **/
+ function addMarker(farm, results) {
+ var marker = new google.maps.Marker({
+ map: map,
+ position: results[0].geometry.location,
+ title: farm.name,
+ });
+
+ // data string for display tooltip
+ var data = farm.name;
+ // info window for tooltip, contains data
+ var infowindow = new google.maps.InfoWindow({
+ content: data
+ });
+ // add listener to map for marker to display info window
+ google.maps.event.addListener(marker, 'click', function() {
+ // open info window
+ infowindow.open(map, marker);
+ });
+ markers.push(marker);
+}
+/**
+ show markers on the map
+ @param
+ results: an array of farm jsons
+ **/
+function showMarkers(result){
+ for (var i = 0; i < result.length; i++) {
+ // add marker at proper place
+ geocodeAddressAndAddMarker(result[i]);
+ }
+}
+
+
+/***********************
+ * DELETE MARKERS ON MAP *
+ * *********************/
+
+function DeleteMarkers() {
+ //Loop through all the markers and remove
+ for (var i = 0; i < markers.length; i++) {
+ markers[i].setMap(null);
+ }
+ markers = [];
+};
+/*************
+ * INIT MAP *
+ * ***********/
+function initMap() {
+ // set location set to grinnell as center of map
+ var grinnell = {
+ lat: 41.7434,
+ lng: -92.7232
+ };
+
+ // init map
+ map = new google.maps.Map(document.getElementById('farmmap'), {
+ zoom: 12,
+ center: grinnell
+ });
+
+ // init geocoder
+ geocoder = new google.maps.Geocoder();
+
+
+ //make a ajax call to show all the markers
+ var call_url = "/farms/farm_json";
+ callIndexApi(call_url, showMarkers)
+
+}
\ No newline at end of file
diff --git a/app/assets/javascripts/model_method.js b/app/assets/javascripts/model_method.js
new file mode 100644
index 0000000..52e86b4
--- /dev/null
+++ b/app/assets/javascripts/model_method.js
@@ -0,0 +1,194 @@
+//Used for modal, disgarded right now, may be used later
+
+/********************
+ * MODAL FUNCTIONS *
+ * ******************/
+function capitalize_words(str) {
+ return str.replace(/\w\S*/g, function(txt) {
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
+ });
+}
+
+function getOperation(farm) {
+ var result = "";
+ if (!farm.operations) {
+ farm = farm[0];
+ }
+ for (var i = 0; i < farm.operations.length; i++) {
+ result += capitalize_words(farm.operations[i].food);
+ if (i != farm.operations.length - 1) {
+ result += ', ';
+ }
+ }
+
+ if (result == "") {
+ return "N/A"
+ }
+ return result;
+}
+
+function getGrowingMethod(farm) {
+ var result = "";
+ if (!farm.growing_methods) {
+ farm = farm[0];
+ }
+ for (var i = 0; i < farm.growing_methods.length; i++) {
+ result += capitalize_words(farm.growing_methods[i].grow_method);
+ if (i != farm.growing_methods.length - 1) {
+ result += ', ';
+ }
+ }
+ if (result == "") {
+ return "N/A"
+ }
+ return result
+}
+
+function getSellingMethod(farm) {
+ var result = "";
+ if (!farm.selling_methods) {
+ farm = farm[0];
+ }
+ for (var i = 0; i < farm.selling_methods.length; i++) {
+ result += capitalize_words(farm.selling_methods[i].sell_method);
+ if (i != farm.selling_methods.length - 1) {
+ result += ', ';
+ }
+ }
+
+ if (result == "") {
+ return "N/A"
+ }
+ return result;
+}
+
+function setAndShowFarmModal(farm) {
+ if (!farm.operations) {
+ farm = farm[0];
+ }
+ var primary_operation;
+ var farm_operations = farm.operations;
+ var primary_operation_id = farm.primary_operation_id;
+ for (var operation of farm_operations) {
+ if (operation.id == primary_operation_id) {
+ primary_operation = operation.food;
+ }
+ }
+ // set modal header html
+ if (!farm.name) {
+ farm = farm[0];
+ }
+
+ if (!primary_operation) {
+ primary_operation = "N/A";
+ } else {
+ primary_operation = capitalize_words(primary_operation);
+ }
+
+
+ $('#modal_header').html('
' + farm.name + '
');
+
+ // set modal tab 1 html
+ $('#tab_1_title').html('Home');
+ $('#tab_1').html(
+ 'Basic Information:' + '
' +
+ 'Growing Method: ' + getGrowingMethod(farm) + '
' +
+ 'Operation: ' + getOperation(farm) + '
' +
+ 'Selling Method: ' + getSellingMethod(farm) + '
' +
+ 'Primary Operation: ' + primary_operation + '
'
+ );
+
+ // set modal tab 2 html
+ $('#tab_2_title').html('Contact');
+ var tab_2_html = '';
+ if(farm.address){
+ tab_2_html = tab_2_html + ' ' + farm.address + '
';
+ }
+ if(farm.phone){
+ tab_2_html = tab_2_html + ' ' + farm.phone + '
';
+ }
+ tab_2_html = tab_2_html+'' ;
+ if(farm.url){
+ tab_2_html = tab_2_html + '
Visit our webpage ';
+ }
+ if(farm.facebook){
+ tab_2_html = tab_2_html + '
| Facebook ';
+ }
+ if(farm.twitter){
+ tab_2_html = tab_2_html + '
| Twitter';
+ }
+ tab_2_html += '
';
+
+
+ $('#tab_2').html(
+ tab_2_html
+ );
+
+ // set modal tab 3 html
+ $('#tab_3_title').html('Media');
+ $('#tab_3').html(
+ ' Pictures/Video
' +
+ ' Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
'
+ );
+
+
+ // show button
+ $('#contact_button').show();
+ $('#recipe_link_button').hide();
+
+ // show modal
+ $("#generic_modal").modal()
+}
+
+function setAndShowRecipeModal(recipe) {
+ // set modal header html
+ $('#modal_header').html(
+ '' + recipe.label + '
' +
+ '' + recipe.source + '
'
+ );
+ // compile tab 1 data
+ var ingredient_list = '';
+ for (var i = 0; i < recipe.ingredients.length; i++) {
+ ingredient_list += "- " + recipe.ingredients[i].text + "
";
+ }
+ ingredient_list += "
";
+ // compile tab 2 data
+ var health_list = '';
+ for (var i = 0; i < recipe.digest.length; i++) {
+ health_list += "- " +
+ recipe.digest[i].label +
+ '' +
+ Math.round(recipe.digest[i].total * 10) / 10 +
+ recipe.digest[i].unit +
+ "
";
+ }
+ health_list += "
";
+ // compile tab 3 data
+ var nutrient_list = '';
+ for (var key in recipe.totalDaily) {
+ //if (!recipe.totalDaily.hasOwnProperty(key)) continue;
+ nutrient_list += '- ' +
+ recipe.totalDaily[key].label +
+ '' +
+ Math.round(recipe.totalNutrients[key].quantity * 10) / 10 +
+ recipe.totalNutrients[key].unit + ' (' +
+ Math.round(recipe.totalDaily[key].quantity * 10) / 10 +
+ recipe.totalDaily[key].unit +
+ ")
";
+ }
+ nutrient_list += "
";
+ // compile tab 4 data
+ // set all modal tabs html content
+ $('#tab_1_title').html('Ingredients');
+ $('#tab_1').html(ingredient_list);
+ $('#tab_2_title').html('Health Information');
+ $('#tab_2').html(health_list);
+ $('#tab_3_title').html("Nutrients");
+ $('#tab_3').html(nutrient_list);
+ // hide button
+ $('#contact_button').hide();
+ $('#recipe_link_button').show();
+ $('#recipe_link_tag').attr("href", recipe.url);
+ // show modal
+ $("#generic_modal").modal()
+}
\ No newline at end of file
diff --git a/app/assets/javascripts/recipe_api.js b/app/assets/javascripts/recipe_api.js
new file mode 100644
index 0000000..b4e5634
--- /dev/null
+++ b/app/assets/javascripts/recipe_api.js
@@ -0,0 +1,80 @@
+//Save for Recipe pages, not in use right now
+
+
+/*************************
+ * RECIPE API FUNCTIONS *
+ * ***********************/
+function callFood2Fork(food_string, checkRecipeValues) {
+ // clear the html to get rid of old recipes
+ $("#recipe_grid").html("");
+ var call_url = "https://api.edamam.com/search?q=" + food_string + "&app_id=" + edemam_app_id + "&app_key=" + edemam_app_key;
+ var health_query = "";
+ for (var i = 0; i < checkRecipeValues.length; i++) {
+ if (i != checkRecipeValues.length - 1) {
+ health_query += checkRecipeValues[i] + ',%20';
+ }
+ }
+ if (checkRecipeValues.length > 0) {
+ call_url += "&healthLabels=" + health_query;
+ }
+ // make call
+ $.ajax({
+ type: "GET",
+ url: call_url,
+ headers: {
+ // "Access-Control-Allow-Origin":"*"
+ "more": true,
+ },
+ dataType: 'json',
+ //contentType: 'text/plain;charset=UTF-8',
+ crossDomain: true,
+ //async: false,
+ success: function(result) {
+ if (result != null && result.hits.length > 0) {
+ handleRecipeAPICall(result.hits);
+ } else {
+ alert("Your search query returned no results . . . ")
+ }
+ },
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
+ console.log("Status: " + textStatus);
+ console.log("Error: " + errorThrown);
+ }
+ });
+}
+
+function handleRecipeAPICall(recipe_list) {
+
+ // reset recipe list
+ recipes = {};
+
+ // iterate through
+ for (var i = 0; i < recipe_list.length; i++) {
+
+ // get current recipe and id
+ var current_recipe = recipe_list[i].recipe;
+ var id = "recipe_" + (i + 1);
+
+ // put in recipe list
+ recipes[id] = current_recipe;
+
+ // add html
+ $('#recipe_grid').append(
+ '