commit db46955f853abb1a4a4abb531dc1063cdae617e3 Author: Steve Ayerhart Date: Mon Feb 21 23:00:50 2022 -0500 initial dundo.farm diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..86923a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.sass-cache/ +/ig_media.db diff --git a/DundoFarms.rb b/DundoFarms.rb new file mode 100644 index 0000000..8527567 --- /dev/null +++ b/DundoFarms.rb @@ -0,0 +1,25 @@ +require 'rubygems' +require 'bundler/setup' +require 'compass' +require 'sinatra' +require 'sinatra/activerecord' +require 'sinatra/reloader' if development? + +set :database, {adapter: 'sqlite3', database: 'ig_media.db'} + +set :pages, [ 'about', 'critters', 'gallery', 'merch' ] + +get '/' do + erb :index +end + +get '/gallery' do + @media = IGMedia.order('timestamp DESC') + erb :gallery +end + +get '/critters' do + erb :critters +end + +require './models' diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..0eef8fe --- /dev/null +++ b/Gemfile @@ -0,0 +1,16 @@ +source 'https://rubygems.org' + +gem 'sinatra' +gem 'sinatra-activerecord' +gem 'sinatra-contrib' +gem 'rake' +gem 'thin' +gem 'shotgun' + +gem 'sqlite3' + +gem 'sassc' +gem 'compass' + +gem 'whenever' +gem 'instagram_basic_display_api' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..0e12d65 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,101 @@ +GEM + remote: https://rubygems.org/ + specs: + activemodel (7.0.2.2) + activesupport (= 7.0.2.2) + activerecord (7.0.2.2) + activemodel (= 7.0.2.2) + activesupport (= 7.0.2.2) + activesupport (7.0.2.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + chronic (0.10.2) + chunky_png (1.4.0) + compass (1.0.3) + chunky_png (~> 1.2) + compass-core (~> 1.0.2) + compass-import-once (~> 1.0.5) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + sass (>= 3.3.13, < 3.5) + compass-core (1.0.3) + multi_json (~> 1.0) + sass (>= 3.3.0, < 3.5) + compass-import-once (1.0.5) + sass (>= 3.2, < 3.5) + concurrent-ruby (1.1.9) + daemons (1.4.1) + eventmachine (1.2.7) + faraday (0.17.4) + multipart-post (>= 1.2, < 3) + faraday_middleware (0.14.0) + faraday (>= 0.7.4, < 1.0) + ffi (1.15.5) + i18n (1.10.0) + concurrent-ruby (~> 1.0) + instagram_basic_display_api (0.0.2) + faraday (~> 0.17.3) + faraday_middleware (~> 0.14.0) + minitest (5.15.0) + multi_json (1.15.0) + multipart-post (2.1.1) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + rack (2.2.3) + rack-protection (2.2.0) + rack + rake (13.0.6) + rb-fsevent (0.11.1) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby2_keywords (0.0.5) + sass (3.4.25) + sassc (2.4.0) + ffi (~> 1.9) + shotgun (0.9.2) + rack (>= 1.0) + sinatra (2.2.0) + mustermann (~> 1.0) + rack (~> 2.2) + rack-protection (= 2.2.0) + tilt (~> 2.0) + sinatra-activerecord (2.0.25) + activerecord (>= 4.1) + sinatra (>= 1.0) + sinatra-contrib (2.2.0) + multi_json + mustermann (~> 1.0) + rack-protection (= 2.2.0) + sinatra (= 2.2.0) + tilt (~> 2.0) + sqlite3 (1.4.2) + thin (1.8.1) + daemons (~> 1.0, >= 1.0.9) + eventmachine (~> 1.0, >= 1.0.4) + rack (>= 1, < 3) + tilt (2.0.10) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + whenever (1.0.0) + chronic (>= 0.6.3) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + compass + instagram_basic_display_api + rake + sassc + shotgun + sinatra + sinatra-activerecord + sinatra-contrib + sqlite3 + thin + whenever + +BUNDLED WITH + 2.3.7 diff --git a/InstagramPosts.rb b/InstagramPosts.rb new file mode 100644 index 0000000..e69de29 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..c6cdbc1 --- /dev/null +++ b/Rakefile @@ -0,0 +1,16 @@ +require 'rubygems' +require 'bundler' +require 'rake' +require 'sinatra/activerecord/rake' +require 'instagram_basic_display_api' + +Bundler.setup + + +namespace :db do + task :load_config do + require './DundoFarms' + end +end + +Dir['tasks/*.rake'].sort.each { |ext| load ext } diff --git a/config.rb b/config.rb new file mode 100644 index 0000000..8990ab5 --- /dev/null +++ b/config.rb @@ -0,0 +1,15 @@ +require './DundoFarms' + +project_path = Sinatra::Application.root + +http_path = '/' +http_stylesheets_path = '/style' +http_images_path = '/images' + +css_dir = File.join 'public', 'style' +sass_dir = File.join 'style' + +preferred_syntax = :scss + +relative_assets = false +output_style = :expanded diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..2c14a22 --- /dev/null +++ b/config.ru @@ -0,0 +1,6 @@ +require 'rubygems' +require 'sinatra' + +require './DundoFarms' + +run Sinatra::Application diff --git a/config/schedule.rb b/config/schedule.rb new file mode 100644 index 0000000..1b98bab --- /dev/null +++ b/config/schedule.rb @@ -0,0 +1,24 @@ +# Use this file to easily define all of your cron jobs. +# +# It's helpful, but not entirely necessary to understand cron before proceeding. +# http://en.wikipedia.org/wiki/Cron + +# Example: +# +# set :output, "/path/to/my/cron_log.log" +# +# every 2.hours do +# command "/usr/bin/some_great_command" +# runner "MyModel.some_method" +# rake "some:great:rake:task" +# end +# +# every 4.days do +# runner "AnotherModel.prune_old_records" +# end + +# Learn more: http://github.com/javan/whenever + +every 1.minute do + rake 'ig:update_media' +end diff --git a/db/migrate/20220221014439_create_ig_media.rb b/db/migrate/20220221014439_create_ig_media.rb new file mode 100644 index 0000000..fe91b36 --- /dev/null +++ b/db/migrate/20220221014439_create_ig_media.rb @@ -0,0 +1,14 @@ +class CreateIgMedia < ActiveRecord::Migration[7.0] + def change + create_table :media do |t| + t.string :media_url + t.string :media_type + t.string :thumbnail_url + t.string :permalink + t.text :caption + t.datetime :timestamp + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..3807f9d --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,25 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[7.0].define(version: 2022_02_21_014439) do + create_table "media", force: :cascade do |t| + t.string "media_url" + t.string "media_type" + t.string "thumbnail_url" + t.string "permalink" + t.text "caption" + t.datetime "timestamp" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000..7362806 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,25 @@ +require 'instagram_basic_display_api' +require 'sinatra/activerecord' + +client = InstagramBasicDisplayAPI.client(access_token: ENV['DUNDO_FARMS_IG_TOKEN']) + +media = client.user_recent_media[:data].reduce([]) do |media, media_item| + if media_item[:media_type] == 'CAROUSEL_ALBUM' + media.concat client.media_children(media_item[:id])[:data] + media + else + media.append media_item + end +end + +media.each do |media_item| + IGMedia.create( + id: media_item[:id], + media_url: media_item[:media_url], + media_type: media_item[:media_type], + thumbnail_url: media_item[:thumbnail_url], + permalink: media_item[:permalink], + caption: media_item[:caption], + timestamp: DateTime.parse(media_item[:timestamp]) + ) +end diff --git a/models.rb b/models.rb new file mode 100644 index 0000000..7ae670a --- /dev/null +++ b/models.rb @@ -0,0 +1,3 @@ +class IGMedia < ActiveRecord::Base + self.table_name = "media" +end diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..11ab729 --- /dev/null +++ b/public/index.html @@ -0,0 +1,300 @@ + + + + + + + + + + Dundo Farms + + + + + + + +
+
+ + +
+
+
+
+ +
+
+ + + diff --git a/public/style/img/bio/2021Hens.jpg b/public/style/img/bio/2021Hens.jpg new file mode 100644 index 0000000..7bb8af1 Binary files /dev/null and b/public/style/img/bio/2021Hens.jpg differ diff --git a/public/style/img/bio/2022Chicks.jpg b/public/style/img/bio/2022Chicks.jpg new file mode 100644 index 0000000..da2e04f Binary files /dev/null and b/public/style/img/bio/2022Chicks.jpg differ diff --git a/public/style/img/bio/Clementine.jpg b/public/style/img/bio/Clementine.jpg new file mode 100644 index 0000000..23087cc Binary files /dev/null and b/public/style/img/bio/Clementine.jpg differ diff --git a/public/style/img/bio/Feta.jpg b/public/style/img/bio/Feta.jpg new file mode 100644 index 0000000..8ba211b Binary files /dev/null and b/public/style/img/bio/Feta.jpg differ diff --git a/public/style/img/bio/Gorgonzola.jpg b/public/style/img/bio/Gorgonzola.jpg new file mode 100644 index 0000000..69fd907 Binary files /dev/null and b/public/style/img/bio/Gorgonzola.jpg differ diff --git a/public/style/img/bio/Maggie.jpg b/public/style/img/bio/Maggie.jpg new file mode 100644 index 0000000..1b634f6 Binary files /dev/null and b/public/style/img/bio/Maggie.jpg differ diff --git a/public/style/img/bio/Merch.jpg b/public/style/img/bio/Merch.jpg new file mode 100644 index 0000000..1485637 Binary files /dev/null and b/public/style/img/bio/Merch.jpg differ diff --git a/public/style/img/bio/Mozzarella.jpg b/public/style/img/bio/Mozzarella.jpg new file mode 100644 index 0000000..e458da5 Binary files /dev/null and b/public/style/img/bio/Mozzarella.jpg differ diff --git a/public/style/img/bio/Opie.jpg b/public/style/img/bio/Opie.jpg new file mode 100644 index 0000000..8737443 Binary files /dev/null and b/public/style/img/bio/Opie.jpg differ diff --git a/public/style/img/bio/Otis.jpg b/public/style/img/bio/Otis.jpg new file mode 100644 index 0000000..58ad896 Binary files /dev/null and b/public/style/img/bio/Otis.jpg differ diff --git a/public/style/img/bio/Parmesan.jpg b/public/style/img/bio/Parmesan.jpg new file mode 100644 index 0000000..723d220 Binary files /dev/null and b/public/style/img/bio/Parmesan.jpg differ diff --git a/public/style/img/bio/Sammie.jpg b/public/style/img/bio/Sammie.jpg new file mode 100644 index 0000000..4edbef6 Binary files /dev/null and b/public/style/img/bio/Sammie.jpg differ diff --git a/public/style/img/dundo-farms-logo.png b/public/style/img/dundo-farms-logo.png new file mode 100755 index 0000000..f918ca6 Binary files /dev/null and b/public/style/img/dundo-farms-logo.png differ diff --git a/public/style/img/dundo-farms-logo.svg b/public/style/img/dundo-farms-logo.svg new file mode 100755 index 0000000..da4d28f --- /dev/null +++ b/public/style/img/dundo-farms-logo.svg @@ -0,0 +1,284 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/style/img/dundo-farms.svg b/public/style/img/dundo-farms.svg new file mode 100644 index 0000000..80cc166 --- /dev/null +++ b/public/style/img/dundo-farms.svg @@ -0,0 +1,34 @@ + + + Dundo Farms + + + + DUNDO + farms + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/style/_critters.scss b/style/_critters.scss new file mode 100644 index 0000000..19ca3d1 --- /dev/null +++ b/style/_critters.scss @@ -0,0 +1,63 @@ + +#critters { + .bios { + list-style: none; + + .bio { + display: flex; + width: 100%; + justify-content: center; + align-items: center; + + &:nth-child(even) { + flex-direction: row-reverse; + + img { + box-shadow: 30px 0px 0px #f2dfce; + } + .info { + text-align: right; + } + } + + &:nth-child(odd) { + img { + box-shadow: -30px 0px 0px #f2dfce; + + } + } + + .info { + width: 50%; + padding: 10px 30px; + + h1 { + font-family: 'Handlee', cursive; + text-transform: uppercase; + font-weight: 800; + font-size: 2em; + } + + h2 { + font-size: .75em; + font-family: sans-serif; + color: $dundo-green; + } + + p { + padding: 12px 0; + } + } + + img { + border: 5px solid $off-white; + height: 200px; + width: 200px; + object-fit: cover; + border-radius: 50%; + } + + + } + } +} diff --git a/style/_gallery.scss b/style/_gallery.scss new file mode 100644 index 0000000..da1ee61 --- /dev/null +++ b/style/_gallery.scss @@ -0,0 +1,48 @@ + +body { + main { + #gallery { + .gallery { + list-style-type: none; + display: flex; + flex-wrap: wrap; + margin: -1rem -1rem; + padding-bottom: 3rem; + + .gallery-item { + position: relative; + flex: 1 0 22rem; + margin: 1rem; + color: $off-white; + box-shadow: 1px 1px 1px 2px rgba(200, 200, 200,.5); cursor: pointer; + border-radius: 5%; + + .gallery-image { + cursor: pointer; + border-radius: 5%; + width: 100%; + height: 100%; + object-fit: cover; + } + } + } + + .gallery-item, + .gallery { + width: auto; + margin: 0; + } + + img, video { + display: block; + } + + @supports (display: grid) { + .gallery { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); + } + } + } + } +} diff --git a/style/_shared.scss b/style/_shared.scss new file mode 100644 index 0000000..00d65bf --- /dev/null +++ b/style/_shared.scss @@ -0,0 +1,99 @@ + +html, body { + height: 100%; +} + +body { + min-width: 375px; + display: flex; + flex-direction: column; + background-color: $off-white; + + header { + background-image: linear-gradient(to bottom, $dundo-sun, $off-white); + display: flex; + justify-content: center; + flex-direction: column; + align-items: center; + padding: 1em 0 3em 0; + + .container { + max-width: 93.5rem; + margin: 0 auto; + padding: 0 2rem; + + .main-logo { + display: block; + img { + height: 100%; + width: 100%; + } + } + } + + nav { + width: 50%; + max-width: 100%; + padding: .5em 0; + + ul { + display: flex; + list-style: none; + justify-content: space-evenly; + padding: 0 12px; + li { + padding: 0 5px; + position: relative; + + a { + font-size: 1.25em; + text-decoration: none; + color: $dundo-black; + font-weight: 500; + font-family: Raleway; + &.current { + font-weight: 700; + } + + &:hover::before { + transform: scaleX(1); + transform-origin: left; + } + &::before { + content: ''; + position: absolute; + left: 0; + bottom: 23px; + width: 100%; + height: 3px; + background-color: #bacbc6; + transform: scaleX(0); + transition: .3s ease transform, .3s ease color; + transform-origin: right; + } + } + } + } + } + + + } + + main { + padding: 0 15px; + flex: 1 0 auto; + display: flex; + justify-content: center; + + .container { + max-width: 900px; + min-width: 760px; + } + } + + footer { + padding: 36px 12px; + flex-shrink: 0; + height: 30px; + } +} diff --git a/style/_variables.scss b/style/_variables.scss new file mode 100644 index 0000000..11e2426 --- /dev/null +++ b/style/_variables.scss @@ -0,0 +1,11 @@ + + +// Colors +$dundo-green: #497364; +$dundo-yellow: #f2ac57; +$dundo-brown: #402814; +$dundo-peach: #f2dfce; +$dundo-gray: #f2f2f2; +$dundo-black: #0d0d0d; +$dundo-sun: #f7d193; +$off-white: #f8f8ff; diff --git a/style/dundo.scss b/style/dundo.scss new file mode 100644 index 0000000..fa79000 --- /dev/null +++ b/style/dundo.scss @@ -0,0 +1,15 @@ + +@import 'compass'; +@import 'compass/reset'; +@import 'compass/utilities'; +@import 'compass/css3'; + +@import 'https://fonts.googleapis.com/css?family=Raleway'; +@import 'https://fonts.googleapis.com/css2?family=Nanum+Pen+Script'; +@import 'https://fonts.googleapis.com/css2?family=Handlee'; + +@import 'variables'; +@import 'shared'; + +@import 'gallery'; +@import 'critters'; diff --git a/tasks/application.rake b/tasks/application.rake new file mode 100644 index 0000000..5186c84 --- /dev/null +++ b/tasks/application.rake @@ -0,0 +1,33 @@ +desc 'Run the DundoFarms site' +task :s do + system 'rackup -p 8978' +end + +namespace :ig do + desc 'update ig media cache' + task :media_sync do + get_all_ig_media + end + + def get_all_ig_media + client = InstagramBasicDisplayAPI.client(access_token: ENV['DUNDO_FARMS_IG_TOKEN']) + + media = client.user_recent_media[:data].reduce([]) do |media, media_item| + if media_item[:media_type] == 'CAROUSEL_ALBUM' + media.concat client.media_children(media_item[:id])[:data] + media + else + media.append media_item + end + end + puts media + end +end + +# if media_item[:media_type] == "CAROUSEL_ALBUM" +# puts media_item +# puts client.media_children(media_item[:media_id]) +# else +# media.append media_item +# end +# end diff --git a/views/critters.erb b/views/critters.erb new file mode 100644 index 0000000..36878b6 --- /dev/null +++ b/views/critters.erb @@ -0,0 +1,92 @@ +
+ +
diff --git a/views/gallery.erb b/views/gallery.erb new file mode 100644 index 0000000..0b5c25a --- /dev/null +++ b/views/gallery.erb @@ -0,0 +1,21 @@ + diff --git a/views/index.erb b/views/index.erb new file mode 100644 index 0000000..c827fa5 --- /dev/null +++ b/views/index.erb @@ -0,0 +1,2 @@ +
+
diff --git a/views/layout.erb b/views/layout.erb new file mode 100644 index 0000000..56cd12c --- /dev/null +++ b/views/layout.erb @@ -0,0 +1,50 @@ + + + + + + + + + + Dundo Farms + + + + + + + +
+
+ +
+ +
+
+
+ <%= yield %> +
+
+ + +