diff --git a/alex_maunder/week_05/famous-mountains/.ruby-version b/alex_maunder/week_05/famous-mountains/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/alex_maunder/week_05/famous-mountains/Gemfile b/alex_maunder/week_05/famous-mountains/Gemfile new file mode 100644 index 0000000..9c716e1 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/Gemfile @@ -0,0 +1,58 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/alex_maunder/week_05/famous-mountains/Gemfile.lock b/alex_maunder/week_05/famous-mountains/Gemfile.lock new file mode 100644 index 0000000..3917870 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/Gemfile.lock @@ -0,0 +1,227 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.32.2) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + io-like (0.3.1) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1-x86_64-darwin-19) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (1.7.1) + ruby_dep (1.5.0) + rubyzip (2.3.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/alex_maunder/week_05/famous-mountains/README.md b/alex_maunder/week_05/famous-mountains/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/alex_maunder/week_05/famous-mountains/Rakefile b/alex_maunder/week_05/famous-mountains/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/alex_maunder/week_05/famous-mountains/app/assets/config/manifest.js b/alex_maunder/week_05/famous-mountains/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/alex_maunder/week_05/famous-mountains/app/assets/images/.keep b/alex_maunder/week_05/famous-mountains/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/app/assets/javascripts/application.js b/alex_maunder/week_05/famous-mountains/app/assets/javascripts/application.js new file mode 100644 index 0000000..46b2035 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require turbolinks +//= require_tree . diff --git a/alex_maunder/week_05/famous-mountains/app/assets/stylesheets/application.css b/alex_maunder/week_05/famous-mountains/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/alex_maunder/week_05/famous-mountains/app/controllers/application_controller.rb b/alex_maunder/week_05/famous-mountains/app/controllers/application_controller.rb new file mode 100644 index 0000000..75f1154 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + skip_before_action :verify_authenticity_token +end diff --git a/alex_maunder/week_05/famous-mountains/app/controllers/concerns/.keep b/alex_maunder/week_05/famous-mountains/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/app/controllers/mountains_controller.rb b/alex_maunder/week_05/famous-mountains/app/controllers/mountains_controller.rb new file mode 100644 index 0000000..0bf4b87 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/controllers/mountains_controller.rb @@ -0,0 +1,48 @@ +class MountainsController < ApplicationController + def index + @mountains = Mountain.all + end + + def show + @mountain = Mountain.find params[:id] + end + + def new + end + + def create + mountain = Mountain.create :name => params[:name], :image => params[:image], :location => params[:location], :height => params[:height], :height_sealevel => params[:height_sealevel] + + redirect_to mountain_path(mountain.id) + end + + def edit + @mountain = Mountain.find params[:id] + end + + def update + # raise "hell" + # get the existing mountain from the db + mountain = Mountain.find params[:id] # doesn't need to be an instance variable as we aren't outputting anything in this "update" view that needs to access this variable + # update ALL the fields + mountain.name = params[:name] + mountain.image = params[:image] + mountain.location = params[:location] + mountain.height = params[:height] + mountain.height_sealevel = params[:height_sealevel] + # save changes + mountain.save + # redirect to show page so user knows the edit worked + redirect_to mountain_path(mountain.id) # show page + end + + def destroy + # find the mountain + mountain = Mountain.find params[:id] + # destroy the mountain + mountain.destroy + # redirect to all mountains + redirect_to mountains_path +end + +end diff --git a/alex_maunder/week_05/famous-mountains/app/helpers/application_helper.rb b/alex_maunder/week_05/famous-mountains/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/alex_maunder/week_05/famous-mountains/app/jobs/application_job.rb b/alex_maunder/week_05/famous-mountains/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/alex_maunder/week_05/famous-mountains/app/mailers/application_mailer.rb b/alex_maunder/week_05/famous-mountains/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/alex_maunder/week_05/famous-mountains/app/models/application_record.rb b/alex_maunder/week_05/famous-mountains/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/alex_maunder/week_05/famous-mountains/app/models/concerns/.keep b/alex_maunder/week_05/famous-mountains/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/app/models/mountain.rb b/alex_maunder/week_05/famous-mountains/app/models/mountain.rb new file mode 100644 index 0000000..df54b3f --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/models/mountain.rb @@ -0,0 +1,2 @@ +class Mountain < ActiveRecord::Base +end diff --git a/alex_maunder/week_05/famous-mountains/app/views/layouts/application.html.erb b/alex_maunder/week_05/famous-mountains/app/views/layouts/application.html.erb new file mode 100644 index 0000000..3b91df5 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/views/layouts/application.html.erb @@ -0,0 +1,20 @@ + + + + FamousMountains + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + + <%= yield %> + + diff --git a/alex_maunder/week_05/famous-mountains/app/views/layouts/mailer.html.erb b/alex_maunder/week_05/famous-mountains/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/alex_maunder/week_05/famous-mountains/app/views/layouts/mailer.text.erb b/alex_maunder/week_05/famous-mountains/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/alex_maunder/week_05/famous-mountains/app/views/mountains/edit.html.erb b/alex_maunder/week_05/famous-mountains/app/views/mountains/edit.html.erb new file mode 100644 index 0000000..e390700 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/views/mountains/edit.html.erb @@ -0,0 +1,30 @@ +

Edit Mountain

+ +
+ + + + + + + + + + + +
diff --git a/alex_maunder/week_05/famous-mountains/app/views/mountains/index.html.erb b/alex_maunder/week_05/famous-mountains/app/views/mountains/index.html.erb new file mode 100644 index 0000000..951beb9 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/views/mountains/index.html.erb @@ -0,0 +1,9 @@ +

Famous Mountains

+ +<% @mountains.each do |mountain| %> +

+ <%= link_to mountain.name, mountain_path(mountain.id) %> + is + <%= pluralize mountain.height, 'meter' %> tall +

+<% end %> diff --git a/alex_maunder/week_05/famous-mountains/app/views/mountains/new.html.erb b/alex_maunder/week_05/famous-mountains/app/views/mountains/new.html.erb new file mode 100644 index 0000000..b0806de --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/views/mountains/new.html.erb @@ -0,0 +1,30 @@ +

New Mountain

+ +
+ + + + + + + + + + + +
diff --git a/alex_maunder/week_05/famous-mountains/app/views/mountains/show.html.erb b/alex_maunder/week_05/famous-mountains/app/views/mountains/show.html.erb new file mode 100644 index 0000000..1ad7da6 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/app/views/mountains/show.html.erb @@ -0,0 +1,16 @@ +

<%= @mountain.name %>

+ + +<%= image_tag @mountain.image, :class => 'feature' if @mountain.image.present? %> + + + +
+ <%= link_to 'Edit mountain', edit_mountain_path(@mountain.id) %> + <%= button_to 'Delete mountain', mountain_path(@mountain.id), :method => 'delete' %> +
diff --git a/alex_maunder/week_05/famous-mountains/bin/bundle b/alex_maunder/week_05/famous-mountains/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/alex_maunder/week_05/famous-mountains/bin/rails b/alex_maunder/week_05/famous-mountains/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/alex_maunder/week_05/famous-mountains/bin/rake b/alex_maunder/week_05/famous-mountains/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/alex_maunder/week_05/famous-mountains/bin/setup b/alex_maunder/week_05/famous-mountains/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/alex_maunder/week_05/famous-mountains/bin/spring b/alex_maunder/week_05/famous-mountains/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/alex_maunder/week_05/famous-mountains/bin/update b/alex_maunder/week_05/famous-mountains/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/alex_maunder/week_05/famous-mountains/bin/yarn b/alex_maunder/week_05/famous-mountains/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/alex_maunder/week_05/famous-mountains/config.ru b/alex_maunder/week_05/famous-mountains/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/alex_maunder/week_05/famous-mountains/config/application.rb b/alex_maunder/week_05/famous-mountains/config/application.rb new file mode 100644 index 0000000..28f5f60 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/application.rb @@ -0,0 +1,30 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module FamousMountains + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/alex_maunder/week_05/famous-mountains/config/boot.rb b/alex_maunder/week_05/famous-mountains/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/alex_maunder/week_05/famous-mountains/config/credentials.yml.enc b/alex_maunder/week_05/famous-mountains/config/credentials.yml.enc new file mode 100644 index 0000000..a7f59e6 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/credentials.yml.enc @@ -0,0 +1 @@ +U9aJigQON/bqpn0FMs63eGh0cnyX0cL7wUupHI2ieAGueE53YVzf3mpvH8TAkv9px2LR/eov6zXrzoGwhEy2AJrzm1yo/+mA55nOzuXqIpAA2jnHg+ViwNOHbBZ4ZH1sWdGBlqRYOtYl62PE23BznfgGCXIkGp6oXcw/rP6nLq5yJs6TxSwXdKKEMx8K/5dG8OvA3JGjlzepSIAbgQw5oBOmeGOahPdrhkymYLoIwn7eikgGF7DY8e0bUUIAMVnF5gPZ70IHirQ/fAxOBI7Ot05BcvjcbRWOMmwt9SgawwiBR0VqDk1sTJmGp8oX+nOM88T7Hw1zTbqNaS6nR+c2jAEYIIKOp8PdN+7sy2l75jo8P5kkrPHWKTje0cUf8Q9LFInlSg/olEAIVsTNRUlGl0MYjNglaxrT+LH+--Xhf0T4Oo+wmtf99u--B6AI6GMHW5Ze/zXxgml3NA== \ No newline at end of file diff --git a/alex_maunder/week_05/famous-mountains/config/database.yml b/alex_maunder/week_05/famous-mountains/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/alex_maunder/week_05/famous-mountains/config/environment.rb b/alex_maunder/week_05/famous-mountains/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/alex_maunder/week_05/famous-mountains/config/environments/development.rb b/alex_maunder/week_05/famous-mountains/config/environments/development.rb new file mode 100644 index 0000000..92bfc1d --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/environments/development.rb @@ -0,0 +1,58 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/alex_maunder/week_05/famous-mountains/config/environments/production.rb b/alex_maunder/week_05/famous-mountains/config/environments/production.rb new file mode 100644 index 0000000..060edd4 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/environments/production.rb @@ -0,0 +1,86 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "famous-mountains_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/alex_maunder/week_05/famous-mountains/config/environments/test.rb b/alex_maunder/week_05/famous-mountains/config/environments/test.rb new file mode 100644 index 0000000..b08fc84 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/environments/test.rb @@ -0,0 +1,43 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/alex_maunder/week_05/famous-mountains/config/initializers/application_controller_renderer.rb b/alex_maunder/week_05/famous-mountains/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/alex_maunder/week_05/famous-mountains/config/initializers/assets.rb b/alex_maunder/week_05/famous-mountains/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/alex_maunder/week_05/famous-mountains/config/initializers/backtrace_silencers.rb b/alex_maunder/week_05/famous-mountains/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/alex_maunder/week_05/famous-mountains/config/initializers/content_security_policy.rb b/alex_maunder/week_05/famous-mountains/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/alex_maunder/week_05/famous-mountains/config/initializers/cookies_serializer.rb b/alex_maunder/week_05/famous-mountains/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/alex_maunder/week_05/famous-mountains/config/initializers/filter_parameter_logging.rb b/alex_maunder/week_05/famous-mountains/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/alex_maunder/week_05/famous-mountains/config/initializers/inflections.rb b/alex_maunder/week_05/famous-mountains/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/alex_maunder/week_05/famous-mountains/config/initializers/mime_types.rb b/alex_maunder/week_05/famous-mountains/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/alex_maunder/week_05/famous-mountains/config/initializers/wrap_parameters.rb b/alex_maunder/week_05/famous-mountains/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/alex_maunder/week_05/famous-mountains/config/locales/en.yml b/alex_maunder/week_05/famous-mountains/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/alex_maunder/week_05/famous-mountains/config/master.key b/alex_maunder/week_05/famous-mountains/config/master.key new file mode 100644 index 0000000..1bd2d6f --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/master.key @@ -0,0 +1 @@ +03cc35c846860f91c0a03a891c4f4e1b \ No newline at end of file diff --git a/alex_maunder/week_05/famous-mountains/config/puma.rb b/alex_maunder/week_05/famous-mountains/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/alex_maunder/week_05/famous-mountains/config/routes.rb b/alex_maunder/week_05/famous-mountains/config/routes.rb new file mode 100644 index 0000000..10c7368 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/routes.rb @@ -0,0 +1,9 @@ +Rails.application.routes.draw do + get '/mountains' => 'mountains#index' + get '/mountains/new' => 'mountains#new', :as => 'new_mountain' # new_mountain_path + post '/mountains' => 'mountains#create' + get '/mountains/:id'=> 'mountains#show', :as => 'mountain' # mountain_path + get '/mountains/:id/edit' => 'mountains#edit', :as => 'edit_mountain' # edit_mountain_path + post '/mountains/:id' => 'mountains#update' + delete '/mountains/:id' => 'mountains#destroy' +end diff --git a/alex_maunder/week_05/famous-mountains/config/spring.rb b/alex_maunder/week_05/famous-mountains/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/alex_maunder/week_05/famous-mountains/db/create_mountains.sql b/alex_maunder/week_05/famous-mountains/db/create_mountains.sql new file mode 100644 index 0000000..9ead6c0 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/db/create_mountains.sql @@ -0,0 +1,8 @@ +CREATE TABLE mountains ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + image TEXT, + location TEXT, + height FLOAT, + height_sealevel FLOAT +); diff --git a/alex_maunder/week_05/famous-mountains/db/development.sqlite3 b/alex_maunder/week_05/famous-mountains/db/development.sqlite3 new file mode 100644 index 0000000..0feffaf Binary files /dev/null and b/alex_maunder/week_05/famous-mountains/db/development.sqlite3 differ diff --git a/alex_maunder/week_05/famous-mountains/db/seeds.rb b/alex_maunder/week_05/famous-mountains/db/seeds.rb new file mode 100644 index 0000000..0bf3da2 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/db/seeds.rb @@ -0,0 +1,7 @@ +Mountain.destroy_all + +Mountain.create :name => 'Mt Fujitsu', :location => 'Japan', :height => 123123 +Mountain.create :name => 'Mt Everest', :location => 'Nepal', :height => 283 +Mountain.create :name => 'Mt Kiliminjaro', :location => 'Sth Africa', :height => 511 + +puts "#{Mountain.count} mountains available." diff --git a/alex_maunder/week_05/famous-mountains/db/test.sqlite3 b/alex_maunder/week_05/famous-mountains/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/lib/assets/.keep b/alex_maunder/week_05/famous-mountains/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/lib/tasks/.keep b/alex_maunder/week_05/famous-mountains/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/package.json b/alex_maunder/week_05/famous-mountains/package.json new file mode 100644 index 0000000..2b5a635 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/package.json @@ -0,0 +1,5 @@ +{ + "name": "famous-mountains", + "private": true, + "dependencies": {} +} diff --git a/alex_maunder/week_05/famous-mountains/public/404.html b/alex_maunder/week_05/famous-mountains/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/alex_maunder/week_05/famous-mountains/public/422.html b/alex_maunder/week_05/famous-mountains/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/alex_maunder/week_05/famous-mountains/public/500.html b/alex_maunder/week_05/famous-mountains/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/alex_maunder/week_05/famous-mountains/public/apple-touch-icon-precomposed.png b/alex_maunder/week_05/famous-mountains/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/public/apple-touch-icon.png b/alex_maunder/week_05/famous-mountains/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/public/favicon.ico b/alex_maunder/week_05/famous-mountains/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/public/robots.txt b/alex_maunder/week_05/famous-mountains/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/alex_maunder/week_05/famous-mountains/test/application_system_test_case.rb b/alex_maunder/week_05/famous-mountains/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/alex_maunder/week_05/famous-mountains/test/controllers/.keep b/alex_maunder/week_05/famous-mountains/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/test/fixtures/.keep b/alex_maunder/week_05/famous-mountains/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/test/fixtures/files/.keep b/alex_maunder/week_05/famous-mountains/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/test/helpers/.keep b/alex_maunder/week_05/famous-mountains/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/test/integration/.keep b/alex_maunder/week_05/famous-mountains/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/test/mailers/.keep b/alex_maunder/week_05/famous-mountains/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/test/models/.keep b/alex_maunder/week_05/famous-mountains/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/test/system/.keep b/alex_maunder/week_05/famous-mountains/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/famous-mountains/test/test_helper.rb b/alex_maunder/week_05/famous-mountains/test/test_helper.rb new file mode 100644 index 0000000..3ab84e3 --- /dev/null +++ b/alex_maunder/week_05/famous-mountains/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/alex_maunder/week_05/famous-mountains/vendor/.keep b/alex_maunder/week_05/famous-mountains/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/.gitignore b/alex_maunder/week_05/games_on_rails/.gitignore new file mode 100644 index 0000000..81452db --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/.gitignore @@ -0,0 +1,31 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore uploaded files in development +/storage/* +!/storage/.keep + +/node_modules +/yarn-error.log + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/alex_maunder/week_05/games_on_rails/.ruby-version b/alex_maunder/week_05/games_on_rails/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/alex_maunder/week_05/games_on_rails/Gemfile b/alex_maunder/week_05/games_on_rails/Gemfile new file mode 100644 index 0000000..8737e66 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/Gemfile @@ -0,0 +1,62 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/alex_maunder/week_05/games_on_rails/Gemfile.lock b/alex_maunder/week_05/games_on_rails/Gemfile.lock new file mode 100644 index 0000000..36b125c --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/Gemfile.lock @@ -0,0 +1,220 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.32.2) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + io-like (0.3.1) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (1.7.1) + ruby_dep (1.5.0) + rubyzip (2.3.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/alex_maunder/week_05/games_on_rails/README.md b/alex_maunder/week_05/games_on_rails/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/alex_maunder/week_05/games_on_rails/Rakefile b/alex_maunder/week_05/games_on_rails/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/alex_maunder/week_05/games_on_rails/app/assets/config/manifest.js b/alex_maunder/week_05/games_on_rails/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/alex_maunder/week_05/games_on_rails/app/assets/images/.keep b/alex_maunder/week_05/games_on_rails/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/app/assets/javascripts/application.js b/alex_maunder/week_05/games_on_rails/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/alex_maunder/week_05/games_on_rails/app/assets/javascripts/cable.js b/alex_maunder/week_05/games_on_rails/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/alex_maunder/week_05/games_on_rails/app/assets/javascripts/channels/.keep b/alex_maunder/week_05/games_on_rails/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/app/assets/stylesheets/application.css b/alex_maunder/week_05/games_on_rails/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/alex_maunder/week_05/games_on_rails/app/channels/application_cable/channel.rb b/alex_maunder/week_05/games_on_rails/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/alex_maunder/week_05/games_on_rails/app/channels/application_cable/connection.rb b/alex_maunder/week_05/games_on_rails/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/alex_maunder/week_05/games_on_rails/app/controllers/application_controller.rb b/alex_maunder/week_05/games_on_rails/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/alex_maunder/week_05/games_on_rails/app/controllers/concerns/.keep b/alex_maunder/week_05/games_on_rails/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/app/controllers/game_controller.rb b/alex_maunder/week_05/games_on_rails/app/controllers/game_controller.rb new file mode 100644 index 0000000..66a6b7f --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/controllers/game_controller.rb @@ -0,0 +1,30 @@ +class GameController < ApplicationController + attr_accessor :rock, :paper, :scissors + + def rock_paper_scissors + render :rock_paper_scissors + end + + def rock_paper_scissors_answer + possible_answers = [ + "Rock", "Paper", "Scissors" + ] + + @sample = possible_answers.sample + + # raise "hell" + @answer = params[:throw] + + @output = '' + + if @sample == @answer + @output += 'Tie!' + redirect to :rock_paper_scissors_answer + end + + raise "hell" + + render :rock_paper_scissors_answer + end + +end diff --git a/alex_maunder/week_05/games_on_rails/app/controllers/number_controller.rb b/alex_maunder/week_05/games_on_rails/app/controllers/number_controller.rb new file mode 100644 index 0000000..7e1f258 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/controllers/number_controller.rb @@ -0,0 +1,49 @@ +class NumberController < ApplicationController + + def secret_number + render :secret_number + end + + def secret_number_game + # number_one = gets.to_i + @high_num = params[:secret_number_game].to_i + # @zer_to_inp = Random.rand @high_num + + # def choose(input, zer_to_ten) + # if input != zer_to_ten.to_i + # if input < zer_to_ten.to_i + # # puts "Wrong, guess Higher!" + # else + # # puts "Wrong, guess Lower!" + # end + # number_one = gets.to_i + # choose(number_one, zer_to_ten) + # else + # puts "wow your guess of #{input} matched the random number!" + # end + # end + # + # if number_one == 13 + # puts "What is the highest number you want? " + # update = gets.to_i + # zer_to_ten = Random.rand update + # puts "OK, playing from 0 to #{update}" + # puts "Guess a number between 0 and #{update}" + # number_update = gets.to_i + # choose(number_update, zer_to_ten) + # else + # choose(number_one, zer_to_ten) + # end + # raise 'hell' + render :secret_number_game + end + + def guess + @current_guess = params["guess"].to_i + # @zer_to_inp = Random.rand @high_num + @output = 'Correct!' + # raise "hell" + render :secret_number_game + end + +end diff --git a/alex_maunder/week_05/games_on_rails/app/controllers/pages_controller.rb b/alex_maunder/week_05/games_on_rails/app/controllers/pages_controller.rb new file mode 100644 index 0000000..55cee23 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/controllers/pages_controller.rb @@ -0,0 +1,25 @@ +class PagesController < ApplicationController + def home + render :home + end + + def magic + render :magic + end + + def magic_answer + possible_answers = [ + "It is certain.", "It is decidedly so.", "Without a doubt.", "Yes – definitely.", + "You may rely on it.", "As I see it, yes.", "Most likely.", "Outlook good.", + "Yes.", "Signs point to yes.", "Reply hazy, try again.", "Ask again later.", + "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", + "Don't count on it.", "My reply is no.", "My sources say no.", + "Outlook not so good.", "Very doubtful." + ] + + @sample = possible_answers.sample + + render :magic_answer + end + +end diff --git a/alex_maunder/week_05/games_on_rails/app/helpers/application_helper.rb b/alex_maunder/week_05/games_on_rails/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/alex_maunder/week_05/games_on_rails/app/jobs/application_job.rb b/alex_maunder/week_05/games_on_rails/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/alex_maunder/week_05/games_on_rails/app/mailers/application_mailer.rb b/alex_maunder/week_05/games_on_rails/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/alex_maunder/week_05/games_on_rails/app/models/application_record.rb b/alex_maunder/week_05/games_on_rails/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/alex_maunder/week_05/games_on_rails/app/models/concerns/.keep b/alex_maunder/week_05/games_on_rails/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/app/views/game/rock_paper_scissors.html.erb b/alex_maunder/week_05/games_on_rails/app/views/game/rock_paper_scissors.html.erb new file mode 100644 index 0000000..ceb5f22 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/views/game/rock_paper_scissors.html.erb @@ -0,0 +1,13 @@ +

Rock Paper Scissors

+ +
+ + +
diff --git a/alex_maunder/week_05/games_on_rails/app/views/game/rock_paper_scissors_answer.html.erb b/alex_maunder/week_05/games_on_rails/app/views/game/rock_paper_scissors_answer.html.erb new file mode 100644 index 0000000..d76a052 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/views/game/rock_paper_scissors_answer.html.erb @@ -0,0 +1,3 @@ +

Computer chose: <%= @sample %>

+ +

<%= @output %>

diff --git a/alex_maunder/week_05/games_on_rails/app/views/layouts/application.html.erb b/alex_maunder/week_05/games_on_rails/app/views/layouts/application.html.erb new file mode 100644 index 0000000..60fadd1 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/views/layouts/application.html.erb @@ -0,0 +1,22 @@ + + + + GamesOnRails + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + + <%= yield %> + + diff --git a/alex_maunder/week_05/games_on_rails/app/views/layouts/mailer.html.erb b/alex_maunder/week_05/games_on_rails/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/alex_maunder/week_05/games_on_rails/app/views/layouts/mailer.text.erb b/alex_maunder/week_05/games_on_rails/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/alex_maunder/week_05/games_on_rails/app/views/number/secret_number.html.erb b/alex_maunder/week_05/games_on_rails/app/views/number/secret_number.html.erb new file mode 100644 index 0000000..e5af729 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/views/number/secret_number.html.erb @@ -0,0 +1,9 @@ +

Guess the Secret Number

+ +
+ + +
diff --git a/alex_maunder/week_05/games_on_rails/app/views/number/secret_number_game.html.erb b/alex_maunder/week_05/games_on_rails/app/views/number/secret_number_game.html.erb new file mode 100644 index 0000000..0a2c9fd --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/views/number/secret_number_game.html.erb @@ -0,0 +1,11 @@ +

Guess a number between 0 and <%= @high_num %>

+ +
+ + +
+ +

<%= "Correct!" if @current_guess == @zer_to_inp %>

diff --git a/alex_maunder/week_05/games_on_rails/app/views/pages/home.html.erb b/alex_maunder/week_05/games_on_rails/app/views/pages/home.html.erb new file mode 100644 index 0000000..b04bdc4 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/views/pages/home.html.erb @@ -0,0 +1,6 @@ +

Welcome to Games on Rails!

+ + +

Magic 8 Ball

+

Secret Number

+

Rock Paper Scissors

diff --git a/alex_maunder/week_05/games_on_rails/app/views/pages/magic.html.erb b/alex_maunder/week_05/games_on_rails/app/views/pages/magic.html.erb new file mode 100644 index 0000000..95e7ba0 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/views/pages/magic.html.erb @@ -0,0 +1,11 @@ +

Magic 8 Ball

+ +

Ask a question then consult the ball!

+ +
+ + +
diff --git a/alex_maunder/week_05/games_on_rails/app/views/pages/magic_answer.html.erb b/alex_maunder/week_05/games_on_rails/app/views/pages/magic_answer.html.erb new file mode 100644 index 0000000..ebc2e65 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/app/views/pages/magic_answer.html.erb @@ -0,0 +1,4 @@ +

The allmighty ball says:

+

+ <%= @sample %> +

diff --git a/alex_maunder/week_05/games_on_rails/bin/bundle b/alex_maunder/week_05/games_on_rails/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/alex_maunder/week_05/games_on_rails/bin/rails b/alex_maunder/week_05/games_on_rails/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/alex_maunder/week_05/games_on_rails/bin/rake b/alex_maunder/week_05/games_on_rails/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/alex_maunder/week_05/games_on_rails/bin/setup b/alex_maunder/week_05/games_on_rails/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/alex_maunder/week_05/games_on_rails/bin/spring b/alex_maunder/week_05/games_on_rails/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/alex_maunder/week_05/games_on_rails/bin/update b/alex_maunder/week_05/games_on_rails/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/alex_maunder/week_05/games_on_rails/bin/yarn b/alex_maunder/week_05/games_on_rails/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/alex_maunder/week_05/games_on_rails/config.ru b/alex_maunder/week_05/games_on_rails/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/alex_maunder/week_05/games_on_rails/config/application.rb b/alex_maunder/week_05/games_on_rails/config/application.rb new file mode 100644 index 0000000..dfc9199 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/application.rb @@ -0,0 +1,19 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module GamesOnRails + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/alex_maunder/week_05/games_on_rails/config/boot.rb b/alex_maunder/week_05/games_on_rails/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/alex_maunder/week_05/games_on_rails/config/cable.yml b/alex_maunder/week_05/games_on_rails/config/cable.yml new file mode 100644 index 0000000..f456b2d --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: games_on_rails_production diff --git a/alex_maunder/week_05/games_on_rails/config/credentials.yml.enc b/alex_maunder/week_05/games_on_rails/config/credentials.yml.enc new file mode 100644 index 0000000..181597a --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/credentials.yml.enc @@ -0,0 +1 @@ +t963oL3/d82JEYZBGJIo4AhZ2FWieke9L6OBHYw22TlmLkhQqz2YR7cCbAFoIupntlrslvubJgua9u4lrf9h13Sf2LlqIdonDVTfXKMDBNQqP67esX7+2lIWq8JYlhGnlnfsmp9Zkmbt2RhtZykMzyskeu4uOuH9hpT+/gj+3HuCcWrewQ2PR/KG/IWn01pdLxkSYhLmGpXZSMAvhWF7WK5WGzDgw8dkpGRv/j5J1v/EzelaLz8pooe8RslNU0TvhYbcbfnaCzbrwMXdTJkdKAqPrprfubo5cHUB5RwhDzfYzdVuVIhF+9kTguQLR6Jwta2+BCUJhFhz9t/A1xOKZBsNTR3EoWkdgofFfksBTc/v0Ugc1gcBdM6EmPWKFWRnZBOfgqC3ttpHFNsIjOEbf/N9gkVfu5WDKFth--Y8vgaVJG/TJHt5KZ--mjuGIzVvF/J2L0fGX0i2UQ== \ No newline at end of file diff --git a/alex_maunder/week_05/games_on_rails/config/database.yml b/alex_maunder/week_05/games_on_rails/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/alex_maunder/week_05/games_on_rails/config/environment.rb b/alex_maunder/week_05/games_on_rails/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/alex_maunder/week_05/games_on_rails/config/environments/development.rb b/alex_maunder/week_05/games_on_rails/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/alex_maunder/week_05/games_on_rails/config/environments/production.rb b/alex_maunder/week_05/games_on_rails/config/environments/production.rb new file mode 100644 index 0000000..4e7370d --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "games_on_rails_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/alex_maunder/week_05/games_on_rails/config/environments/test.rb b/alex_maunder/week_05/games_on_rails/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/alex_maunder/week_05/games_on_rails/config/initializers/application_controller_renderer.rb b/alex_maunder/week_05/games_on_rails/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/alex_maunder/week_05/games_on_rails/config/initializers/assets.rb b/alex_maunder/week_05/games_on_rails/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/alex_maunder/week_05/games_on_rails/config/initializers/backtrace_silencers.rb b/alex_maunder/week_05/games_on_rails/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/alex_maunder/week_05/games_on_rails/config/initializers/content_security_policy.rb b/alex_maunder/week_05/games_on_rails/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/alex_maunder/week_05/games_on_rails/config/initializers/cookies_serializer.rb b/alex_maunder/week_05/games_on_rails/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/alex_maunder/week_05/games_on_rails/config/initializers/filter_parameter_logging.rb b/alex_maunder/week_05/games_on_rails/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/alex_maunder/week_05/games_on_rails/config/initializers/inflections.rb b/alex_maunder/week_05/games_on_rails/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/alex_maunder/week_05/games_on_rails/config/initializers/mime_types.rb b/alex_maunder/week_05/games_on_rails/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/alex_maunder/week_05/games_on_rails/config/initializers/wrap_parameters.rb b/alex_maunder/week_05/games_on_rails/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/alex_maunder/week_05/games_on_rails/config/locales/en.yml b/alex_maunder/week_05/games_on_rails/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/alex_maunder/week_05/games_on_rails/config/puma.rb b/alex_maunder/week_05/games_on_rails/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/alex_maunder/week_05/games_on_rails/config/routes.rb b/alex_maunder/week_05/games_on_rails/config/routes.rb new file mode 100644 index 0000000..d831a1d --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/routes.rb @@ -0,0 +1,15 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + root :to => 'pages#home' + + get '/' => 'pages#home' + get '/magic' => 'pages#magic' + get '/magic/answer' => 'pages#magic_answer' + + get '/secret_number' => 'number#secret_number' + get '/secret_number/game' => 'number#secret_number_game' + get '/secret_number/game/compute' => 'number#guess' + + get '/rock_paper_scissors' => 'game#rock_paper_scissors' + get '/rock_paper_scissors/answer' => 'game#rock_paper_scissors_answer' +end diff --git a/alex_maunder/week_05/games_on_rails/config/spring.rb b/alex_maunder/week_05/games_on_rails/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/alex_maunder/week_05/games_on_rails/config/storage.yml b/alex_maunder/week_05/games_on_rails/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/alex_maunder/week_05/games_on_rails/db/seeds.rb b/alex_maunder/week_05/games_on_rails/db/seeds.rb new file mode 100644 index 0000000..1beea2a --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) diff --git a/alex_maunder/week_05/games_on_rails/lib/assets/.keep b/alex_maunder/week_05/games_on_rails/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/lib/tasks/.keep b/alex_maunder/week_05/games_on_rails/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/package.json b/alex_maunder/week_05/games_on_rails/package.json new file mode 100644 index 0000000..55cf4b4 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/package.json @@ -0,0 +1,5 @@ +{ + "name": "games_on_rails", + "private": true, + "dependencies": {} +} diff --git a/alex_maunder/week_05/games_on_rails/public/404.html b/alex_maunder/week_05/games_on_rails/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/alex_maunder/week_05/games_on_rails/public/422.html b/alex_maunder/week_05/games_on_rails/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/alex_maunder/week_05/games_on_rails/public/500.html b/alex_maunder/week_05/games_on_rails/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/alex_maunder/week_05/games_on_rails/public/apple-touch-icon-precomposed.png b/alex_maunder/week_05/games_on_rails/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/public/apple-touch-icon.png b/alex_maunder/week_05/games_on_rails/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/public/favicon.ico b/alex_maunder/week_05/games_on_rails/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/public/robots.txt b/alex_maunder/week_05/games_on_rails/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/alex_maunder/week_05/games_on_rails/storage/.keep b/alex_maunder/week_05/games_on_rails/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/test/application_system_test_case.rb b/alex_maunder/week_05/games_on_rails/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/alex_maunder/week_05/games_on_rails/test/controllers/.keep b/alex_maunder/week_05/games_on_rails/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/test/fixtures/.keep b/alex_maunder/week_05/games_on_rails/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/test/fixtures/files/.keep b/alex_maunder/week_05/games_on_rails/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/test/helpers/.keep b/alex_maunder/week_05/games_on_rails/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/test/integration/.keep b/alex_maunder/week_05/games_on_rails/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/test/mailers/.keep b/alex_maunder/week_05/games_on_rails/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/test/models/.keep b/alex_maunder/week_05/games_on_rails/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/test/system/.keep b/alex_maunder/week_05/games_on_rails/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/games_on_rails/test/test_helper.rb b/alex_maunder/week_05/games_on_rails/test/test_helper.rb new file mode 100644 index 0000000..3ab84e3 --- /dev/null +++ b/alex_maunder/week_05/games_on_rails/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/alex_maunder/week_05/games_on_rails/vendor/.keep b/alex_maunder/week_05/games_on_rails/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/library/.ruby-version b/alex_maunder/week_05/library/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/alex_maunder/week_05/library/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/alex_maunder/week_05/library/Gemfile b/alex_maunder/week_05/library/Gemfile new file mode 100644 index 0000000..2792f24 --- /dev/null +++ b/alex_maunder/week_05/library/Gemfile @@ -0,0 +1,51 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/alex_maunder/week_05/library/Gemfile.lock b/alex_maunder/week_05/library/Gemfile.lock new file mode 100644 index 0000000..a2adb22 --- /dev/null +++ b/alex_maunder/week_05/library/Gemfile.lock @@ -0,0 +1,199 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.6.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/alex_maunder/week_05/library/README.md b/alex_maunder/week_05/library/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/alex_maunder/week_05/library/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/alex_maunder/week_05/library/Rakefile b/alex_maunder/week_05/library/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/alex_maunder/week_05/library/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/alex_maunder/week_05/library/app/assets/config/manifest.js b/alex_maunder/week_05/library/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/alex_maunder/week_05/library/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/alex_maunder/week_05/library/app/assets/images/.keep b/alex_maunder/week_05/library/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/library/app/assets/javascripts/application.js b/alex_maunder/week_05/library/app/assets/javascripts/application.js new file mode 100644 index 0000000..46b2035 --- /dev/null +++ b/alex_maunder/week_05/library/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require turbolinks +//= require_tree . diff --git a/alex_maunder/week_05/library/app/assets/javascripts/authors.coffee b/alex_maunder/week_05/library/app/assets/javascripts/authors.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/alex_maunder/week_05/library/app/assets/javascripts/authors.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/alex_maunder/week_05/library/app/assets/javascripts/books.coffee b/alex_maunder/week_05/library/app/assets/javascripts/books.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/alex_maunder/week_05/library/app/assets/javascripts/books.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/alex_maunder/week_05/library/app/assets/stylesheets/application.css b/alex_maunder/week_05/library/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/alex_maunder/week_05/library/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/alex_maunder/week_05/library/app/assets/stylesheets/authors.scss b/alex_maunder/week_05/library/app/assets/stylesheets/authors.scss new file mode 100644 index 0000000..4434aba --- /dev/null +++ b/alex_maunder/week_05/library/app/assets/stylesheets/authors.scss @@ -0,0 +1,7 @@ +body { + +} + +.thumb { + height: 12em; +} diff --git a/alex_maunder/week_05/library/app/assets/stylesheets/books.scss b/alex_maunder/week_05/library/app/assets/stylesheets/books.scss new file mode 100644 index 0000000..81379d1 --- /dev/null +++ b/alex_maunder/week_05/library/app/assets/stylesheets/books.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the books controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/alex_maunder/week_05/library/app/controllers/application_controller.rb b/alex_maunder/week_05/library/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/alex_maunder/week_05/library/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/alex_maunder/week_05/library/app/controllers/authors_controller.rb b/alex_maunder/week_05/library/app/controllers/authors_controller.rb new file mode 100644 index 0000000..dc02311 --- /dev/null +++ b/alex_maunder/week_05/library/app/controllers/authors_controller.rb @@ -0,0 +1,39 @@ +class AuthorsController < ApplicationController + def index + @authors = Author.all + end + + def new + @author = Author.new + end + + def create + author = Author.create author_params + redirect_to author + end + + def edit + @author = Author.find params[:id] + end + + def update + author = Author.find params[:id] + author.update author_params + redirect_to author + end + + def show + @author = Author.find params[:id] + end + + def destroy + author = Author.find params[:id] + author.destroy + redirect_to authors_path + end + + private + def author_params + params.require(:author).permit(:name, :nationality, :dob, :genre, :image, :wiki) + end +end diff --git a/alex_maunder/week_05/library/app/controllers/books_controller.rb b/alex_maunder/week_05/library/app/controllers/books_controller.rb new file mode 100644 index 0000000..c6294fe --- /dev/null +++ b/alex_maunder/week_05/library/app/controllers/books_controller.rb @@ -0,0 +1,39 @@ +class BooksController < ApplicationController + def index + @books = Book.all + end + + def new + @book = Book.new + end + + def create + book = Book.create book_params + redirect_to book + end + + def edit + @book = Book.find params[:id] + end + + def update + book = Book.find params[:id] + book.update book_params + redirect_to book + end + + def show + @book = Book.find params[:id] + end + + def destroy + book = Book.find params[:id] + book.destroy + redirect_to books_path + end + + private + def book_params + params.require(:book).permit(:title, :year, :publisher, :image, :bio, :author_id) + end +end diff --git a/alex_maunder/week_05/library/app/controllers/concerns/.keep b/alex_maunder/week_05/library/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/library/app/helpers/application_helper.rb b/alex_maunder/week_05/library/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/alex_maunder/week_05/library/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/alex_maunder/week_05/library/app/helpers/authors_helper.rb b/alex_maunder/week_05/library/app/helpers/authors_helper.rb new file mode 100644 index 0000000..f22e1f9 --- /dev/null +++ b/alex_maunder/week_05/library/app/helpers/authors_helper.rb @@ -0,0 +1,2 @@ +module AuthorsHelper +end diff --git a/alex_maunder/week_05/library/app/helpers/books_helper.rb b/alex_maunder/week_05/library/app/helpers/books_helper.rb new file mode 100644 index 0000000..4b9311e --- /dev/null +++ b/alex_maunder/week_05/library/app/helpers/books_helper.rb @@ -0,0 +1,2 @@ +module BooksHelper +end diff --git a/alex_maunder/week_05/library/app/jobs/application_job.rb b/alex_maunder/week_05/library/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/alex_maunder/week_05/library/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/alex_maunder/week_05/library/app/mailers/application_mailer.rb b/alex_maunder/week_05/library/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/alex_maunder/week_05/library/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/alex_maunder/week_05/library/app/models/application_record.rb b/alex_maunder/week_05/library/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/alex_maunder/week_05/library/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/alex_maunder/week_05/library/app/models/author.rb b/alex_maunder/week_05/library/app/models/author.rb new file mode 100644 index 0000000..ed1417f --- /dev/null +++ b/alex_maunder/week_05/library/app/models/author.rb @@ -0,0 +1,3 @@ +class Author < ActiveRecord::Base + has_many :books +end diff --git a/alex_maunder/week_05/library/app/models/book.rb b/alex_maunder/week_05/library/app/models/book.rb new file mode 100644 index 0000000..b26843e --- /dev/null +++ b/alex_maunder/week_05/library/app/models/book.rb @@ -0,0 +1,3 @@ +class Book < ActiveRecord::Base + belongs_to :author, :optional => true +end diff --git a/alex_maunder/week_05/library/app/models/concerns/.keep b/alex_maunder/week_05/library/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/library/app/views/authors/_form.html.erb b/alex_maunder/week_05/library/app/views/authors/_form.html.erb new file mode 100644 index 0000000..f11ea9a --- /dev/null +++ b/alex_maunder/week_05/library/app/views/authors/_form.html.erb @@ -0,0 +1,21 @@ +<%= form_for @author do |f| %> + <%= f.label :name %> + <%= f.text_field :name, :required => true, :autofocus => true %> + + <%= f.label :nationality %> + <%= f.text_field :nationality, :placeholder => 'Irish' %> + + <%= f.label :dob, 'Date of Birth' %> + <%= f.text_field :dob, :placeholder => 'YYY-MM-DD' %> + + <%= f.label :genre %> + <%= f.text_field :genre, :placeholder => 'Fiction' %> + + <%= f.label :image %> + <%= f.url_field :image %> + + <%= f.label :wiki %> + <%= f.url_field :wiki %> + + <%= f.submit %> +<% end %> diff --git a/alex_maunder/week_05/library/app/views/authors/edit.html.erb b/alex_maunder/week_05/library/app/views/authors/edit.html.erb new file mode 100644 index 0000000..7314eff --- /dev/null +++ b/alex_maunder/week_05/library/app/views/authors/edit.html.erb @@ -0,0 +1,2 @@ +

Edit Author

+<%= render :partial => 'form' %> diff --git a/alex_maunder/week_05/library/app/views/authors/index.html.erb b/alex_maunder/week_05/library/app/views/authors/index.html.erb new file mode 100644 index 0000000..2b9365a --- /dev/null +++ b/alex_maunder/week_05/library/app/views/authors/index.html.erb @@ -0,0 +1,12 @@ +

All Authors

+ +<% @authors.each do |author| %> + <%= image_tag author.image, :class => 'thumb' if author.image.present? %> + +<% end %> diff --git a/alex_maunder/week_05/library/app/views/authors/new.html.erb b/alex_maunder/week_05/library/app/views/authors/new.html.erb new file mode 100644 index 0000000..4a47c0e --- /dev/null +++ b/alex_maunder/week_05/library/app/views/authors/new.html.erb @@ -0,0 +1,3 @@ +

New Author

+ +<%= render :partial => 'form' %> diff --git a/alex_maunder/week_05/library/app/views/authors/show.html.erb b/alex_maunder/week_05/library/app/views/authors/show.html.erb new file mode 100644 index 0000000..c38fd5a --- /dev/null +++ b/alex_maunder/week_05/library/app/views/authors/show.html.erb @@ -0,0 +1,19 @@ +

<%= @author.name %>

+ +<%= image_tag @author.image, :class => 'feature' if @author.image.present? %> + + +<% @author.books.each do |book| %> + <%= link_to image_tag(book.image, :class => 'thumb'), book %> +<% end %> + +
+ <%= link_to 'Edit Author', edit_author_path(@author) %> + <%= button_to 'Delete Author', @author, :method => 'delete' %> +
diff --git a/alex_maunder/week_05/library/app/views/books/_form.html.erb b/alex_maunder/week_05/library/app/views/books/_form.html.erb new file mode 100644 index 0000000..e77e64b --- /dev/null +++ b/alex_maunder/week_05/library/app/views/books/_form.html.erb @@ -0,0 +1,21 @@ +<%= form_for @book do |f| %> + <%= f.label :title %> + <%= f.text_field :title, :required => true %> + + <%= f.label :year %> + <%= f.text_field :year %> + + <%= f.label :publisher %> + <%= f.text_field :publisher %> + + <%= f.label :image %> + <%= f.url_field :image %> + + <%= f.label :author_id %> + <%= f.select :author_id, Author.pluck(:name, :id), :include_blank => true %> + + <%= f.label :bio %> + <%= f.text_field :bio %> + + <%= f.submit %> +<% end %> diff --git a/alex_maunder/week_05/library/app/views/books/edit.html.erb b/alex_maunder/week_05/library/app/views/books/edit.html.erb new file mode 100644 index 0000000..29423fc --- /dev/null +++ b/alex_maunder/week_05/library/app/views/books/edit.html.erb @@ -0,0 +1,2 @@ +

Edit Book

+<%= render :partial => 'form' %> diff --git a/alex_maunder/week_05/library/app/views/books/index.html.erb b/alex_maunder/week_05/library/app/views/books/index.html.erb new file mode 100644 index 0000000..ba67f67 --- /dev/null +++ b/alex_maunder/week_05/library/app/views/books/index.html.erb @@ -0,0 +1,4 @@ +

All Books

+<% @books.each do |book| %> + <%= link_to image_tag(book.image, :class => 'thumb', :alt => book.title), book %> +<% end %> diff --git a/alex_maunder/week_05/library/app/views/books/new.html.erb b/alex_maunder/week_05/library/app/views/books/new.html.erb new file mode 100644 index 0000000..4da8a1d --- /dev/null +++ b/alex_maunder/week_05/library/app/views/books/new.html.erb @@ -0,0 +1,2 @@ +

New Book

+<%= render :partial => 'form' %> diff --git a/alex_maunder/week_05/library/app/views/books/show.html.erb b/alex_maunder/week_05/library/app/views/books/show.html.erb new file mode 100644 index 0000000..93cbfa1 --- /dev/null +++ b/alex_maunder/week_05/library/app/views/books/show.html.erb @@ -0,0 +1,18 @@ +

<%= @book.title %>

+ +<%= image_tag @book.image, :class => 'feature', :alt => @book.title %> + + + +
+ <%= link_to 'Edit Book', edit_book_path(@book) %> + <%= button_to 'Delete Book', @book, :method => 'delete' %> +
diff --git a/alex_maunder/week_05/library/app/views/layouts/application.html.erb b/alex_maunder/week_05/library/app/views/layouts/application.html.erb new file mode 100644 index 0000000..bdb68ce --- /dev/null +++ b/alex_maunder/week_05/library/app/views/layouts/application.html.erb @@ -0,0 +1,23 @@ + + + + Library + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + + <%= yield %> + + diff --git a/alex_maunder/week_05/library/app/views/layouts/mailer.html.erb b/alex_maunder/week_05/library/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/alex_maunder/week_05/library/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/alex_maunder/week_05/library/app/views/layouts/mailer.text.erb b/alex_maunder/week_05/library/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/alex_maunder/week_05/library/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/alex_maunder/week_05/library/bin/bundle b/alex_maunder/week_05/library/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/alex_maunder/week_05/library/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/alex_maunder/week_05/library/bin/rails b/alex_maunder/week_05/library/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/alex_maunder/week_05/library/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/alex_maunder/week_05/library/bin/rake b/alex_maunder/week_05/library/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/alex_maunder/week_05/library/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/alex_maunder/week_05/library/bin/setup b/alex_maunder/week_05/library/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/alex_maunder/week_05/library/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/alex_maunder/week_05/library/bin/spring b/alex_maunder/week_05/library/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/alex_maunder/week_05/library/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/alex_maunder/week_05/library/bin/update b/alex_maunder/week_05/library/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/alex_maunder/week_05/library/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/alex_maunder/week_05/library/bin/yarn b/alex_maunder/week_05/library/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/alex_maunder/week_05/library/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/alex_maunder/week_05/library/config.ru b/alex_maunder/week_05/library/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/alex_maunder/week_05/library/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/alex_maunder/week_05/library/config/application.rb b/alex_maunder/week_05/library/config/application.rb new file mode 100644 index 0000000..d2e03e8 --- /dev/null +++ b/alex_maunder/week_05/library/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Library + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/alex_maunder/week_05/library/config/boot.rb b/alex_maunder/week_05/library/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/alex_maunder/week_05/library/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/alex_maunder/week_05/library/config/credentials.yml.enc b/alex_maunder/week_05/library/config/credentials.yml.enc new file mode 100644 index 0000000..a3f5a6f --- /dev/null +++ b/alex_maunder/week_05/library/config/credentials.yml.enc @@ -0,0 +1 @@ +PP2Vuizt2sM+kmr/VpvtNRrJMtoss5Cn63vN1idfXoICuiKpR1IKbBT+arzPsZjM4qYobT1SNc4RtZnvM45vp75AMuNUEPvglFzQbwRz6h30lZhhkqkkDNdLdwxWA/D/rxj4VhXaEgqsFn8tkg4GUzucrbNsStJYilT6g9haAhJPpEe4Ihi6og68lj6qpN95H6jMwR/ppEohFKZltUK6J+vfzcQANQndYCc3DW/kTcaju7kVZWVFTCouvTG0aN+6dqMuVkm83f+L9OJSddCGtPbDlVqKgWpufMGjWOPjmhr/RaWeVWIf90yA7zTx3+NnQo/TfeBEyqpYv1hwM8UlkY9+hdF8yPHYTNuHNyHevTsZBdmg97/V8jhgpdrY8/nY+3KaLoND4chI8GiO2XGKn/X2U5USu0esKgH6--gK4s/2DFvqif10GL--O6c8o4k+t34imrbXsCdp9g== \ No newline at end of file diff --git a/alex_maunder/week_05/library/config/database.yml b/alex_maunder/week_05/library/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/alex_maunder/week_05/library/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/alex_maunder/week_05/library/config/environment.rb b/alex_maunder/week_05/library/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/alex_maunder/week_05/library/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/alex_maunder/week_05/library/config/environments/development.rb b/alex_maunder/week_05/library/config/environments/development.rb new file mode 100644 index 0000000..92bfc1d --- /dev/null +++ b/alex_maunder/week_05/library/config/environments/development.rb @@ -0,0 +1,58 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/alex_maunder/week_05/library/config/environments/production.rb b/alex_maunder/week_05/library/config/environments/production.rb new file mode 100644 index 0000000..0501a20 --- /dev/null +++ b/alex_maunder/week_05/library/config/environments/production.rb @@ -0,0 +1,86 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "library_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/alex_maunder/week_05/library/config/environments/test.rb b/alex_maunder/week_05/library/config/environments/test.rb new file mode 100644 index 0000000..b08fc84 --- /dev/null +++ b/alex_maunder/week_05/library/config/environments/test.rb @@ -0,0 +1,43 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/alex_maunder/week_05/library/config/initializers/application_controller_renderer.rb b/alex_maunder/week_05/library/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/alex_maunder/week_05/library/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/alex_maunder/week_05/library/config/initializers/assets.rb b/alex_maunder/week_05/library/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/alex_maunder/week_05/library/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/alex_maunder/week_05/library/config/initializers/backtrace_silencers.rb b/alex_maunder/week_05/library/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/alex_maunder/week_05/library/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/alex_maunder/week_05/library/config/initializers/content_security_policy.rb b/alex_maunder/week_05/library/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/alex_maunder/week_05/library/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/alex_maunder/week_05/library/config/initializers/cookies_serializer.rb b/alex_maunder/week_05/library/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/alex_maunder/week_05/library/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/alex_maunder/week_05/library/config/initializers/filter_parameter_logging.rb b/alex_maunder/week_05/library/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/alex_maunder/week_05/library/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/alex_maunder/week_05/library/config/initializers/inflections.rb b/alex_maunder/week_05/library/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/alex_maunder/week_05/library/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/alex_maunder/week_05/library/config/initializers/mime_types.rb b/alex_maunder/week_05/library/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/alex_maunder/week_05/library/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/alex_maunder/week_05/library/config/initializers/wrap_parameters.rb b/alex_maunder/week_05/library/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/alex_maunder/week_05/library/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/alex_maunder/week_05/library/config/locales/en.yml b/alex_maunder/week_05/library/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/alex_maunder/week_05/library/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/alex_maunder/week_05/library/config/master.key b/alex_maunder/week_05/library/config/master.key new file mode 100644 index 0000000..00c1203 --- /dev/null +++ b/alex_maunder/week_05/library/config/master.key @@ -0,0 +1 @@ +ba4033b1e2d3e811e0d1e5d91e1bff1c \ No newline at end of file diff --git a/alex_maunder/week_05/library/config/puma.rb b/alex_maunder/week_05/library/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/alex_maunder/week_05/library/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/alex_maunder/week_05/library/config/routes.rb b/alex_maunder/week_05/library/config/routes.rb new file mode 100644 index 0000000..bc5f9c4 --- /dev/null +++ b/alex_maunder/week_05/library/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + resources :authors + resources :books +end diff --git a/alex_maunder/week_05/library/config/spring.rb b/alex_maunder/week_05/library/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/alex_maunder/week_05/library/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/alex_maunder/week_05/library/db/development.sqlite3 b/alex_maunder/week_05/library/db/development.sqlite3 new file mode 100644 index 0000000..68bbd29 Binary files /dev/null and b/alex_maunder/week_05/library/db/development.sqlite3 differ diff --git a/alex_maunder/week_05/library/db/migrate/20200617072609_create_authors.rb b/alex_maunder/week_05/library/db/migrate/20200617072609_create_authors.rb new file mode 100644 index 0000000..4054048 --- /dev/null +++ b/alex_maunder/week_05/library/db/migrate/20200617072609_create_authors.rb @@ -0,0 +1,12 @@ +class CreateAuthors < ActiveRecord::Migration[5.2] + def change + create_table :authors do |t| + t.text :name + t.text :nationality + t.date :dob + t.text :genre + t.text :image + t.text :wiki + end + end +end diff --git a/alex_maunder/week_05/library/db/migrate/20200617101551_create_books.rb b/alex_maunder/week_05/library/db/migrate/20200617101551_create_books.rb new file mode 100644 index 0000000..bd4051e --- /dev/null +++ b/alex_maunder/week_05/library/db/migrate/20200617101551_create_books.rb @@ -0,0 +1,11 @@ +class CreateBooks < ActiveRecord::Migration[5.2] + def change + create_table :books do |t| + t.text :title + t.text :year + t.text :publisher + t.text :image + t.text :bio + end + end +end diff --git a/alex_maunder/week_05/library/db/migrate/20200617111948_add_author_id_to_books.rb b/alex_maunder/week_05/library/db/migrate/20200617111948_add_author_id_to_books.rb new file mode 100644 index 0000000..320cd7c --- /dev/null +++ b/alex_maunder/week_05/library/db/migrate/20200617111948_add_author_id_to_books.rb @@ -0,0 +1,5 @@ +class AddAuthorIdToBooks < ActiveRecord::Migration[5.2] + def change + add_column :books, :author_id, :integer + end +end diff --git a/alex_maunder/week_05/library/db/schema.rb b/alex_maunder/week_05/library/db/schema.rb new file mode 100644 index 0000000..aa0e408 --- /dev/null +++ b/alex_maunder/week_05/library/db/schema.rb @@ -0,0 +1,33 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_17_111948) do + + create_table "authors", force: :cascade do |t| + t.text "name" + t.text "nationality" + t.date "dob" + t.text "genre" + t.text "image" + t.text "wiki" + end + + create_table "books", force: :cascade do |t| + t.text "title" + t.text "year" + t.text "publisher" + t.text "image" + t.text "bio" + t.integer "author_id" + end + +end diff --git a/alex_maunder/week_05/library/db/seeds.rb b/alex_maunder/week_05/library/db/seeds.rb new file mode 100644 index 0000000..3fbc6a5 --- /dev/null +++ b/alex_maunder/week_05/library/db/seeds.rb @@ -0,0 +1,16 @@ +Author.destroy_all + +Author.create(:name => 'J.R.R Tolkien', :nationality => 'English', :dob => '1892-01-03', :genre => 'non-fiction', :image => 'https://images.gr-assets.com/authors/1564399522p5/656983.jpg', :wiki => 'https://en.wikipedia.org/wiki/J._R._R._Tolkien') +Author.create(:name => 'J. K. Rowling', :nationality => 'British', :dob => '1965-07-31', :genre => 'non-fiction', :image => 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSCOOqg_zUm5pAi_ZIbuZu198okQLeuoDaEblNd5AIlvqgkX9QZ&usqp=CAU', :wiki => 'https://en.wikipedia.org/wiki/J._K._Rowling') +Author.create(:name => 'Patrick Rothfuss', :nationality => 'American', :dob => '1973-06-06', :genre => 'Fantasy', :image => 'https://upload.wikimedia.org/wikipedia/commons/7/7f/Patrick-rothfuss-2014-kyle-cassidy.jpg', :wiki => 'https://en.wikipedia.org/wiki/Patrick_Rothfuss') + +puts "#{ Author.count } authors created." + + +Book.destroy_all + +Book.create(:title => 'The Hobbit', :year => '1937', :publisher => 'Harper Collins', :image => 'https://m.media-amazon.com/images/I/5187PQgDScL.jpg', :bio => "The Hobbit, or There and Back Again is a children's fantasy novel by English author J. R. R. Tolkien. ... The Hobbit is set within Tolkien's fictional universe and follows the quest of home-loving Bilbo Baggins, the titular hobbit, to win a share of the treasure guarded by Smaug the dragon.") +Book.create(:title => 'Harry Potter', :year => '1999', :publisher => 'Bloomsbury Publishing', :image => 'https://upload.wikimedia.org/wikipedia/en/thumb/6/6b/Harry_Potter_and_the_Philosopher%27s_Stone_Book_Cover.jpg/220px-Harry_Potter_and_the_Philosopher%27s_Stone_Book_Cover.jpg', :bio => "The first novel in the Harry Potter series and Rowling's debut novel, it follows Harry Potter, a young wizard who discovers his magical heritage on his eleventh birthday, when he receives a letter of acceptance to Hogwarts School of Witchcraft and Wizardry.") +Book.create(:title => 'The Name of the Wind', :year => '2007', :publisher => 'DAW books', :image => 'https://upload.wikimedia.org/wikipedia/en/5/56/TheNameoftheWind_cover.jpg', :bio => "The Name of the Wind, also called The Kingkiller Chronicle: Day One, is a heroic fantasy novel written by American author Patrick Rothfuss. It is the first book in the ongoing fantasy trilogy The Kingkiller Chronicle, followed by The Wise Man's Fear. It was published on March 27, 2007 by DAW Books.") + +puts "#{Book.count} books created." diff --git a/alex_maunder/week_05/library/db/test.sqlite3 b/alex_maunder/week_05/library/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/library/lib/assets/.keep b/alex_maunder/week_05/library/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/library/lib/tasks/.keep b/alex_maunder/week_05/library/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/library/package.json b/alex_maunder/week_05/library/package.json new file mode 100644 index 0000000..7562efd --- /dev/null +++ b/alex_maunder/week_05/library/package.json @@ -0,0 +1,5 @@ +{ + "name": "library", + "private": true, + "dependencies": {} +} diff --git a/alex_maunder/week_05/library/public/404.html b/alex_maunder/week_05/library/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/alex_maunder/week_05/library/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/alex_maunder/week_05/library/public/422.html b/alex_maunder/week_05/library/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/alex_maunder/week_05/library/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/alex_maunder/week_05/library/public/500.html b/alex_maunder/week_05/library/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/alex_maunder/week_05/library/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/alex_maunder/week_05/library/public/apple-touch-icon-precomposed.png b/alex_maunder/week_05/library/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/library/public/apple-touch-icon.png b/alex_maunder/week_05/library/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/library/public/favicon.ico b/alex_maunder/week_05/library/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/alex_maunder/week_05/library/public/robots.txt b/alex_maunder/week_05/library/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/alex_maunder/week_05/library/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/alex_maunder/week_05/library/vendor/.keep b/alex_maunder/week_05/library/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week-07/google_books/.vscode/settings.json b/behdad_setoodegan/week-07/google_books/.vscode/settings.json new file mode 100644 index 0000000..3b66410 --- /dev/null +++ b/behdad_setoodegan/week-07/google_books/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "git.ignoreLimitWarning": true +} \ No newline at end of file diff --git a/behdad_setoodegan/week-07/google_books/index.html b/behdad_setoodegan/week-07/google_books/index.html new file mode 100644 index 0000000..36a9246 --- /dev/null +++ b/behdad_setoodegan/week-07/google_books/index.html @@ -0,0 +1,15 @@ + + + + + + Google Books Ajax + + +

Google Books

+

Pleas enter the book name:

+ + +

+ + \ No newline at end of file diff --git a/behdad_setoodegan/week-07/google_books/js/gBooks.js b/behdad_setoodegan/week-07/google_books/js/gBooks.js new file mode 100644 index 0000000..54f3caf --- /dev/null +++ b/behdad_setoodegan/week-07/google_books/js/gBooks.js @@ -0,0 +1,26 @@ +const xhr = new XMLHttpRequest(); + +const fetchFact = function(){ + + title = document.getElementById("bookName").value; + xhr.onreadystatechange = function(){ + if(this.readyState != 4) return; + + const img = document.createElement('img') + const data = JSON.parse(this.responseText) + imageLink = data["items"][0]["volumeInfo"]["imageLinks"]["thumbnail"] + img.src = imageLink + document.body.appendChild(img) + } + + + xhr.open('GET', `https://www.googleapis.com/books/v1/volumes?q=title:${title}`, true); + xhr.send(); +} + +document.getElementById('searchBox').addEventListener('click', fetchFact) + + + + + \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/.ruby-version b/behdad_setoodegan/week_05/Books/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/.vscode/settings.json b/behdad_setoodegan/week_05/Books/.vscode/settings.json new file mode 100644 index 0000000..3b66410 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "git.ignoreLimitWarning": true +} \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/Gemfile b/behdad_setoodegan/week_05/Books/Gemfile new file mode 100644 index 0000000..e3e01dc --- /dev/null +++ b/behdad_setoodegan/week_05/Books/Gemfile @@ -0,0 +1,56 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/behdad_setoodegan/week_05/Books/Gemfile.lock b/behdad_setoodegan/week_05/Books/Gemfile.lock new file mode 100644 index 0000000..b99a956 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/Gemfile.lock @@ -0,0 +1,195 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.6.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/behdad_setoodegan/week_05/Books/README.md b/behdad_setoodegan/week_05/Books/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/behdad_setoodegan/week_05/Books/Rakefile b/behdad_setoodegan/week_05/Books/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/behdad_setoodegan/week_05/Books/app/assets/config/manifest.js b/behdad_setoodegan/week_05/Books/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/behdad_setoodegan/week_05/Books/app/assets/images/.keep b/behdad_setoodegan/week_05/Books/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/app/assets/javascripts/application.js b/behdad_setoodegan/week_05/Books/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/behdad_setoodegan/week_05/Books/app/assets/javascripts/authors.coffee b/behdad_setoodegan/week_05/Books/app/assets/javascripts/authors.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/assets/javascripts/authors.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/behdad_setoodegan/week_05/Books/app/assets/javascripts/books.coffee b/behdad_setoodegan/week_05/Books/app/assets/javascripts/books.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/assets/javascripts/books.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/behdad_setoodegan/week_05/Books/app/assets/javascripts/cable.js b/behdad_setoodegan/week_05/Books/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/behdad_setoodegan/week_05/Books/app/assets/javascripts/channels/.keep b/behdad_setoodegan/week_05/Books/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/app/assets/stylesheets/application.css b/behdad_setoodegan/week_05/Books/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/behdad_setoodegan/week_05/Books/app/assets/stylesheets/authors.scss b/behdad_setoodegan/week_05/Books/app/assets/stylesheets/authors.scss new file mode 100644 index 0000000..c02b279 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/assets/stylesheets/authors.scss @@ -0,0 +1,12 @@ +body{ + background-color: #ccd; + +} + +.thumb{ + height: 12em; +} + +.feature{ + max-height: 30em; +} \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/assets/stylesheets/books.scss b/behdad_setoodegan/week_05/Books/app/assets/stylesheets/books.scss new file mode 100644 index 0000000..9fab565 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/assets/stylesheets/books.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Books controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/behdad_setoodegan/week_05/Books/app/channels/application_cable/channel.rb b/behdad_setoodegan/week_05/Books/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/behdad_setoodegan/week_05/Books/app/channels/application_cable/connection.rb b/behdad_setoodegan/week_05/Books/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/behdad_setoodegan/week_05/Books/app/controllers/application_controller.rb b/behdad_setoodegan/week_05/Books/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/behdad_setoodegan/week_05/Books/app/controllers/authors_controller.rb b/behdad_setoodegan/week_05/Books/app/controllers/authors_controller.rb new file mode 100644 index 0000000..c071577 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/controllers/authors_controller.rb @@ -0,0 +1,39 @@ +class AuthorsController < ApplicationController + def index + @authors = Author.all + end + + def new + @author = Author.new + end + + def create + author = Author.create author_params + redirect_to author + end + + def edit + @author = Author.find params[:id] + end + + def update + author = Author.find params[:id] + author.update author_params + redirect_to author + end + + def show + @author = Author.find params[:id] + end + + def destroy + author = Author.find params[:id] + author.destroy + redirect_to authors_path + end + + private + def author_params + params.require(:author).permit(:name, :nationality, :dob, :image) + end +end \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/controllers/books_controller.rb b/behdad_setoodegan/week_05/Books/app/controllers/books_controller.rb new file mode 100644 index 0000000..fb2bcde --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/controllers/books_controller.rb @@ -0,0 +1,38 @@ +class BooksController < ApplicationController + def index + @books = Book.all + end + + def new + @book = Book.new + end + + def create + book = Book.create book_params + redirect_to book + end + + def edit + @book = Book.find params[:id] + end + + def update + book = Book.find params[:id] + book.update book_params + redirect_to book + end + + def destroy + book = Book.find params[:id] + book.destroy + redirect_to books_path + end + + def show + @book = Book.find params[:id] + end + private + def book_params + params.require(:book).permit(:title, :year, :image, :author_id) + end +end diff --git a/behdad_setoodegan/week_05/Books/app/controllers/concerns/.keep b/behdad_setoodegan/week_05/Books/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/app/helpers/application_helper.rb b/behdad_setoodegan/week_05/Books/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/behdad_setoodegan/week_05/Books/app/helpers/authors_helper.rb b/behdad_setoodegan/week_05/Books/app/helpers/authors_helper.rb new file mode 100644 index 0000000..f22e1f9 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/helpers/authors_helper.rb @@ -0,0 +1,2 @@ +module AuthorsHelper +end diff --git a/behdad_setoodegan/week_05/Books/app/helpers/books_helper.rb b/behdad_setoodegan/week_05/Books/app/helpers/books_helper.rb new file mode 100644 index 0000000..4b9311e --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/helpers/books_helper.rb @@ -0,0 +1,2 @@ +module BooksHelper +end diff --git a/behdad_setoodegan/week_05/Books/app/jobs/application_job.rb b/behdad_setoodegan/week_05/Books/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/behdad_setoodegan/week_05/Books/app/mailers/application_mailer.rb b/behdad_setoodegan/week_05/Books/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/behdad_setoodegan/week_05/Books/app/models/application_record.rb b/behdad_setoodegan/week_05/Books/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/behdad_setoodegan/week_05/Books/app/models/author.rb b/behdad_setoodegan/week_05/Books/app/models/author.rb new file mode 100644 index 0000000..80d7ad5 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/models/author.rb @@ -0,0 +1,3 @@ +class Author < ActiveRecord::Base + has_many :books +end \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/models/book.rb b/behdad_setoodegan/week_05/Books/app/models/book.rb new file mode 100644 index 0000000..8791171 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/models/book.rb @@ -0,0 +1,3 @@ +class Book < ActiveRecord::Base + belongs_to :author, :optional => true +end \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/models/concerns/.keep b/behdad_setoodegan/week_05/Books/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/app/views/authors/_form.html.erb b/behdad_setoodegan/week_05/Books/app/views/authors/_form.html.erb new file mode 100644 index 0000000..b01f4cc --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/authors/_form.html.erb @@ -0,0 +1,18 @@ + +<%= form_for @author do |f| %> + <%= f.label :name %> + <%= f.text_field :name, :required => true, :autofocus => true %> + + <%= f.label :nationality %> + <%= f.text_field :nationality %> + + <%= f.label :dob, 'Date of birth' %> + <%= f.text_field :dob, :placeholder => 'YYYY-MM-DD' %> + + <%= f.label :image %> + <%= f.text_field :image %> + + + <%= f.submit %> + +<% end %> diff --git a/behdad_setoodegan/week_05/Books/app/views/authors/edit.html.erb b/behdad_setoodegan/week_05/Books/app/views/authors/edit.html.erb new file mode 100644 index 0000000..ce36782 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/authors/edit.html.erb @@ -0,0 +1,2 @@ +

Edit Author

+<%= render :partial => 'form' %> \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/views/authors/index.html.erb b/behdad_setoodegan/week_05/Books/app/views/authors/index.html.erb new file mode 100644 index 0000000..0287863 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/authors/index.html.erb @@ -0,0 +1,10 @@ +

All Authors

+ +<% @authors.each do |author|%> + <%= image_tag author.image, :class => 'thumb' if author.image.present? %> + +<% end %> \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/views/authors/new.html.erb b/behdad_setoodegan/week_05/Books/app/views/authors/new.html.erb new file mode 100644 index 0000000..4a47c0e --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/authors/new.html.erb @@ -0,0 +1,3 @@ +

New Author

+ +<%= render :partial => 'form' %> diff --git a/behdad_setoodegan/week_05/Books/app/views/authors/show.html.erb b/behdad_setoodegan/week_05/Books/app/views/authors/show.html.erb new file mode 100644 index 0000000..b8dbf2a --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/authors/show.html.erb @@ -0,0 +1,17 @@ +

<%= @author.name %>

+ +<%= image_tag @author.image, :class => 'feature' if @author.image.present? %> + + +<% @author.books.each do |book| %> + <%= link_to image_tag(book.image, :class => 'thumb'), book %> +<% end %> + +
+<%= link_to 'Edit author', edit_author_path(@author)%> +<%= link_to 'Delete Author', @author, :method => 'delete' %> +
\ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/views/books/_form.html.erb b/behdad_setoodegan/week_05/Books/app/views/books/_form.html.erb new file mode 100644 index 0000000..412508f --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/books/_form.html.erb @@ -0,0 +1,15 @@ +<%= form_for @book do |f| %> + <%= f.label :title %> + <%= f.text_field :title, :required => true, :autofocus => true %> + + <%= f.label :year %> + <%= f.text_field :year %> + + <%= f.label :image %> + <%= f.text_field :image, :required => true %> + <%= f.label :author_id %> + <%= f.select :author_id, Author.pluck(:name, :id), :include_blank => true %> + + <%= f.submit %> + +<% end %> \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/views/books/edit.html.erb b/behdad_setoodegan/week_05/Books/app/views/books/edit.html.erb new file mode 100644 index 0000000..933407d --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/books/edit.html.erb @@ -0,0 +1,2 @@ +

Edit book

+<%= render :partial => 'form'%> \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/views/books/index.html.erb b/behdad_setoodegan/week_05/Books/app/views/books/index.html.erb new file mode 100644 index 0000000..64c85aa --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/books/index.html.erb @@ -0,0 +1,4 @@ +

All books

+<% @books.each do |book| %> + <%= link_to image_tag(book.image, :class=> 'thumb', :alt =>book.title), book %> +<% end %> \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/views/books/new.html.erb b/behdad_setoodegan/week_05/Books/app/views/books/new.html.erb new file mode 100644 index 0000000..18e59bf --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/books/new.html.erb @@ -0,0 +1,2 @@ +

New Book

+<%= render :partial => 'form' %> \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/views/books/show.html.erb b/behdad_setoodegan/week_05/Books/app/views/books/show.html.erb new file mode 100644 index 0000000..3c88331 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/books/show.html.erb @@ -0,0 +1,18 @@ +

<%= @book.title%>

+<%= image_tag @book.image, :class => 'feature', :alt => @book.title%> + + + + + +
+ <%= link_to 'Edit book', edit_book_path(@book) %> + <%= link_to 'Delete book', @book, :method => 'delete' %> +
\ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/app/views/layouts/application.html.erb b/behdad_setoodegan/week_05/Books/app/views/layouts/application.html.erb new file mode 100644 index 0000000..10d07e8 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/layouts/application.html.erb @@ -0,0 +1,23 @@ + + + + Books + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + + <%= yield %> + + diff --git a/behdad_setoodegan/week_05/Books/app/views/layouts/mailer.html.erb b/behdad_setoodegan/week_05/Books/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/behdad_setoodegan/week_05/Books/app/views/layouts/mailer.text.erb b/behdad_setoodegan/week_05/Books/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/behdad_setoodegan/week_05/Books/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/behdad_setoodegan/week_05/Books/bin/bundle b/behdad_setoodegan/week_05/Books/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/behdad_setoodegan/week_05/Books/bin/rails b/behdad_setoodegan/week_05/Books/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/behdad_setoodegan/week_05/Books/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/behdad_setoodegan/week_05/Books/bin/rake b/behdad_setoodegan/week_05/Books/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/behdad_setoodegan/week_05/Books/bin/setup b/behdad_setoodegan/week_05/Books/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/behdad_setoodegan/week_05/Books/bin/spring b/behdad_setoodegan/week_05/Books/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/behdad_setoodegan/week_05/Books/bin/update b/behdad_setoodegan/week_05/Books/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/behdad_setoodegan/week_05/Books/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/behdad_setoodegan/week_05/Books/bin/yarn b/behdad_setoodegan/week_05/Books/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/behdad_setoodegan/week_05/Books/config.ru b/behdad_setoodegan/week_05/Books/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/behdad_setoodegan/week_05/Books/config/application.rb b/behdad_setoodegan/week_05/Books/config/application.rb new file mode 100644 index 0000000..bee19ce --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Books + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/behdad_setoodegan/week_05/Books/config/boot.rb b/behdad_setoodegan/week_05/Books/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/behdad_setoodegan/week_05/Books/config/cable.yml b/behdad_setoodegan/week_05/Books/config/cable.yml new file mode 100644 index 0000000..c2887b3 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: Books_production diff --git a/behdad_setoodegan/week_05/Books/config/credentials.yml.enc b/behdad_setoodegan/week_05/Books/config/credentials.yml.enc new file mode 100644 index 0000000..1eb8aee --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/credentials.yml.enc @@ -0,0 +1 @@ +wUjrM4pN5feBxSDczt/sWu57fv6uJS2RWKy0L4U5oHROBt6YlYCDKgHmklMu/H2QuPvyq0xAgExW8uOzg7GdLT9zDw5qIstxkoOJ2P4NGvE8nMxQNX6FG6iB9+X9xC2Kzy4RK2wAuD7OTUVBP0sd8OnGF0nWFXzLM2Z5TBTUfRA6t12TgJKGkcqVIiNmZ2cFQmIiQ/qCCj7jI8O8aEjC/gdNKAUpON0zicNVakuHVgBDxO4x9GBt5mbQYAnj7ms/vY5PbzzNMIOhnbpCtI5HaLru7plMnbLVs0CsNpM7bd3oWgEKV1xQslZBNAmrpzdG5jHNN1JORMLjRYykk4RDB4zpraKG6OyURLMgyjq3qGErXDRPhQTD1M8kThlg/FbhrT+537t0lHjTDmEHRExpgLwPW3XFJhVdUj4T--WDMU+7i1Q0Hvz33y--znWuSUBn7AQitxK2xYNejg== \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/config/database.yml b/behdad_setoodegan/week_05/Books/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/behdad_setoodegan/week_05/Books/config/environment.rb b/behdad_setoodegan/week_05/Books/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/behdad_setoodegan/week_05/Books/config/environments/development.rb b/behdad_setoodegan/week_05/Books/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/behdad_setoodegan/week_05/Books/config/environments/production.rb b/behdad_setoodegan/week_05/Books/config/environments/production.rb new file mode 100644 index 0000000..3d38a1d --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "Books_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/behdad_setoodegan/week_05/Books/config/environments/test.rb b/behdad_setoodegan/week_05/Books/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/behdad_setoodegan/week_05/Books/config/initializers/application_controller_renderer.rb b/behdad_setoodegan/week_05/Books/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/behdad_setoodegan/week_05/Books/config/initializers/assets.rb b/behdad_setoodegan/week_05/Books/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/behdad_setoodegan/week_05/Books/config/initializers/backtrace_silencers.rb b/behdad_setoodegan/week_05/Books/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/behdad_setoodegan/week_05/Books/config/initializers/content_security_policy.rb b/behdad_setoodegan/week_05/Books/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/behdad_setoodegan/week_05/Books/config/initializers/cookies_serializer.rb b/behdad_setoodegan/week_05/Books/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/behdad_setoodegan/week_05/Books/config/initializers/filter_parameter_logging.rb b/behdad_setoodegan/week_05/Books/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/behdad_setoodegan/week_05/Books/config/initializers/inflections.rb b/behdad_setoodegan/week_05/Books/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/behdad_setoodegan/week_05/Books/config/initializers/mime_types.rb b/behdad_setoodegan/week_05/Books/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/behdad_setoodegan/week_05/Books/config/initializers/wrap_parameters.rb b/behdad_setoodegan/week_05/Books/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/behdad_setoodegan/week_05/Books/config/locales/en.yml b/behdad_setoodegan/week_05/Books/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/behdad_setoodegan/week_05/Books/config/master.key b/behdad_setoodegan/week_05/Books/config/master.key new file mode 100644 index 0000000..0784218 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/master.key @@ -0,0 +1 @@ +6a0d0aba18ac2ca43bb28fa39aca4f43 \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/config/puma.rb b/behdad_setoodegan/week_05/Books/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/behdad_setoodegan/week_05/Books/config/routes.rb b/behdad_setoodegan/week_05/Books/config/routes.rb new file mode 100644 index 0000000..bc5f9c4 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + resources :authors + resources :books +end diff --git a/behdad_setoodegan/week_05/Books/config/spring.rb b/behdad_setoodegan/week_05/Books/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/behdad_setoodegan/week_05/Books/config/storage.yml b/behdad_setoodegan/week_05/Books/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/behdad_setoodegan/week_05/Books/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/behdad_setoodegan/week_05/Books/db/development.sqlite3 b/behdad_setoodegan/week_05/Books/db/development.sqlite3 new file mode 100644 index 0000000..b89784a Binary files /dev/null and b/behdad_setoodegan/week_05/Books/db/development.sqlite3 differ diff --git a/behdad_setoodegan/week_05/Books/db/migrate/20200617115953_create_authors.rb b/behdad_setoodegan/week_05/Books/db/migrate/20200617115953_create_authors.rb new file mode 100644 index 0000000..5e5ec23 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/db/migrate/20200617115953_create_authors.rb @@ -0,0 +1,10 @@ +class CreateAuthors < ActiveRecord::Migration[5.2] + def change + create_table :authors do |t| + t.text "name" + t.text "nationality" + t.date "dob" + t.text "image" + end + end +end diff --git a/behdad_setoodegan/week_05/Books/db/migrate/20200617124925_create_books.rb b/behdad_setoodegan/week_05/Books/db/migrate/20200617124925_create_books.rb new file mode 100644 index 0000000..5964e0b --- /dev/null +++ b/behdad_setoodegan/week_05/Books/db/migrate/20200617124925_create_books.rb @@ -0,0 +1,9 @@ +class CreateBooks < ActiveRecord::Migration[5.2] + def change + create_table :books do |t| + t.text :title + t.text :year + t.text :image + end + end +end diff --git a/behdad_setoodegan/week_05/Books/db/migrate/20200617133432_add_author_id_to_books.rb b/behdad_setoodegan/week_05/Books/db/migrate/20200617133432_add_author_id_to_books.rb new file mode 100644 index 0000000..320cd7c --- /dev/null +++ b/behdad_setoodegan/week_05/Books/db/migrate/20200617133432_add_author_id_to_books.rb @@ -0,0 +1,5 @@ +class AddAuthorIdToBooks < ActiveRecord::Migration[5.2] + def change + add_column :books, :author_id, :integer + end +end diff --git a/behdad_setoodegan/week_05/Books/db/schema.rb b/behdad_setoodegan/week_05/Books/db/schema.rb new file mode 100644 index 0000000..38d6414 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/db/schema.rb @@ -0,0 +1,29 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_17_133432) do + + create_table "authors", force: :cascade do |t| + t.text "name" + t.text "nationality" + t.date "dob" + t.text "image" + end + + create_table "books", force: :cascade do |t| + t.text "title" + t.text "year" + t.text "image" + t.integer "author_id" + end + +end diff --git a/behdad_setoodegan/week_05/Books/db/seeds.rb b/behdad_setoodegan/week_05/Books/db/seeds.rb new file mode 100644 index 0000000..8e660fe --- /dev/null +++ b/behdad_setoodegan/week_05/Books/db/seeds.rb @@ -0,0 +1,19 @@ +Author.destroy_all +Author.create(:name => 'Norman Lindsay', :nationality => 'Australian', :dob => '1879-02-22', :image => 'https://upload.wikimedia.org/wikipedia/commons/3/32/Norman_Lindsay_1931.jpg') +Author.create(:name => 'Russell Drysdale', :nationality => 'Australian', :dob => '1912-02-07', :image => 'https://upload.wikimedia.org/wikipedia/commons/c/ca/Russell_Drysdale_Max_Dupain_1945.jpg') +Author.create(:name => 'James Gleeson', :nationality => 'Australian', :dob => '1915-11-21', :image => 'https://media.artgallery.nsw.gov.au/uploads/artists/James_Gleeson_nla.jpg') +Author.create(:name => 'Sidney Nolan', :nationality => 'Australian', :dob => '1917-04-22', :image => 'https://upload.wikimedia.org/wikipedia/commons/e/ef/Portrait_of_Sidney_Nolan.jpg') +Author.create(:name => 'Arthur Boyd', :nationality => 'Australian', :dob => '1920-07-24', :image => 'https://upload.wikimedia.org/wikipedia/en/9/98/Arthur_Boyd.jpg') +Author.create(:name => 'Jeffrey Smart', :nationality => 'Australian', :dob => '1921-07-26', :image => 'https://upload.wikimedia.org/wikipedia/en/b/b0/Australian_artist_Jeffrey_Smart.jpg') +Author.create(:name => 'Brett Whiteley', :nationality => 'Australian', :dob => '1939-04-07', :image => 'https://www.portrait.gov.au/files/b/9/4/f/i9331.jpg') +puts "#{ Author.count } authors created." + +Book.destroy_all +Book.create(:title => 'Thieves Kitchen', :year => '1929', :image => 'https://content.ngv.vic.gov.au/retrieve.php?size=1280&type=image&vernonID=29145') +Book.create(:title => 'The Rabbiters', :year => '1947', :image => 'https://content.ngv.vic.gov.au/retrieve.php?size=1280&type=image&vernonID=5520') +Book.create(:title => 'The Darkening Stage', :year => '1991', :image => 'https://content.ngv.vic.gov.au/col-images/api/EPUB001055/1280') +Book.create(:title => 'Carcass', :year => '1953', :image => 'https://content.ngv.vic.gov.au/retrieve.php?size=1280&type=image&vernonID=57510') +Book.create(:title => 'Bride Running Away', :year => '1957', :image => 'http://www.abc.net.au/news/image/4197918-3x2-940x627.jpg') +Book.create(:title => 'Portrait of Clive James', :year => '1991 - 1992', :image => 'https://media.artgallery.nsw.gov.au/thumbnails/collection_images/2/276.1992%23%23S.jpg.505x464_q85.jpg') +Book.create(:title => 'The Naked Studio', :year => '1981', :image => 'https://mona.net.au//media/37522/brett-whiteley-the-naked-studio-mona-01.jpg') +puts "#{ Book.count } books created." \ No newline at end of file diff --git a/behdad_setoodegan/week_05/Books/db/test.sqlite3 b/behdad_setoodegan/week_05/Books/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/lib/assets/.keep b/behdad_setoodegan/week_05/Books/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/lib/tasks/.keep b/behdad_setoodegan/week_05/Books/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/package.json b/behdad_setoodegan/week_05/Books/package.json new file mode 100644 index 0000000..ca49f92 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/package.json @@ -0,0 +1,5 @@ +{ + "name": "Books", + "private": true, + "dependencies": {} +} diff --git a/behdad_setoodegan/week_05/Books/public/404.html b/behdad_setoodegan/week_05/Books/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/behdad_setoodegan/week_05/Books/public/422.html b/behdad_setoodegan/week_05/Books/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/behdad_setoodegan/week_05/Books/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/behdad_setoodegan/week_05/Books/public/500.html b/behdad_setoodegan/week_05/Books/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/behdad_setoodegan/week_05/Books/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/behdad_setoodegan/week_05/Books/public/apple-touch-icon-precomposed.png b/behdad_setoodegan/week_05/Books/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/public/apple-touch-icon.png b/behdad_setoodegan/week_05/Books/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/public/favicon.ico b/behdad_setoodegan/week_05/Books/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/public/robots.txt b/behdad_setoodegan/week_05/Books/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/behdad_setoodegan/week_05/Books/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/behdad_setoodegan/week_05/Books/storage/.keep b/behdad_setoodegan/week_05/Books/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Books/vendor/.keep b/behdad_setoodegan/week_05/Books/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/Magic_8_Ball/magicballs/Gemfile.lock b/behdad_setoodegan/week_05/Magic_8_Ball/magicballs/Gemfile.lock index 9a3cb4f..473a7c0 100644 --- a/behdad_setoodegan/week_05/Magic_8_Ball/magicballs/Gemfile.lock +++ b/behdad_setoodegan/week_05/Magic_8_Ball/magicballs/Gemfile.lock @@ -105,7 +105,7 @@ GEM mini_portile2 (~> 2.4.0) public_suffix (4.0.5) puma (3.12.6) - rack (2.2.2) + rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.2.4.3) diff --git a/behdad_setoodegan/week_05/cats/.ruby-version b/behdad_setoodegan/week_05/cats/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/behdad_setoodegan/week_05/cats/Gemfile b/behdad_setoodegan/week_05/cats/Gemfile new file mode 100644 index 0000000..885be62 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/Gemfile @@ -0,0 +1,56 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/behdad_setoodegan/week_05/cats/Gemfile.lock b/behdad_setoodegan/week_05/cats/Gemfile.lock new file mode 100644 index 0000000..a266a3b --- /dev/null +++ b/behdad_setoodegan/week_05/cats/Gemfile.lock @@ -0,0 +1,195 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/behdad_setoodegan/week_05/cats/README.md b/behdad_setoodegan/week_05/cats/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/behdad_setoodegan/week_05/cats/Rakefile b/behdad_setoodegan/week_05/cats/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/behdad_setoodegan/week_05/cats/app/assets/config/manifest.js b/behdad_setoodegan/week_05/cats/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/behdad_setoodegan/week_05/cats/app/assets/images/.keep b/behdad_setoodegan/week_05/cats/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/app/assets/javascripts/application.js b/behdad_setoodegan/week_05/cats/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/behdad_setoodegan/week_05/cats/app/assets/javascripts/cable.js b/behdad_setoodegan/week_05/cats/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/behdad_setoodegan/week_05/cats/app/assets/javascripts/channels/.keep b/behdad_setoodegan/week_05/cats/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/app/assets/stylesheets/application.css b/behdad_setoodegan/week_05/cats/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/behdad_setoodegan/week_05/cats/app/channels/application_cable/channel.rb b/behdad_setoodegan/week_05/cats/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/behdad_setoodegan/week_05/cats/app/channels/application_cable/connection.rb b/behdad_setoodegan/week_05/cats/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/behdad_setoodegan/week_05/cats/app/controllers/application_controller.rb b/behdad_setoodegan/week_05/cats/app/controllers/application_controller.rb new file mode 100644 index 0000000..a01946b --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + skip_before_action :verify_authenticity_token +end diff --git a/behdad_setoodegan/week_05/cats/app/controllers/cats_controller.rb b/behdad_setoodegan/week_05/cats/app/controllers/cats_controller.rb new file mode 100644 index 0000000..90b654c --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/controllers/cats_controller.rb @@ -0,0 +1,36 @@ +class CatsController < ApplicationController + def index + @cats = Cat.all + end + + def show + @cat = Cat.find params[:id] + end + + def new + end + + def create + cat = Cat.create :name => params[:name], :image => params[:image], :age => params[:age] + redirect_to cats_path(cat.id) + end + + def edit + @cat = Cat.find params[:id] + end + + def update + cat =Cat.find params[:id] + cat.name = params[:name] + cat.image = params[:image] + cat.age = params[:age] + cat.save + redirect_to cats_path(cat.id) + end + + def destroy + cat = Cat.find params[:id] + cat.destroy + redirect_to cats_path + end +end \ No newline at end of file diff --git a/behdad_setoodegan/week_05/cats/app/controllers/concerns/.keep b/behdad_setoodegan/week_05/cats/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/app/helpers/application_helper.rb b/behdad_setoodegan/week_05/cats/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/behdad_setoodegan/week_05/cats/app/jobs/application_job.rb b/behdad_setoodegan/week_05/cats/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/behdad_setoodegan/week_05/cats/app/mailers/application_mailer.rb b/behdad_setoodegan/week_05/cats/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/behdad_setoodegan/week_05/cats/app/models/application_record.rb b/behdad_setoodegan/week_05/cats/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/behdad_setoodegan/week_05/cats/app/models/cat.rb b/behdad_setoodegan/week_05/cats/app/models/cat.rb new file mode 100644 index 0000000..48740cb --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/models/cat.rb @@ -0,0 +1,2 @@ +class Cat < ActiveRecord::Base +end \ No newline at end of file diff --git a/behdad_setoodegan/week_05/cats/app/models/concerns/.keep b/behdad_setoodegan/week_05/cats/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/app/views/cats/edit.html.erb b/behdad_setoodegan/week_05/cats/app/views/cats/edit.html.erb new file mode 100644 index 0000000..c8bdcc5 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/views/cats/edit.html.erb @@ -0,0 +1,19 @@ +

Edit Cat

+ +
+ + Name: + + + + Image: + + + + Age: + + + + + +
diff --git a/behdad_setoodegan/week_05/cats/app/views/cats/index.html.erb b/behdad_setoodegan/week_05/cats/app/views/cats/index.html.erb new file mode 100644 index 0000000..55200ab --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/views/cats/index.html.erb @@ -0,0 +1,12 @@ +

All cats

+ +<% @cats.each do |cat|%> +

+ <%= link_to cat.name, cat_path(cat.id)%> + is + <%= pluralize (cat.age).to_i, 'year'%> + old. + +

+ +<% end %> \ No newline at end of file diff --git a/behdad_setoodegan/week_05/cats/app/views/cats/new.html.erb b/behdad_setoodegan/week_05/cats/app/views/cats/new.html.erb new file mode 100644 index 0000000..df0a7c5 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/views/cats/new.html.erb @@ -0,0 +1,19 @@ +

New Cat

+ +
+ + Name: + + + + Image: + + + + Age: + + + + + +
diff --git a/behdad_setoodegan/week_05/cats/app/views/cats/show.html.erb b/behdad_setoodegan/week_05/cats/app/views/cats/show.html.erb new file mode 100644 index 0000000..abbd6dc --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/views/cats/show.html.erb @@ -0,0 +1,13 @@ +

<%= @cat.name%>

+ +<%= image_tag @cat.image, :class => 'feature' if @cat.image.present? %> + + + +
+<%= link_to 'Edit Cat', edit_cat_path(@cat.id) %> +<%= button_to 'Delete Cat', cat_path(@cat.id), :method => 'delete' %> +
\ No newline at end of file diff --git a/behdad_setoodegan/week_05/cats/app/views/layouts/application.html.erb b/behdad_setoodegan/week_05/cats/app/views/layouts/application.html.erb new file mode 100644 index 0000000..4fdef68 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/views/layouts/application.html.erb @@ -0,0 +1,21 @@ + + + + Cats + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + + + <%= yield %> + + diff --git a/behdad_setoodegan/week_05/cats/app/views/layouts/mailer.html.erb b/behdad_setoodegan/week_05/cats/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/behdad_setoodegan/week_05/cats/app/views/layouts/mailer.text.erb b/behdad_setoodegan/week_05/cats/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/behdad_setoodegan/week_05/cats/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/behdad_setoodegan/week_05/cats/bin/bundle b/behdad_setoodegan/week_05/cats/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/behdad_setoodegan/week_05/cats/bin/rails b/behdad_setoodegan/week_05/cats/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/behdad_setoodegan/week_05/cats/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/behdad_setoodegan/week_05/cats/bin/rake b/behdad_setoodegan/week_05/cats/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/behdad_setoodegan/week_05/cats/bin/setup b/behdad_setoodegan/week_05/cats/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/behdad_setoodegan/week_05/cats/bin/spring b/behdad_setoodegan/week_05/cats/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/behdad_setoodegan/week_05/cats/bin/update b/behdad_setoodegan/week_05/cats/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/behdad_setoodegan/week_05/cats/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/behdad_setoodegan/week_05/cats/bin/yarn b/behdad_setoodegan/week_05/cats/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/behdad_setoodegan/week_05/cats/config.ru b/behdad_setoodegan/week_05/cats/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/behdad_setoodegan/week_05/cats/config/application.rb b/behdad_setoodegan/week_05/cats/config/application.rb new file mode 100644 index 0000000..6e795c9 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Cats + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/behdad_setoodegan/week_05/cats/config/boot.rb b/behdad_setoodegan/week_05/cats/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/behdad_setoodegan/week_05/cats/config/cable.yml b/behdad_setoodegan/week_05/cats/config/cable.yml new file mode 100644 index 0000000..e53386f --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: cats_production diff --git a/behdad_setoodegan/week_05/cats/config/credentials.yml.enc b/behdad_setoodegan/week_05/cats/config/credentials.yml.enc new file mode 100644 index 0000000..7926054 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/credentials.yml.enc @@ -0,0 +1 @@ +hxjWwC+WtgWTm5qBYPiEA00PhDYOWYWds+IHqkfH3tnkfmLWilrhHYR967zNlL98ivX+mjxiF9JdwAWuABje8lGhUPcNY4WaamomXeXgdKpmtJ1kaOvmjlr99MLdr4USpH/vd4IFTxDGq/JMHNScESngItFzFy8LGr0n6c+y+LgsDKwUou3zJQDtUfXL3Vqo07r0DW51lA/TjW8Bd0gOlYLuA/ilAz0skfWhFI0XBBGWk4bxT5OupAPLxO9ppbSmYxYr22Q+91Em6snLEwmWguZDKyclTCddiZ0LRfuDSYLk+VKUL4rut4uZoSHcvM2LmRJ4//QoG0oxfOAUCw9zV2xGsMwDkeZUTnYOD+/4iEKMDfi1lARjmTj/OvJ3IFyzJ4jJY8UnAMi0KU1I1BEqITDy074zl5l2FQSJ--gFp46ys6sjrqDdHt--8aazN7xesvIP7YV3vZWAUQ== \ No newline at end of file diff --git a/behdad_setoodegan/week_05/cats/config/database.yml b/behdad_setoodegan/week_05/cats/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/behdad_setoodegan/week_05/cats/config/environment.rb b/behdad_setoodegan/week_05/cats/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/behdad_setoodegan/week_05/cats/config/environments/development.rb b/behdad_setoodegan/week_05/cats/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/behdad_setoodegan/week_05/cats/config/environments/production.rb b/behdad_setoodegan/week_05/cats/config/environments/production.rb new file mode 100644 index 0000000..d76d999 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "cats_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/behdad_setoodegan/week_05/cats/config/environments/test.rb b/behdad_setoodegan/week_05/cats/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/behdad_setoodegan/week_05/cats/config/initializers/application_controller_renderer.rb b/behdad_setoodegan/week_05/cats/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/behdad_setoodegan/week_05/cats/config/initializers/assets.rb b/behdad_setoodegan/week_05/cats/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/behdad_setoodegan/week_05/cats/config/initializers/backtrace_silencers.rb b/behdad_setoodegan/week_05/cats/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/behdad_setoodegan/week_05/cats/config/initializers/content_security_policy.rb b/behdad_setoodegan/week_05/cats/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/behdad_setoodegan/week_05/cats/config/initializers/cookies_serializer.rb b/behdad_setoodegan/week_05/cats/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/behdad_setoodegan/week_05/cats/config/initializers/filter_parameter_logging.rb b/behdad_setoodegan/week_05/cats/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/behdad_setoodegan/week_05/cats/config/initializers/inflections.rb b/behdad_setoodegan/week_05/cats/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/behdad_setoodegan/week_05/cats/config/initializers/mime_types.rb b/behdad_setoodegan/week_05/cats/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/behdad_setoodegan/week_05/cats/config/initializers/wrap_parameters.rb b/behdad_setoodegan/week_05/cats/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/behdad_setoodegan/week_05/cats/config/locales/en.yml b/behdad_setoodegan/week_05/cats/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/behdad_setoodegan/week_05/cats/config/master.key b/behdad_setoodegan/week_05/cats/config/master.key new file mode 100644 index 0000000..f4ce711 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/master.key @@ -0,0 +1 @@ +4e70b8bbec7e29bd9449282f9920f199 \ No newline at end of file diff --git a/behdad_setoodegan/week_05/cats/config/puma.rb b/behdad_setoodegan/week_05/cats/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/behdad_setoodegan/week_05/cats/config/routes.rb b/behdad_setoodegan/week_05/cats/config/routes.rb new file mode 100644 index 0000000..c36b528 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/routes.rb @@ -0,0 +1,9 @@ +Rails.application.routes.draw do + get '/cats' => 'cats#index' + get '/cats/new' => 'cats#new', :as => 'new_cat' + post '/cats' => 'cats#create' + get '/cats/:id' => 'cats#show', :as => 'cat' + get 'cats/:id/edit' => 'cats#edit', :as => 'edit_cat' + post '/cats/:id' => 'cats#update' + delete '/cats/:id' => 'cats#destroy' +end diff --git a/behdad_setoodegan/week_05/cats/config/spring.rb b/behdad_setoodegan/week_05/cats/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/behdad_setoodegan/week_05/cats/config/storage.yml b/behdad_setoodegan/week_05/cats/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/behdad_setoodegan/week_05/cats/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/behdad_setoodegan/week_05/cats/db/create_cats.sql b/behdad_setoodegan/week_05/cats/db/create_cats.sql new file mode 100644 index 0000000..67d36e0 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/db/create_cats.sql @@ -0,0 +1,7 @@ + +CREATE TABLE cats ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + image TEXT, + age FLOAT +); \ No newline at end of file diff --git a/behdad_setoodegan/week_05/cats/db/development.sqlite3 b/behdad_setoodegan/week_05/cats/db/development.sqlite3 new file mode 100644 index 0000000..0cf10b5 Binary files /dev/null and b/behdad_setoodegan/week_05/cats/db/development.sqlite3 differ diff --git a/behdad_setoodegan/week_05/cats/db/seeds.rb b/behdad_setoodegan/week_05/cats/db/seeds.rb new file mode 100644 index 0000000..f136e9a --- /dev/null +++ b/behdad_setoodegan/week_05/cats/db/seeds.rb @@ -0,0 +1,7 @@ +Cat.destroy_all + +Cat.create :name => 'kitty', :age => '3' +Cat.create :name => 'flufy', :age => '2' +Cat.create :name => 'missy', :age => '4' + +puts "#{ Cat.count} planets available." \ No newline at end of file diff --git a/behdad_setoodegan/week_05/cats/db/test.sqlite3 b/behdad_setoodegan/week_05/cats/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/lib/assets/.keep b/behdad_setoodegan/week_05/cats/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/lib/tasks/.keep b/behdad_setoodegan/week_05/cats/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/package.json b/behdad_setoodegan/week_05/cats/package.json new file mode 100644 index 0000000..51beb4d --- /dev/null +++ b/behdad_setoodegan/week_05/cats/package.json @@ -0,0 +1,5 @@ +{ + "name": "cats", + "private": true, + "dependencies": {} +} diff --git a/behdad_setoodegan/week_05/cats/public/404.html b/behdad_setoodegan/week_05/cats/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/behdad_setoodegan/week_05/cats/public/422.html b/behdad_setoodegan/week_05/cats/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/behdad_setoodegan/week_05/cats/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/behdad_setoodegan/week_05/cats/public/500.html b/behdad_setoodegan/week_05/cats/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/behdad_setoodegan/week_05/cats/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/behdad_setoodegan/week_05/cats/public/apple-touch-icon-precomposed.png b/behdad_setoodegan/week_05/cats/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/public/apple-touch-icon.png b/behdad_setoodegan/week_05/cats/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/public/favicon.ico b/behdad_setoodegan/week_05/cats/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/public/robots.txt b/behdad_setoodegan/week_05/cats/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/behdad_setoodegan/week_05/cats/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/behdad_setoodegan/week_05/cats/storage/.keep b/behdad_setoodegan/week_05/cats/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/behdad_setoodegan/week_05/cats/vendor/.keep b/behdad_setoodegan/week_05/cats/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/blake_davis/week_04/beers/beers.sql b/blake_davis/week_04/beers/beers.sql new file mode 100644 index 0000000..45aec6b --- /dev/null +++ b/blake_davis/week_04/beers/beers.sql @@ -0,0 +1,10 @@ +CREATE TABLE beers ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + family TEXT, + image TEXT +); + +-- seed data +INSERT INTO beers (name, family) VALUES ('Carlton Draught', 'Draught'); +INSERT INTO beers (name, family) VALUES ('Cricketers Arms', 'Lager'); diff --git a/blake_davis/week_04/beers/database.sqlite3 b/blake_davis/week_04/beers/database.sqlite3 new file mode 100644 index 0000000..7664f4b Binary files /dev/null and b/blake_davis/week_04/beers/database.sqlite3 differ diff --git a/blake_davis/week_04/beers/main.rb b/blake_davis/week_04/beers/main.rb new file mode 100644 index 0000000..069a34f --- /dev/null +++ b/blake_davis/week_04/beers/main.rb @@ -0,0 +1,71 @@ +require 'sinatra' +require 'sinatra/reloader' +require 'sqlite3' +require 'pry' + +get '/' do + erb :home +end + +# INDEX -- show all beers READ + +get '/beers' do + @beers = query_db 'SELECT * FROM beers' + erb :beers_index +end + +#NEW +get '/beers/new' do + erb :beers_new +end + +#CREATE add new beer to database + +post '/beers' do + #generate query + query = "INSERT INTO beers (name, family, image) VALUES ('#{ params[:name]}', '#{params[:family]}', '#{params[:image]}')" + #execute query + query_db query + #go back to INDEX + redirect to ('/beers') +end +#FUNCTION/METHOD +# SHOW = shows a single beer + +get '/beers/:id' do + @beer = query_db "SELECT * FROM beers WHERE id= #{params[:id]}" + @beer = @beer.first #extract beer from array + erb :beers_show +end + +#EDIT - shows the form to edit - READ # OP + +get '/beers/:id/edit' do + @beer = query_db "SELECT * FROM beers WHERE id=#{params[:id]}" #returns array + @beer = @beer.first #single beer + erb :beers_edit +end + +#UPDATE -- the database with new info +post '/beers/:id' do + query = "UPDATE beers SET name='#{params[:name]}', family='#{params[:family]}', image='#{params[:image]}' WHERE id=#{ params[:id]}" + query_db query + redirect to ("/beers/#{ params[:id]}") #GET +end + +#DELETE A SINGLE BEER + +get '/beers/:id/delete' do + query_db "DELETE FROM beers WHERE id = #{ params[:id]}" + redirect to ('/beers') +end +#FUNCTION/METHOD + +def query_db(sql_statement) + puts sql_statement #optional but nice for debuggging + db = SQLite3::Database.new 'database.sqlite3' + db.results_as_hash = true + results = db.execute sql_statement + db.close + results #implicit returned +end diff --git a/blake_davis/week_04/beers/public/css/beers.css b/blake_davis/week_04/beers/public/css/beers.css new file mode 100644 index 0000000..eeff8e6 --- /dev/null +++ b/blake_davis/week_04/beers/public/css/beers.css @@ -0,0 +1,27 @@ +body { + background-color: lavender; + +} + +.container { + max-width: 960px; + margin: 0 auto; +} + +nav { + text-align: right; +} + +nav a { + color: white; + text-decoration: none; + line-height: 10px; +} + +label { + display: block; +} + +.feature { + max-width: 100%; +} diff --git a/blake_davis/week_04/beers/views/beers_edit.erb b/blake_davis/week_04/beers/views/beers_edit.erb new file mode 100644 index 0000000..8016cf9 --- /dev/null +++ b/blake_davis/week_04/beers/views/beers_edit.erb @@ -0,0 +1,23 @@ +

Edit Beers

+ +
" method="post"> + + + + + + + + +
diff --git a/blake_davis/week_04/beers/views/beers_index.erb b/blake_davis/week_04/beers/views/beers_index.erb new file mode 100644 index 0000000..1e268c9 --- /dev/null +++ b/blake_davis/week_04/beers/views/beers_index.erb @@ -0,0 +1,12 @@ +

All Beers

+ +<% @beers.each do |beer| %> +

+ + "> + + <%= beer["name"] %> + + +

+<% end %> diff --git a/blake_davis/week_04/beers/views/beers_new.erb b/blake_davis/week_04/beers/views/beers_new.erb new file mode 100644 index 0000000..81aab3e --- /dev/null +++ b/blake_davis/week_04/beers/views/beers_new.erb @@ -0,0 +1,21 @@ +

New Beers

+ +
+ + + + + + + + +
diff --git a/blake_davis/week_04/beers/views/beers_show.erb b/blake_davis/week_04/beers/views/beers_show.erb new file mode 100644 index 0000000..6de1bfa --- /dev/null +++ b/blake_davis/week_04/beers/views/beers_show.erb @@ -0,0 +1,11 @@ +

<%= @beer["name"] %>

+

Family: <%= @beer["family"] %>

+ +<% unless @beer["image"].nil? || @beer["image"].empty? %> +" alt="<%= @beer["name"] %>"> +<% end %> + +
+ /edit">Edit This Beer! + delete"> Delete This Beer! +
diff --git a/blake_davis/week_04/beers/views/home.erb b/blake_davis/week_04/beers/views/home.erb new file mode 100644 index 0000000..d32e4b7 --- /dev/null +++ b/blake_davis/week_04/beers/views/home.erb @@ -0,0 +1,3 @@ +

Welcome to the wonderful book of beers

+ +

Here is your friendly beer catalogue, tailored by you, for you.

diff --git a/blake_davis/week_04/beers/views/layout.erb b/blake_davis/week_04/beers/views/layout.erb new file mode 100644 index 0000000..2ce2b80 --- /dev/null +++ b/blake_davis/week_04/beers/views/layout.erb @@ -0,0 +1,21 @@ + + + + + + + + + + + +
+ + <%= yield %> +
+ + diff --git a/blake_davis/week_07/index.html b/blake_davis/week_07/index.html new file mode 100644 index 0000000..e21ff23 --- /dev/null +++ b/blake_davis/week_07/index.html @@ -0,0 +1,16 @@ + + + + + + AJAX booksearch + + +
+

AJAX booksearch

+

+ + +
+ + diff --git a/blake_davis/week_07/js/getbook.js b/blake_davis/week_07/js/getbook.js new file mode 100644 index 0000000..f702b34 --- /dev/null +++ b/blake_davis/week_07/js/getbook.js @@ -0,0 +1,19 @@ +const fetchBook = function () { + const book = document.getElementById('searchRequest').value + const xhr = new XMLHttpRequest(); + xhr.open('GET', 'https://www.googleapis.com/books/v1/volumes?q=title:'+book); + xhr.send(); + xhr.onreadystatechange = function () { + if (xhr.readyState !== 4) return; + data = JSON.parse(xhr.responseText) + const title = document.createElement('p') + title.setAttribute("class", "title"); + title.innerText = data.items[0].volumeInfo.title + document.getElementById("container").appendChild(title); + const image = document.createElement('img') + image.setAttribute("class", "image"); + image.src = data.items[0].volumeInfo.imageLinks.smallThumbnail + document.getElementById("container").appendChild(image); + } +} +document.getElementById('fetch').addEventListener('click', fetchBook) diff --git a/blake_davis/week_07/styles.css b/blake_davis/week_07/styles.css new file mode 100644 index 0000000..4ec4ad8 --- /dev/null +++ b/blake_davis/week_07/styles.css @@ -0,0 +1,14 @@ +#container { + width: 500px; + margin: 0 auto; + text-align: center; +} +.title { + background-color: lightpink; + font-size: 22px; + margin-left: 25%; + margin-right: 25%; +} +.image { + height: 200px; +} diff --git a/cale_shanley/week_04/beer/beers.sql b/cale_shanley/week_04/beer/beers.sql new file mode 100644 index 0000000..9b52e85 --- /dev/null +++ b/cale_shanley/week_04/beer/beers.sql @@ -0,0 +1,18 @@ +CREATE TABLE beers ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + family TEXT, + image TEXT +); + + +-- seed data + +INSERT INTO beers + (name, family) +VALUES + ('Great Northern', 'Australian'); +INSERT INTO beers + (name, family) +VALUES + ('Corona', 'Mexican') \ No newline at end of file diff --git a/cale_shanley/week_04/beer/database.sqlite3 b/cale_shanley/week_04/beer/database.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_04/beer/main.rb b/cale_shanley/week_04/beer/main.rb new file mode 100644 index 0000000..a4d1b41 --- /dev/null +++ b/cale_shanley/week_04/beer/main.rb @@ -0,0 +1,16 @@ +require 'sinatra' +require 'sinatra/reloader' +require 'sqlite3' +require 'pry' + +get '/' do + erb :home +end + +# index -- Show all the Beers: READ +get '/beers' do + @beers = query_db 'SELECT * FROM beers' + # Render a view + erb :beers_index +end + diff --git a/cale_shanley/week_04/beer/public/css/beer.css b/cale_shanley/week_04/beer/public/css/beer.css new file mode 100644 index 0000000..8db9e4a --- /dev/null +++ b/cale_shanley/week_04/beer/public/css/beer.css @@ -0,0 +1,36 @@ +.container { + max-width: 960px; + margin: 0 auto; +} + +nav { + background-color: rgb(1, 1, 24); + overflow: hidden; + margin-bottom: 15px; +} + +nav a { + float: left; + color: #f2f2f2; + text-align: center; + padding: 14px 16px; + text-decoration: none; + font-size: 17px; +} + +nav a:hover { + background-color: #ddd; + color: black; +} + +nav a.active { + color: white; +} + +label { + display: block; +} + +.feature { + max-width: 100%; +} diff --git a/cale_shanley/week_04/beer/views/beers_index.erb b/cale_shanley/week_04/beer/views/beers_index.erb new file mode 100644 index 0000000..bd29a0b --- /dev/null +++ b/cale_shanley/week_04/beer/views/beers_index.erb @@ -0,0 +1,7 @@ +

All Beers

+<% @beers.each do |beers| %> +

+ + <%= beers['name'] %> +

+<% end %> \ No newline at end of file diff --git a/cale_shanley/week_04/beer/views/beers_show.erb b/cale_shanley/week_04/beer/views/beers_show.erb new file mode 100644 index 0000000..f0aa072 --- /dev/null +++ b/cale_shanley/week_04/beer/views/beers_show.erb @@ -0,0 +1,11 @@ +

<%= @beers["name"] %>

+

Family:<%= @beers['family'] %>

+ +<% unless @beers["image"].nil? || @beers["image"].empty? %> + " alt="<%= @beers["name"] %>"> +<% end %> + +
+ Edit Beers + Delete Beers +
\ No newline at end of file diff --git a/cale_shanley/week_04/beer/views/home.erb b/cale_shanley/week_04/beer/views/home.erb new file mode 100644 index 0000000..9d76587 --- /dev/null +++ b/cale_shanley/week_04/beer/views/home.erb @@ -0,0 +1 @@ +

List of my favourite Beer

\ No newline at end of file diff --git a/cale_shanley/week_04/beer/views/layout.erb b/cale_shanley/week_04/beer/views/layout.erb new file mode 100644 index 0000000..5ced769 --- /dev/null +++ b/cale_shanley/week_04/beer/views/layout.erb @@ -0,0 +1,20 @@ + + + + + + + Beer + + +
+ + <%= yield %> + +
+ + + \ No newline at end of file diff --git a/cale_shanley/week_05/books-app/.gitignore b/cale_shanley/week_05/books-app/.gitignore new file mode 100644 index 0000000..a6fa687 --- /dev/null +++ b/cale_shanley/week_05/books-app/.gitignore @@ -0,0 +1,28 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + + +/node_modules +/yarn-error.log + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/cale_shanley/week_05/books-app/.ruby-version b/cale_shanley/week_05/books-app/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/cale_shanley/week_05/books-app/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/cale_shanley/week_05/books-app/Gemfile b/cale_shanley/week_05/books-app/Gemfile new file mode 100644 index 0000000..2792f24 --- /dev/null +++ b/cale_shanley/week_05/books-app/Gemfile @@ -0,0 +1,51 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/cale_shanley/week_05/books-app/Gemfile.lock b/cale_shanley/week_05/books-app/Gemfile.lock new file mode 100644 index 0000000..512d5aa --- /dev/null +++ b/cale_shanley/week_05/books-app/Gemfile.lock @@ -0,0 +1,199 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1-x86_64-darwin-19) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.6.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/cale_shanley/week_05/books-app/README.md b/cale_shanley/week_05/books-app/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/cale_shanley/week_05/books-app/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/cale_shanley/week_05/books-app/Rakefile b/cale_shanley/week_05/books-app/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/cale_shanley/week_05/books-app/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/cale_shanley/week_05/books-app/app/assets/config/manifest.js b/cale_shanley/week_05/books-app/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/cale_shanley/week_05/books-app/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/cale_shanley/week_05/books-app/app/assets/images/.keep b/cale_shanley/week_05/books-app/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/books-app/app/assets/javascripts/application.js b/cale_shanley/week_05/books-app/app/assets/javascripts/application.js new file mode 100644 index 0000000..46b2035 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require turbolinks +//= require_tree . diff --git a/cale_shanley/week_05/books-app/app/assets/javascripts/author.coffee b/cale_shanley/week_05/books-app/app/assets/javascripts/author.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/assets/javascripts/author.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/cale_shanley/week_05/books-app/app/assets/javascripts/books.coffee b/cale_shanley/week_05/books-app/app/assets/javascripts/books.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/assets/javascripts/books.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/cale_shanley/week_05/books-app/app/assets/stylesheets/application.css b/cale_shanley/week_05/books-app/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/cale_shanley/week_05/books-app/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/cale_shanley/week_05/books-app/app/assets/stylesheets/author.scss b/cale_shanley/week_05/books-app/app/assets/stylesheets/author.scss new file mode 100644 index 0000000..ec5f52a --- /dev/null +++ b/cale_shanley/week_05/books-app/app/assets/stylesheets/author.scss @@ -0,0 +1,7 @@ +.thumb { + height: 12em; +} + +.feature { + max-height: 30em; +} diff --git a/cale_shanley/week_05/books-app/app/assets/stylesheets/books.scss b/cale_shanley/week_05/books-app/app/assets/stylesheets/books.scss new file mode 100644 index 0000000..81379d1 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/assets/stylesheets/books.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the books controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/cale_shanley/week_05/books-app/app/controllers/application_controller.rb b/cale_shanley/week_05/books-app/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/cale_shanley/week_05/books-app/app/controllers/authors_controller.rb b/cale_shanley/week_05/books-app/app/controllers/authors_controller.rb new file mode 100644 index 0000000..b2b07ee --- /dev/null +++ b/cale_shanley/week_05/books-app/app/controllers/authors_controller.rb @@ -0,0 +1,44 @@ +class AuthorsController < ApplicationController + + def index + @authors = Author.all + end + + def new + @author = Author.new + end + + def create + author = Author.create author_params # Permitted + redirect_to author # show page + end + + def edit + @author = Author.find params[:id] + end + + def update + # Find the author + author = Author.find params[:id] + # Make the update + author.update author_params + # Redirect somewhere + redirect_to author # Show page + end + + def show + @author = Author.find params[:id] + end + + def destroy + author = Author.find params[:id] + author.destroy + redirect_to authors_path + end + + private # The following method(s) aren't accessible outside this class (so routes can't print to them) + def author_params + # Strong params: White list of sanitised input -- stuff we are happy to accept from the user + params.required(:author).permit(:name, :author, :dob, :image) + end +end diff --git a/cale_shanley/week_05/books-app/app/controllers/books_controller.rb b/cale_shanley/week_05/books-app/app/controllers/books_controller.rb new file mode 100644 index 0000000..cc43ea3 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/controllers/books_controller.rb @@ -0,0 +1,39 @@ +class BooksController < ApplicationController + def index + @books = Book.all + end + + def new + @book = Book.new + end + + def create + book = Book.create book_params + redirect_to book # Show + end + + def edit + @book = Book.find params[:id] + end + + def update + book = Book.find params[:id] + book.update book_params + redirect_to book + end + + def show + @book = Book.find params[:id] + end + + def destroy + book = Book.find params[:id] + book.destroy + redirect_to books_path + end + + private + def book_params + params.require(:book).permit(:name, :author, :date, :image, :book_id) + end +end diff --git a/cale_shanley/week_05/books-app/app/controllers/concerns/.keep b/cale_shanley/week_05/books-app/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/books-app/app/helpers/application_helper.rb b/cale_shanley/week_05/books-app/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/cale_shanley/week_05/books-app/app/helpers/author_helper.rb b/cale_shanley/week_05/books-app/app/helpers/author_helper.rb new file mode 100644 index 0000000..fedf7cd --- /dev/null +++ b/cale_shanley/week_05/books-app/app/helpers/author_helper.rb @@ -0,0 +1,2 @@ +module AuthorHelper +end diff --git a/cale_shanley/week_05/books-app/app/helpers/books_helper.rb b/cale_shanley/week_05/books-app/app/helpers/books_helper.rb new file mode 100644 index 0000000..4b9311e --- /dev/null +++ b/cale_shanley/week_05/books-app/app/helpers/books_helper.rb @@ -0,0 +1,2 @@ +module BooksHelper +end diff --git a/cale_shanley/week_05/books-app/app/jobs/application_job.rb b/cale_shanley/week_05/books-app/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/cale_shanley/week_05/books-app/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/cale_shanley/week_05/books-app/app/mailers/application_mailer.rb b/cale_shanley/week_05/books-app/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/cale_shanley/week_05/books-app/app/models/application_record.rb b/cale_shanley/week_05/books-app/app/models/application_record.rb new file mode 100644 index 0000000..c744833 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/models/application_record.rb @@ -0,0 +1,2 @@ +class ApplicationRecord < ActiveRecord::Base +end diff --git a/cale_shanley/week_05/books-app/app/models/author.rb b/cale_shanley/week_05/books-app/app/models/author.rb new file mode 100644 index 0000000..560e7db --- /dev/null +++ b/cale_shanley/week_05/books-app/app/models/author.rb @@ -0,0 +1,3 @@ +class Author < ActiveRecord::Base + has_many :books +end \ No newline at end of file diff --git a/cale_shanley/week_05/books-app/app/models/book.rb b/cale_shanley/week_05/books-app/app/models/book.rb new file mode 100644 index 0000000..0b5541f --- /dev/null +++ b/cale_shanley/week_05/books-app/app/models/book.rb @@ -0,0 +1,3 @@ +class Book < ActiveRecord::Base + belongs_to :author, :optional => true +end \ No newline at end of file diff --git a/cale_shanley/week_05/books-app/app/models/concerns/.keep b/cale_shanley/week_05/books-app/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/books-app/app/views/authors/_form.html.erb b/cale_shanley/week_05/books-app/app/views/authors/_form.html.erb new file mode 100644 index 0000000..e430c0e --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/authors/_form.html.erb @@ -0,0 +1,15 @@ +<%= form_for @author do |f| %> + <%= f.label :name %> + <%= f.text_field :name %> + + <%= f.label :author %> + <%= f.text_field :author %> + + <%= f.label :dob, 'Date of Birth' %> + <%= f.text_field :dob, :placeholder => 'YYYY-MM-DD'%> + + <%= f.label :image %> + <%= f.url_field :image %> + + <%= f.submit %> +<% end %> \ No newline at end of file diff --git a/cale_shanley/week_05/books-app/app/views/authors/edit.html.erb b/cale_shanley/week_05/books-app/app/views/authors/edit.html.erb new file mode 100644 index 0000000..7314eff --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/authors/edit.html.erb @@ -0,0 +1,2 @@ +

Edit Author

+<%= render :partial => 'form' %> diff --git a/cale_shanley/week_05/books-app/app/views/authors/index.html.erb b/cale_shanley/week_05/books-app/app/views/authors/index.html.erb new file mode 100644 index 0000000..115b1c3 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/authors/index.html.erb @@ -0,0 +1,10 @@ +

All Authors

+ +<% @authors.each do |author| %> + <%= image_tag author.image, :class => 'thumb' if author.image.present? %> + +<% end %> diff --git a/cale_shanley/week_05/books-app/app/views/authors/new.html.erb b/cale_shanley/week_05/books-app/app/views/authors/new.html.erb new file mode 100644 index 0000000..63eef2c --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/authors/new.html.erb @@ -0,0 +1,3 @@ +

New Author

+ +<%= render :partial => 'form' %> \ No newline at end of file diff --git a/cale_shanley/week_05/books-app/app/views/authors/show.html.erb b/cale_shanley/week_05/books-app/app/views/authors/show.html.erb new file mode 100644 index 0000000..8d048da --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/authors/show.html.erb @@ -0,0 +1,15 @@ +

<%= @author.name %>

+ +<%= image_tag @author.image, :class => 'feature' if @author.image.present? %> + + +
+ <%= link_to 'Edit Author', edit_author_path(@author) %> + <%= link_to 'Delete Author', @author, :method => 'delete' %> + +
\ No newline at end of file diff --git a/cale_shanley/week_05/books-app/app/views/books/_form.html.erb b/cale_shanley/week_05/books-app/app/views/books/_form.html.erb new file mode 100644 index 0000000..8f09138 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/books/_form.html.erb @@ -0,0 +1,18 @@ +<%= form_for @book do |f| %> + <%= f.label :name %> + <%= f.text_field :name %> + + <%= f.label :author %> + <%= f.text_field :author %> + + <%= f.label :date, 'Date Published' %> + <%= f.text_field :date, :placeholder => 'YYYY-MM-DD'%> + + <%= f.label :image %> + <%= f.url_field :image %> + + <%= f.label :book_id %> + <%= f.select :book_id, Book.pluck(:author, :id), :include_blank => '' %> + + <%= f.submit %> +<% end %> \ No newline at end of file diff --git a/cale_shanley/week_05/books-app/app/views/books/edit.html.erb b/cale_shanley/week_05/books-app/app/views/books/edit.html.erb new file mode 100644 index 0000000..29423fc --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/books/edit.html.erb @@ -0,0 +1,2 @@ +

Edit Book

+<%= render :partial => 'form' %> diff --git a/cale_shanley/week_05/books-app/app/views/books/index.html.erb b/cale_shanley/week_05/books-app/app/views/books/index.html.erb new file mode 100644 index 0000000..23303ac --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/books/index.html.erb @@ -0,0 +1,4 @@ +

All Books

+<% @books.each do |book| %> + <%= link_to image_tag(book.image, :class => 'thumb', :alt => book.name), books_path %> +<% end %> diff --git a/cale_shanley/week_05/books-app/app/views/books/new.html.erb b/cale_shanley/week_05/books-app/app/views/books/new.html.erb new file mode 100644 index 0000000..0e913ab --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/books/new.html.erb @@ -0,0 +1,3 @@ +

New Book

+ +<%= render :partial => 'form' %> \ No newline at end of file diff --git a/cale_shanley/week_05/books-app/app/views/books/show.html.erb b/cale_shanley/week_05/books-app/app/views/books/show.html.erb new file mode 100644 index 0000000..60fd6e8 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/books/show.html.erb @@ -0,0 +1,15 @@ +

<%= @book.name %>

+<%= image_tag @book.image, :class => 'feature', :alt => @book.name %> + + + +
+ <%= link_to 'Edit book', edit_book_path(@book) %> + <%= link_to 'Delete book', @book, :method => 'delete' %> +
\ No newline at end of file diff --git a/cale_shanley/week_05/books-app/app/views/layouts/application.html.erb b/cale_shanley/week_05/books-app/app/views/layouts/application.html.erb new file mode 100644 index 0000000..d8d897f --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/layouts/application.html.erb @@ -0,0 +1,23 @@ + + + + BooksApp + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + <%= yield %> + + diff --git a/cale_shanley/week_05/books-app/app/views/layouts/mailer.html.erb b/cale_shanley/week_05/books-app/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/cale_shanley/week_05/books-app/app/views/layouts/mailer.text.erb b/cale_shanley/week_05/books-app/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/cale_shanley/week_05/books-app/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/cale_shanley/week_05/books-app/bin/bundle b/cale_shanley/week_05/books-app/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/cale_shanley/week_05/books-app/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/cale_shanley/week_05/books-app/bin/rails b/cale_shanley/week_05/books-app/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/cale_shanley/week_05/books-app/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/cale_shanley/week_05/books-app/bin/rake b/cale_shanley/week_05/books-app/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/cale_shanley/week_05/books-app/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/cale_shanley/week_05/books-app/bin/setup b/cale_shanley/week_05/books-app/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/cale_shanley/week_05/books-app/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/cale_shanley/week_05/books-app/bin/spring b/cale_shanley/week_05/books-app/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/cale_shanley/week_05/books-app/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/cale_shanley/week_05/books-app/bin/update b/cale_shanley/week_05/books-app/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/cale_shanley/week_05/books-app/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/cale_shanley/week_05/books-app/bin/yarn b/cale_shanley/week_05/books-app/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/cale_shanley/week_05/books-app/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/cale_shanley/week_05/books-app/config.ru b/cale_shanley/week_05/books-app/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/cale_shanley/week_05/books-app/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/cale_shanley/week_05/books-app/config/application.rb b/cale_shanley/week_05/books-app/config/application.rb new file mode 100644 index 0000000..e326c9e --- /dev/null +++ b/cale_shanley/week_05/books-app/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module BooksApp + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/cale_shanley/week_05/books-app/config/boot.rb b/cale_shanley/week_05/books-app/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/cale_shanley/week_05/books-app/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/cale_shanley/week_05/books-app/config/credentials.yml.enc b/cale_shanley/week_05/books-app/config/credentials.yml.enc new file mode 100644 index 0000000..3d2f44f --- /dev/null +++ b/cale_shanley/week_05/books-app/config/credentials.yml.enc @@ -0,0 +1 @@ +V7ZaRy0yY+DY4Z5vLCCPEyYCZl2PX3Zi5F/wyPXYXemsOEhyGPsXnEq9jileDtAC3hI9vWN0kfr5QRIgsGiALPcehJ9QWJUlJ0q2phbN9MmGLKk5DCPEuvcbRTxP8R5cZoEj9fHCX2uBSzrxUe9IlPCcG9LdzExQwdL1k0DDE21yJirM2PaJJzflKyQUSLUAMcqtyi/FxZ8RX/NwhyD52Ydz3KkacfqjJD85ksTTDm+5MfqCEtIy5am3j6q56DsnybFJM0cy/y/maxgrNv/iafVFdXoxjgRiuA4b/VJAJf7hgIk9CQ3zWylula+Kpqbr7ELvUW1tAT9InwZolGAxftyYvFV1m0nraMKybDBtZ/2k3oRsumhAss7nNC6KgJIA3UEP6n4n6UaQZjx5XnlEfnjXaZEnlw7VdG5n--zbzTyTOWWZik1VWr--8J/N4nWHdtGrSqqsab+KSw== \ No newline at end of file diff --git a/cale_shanley/week_05/books-app/config/database.yml b/cale_shanley/week_05/books-app/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/cale_shanley/week_05/books-app/config/environment.rb b/cale_shanley/week_05/books-app/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/cale_shanley/week_05/books-app/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/cale_shanley/week_05/books-app/config/environments/development.rb b/cale_shanley/week_05/books-app/config/environments/development.rb new file mode 100644 index 0000000..92bfc1d --- /dev/null +++ b/cale_shanley/week_05/books-app/config/environments/development.rb @@ -0,0 +1,58 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/cale_shanley/week_05/books-app/config/environments/production.rb b/cale_shanley/week_05/books-app/config/environments/production.rb new file mode 100644 index 0000000..f935cf7 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/environments/production.rb @@ -0,0 +1,86 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "books-app_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/cale_shanley/week_05/books-app/config/environments/test.rb b/cale_shanley/week_05/books-app/config/environments/test.rb new file mode 100644 index 0000000..b08fc84 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/environments/test.rb @@ -0,0 +1,43 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/cale_shanley/week_05/books-app/config/initializers/application_controller_renderer.rb b/cale_shanley/week_05/books-app/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/cale_shanley/week_05/books-app/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/cale_shanley/week_05/books-app/config/initializers/assets.rb b/cale_shanley/week_05/books-app/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/cale_shanley/week_05/books-app/config/initializers/backtrace_silencers.rb b/cale_shanley/week_05/books-app/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/cale_shanley/week_05/books-app/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/cale_shanley/week_05/books-app/config/initializers/content_security_policy.rb b/cale_shanley/week_05/books-app/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/cale_shanley/week_05/books-app/config/initializers/cookies_serializer.rb b/cale_shanley/week_05/books-app/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/cale_shanley/week_05/books-app/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/cale_shanley/week_05/books-app/config/initializers/filter_parameter_logging.rb b/cale_shanley/week_05/books-app/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/cale_shanley/week_05/books-app/config/initializers/inflections.rb b/cale_shanley/week_05/books-app/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/cale_shanley/week_05/books-app/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/cale_shanley/week_05/books-app/config/initializers/mime_types.rb b/cale_shanley/week_05/books-app/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/cale_shanley/week_05/books-app/config/initializers/wrap_parameters.rb b/cale_shanley/week_05/books-app/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/cale_shanley/week_05/books-app/config/locales/en.yml b/cale_shanley/week_05/books-app/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/cale_shanley/week_05/books-app/config/puma.rb b/cale_shanley/week_05/books-app/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/cale_shanley/week_05/books-app/config/routes.rb b/cale_shanley/week_05/books-app/config/routes.rb new file mode 100644 index 0000000..bc5f9c4 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + resources :authors + resources :books +end diff --git a/cale_shanley/week_05/books-app/config/spring.rb b/cale_shanley/week_05/books-app/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/cale_shanley/week_05/books-app/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/cale_shanley/week_05/books-app/db/migrate/20200617090051_create_authors.rb b/cale_shanley/week_05/books-app/db/migrate/20200617090051_create_authors.rb new file mode 100644 index 0000000..bda1500 --- /dev/null +++ b/cale_shanley/week_05/books-app/db/migrate/20200617090051_create_authors.rb @@ -0,0 +1,10 @@ +class CreateAuthors < ActiveRecord::Migration[5.2] + def change + create_table :authors do |t| + t.text :name + t.text :author + t.date :dob + t.text :image + end + end +end diff --git a/cale_shanley/week_05/books-app/db/migrate/20200617113504_create_books.rb b/cale_shanley/week_05/books-app/db/migrate/20200617113504_create_books.rb new file mode 100644 index 0000000..84513f5 --- /dev/null +++ b/cale_shanley/week_05/books-app/db/migrate/20200617113504_create_books.rb @@ -0,0 +1,11 @@ +class CreateBooks < ActiveRecord::Migration[5.2] + def change + create_table :books do |t| + t.text :name + t.text :author + t.date :date + t.text :image + t.integer "book_id" + end + end +end diff --git a/cale_shanley/week_05/books-app/db/schema.rb b/cale_shanley/week_05/books-app/db/schema.rb new file mode 100644 index 0000000..d33d05d --- /dev/null +++ b/cale_shanley/week_05/books-app/db/schema.rb @@ -0,0 +1,30 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_17_113504) do + + create_table "authors", force: :cascade do |t| + t.text "name" + t.text "author" + t.date "dob" + t.text "image" + end + + create_table "books", force: :cascade do |t| + t.text "name" + t.text "author" + t.date "date" + t.text "image" + t.integer "book_id" + end + +end diff --git a/cale_shanley/week_05/books-app/db/seeds.rb b/cale_shanley/week_05/books-app/db/seeds.rb new file mode 100644 index 0000000..8691388 --- /dev/null +++ b/cale_shanley/week_05/books-app/db/seeds.rb @@ -0,0 +1,13 @@ +Author.destroy_all +Author.create(:name => 'Joanne Rowling', :author => 'J. K. Rowling', :dob => '31-07-1965', :image => 'https://pyxis.nymag.com/v1/imgs/f4a/b87/495cb0edf3374af9ecb88570abe4a6c961-jk-rowling.2x.rsquare.w330.jpg') +Author.create(:name => 'Herman Melville', :author => 'Herman Melville', :dob => '01-08-1819', :image => 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/Herman_Melville_1860.jpg/170px-Herman_Melville_1860.jpg') +Author.create(:name => 'Francis Scott Key Fitzgerald', :author => 'F. Scott Fitzgerald', :dob => '24-09-1896', :image => 'https://www.biography.com/.image/t_share/MTE1ODA0OTcxMTk2NTgxMzg5/f-scott-fitzgerald.jpg') +Author.create(:name => 'Harper Lee', :author => 'Harper Lee', :dob => '28-04-1926', :image => 'https://pyxis.nymag.com/v1/imgs/bf8/773/56b03ba7a7553bfb1bb50c63e1ad0a6457-17-harper-lee.rsquare.w700.jpg') +puts "#{Author.count} authors created" + +Book.destroy_all +Book.create(:name => 'Harry Potter and the Prisoner of Azkaban', :date => '08-07-1999', :image => 'https://kbimages1-a.akamaihd.net/be00a641-64ad-4f99-ad3f-5ecf872c904c/1200/1200/False/harry-potter-and-the-prisoner-of-azkaban-5.jpg') +Book.create(:name => 'Moby Dick', :image => 'https://images-na.ssl-images-amazon.com/images/I/41WMBltiqdL.jpg') +Book.create(:name => 'The Great Gatsby', :date => '10-04-1925', :image => 'https://m.media-amazon.com/images/I/41iers+HLSL.jpg') +Book.create(:name => 'To Kill a Mockingbird', :date => '11-06-1960', :image => 'https://m.media-amazon.com/images/I/51g3AS16r9L.jpg') +puts "#{Book.count} books created" \ No newline at end of file diff --git a/cale_shanley/week_05/books-app/lib/assets/.keep b/cale_shanley/week_05/books-app/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/books-app/lib/tasks/.keep b/cale_shanley/week_05/books-app/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/books-app/package.json b/cale_shanley/week_05/books-app/package.json new file mode 100644 index 0000000..2832faa --- /dev/null +++ b/cale_shanley/week_05/books-app/package.json @@ -0,0 +1,5 @@ +{ + "name": "books-app", + "private": true, + "dependencies": {} +} diff --git a/cale_shanley/week_05/books-app/public/404.html b/cale_shanley/week_05/books-app/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/cale_shanley/week_05/books-app/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/cale_shanley/week_05/books-app/public/422.html b/cale_shanley/week_05/books-app/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/cale_shanley/week_05/books-app/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/cale_shanley/week_05/books-app/public/500.html b/cale_shanley/week_05/books-app/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/cale_shanley/week_05/books-app/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/cale_shanley/week_05/books-app/public/apple-touch-icon-precomposed.png b/cale_shanley/week_05/books-app/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/books-app/public/apple-touch-icon.png b/cale_shanley/week_05/books-app/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/books-app/public/favicon.ico b/cale_shanley/week_05/books-app/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/books-app/public/robots.txt b/cale_shanley/week_05/books-app/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/cale_shanley/week_05/books-app/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/cale_shanley/week_05/books-app/vendor/.keep b/cale_shanley/week_05/books-app/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/mountain-app/.ruby-version b/cale_shanley/week_05/mountain-app/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/cale_shanley/week_05/mountain-app/Gemfile b/cale_shanley/week_05/mountain-app/Gemfile new file mode 100644 index 0000000..2792f24 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/Gemfile @@ -0,0 +1,51 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/cale_shanley/week_05/mountain-app/Gemfile.lock b/cale_shanley/week_05/mountain-app/Gemfile.lock new file mode 100644 index 0000000..b5d3afe --- /dev/null +++ b/cale_shanley/week_05/mountain-app/Gemfile.lock @@ -0,0 +1,199 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1-x86_64-darwin-19) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/cale_shanley/week_05/mountain-app/README.md b/cale_shanley/week_05/mountain-app/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/cale_shanley/week_05/mountain-app/Rakefile b/cale_shanley/week_05/mountain-app/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/cale_shanley/week_05/mountain-app/app/assets/config/manifest.js b/cale_shanley/week_05/mountain-app/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/cale_shanley/week_05/mountain-app/app/assets/images/.keep b/cale_shanley/week_05/mountain-app/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/mountain-app/app/assets/images/k2_70009246-56a16a343df78cf7726a881f.webp b/cale_shanley/week_05/mountain-app/app/assets/images/k2_70009246-56a16a343df78cf7726a881f.webp new file mode 100644 index 0000000..0122b40 Binary files /dev/null and b/cale_shanley/week_05/mountain-app/app/assets/images/k2_70009246-56a16a343df78cf7726a881f.webp differ diff --git a/cale_shanley/week_05/mountain-app/app/assets/javascripts/application.js b/cale_shanley/week_05/mountain-app/app/assets/javascripts/application.js new file mode 100644 index 0000000..46b2035 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require turbolinks +//= require_tree . diff --git a/cale_shanley/week_05/mountain-app/app/assets/stylesheets/application.css b/cale_shanley/week_05/mountain-app/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/cale_shanley/week_05/mountain-app/app/assets/stylesheets/style.css b/cale_shanley/week_05/mountain-app/app/assets/stylesheets/style.css new file mode 100644 index 0000000..3cca013 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/assets/stylesheets/style.css @@ -0,0 +1,29 @@ +.container { + max-width: 960px; /* lazy responsice container */ + background-color: white; + margin: auto; /* Horizontal centering */ +} + +nav { + background-color: rgb(1, 1, 16); + overflow: hidden; + margin-bottom: 15px; +} + +nav a { + float: left; + color: #f2f2f2; + text-align: center; + padding: 14px 16px; + text-decoration: none; + font-size: 17px; +} + +nav a:hover { + background-color: #ddd; + color: black; +} + +nav a.active { + color: white; +} diff --git a/cale_shanley/week_05/mountain-app/app/controllers/application_controller.rb b/cale_shanley/week_05/mountain-app/app/controllers/application_controller.rb new file mode 100644 index 0000000..75f1154 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + skip_before_action :verify_authenticity_token +end diff --git a/cale_shanley/week_05/mountain-app/app/controllers/concerns/.keep b/cale_shanley/week_05/mountain-app/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/mountain-app/app/controllers/mountains_controller.rb b/cale_shanley/week_05/mountain-app/app/controllers/mountains_controller.rb new file mode 100644 index 0000000..61ea7d4 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/controllers/mountains_controller.rb @@ -0,0 +1,40 @@ +class MountainsController < ApplicationController + def index + @mountains = Mountain.all + end + + def show + @mountains = Mountain.find params[:id] + end + + def new + end + + def create + mountain = Mountain.create :name => params[:name], :image => params[:image], :height => params[:height], :country => params[:country] + redirect_to mountain_path(mountain.id) + end + + def edit + @mountains = Mountain.find params[:id] + end + + def update + # get the exisiting mountain from the db + mountain = Mountain.find params[:id] + # Update ALL the fields + mountain.name = params[:name] + mountain.image = params[:image] + mountain.height = params[:height] + mountain.country = params[:country] + mountain.save + # Redirect to the show page + redirect_to mountain_path(mountain.id) + end + + def destroy + mountain = Mountain.find params[:id] + mountain.destroy + redirect_to mountains_path + end +end \ No newline at end of file diff --git a/cale_shanley/week_05/mountain-app/app/helpers/application_helper.rb b/cale_shanley/week_05/mountain-app/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/cale_shanley/week_05/mountain-app/app/jobs/application_job.rb b/cale_shanley/week_05/mountain-app/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/cale_shanley/week_05/mountain-app/app/mailers/application_mailer.rb b/cale_shanley/week_05/mountain-app/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/cale_shanley/week_05/mountain-app/app/models/application_record.rb b/cale_shanley/week_05/mountain-app/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/cale_shanley/week_05/mountain-app/app/models/concerns/.keep b/cale_shanley/week_05/mountain-app/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/mountain-app/app/models/mountain.rb b/cale_shanley/week_05/mountain-app/app/models/mountain.rb new file mode 100644 index 0000000..df54b3f --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/models/mountain.rb @@ -0,0 +1,2 @@ +class Mountain < ActiveRecord::Base +end diff --git a/cale_shanley/week_05/mountain-app/app/views/layouts/application.html.erb b/cale_shanley/week_05/mountain-app/app/views/layouts/application.html.erb new file mode 100644 index 0000000..3922417 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/views/layouts/application.html.erb @@ -0,0 +1,19 @@ + + + + MountainApp + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + <%= yield %> + + diff --git a/cale_shanley/week_05/mountain-app/app/views/layouts/mailer.html.erb b/cale_shanley/week_05/mountain-app/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/cale_shanley/week_05/mountain-app/app/views/layouts/mailer.text.erb b/cale_shanley/week_05/mountain-app/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/cale_shanley/week_05/mountain-app/app/views/mountains/edit.html.erb b/cale_shanley/week_05/mountain-app/app/views/mountains/edit.html.erb new file mode 100644 index 0000000..ff946be --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/views/mountains/edit.html.erb @@ -0,0 +1,24 @@ +

Edit Mountain

+ +
+ + + + + + + + +
\ No newline at end of file diff --git a/cale_shanley/week_05/mountain-app/app/views/mountains/index.html.erb b/cale_shanley/week_05/mountain-app/app/views/mountains/index.html.erb new file mode 100644 index 0000000..a169a75 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/views/mountains/index.html.erb @@ -0,0 +1,7 @@ +

All Mountains

+ +<% @mountains.each do |mountain| %> +

+ <%= mountain.name %> +

+<% end %> \ No newline at end of file diff --git a/cale_shanley/week_05/mountain-app/app/views/mountains/new.html.erb b/cale_shanley/week_05/mountain-app/app/views/mountains/new.html.erb new file mode 100644 index 0000000..c57ec34 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/views/mountains/new.html.erb @@ -0,0 +1,24 @@ +

New Mountain

+ +
+ + + + + + + + +
\ No newline at end of file diff --git a/cale_shanley/week_05/mountain-app/app/views/mountains/show.html.erb b/cale_shanley/week_05/mountain-app/app/views/mountains/show.html.erb new file mode 100644 index 0000000..b51a892 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/app/views/mountains/show.html.erb @@ -0,0 +1,15 @@ +

<%= @mountains.name %>

+ + +<%= image_tag @mountains.image, :class => 'feature' if @mountains.image.present? %> + + + +
+ <%= link_to 'Edit Mountain', edit_mountain_path(@mountains.id) %> + <%= button_to 'Delete Mountains', mountain_path(@mountains.id), :method => 'delete' %> +
\ No newline at end of file diff --git a/cale_shanley/week_05/mountain-app/bin/bundle b/cale_shanley/week_05/mountain-app/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/cale_shanley/week_05/mountain-app/bin/rails b/cale_shanley/week_05/mountain-app/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/cale_shanley/week_05/mountain-app/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/cale_shanley/week_05/mountain-app/bin/rake b/cale_shanley/week_05/mountain-app/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/cale_shanley/week_05/mountain-app/bin/setup b/cale_shanley/week_05/mountain-app/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/cale_shanley/week_05/mountain-app/bin/spring b/cale_shanley/week_05/mountain-app/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/cale_shanley/week_05/mountain-app/bin/update b/cale_shanley/week_05/mountain-app/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/cale_shanley/week_05/mountain-app/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/cale_shanley/week_05/mountain-app/bin/yarn b/cale_shanley/week_05/mountain-app/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/cale_shanley/week_05/mountain-app/config.ru b/cale_shanley/week_05/mountain-app/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/cale_shanley/week_05/mountain-app/config/application.rb b/cale_shanley/week_05/mountain-app/config/application.rb new file mode 100644 index 0000000..719b2e3 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module MountainApp + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/cale_shanley/week_05/mountain-app/config/boot.rb b/cale_shanley/week_05/mountain-app/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/cale_shanley/week_05/mountain-app/config/credentials.yml.enc b/cale_shanley/week_05/mountain-app/config/credentials.yml.enc new file mode 100644 index 0000000..dcdca51 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/credentials.yml.enc @@ -0,0 +1 @@ +EmkWhUPktYDYFEw0nMMTarj4nUubBrKUgEFF3w92n97Gih04EsscscAsz29Sytr/3qIL/G1f6u856OkANJF3oMqS6dleaLKTFYZlkOORY/o4kEXIJtK8vmzNaB+slxPBUp46R+VfMDj6IDFxqnLqRM/lGGI47uSODoY9cpMjFxYVFA9JKWoR0rwWscPllMH4eC38G6+ugaWPJrdjehplsFTPwE7yUAUPjom1SRfBzncvAagUtkfFbMnJJVrNAzslUEzuWJ7sD4txvEv5g2k+ioUPgL7LSSXxkpF/YwlJ1YdzHBvTW2+wWRa2J+J67la0E43BR2Zg4XPm/ibixLpqAQ8y6v3g8nNkiv/LOzlqr+rv/i5uGTxrz5jtLh+Nh6GORWxrK/RWpzQ8xyOKz45shGNV94O+hNR+wdkb--f0ROekupcg0fR+l8--fU+WuL+ABxyT8zodDf2Pcw== \ No newline at end of file diff --git a/cale_shanley/week_05/mountain-app/config/database.yml b/cale_shanley/week_05/mountain-app/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/cale_shanley/week_05/mountain-app/config/environment.rb b/cale_shanley/week_05/mountain-app/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/cale_shanley/week_05/mountain-app/config/environments/development.rb b/cale_shanley/week_05/mountain-app/config/environments/development.rb new file mode 100644 index 0000000..92bfc1d --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/environments/development.rb @@ -0,0 +1,58 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/cale_shanley/week_05/mountain-app/config/environments/production.rb b/cale_shanley/week_05/mountain-app/config/environments/production.rb new file mode 100644 index 0000000..1778dba --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/environments/production.rb @@ -0,0 +1,86 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "mountain-app_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/cale_shanley/week_05/mountain-app/config/environments/test.rb b/cale_shanley/week_05/mountain-app/config/environments/test.rb new file mode 100644 index 0000000..b08fc84 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/environments/test.rb @@ -0,0 +1,43 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/cale_shanley/week_05/mountain-app/config/initializers/application_controller_renderer.rb b/cale_shanley/week_05/mountain-app/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/cale_shanley/week_05/mountain-app/config/initializers/assets.rb b/cale_shanley/week_05/mountain-app/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/cale_shanley/week_05/mountain-app/config/initializers/backtrace_silencers.rb b/cale_shanley/week_05/mountain-app/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/cale_shanley/week_05/mountain-app/config/initializers/content_security_policy.rb b/cale_shanley/week_05/mountain-app/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/cale_shanley/week_05/mountain-app/config/initializers/cookies_serializer.rb b/cale_shanley/week_05/mountain-app/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/cale_shanley/week_05/mountain-app/config/initializers/filter_parameter_logging.rb b/cale_shanley/week_05/mountain-app/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/cale_shanley/week_05/mountain-app/config/initializers/inflections.rb b/cale_shanley/week_05/mountain-app/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/cale_shanley/week_05/mountain-app/config/initializers/mime_types.rb b/cale_shanley/week_05/mountain-app/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/cale_shanley/week_05/mountain-app/config/initializers/wrap_parameters.rb b/cale_shanley/week_05/mountain-app/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/cale_shanley/week_05/mountain-app/config/locales/en.yml b/cale_shanley/week_05/mountain-app/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/cale_shanley/week_05/mountain-app/config/master.key b/cale_shanley/week_05/mountain-app/config/master.key new file mode 100644 index 0000000..139515e --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/master.key @@ -0,0 +1 @@ +d19925b8b0b8e0e6c5fcdf85a010786c \ No newline at end of file diff --git a/cale_shanley/week_05/mountain-app/config/puma.rb b/cale_shanley/week_05/mountain-app/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/cale_shanley/week_05/mountain-app/config/routes.rb b/cale_shanley/week_05/mountain-app/config/routes.rb new file mode 100644 index 0000000..a52c3b1 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/routes.rb @@ -0,0 +1,12 @@ +Rails.application.routes.draw do + + root :to => 'mountains#index' + get '/mountains' => 'mountains#index' + get '/mountains/new' => 'mountains#new', :as => 'new_mountain' + post '/mountains' => 'mountains#create' + get '/mountains/:id' => 'mountains#show', :as => 'mountain' + get '/mountains/:id/edit' => 'mountains#edit', :as => 'edit_mountain' + post '/mountains/:id/' => 'mountains#update' + delete '/mountains/:id' => 'mountains#destroy' + +end diff --git a/cale_shanley/week_05/mountain-app/config/spring.rb b/cale_shanley/week_05/mountain-app/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/cale_shanley/week_05/mountain-app/db/create_mountains.sql b/cale_shanley/week_05/mountain-app/db/create_mountains.sql new file mode 100644 index 0000000..a7c24d1 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/db/create_mountains.sql @@ -0,0 +1,7 @@ +CREATE TABLE mountains ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + image TEXT, + height INTEGER, + country TEXT +); \ No newline at end of file diff --git a/cale_shanley/week_05/mountain-app/db/development.sqlite3 b/cale_shanley/week_05/mountain-app/db/development.sqlite3 new file mode 100644 index 0000000..ffa9324 Binary files /dev/null and b/cale_shanley/week_05/mountain-app/db/development.sqlite3 differ diff --git a/cale_shanley/week_05/mountain-app/db/seeds.rb b/cale_shanley/week_05/mountain-app/db/seeds.rb new file mode 100644 index 0000000..6699749 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/db/seeds.rb @@ -0,0 +1,7 @@ +Mountain.destroy_all + +Mountain.create :name => 'Mount Everest', :height => 8848, :country => 'Asia' +Mountain.create :name => 'Mount Kilimanjaro', :height => 5895, :country => 'Tanzania' +Mountain.create :name => 'Mount Fuji', :height => 3776, :country => 'Japan' + +puts "#{Mountain.count} Mountains avaliable." \ No newline at end of file diff --git a/cale_shanley/week_05/mountain-app/db/test.sqlite3 b/cale_shanley/week_05/mountain-app/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/mountain-app/lib/assets/.keep b/cale_shanley/week_05/mountain-app/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/mountain-app/lib/tasks/.keep b/cale_shanley/week_05/mountain-app/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/mountain-app/package.json b/cale_shanley/week_05/mountain-app/package.json new file mode 100644 index 0000000..d0c7022 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/package.json @@ -0,0 +1,5 @@ +{ + "name": "mountain-app", + "private": true, + "dependencies": {} +} diff --git a/cale_shanley/week_05/mountain-app/public/404.html b/cale_shanley/week_05/mountain-app/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/cale_shanley/week_05/mountain-app/public/422.html b/cale_shanley/week_05/mountain-app/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/cale_shanley/week_05/mountain-app/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/cale_shanley/week_05/mountain-app/public/500.html b/cale_shanley/week_05/mountain-app/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/cale_shanley/week_05/mountain-app/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/cale_shanley/week_05/mountain-app/public/apple-touch-icon-precomposed.png b/cale_shanley/week_05/mountain-app/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/mountain-app/public/apple-touch-icon.png b/cale_shanley/week_05/mountain-app/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/mountain-app/public/favicon.ico b/cale_shanley/week_05/mountain-app/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/cale_shanley/week_05/mountain-app/public/robots.txt b/cale_shanley/week_05/mountain-app/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/cale_shanley/week_05/mountain-app/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/cale_shanley/week_05/mountain-app/vendor/.keep b/cale_shanley/week_05/mountain-app/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/.ruby-version b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/Gemfile b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/Gemfile new file mode 100644 index 0000000..0c0a30d --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/Gemfile @@ -0,0 +1,62 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/Gemfile.lock b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/Gemfile.lock new file mode 100644 index 0000000..9a3cb4f --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/Gemfile.lock @@ -0,0 +1,216 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.32.2) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + io-like (0.3.1) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.2) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (1.7.1) + ruby_dep (1.5.0) + rubyzip (2.3.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/README.md b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/Rakefile b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/config/manifest.js b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/images/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/javascripts/application.js b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/javascripts/cable.js b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/javascripts/channels/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/stylesheets/application.css b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/channels/application_cable/channel.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/channels/application_cable/connection.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/application_controller.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/concerns/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/magicball_controller.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/magicball_controller.rb new file mode 100644 index 0000000..11f70ff --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/magicball_controller.rb @@ -0,0 +1,34 @@ +class MagicballController < ApplicationController + def form + render :form + end + + def result + outputs =[ + "It is certain.", + "It is decidedly so.", + "Without a doubt.", + "Yes – definitely.", + "You may rely on it.", + "As I see it, yes.", + "Most likely.", + "Outlook good.", + "Yes.", + "Signs point to yes.", + "Reply hazy, try again.", + "Ask again later.", + "Better not tell you now.", + "Cannot predict now.", + "Concentrate and ask again.", + "Don't count on it.", + "My reply is no.", + "My sources say no.", + "Outlook not so good.", + "Very doubtful." + ] + @output = outputs.sample + + render :result + end + +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/pages_controller.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/pages_controller.rb new file mode 100644 index 0000000..b0df01d --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/pages_controller.rb @@ -0,0 +1,5 @@ +class PagesController < ApplicationController + def home + render :home + end +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/rockpaperscissors_controller.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/rockpaperscissors_controller.rb new file mode 100644 index 0000000..7cfd815 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/rockpaperscissors_controller.rb @@ -0,0 +1,5 @@ +class RockpaperscissorsController < ApplicationController + def form + render :form + end +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/secretnumber_controller.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/secretnumber_controller.rb new file mode 100644 index 0000000..73eedc0 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/controllers/secretnumber_controller.rb @@ -0,0 +1,16 @@ +class SecretnumberController < ApplicationController + def form + render :form + end + + def result + @answer = rand(1..10) + @guess = params[:class] + if @guess.to_i == @answer + @message = "correct" + else + @message = "wrong" + end + render :result + end +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/helpers/application_helper.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/jobs/application_job.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/mailers/application_mailer.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/models/application_record.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/models/concerns/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/layouts/application.html.erb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/layouts/application.html.erb new file mode 100644 index 0000000..caa6363 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/layouts/application.html.erb @@ -0,0 +1,21 @@ + + + + GameOnRails + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + <%= yield %> + + diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/layouts/mailer.html.erb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/layouts/mailer.text.erb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/magicball/form.html.erb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/magicball/form.html.erb new file mode 100644 index 0000000..4d3769d --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/magicball/form.html.erb @@ -0,0 +1,9 @@ +

Magic 8 Ball Game

+ +
+ + +
diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/magicball/result.html.erb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/magicball/result.html.erb new file mode 100644 index 0000000..019a985 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/magicball/result.html.erb @@ -0,0 +1,2 @@ +

Magic 8 Ball Result

+

The answer is "<%= @output %>"

diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/pages/home.html.erb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/pages/home.html.erb new file mode 100644 index 0000000..e07b38b --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/pages/home.html.erb @@ -0,0 +1,9 @@ +

Games on Rails

+ +

+ Choose the game you want to play: +

+ +

Magic 8 Ball

+

Secret Number

+

Rock Paper Scissors

diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/rockpaperscissors/form.html.erb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/rockpaperscissors/form.html.erb new file mode 100644 index 0000000..a3857fc --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/rockpaperscissors/form.html.erb @@ -0,0 +1,7 @@ +

Rock Paper Scissors

+

+ Choose one of the following options: +

+ + + diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/secretnumber/form.html.erb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/secretnumber/form.html.erb new file mode 100644 index 0000000..b95f622 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/secretnumber/form.html.erb @@ -0,0 +1,14 @@ +

Guess the Secret Number

+ +
+ + + + + + + + + + +
diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/secretnumber/result.html.erb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/secretnumber/result.html.erb new file mode 100644 index 0000000..341c5ca --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/app/views/secretnumber/result.html.erb @@ -0,0 +1,6 @@ +

Secret Number Game Result

+ +

+ The secret number is <%= @answer %>. Your clicked <%= @guess %> and it is <%= @message %>! + +

diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/bundle b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/rails b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/rake b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/setup b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/spring b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/update b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/yarn b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config.ru b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/application.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/application.rb new file mode 100644 index 0000000..9e9dc86 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/application.rb @@ -0,0 +1,19 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module GameOnRails + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/boot.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/cable.yml b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/cable.yml new file mode 100644 index 0000000..3c149a3 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: game_on_rails_production diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/credentials.yml.enc b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/credentials.yml.enc new file mode 100644 index 0000000..95b1b48 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/credentials.yml.enc @@ -0,0 +1 @@ +z+3qnrnL7nVALsYhR3uB4qWEv96LAPKd4keIL/Lbrj8yCb3THJ5jM6txeAmkTZ0A8VPD5B3RYqTIWPMF2WRV5ciZZ/2oZbHkdtWcGlL3SLVc+6UUedGEVCkNCbintS31hBHchXHNWsKv4CaAB99hkoNY/To/psqfeFLswPf88BHWADPszppRDfDcLCOWIvkonnDu8w9Qjrax60UAtDQivY/JBRQ38KbQ8yFmKqF1cztJdHO5RPIpuit7jJQVoXo4RlS/jVyibOUmDE/8wXy09MqH70tv2Mfn1L8ekvnwbQ+c7z2bmKLfjT9QKAr+odEezyiltwWnrKrhu7pRs7fYmU23z0126QHqUBUZ1pUv4JSFtm+6xHj0Q87p+MOVMGggmFra7TgSe68ukvw4N6UQ2FnnExgpwb409BJd--KDvIZdA2WAlc3RzM--Uvh/IZ9N3yMBLhfEQ5NXpA== \ No newline at end of file diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/database.yml b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environment.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environments/development.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environments/production.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environments/production.rb new file mode 100644 index 0000000..bd8910d --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "game_on_rails_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environments/test.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/application_controller_renderer.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/assets.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/backtrace_silencers.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/content_security_policy.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/cookies_serializer.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/filter_parameter_logging.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/inflections.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/mime_types.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/wrap_parameters.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/locales/en.yml b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/master.key b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/master.key new file mode 100644 index 0000000..e92c050 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/master.key @@ -0,0 +1 @@ +15e86bd380736ca268ccb0de2312cb71 \ No newline at end of file diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/puma.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/routes.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/routes.rb new file mode 100644 index 0000000..a9b5ea9 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/routes.rb @@ -0,0 +1,9 @@ +Rails.application.routes.draw do + root :to => 'pages#home' + get '/home' => 'pages#home' + get '/magicball' => 'magicball#form' + get '/magicball/result' => 'magicball#result' + get '/secretnumber' => 'secretnumber#form' + get '/secretnumber/result' => 'secretnumber#result' + get '/rockpaperscissors' => 'rockpaperscissors#form' +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/spring.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/storage.yml b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/db/development.sqlite3 b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/db/development.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/db/seeds.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/db/seeds.rb new file mode 100644 index 0000000..1beea2a --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/lib/assets/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/lib/tasks/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/package.json b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/package.json new file mode 100644 index 0000000..564a223 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/package.json @@ -0,0 +1,5 @@ +{ + "name": "game_on_rails", + "private": true, + "dependencies": {} +} diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/404.html b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/422.html b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/500.html b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/apple-touch-icon-precomposed.png b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/apple-touch-icon.png b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/favicon.ico b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/robots.txt b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/storage/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/application_system_test_case.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/controllers/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/fixtures/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/fixtures/files/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/helpers/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/integration/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/mailers/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/models/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/system/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/test_helper.rb b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/test_helper.rb new file mode 100644 index 0000000..3ab84e3 --- /dev/null +++ b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/vendor/.keep b/carol_liu/week_05/W1D1_gameOnRails/game_on_rails/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/.ruby-version b/carol_liu/week_05/W1D2_mountains/contour_system/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/Gemfile b/carol_liu/week_05/W1D2_mountains/contour_system/Gemfile new file mode 100644 index 0000000..6db9d99 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/Gemfile @@ -0,0 +1,51 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/Gemfile.lock b/carol_liu/week_05/W1D2_mountains/contour_system/Gemfile.lock new file mode 100644 index 0000000..a266a3b --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/Gemfile.lock @@ -0,0 +1,195 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/README.md b/carol_liu/week_05/W1D2_mountains/contour_system/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/Rakefile b/carol_liu/week_05/W1D2_mountains/contour_system/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/config/manifest.js b/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/images/.keep b/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/javascripts/application.js b/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/javascripts/application.js new file mode 100644 index 0000000..46b2035 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require turbolinks +//= require_tree . diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/stylesheets/application.css b/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/controllers/application_controller.rb b/carol_liu/week_05/W1D2_mountains/contour_system/app/controllers/application_controller.rb new file mode 100644 index 0000000..75f1154 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + skip_before_action :verify_authenticity_token +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/controllers/concerns/.keep b/carol_liu/week_05/W1D2_mountains/contour_system/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/controllers/mountains_controller.rb b/carol_liu/week_05/W1D2_mountains/contour_system/app/controllers/mountains_controller.rb new file mode 100644 index 0000000..1b37955 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/controllers/mountains_controller.rb @@ -0,0 +1,38 @@ +class MountainsController < ApplicationController + def index + @mountains = Mountain.all + end + + def show + @mountain = Mountain.find params[:id] + end + + def new + end + + def create + mountain = Mountain.create :name => params[:name], :image => params[:image], :height => params[:height], :range => params[:range], :first_ascent => params[:first_ascent] + redirect_to mountain_path(mountain.id) + end + + def edit + @mountain = Mountain.find params[:id] + end + + def update + mountain = Mountain.find params[:id] + mountain.name = params[:name] + mountain.image = params[:image] + mountain.height = params[:height] + mountain.range = params[:range] + mountain.first_ascent = params[:first_ascent] + mountain.save + redirect_to mountain_path(mountain.id) + end + + def delete + mountain = Mountain.find params[:id] + mountain.destroy + redirect_to mountains_path + end +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/helpers/application_helper.rb b/carol_liu/week_05/W1D2_mountains/contour_system/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/jobs/application_job.rb b/carol_liu/week_05/W1D2_mountains/contour_system/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/mailers/application_mailer.rb b/carol_liu/week_05/W1D2_mountains/contour_system/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/models/application_record.rb b/carol_liu/week_05/W1D2_mountains/contour_system/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/models/concerns/.keep b/carol_liu/week_05/W1D2_mountains/contour_system/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/models/mountain.rb b/carol_liu/week_05/W1D2_mountains/contour_system/app/models/mountain.rb new file mode 100644 index 0000000..df54b3f --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/models/mountain.rb @@ -0,0 +1,2 @@ +class Mountain < ActiveRecord::Base +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/views/layouts/application.html.erb b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/layouts/application.html.erb new file mode 100644 index 0000000..07ab7e5 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/layouts/application.html.erb @@ -0,0 +1,19 @@ + + + + ContourSystem + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + <%= yield %> + + diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/views/layouts/mailer.html.erb b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/views/layouts/mailer.text.erb b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/edit.html.erb b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/edit.html.erb new file mode 100644 index 0000000..482cd73 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/edit.html.erb @@ -0,0 +1,26 @@ +

Update Mountain

+ + +
+ + + + + + +
diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/index.html.erb b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/index.html.erb new file mode 100644 index 0000000..5db8140 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/index.html.erb @@ -0,0 +1,10 @@ +

All Mountains

+ +<% @mountains.each do |mountain| %> +

+ The height of + <%= link_to mountain.name, mountain_path(mountain.id) %> + is + <%= mountain.height %>m. +

+<% end %> diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/new.html.erb b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/new.html.erb new file mode 100644 index 0000000..18903c7 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/new.html.erb @@ -0,0 +1,26 @@ +

New Mountain

+ + +
+ + + + + + +
diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/show.html.erb b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/show.html.erb new file mode 100644 index 0000000..08174ae --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/app/views/mountains/show.html.erb @@ -0,0 +1,18 @@ +

<%= @mountain.name %>

+ +<%= image_tag @mountain.image, :class => 'feature' if @mountain.image.present? %> + + + + +
+ <%= link_to 'Edit mountain', edit_mountain_path(@mountain.id) %> + <%= button_to 'Delete mountain', mountain_path(@mountain.id), :method => 'delete' %> +
diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/bin/bundle b/carol_liu/week_05/W1D2_mountains/contour_system/bin/bundle new file mode 100644 index 0000000..f19acf5 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/bin/rails b/carol_liu/week_05/W1D2_mountains/contour_system/bin/rails new file mode 100644 index 0000000..5badb2f --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/bin/rake b/carol_liu/week_05/W1D2_mountains/contour_system/bin/rake new file mode 100644 index 0000000..d87d5f5 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/bin/setup b/carol_liu/week_05/W1D2_mountains/contour_system/bin/setup new file mode 100644 index 0000000..94fd4d7 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/bin/spring b/carol_liu/week_05/W1D2_mountains/contour_system/bin/spring new file mode 100644 index 0000000..d89ee49 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/bin/update b/carol_liu/week_05/W1D2_mountains/contour_system/bin/update new file mode 100644 index 0000000..58bfaed --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/bin/yarn b/carol_liu/week_05/W1D2_mountains/contour_system/bin/yarn new file mode 100644 index 0000000..460dd56 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config.ru b/carol_liu/week_05/W1D2_mountains/contour_system/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/application.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/application.rb new file mode 100644 index 0000000..6de5733 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module ContourSystem + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/boot.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/credentials.yml.enc b/carol_liu/week_05/W1D2_mountains/contour_system/config/credentials.yml.enc new file mode 100644 index 0000000..fe34354 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/credentials.yml.enc @@ -0,0 +1 @@ +fcqjsgOpRV5OB1plObLZYxPJi6rtCsCTqS6XqZ5RemSc6cBtc99Icfk1mf7zPgFLK+ySW3Lwaa5s6tgwufO2ksOmb+kVkxs1hY+PinCq0Ga4DNXOuVK1A5EJhzQNKM/nxA1w6ELK6xhzIq6Xr4s9oenMgDBCr2BgqOG/YxAB3sZX/vlGMOwMjtKb6ZoHuvQ0DtxWuZabhqpCuxTgdMNF2OxWDTqAKVFJHBTksQVKWhhR/tUGZVPUto0nFvmvPU4xrcdslGf3Pm6bz9IE4TccUSwq3YaVsyJwsxO2xauQRAkqkOLGX9dEb3qDF8rXTtG5u0vfgMiGxHanJ2kvTfZgBnbFIKB6OAyEDLmkfYRK6YIDzRi3vHPGmU2diIPRE1ZVJFhVRfCNOQmwDGwr3160MOCY87g56CjR8INr--tw8zUsPF2KClrFm4--icnLwld0PSgr+ARs4kl8aw== \ No newline at end of file diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/database.yml b/carol_liu/week_05/W1D2_mountains/contour_system/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/environment.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/environments/development.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/environments/development.rb new file mode 100644 index 0000000..92bfc1d --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/environments/development.rb @@ -0,0 +1,58 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/environments/production.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/environments/production.rb new file mode 100644 index 0000000..c122a1e --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/environments/production.rb @@ -0,0 +1,86 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "contour_system_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/environments/test.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/environments/test.rb new file mode 100644 index 0000000..b08fc84 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/environments/test.rb @@ -0,0 +1,43 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/application_controller_renderer.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/assets.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/backtrace_silencers.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/content_security_policy.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/cookies_serializer.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/filter_parameter_logging.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/inflections.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/mime_types.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/wrap_parameters.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/locales/en.yml b/carol_liu/week_05/W1D2_mountains/contour_system/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/master.key b/carol_liu/week_05/W1D2_mountains/contour_system/config/master.key new file mode 100644 index 0000000..8af988a --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/master.key @@ -0,0 +1 @@ +05b0ea8921228143b42442a63e23f6d6 \ No newline at end of file diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/puma.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/routes.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/routes.rb new file mode 100644 index 0000000..a1affc2 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/routes.rb @@ -0,0 +1,10 @@ +Rails.application.routes.draw do + get '/' => 'mountains#index' + get '/mountains' => 'mountains#index' + get '/mountains/new' => 'mountains#new', :as => 'new_mountain' + post '/mountains' => 'mountains#create' + get '/mountains/:id' => 'mountains#show', :as => 'mountain' + get '/mountains/:id/edit' => 'mountains#edit', :as => 'edit_mountain' + post '/mountains/:id' => 'mountains#update' + delete '/mountains/:id' => 'mountains#delete' +end diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/config/spring.rb b/carol_liu/week_05/W1D2_mountains/contour_system/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/db/create_mountains.sql b/carol_liu/week_05/W1D2_mountains/contour_system/db/create_mountains.sql new file mode 100644 index 0000000..2ad0ec9 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/db/create_mountains.sql @@ -0,0 +1,8 @@ +CREATE TABLE mountains ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + image TEXT, + height FLOAT, + range TEXT, + first_ascent TEXT +); diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/db/development.sqlite3 b/carol_liu/week_05/W1D2_mountains/contour_system/db/development.sqlite3 new file mode 100644 index 0000000..1c57a92 Binary files /dev/null and b/carol_liu/week_05/W1D2_mountains/contour_system/db/development.sqlite3 differ diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/db/seeds.rb b/carol_liu/week_05/W1D2_mountains/contour_system/db/seeds.rb new file mode 100644 index 0000000..b68725c --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/db/seeds.rb @@ -0,0 +1,5 @@ +Mountain.destroy_all + +Mountain.create :name => 'Mount Everest/Sagarmatha/Chomolungma', :height => 8848, :range => 'Mahalangur Himalaya', :first_ascent => '1953' +Mountain.create :name => 'K2', :height => 8611, :range => 'Baltoro Karakoram', :first_ascent => '1954' +Mountain.create :name => 'Kangchenjunga', :height => 8586, :range => 'Kangchenjunga Himalaya', :first_ascent => '1955' diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/db/test.sqlite3 b/carol_liu/week_05/W1D2_mountains/contour_system/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/lib/assets/.keep b/carol_liu/week_05/W1D2_mountains/contour_system/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/lib/tasks/.keep b/carol_liu/week_05/W1D2_mountains/contour_system/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/package.json b/carol_liu/week_05/W1D2_mountains/contour_system/package.json new file mode 100644 index 0000000..74a0db9 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/package.json @@ -0,0 +1,5 @@ +{ + "name": "contour_system", + "private": true, + "dependencies": {} +} diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/public/404.html b/carol_liu/week_05/W1D2_mountains/contour_system/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/public/422.html b/carol_liu/week_05/W1D2_mountains/contour_system/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/public/500.html b/carol_liu/week_05/W1D2_mountains/contour_system/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/public/apple-touch-icon-precomposed.png b/carol_liu/week_05/W1D2_mountains/contour_system/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/public/apple-touch-icon.png b/carol_liu/week_05/W1D2_mountains/contour_system/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/public/favicon.ico b/carol_liu/week_05/W1D2_mountains/contour_system/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/public/robots.txt b/carol_liu/week_05/W1D2_mountains/contour_system/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/carol_liu/week_05/W1D2_mountains/contour_system/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/carol_liu/week_05/W1D2_mountains/contour_system/vendor/.keep b/carol_liu/week_05/W1D2_mountains/contour_system/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/travel_app/.ruby-version b/carol_liu/week_05/travel_app/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/carol_liu/week_05/travel_app/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/carol_liu/week_05/travel_app/Gemfile b/carol_liu/week_05/travel_app/Gemfile new file mode 100644 index 0000000..6db9d99 --- /dev/null +++ b/carol_liu/week_05/travel_app/Gemfile @@ -0,0 +1,51 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/carol_liu/week_05/travel_app/Gemfile.lock b/carol_liu/week_05/travel_app/Gemfile.lock new file mode 100644 index 0000000..b99a956 --- /dev/null +++ b/carol_liu/week_05/travel_app/Gemfile.lock @@ -0,0 +1,195 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.6.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/carol_liu/week_05/travel_app/README.md b/carol_liu/week_05/travel_app/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/carol_liu/week_05/travel_app/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/carol_liu/week_05/travel_app/Rakefile b/carol_liu/week_05/travel_app/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/carol_liu/week_05/travel_app/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/carol_liu/week_05/travel_app/app/assets/config/manifest.js b/carol_liu/week_05/travel_app/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/carol_liu/week_05/travel_app/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/carol_liu/week_05/travel_app/app/assets/images/.keep b/carol_liu/week_05/travel_app/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/travel_app/app/assets/javascripts/application.js b/carol_liu/week_05/travel_app/app/assets/javascripts/application.js new file mode 100644 index 0000000..46b2035 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require turbolinks +//= require_tree . diff --git a/carol_liu/week_05/travel_app/app/assets/javascripts/countries.coffee b/carol_liu/week_05/travel_app/app/assets/javascripts/countries.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/assets/javascripts/countries.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/carol_liu/week_05/travel_app/app/assets/javascripts/places.coffee b/carol_liu/week_05/travel_app/app/assets/javascripts/places.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/assets/javascripts/places.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/carol_liu/week_05/travel_app/app/assets/stylesheets/application.css b/carol_liu/week_05/travel_app/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/carol_liu/week_05/travel_app/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/carol_liu/week_05/travel_app/app/assets/stylesheets/countries.scss b/carol_liu/week_05/travel_app/app/assets/stylesheets/countries.scss new file mode 100644 index 0000000..09db457 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/assets/stylesheets/countries.scss @@ -0,0 +1,11 @@ +body { + background-color: #ccd; +} + +.thumb { + height: 12em; +} + +.feature { + max-height: 30em; +} diff --git a/carol_liu/week_05/travel_app/app/assets/stylesheets/places.scss b/carol_liu/week_05/travel_app/app/assets/stylesheets/places.scss new file mode 100644 index 0000000..09db457 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/assets/stylesheets/places.scss @@ -0,0 +1,11 @@ +body { + background-color: #ccd; +} + +.thumb { + height: 12em; +} + +.feature { + max-height: 30em; +} diff --git a/carol_liu/week_05/travel_app/app/controllers/application_controller.rb b/carol_liu/week_05/travel_app/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/carol_liu/week_05/travel_app/app/controllers/concerns/.keep b/carol_liu/week_05/travel_app/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/travel_app/app/controllers/countries_controller.rb b/carol_liu/week_05/travel_app/app/controllers/countries_controller.rb new file mode 100644 index 0000000..ed48cda --- /dev/null +++ b/carol_liu/week_05/travel_app/app/controllers/countries_controller.rb @@ -0,0 +1,39 @@ +class CountriesController < ApplicationController + def index + @countries = Country.all + end + + def new + @country = Country.new + end + + def create + country = Country.create country_params + redirect_to country + end + + def edit + @country = Country.find params[:id] + end + + def update + country = Country.find params[:id] + country.update country_params + redirect_to country + end + + def show + @country = Country.find params[:id] + end + + def destroy + country = Country.find params[:id] + country.destroy + redirect_to countries_path + end + + private + def country_params + params.require(:country).permit(:name, :capital, :official_language, :area_in_sqkm, :population, :flag) + end +end diff --git a/carol_liu/week_05/travel_app/app/controllers/places_controller.rb b/carol_liu/week_05/travel_app/app/controllers/places_controller.rb new file mode 100644 index 0000000..3710c17 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/controllers/places_controller.rb @@ -0,0 +1,39 @@ +class PlacesController < ApplicationController + def index + @places = Place.all + end + + def new + @place = Place.new + end + + def create + place = Place.create place_params + redirect_to place + end + + def edit + @place = Place.find params[:id] + end + + def update + place = Place.find params[:id] + place.update place_params + redirect_to place + end + + def show + @place = Place.find params[:id] + end + + def destroy + place = Place.find params[:id] + place.destroy + redirect_to places_path + end + + private + def place_params + params.require(:place).permit(:name, :region, :feature, :period, :altitude_in_m, :image, :country_id) + end +end diff --git a/carol_liu/week_05/travel_app/app/helpers/application_helper.rb b/carol_liu/week_05/travel_app/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/carol_liu/week_05/travel_app/app/helpers/countries_helper.rb b/carol_liu/week_05/travel_app/app/helpers/countries_helper.rb new file mode 100644 index 0000000..b8a3171 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/helpers/countries_helper.rb @@ -0,0 +1,2 @@ +module CountriesHelper +end diff --git a/carol_liu/week_05/travel_app/app/helpers/places_helper.rb b/carol_liu/week_05/travel_app/app/helpers/places_helper.rb new file mode 100644 index 0000000..7d8d0ac --- /dev/null +++ b/carol_liu/week_05/travel_app/app/helpers/places_helper.rb @@ -0,0 +1,2 @@ +module PlacesHelper +end diff --git a/carol_liu/week_05/travel_app/app/jobs/application_job.rb b/carol_liu/week_05/travel_app/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/carol_liu/week_05/travel_app/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/carol_liu/week_05/travel_app/app/mailers/application_mailer.rb b/carol_liu/week_05/travel_app/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/carol_liu/week_05/travel_app/app/models/application_record.rb b/carol_liu/week_05/travel_app/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/carol_liu/week_05/travel_app/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/carol_liu/week_05/travel_app/app/models/concerns/.keep b/carol_liu/week_05/travel_app/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/travel_app/app/models/country.rb b/carol_liu/week_05/travel_app/app/models/country.rb new file mode 100644 index 0000000..c319680 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/models/country.rb @@ -0,0 +1,3 @@ +class Country < ActiveRecord::Base + has_many :places +end diff --git a/carol_liu/week_05/travel_app/app/models/place.rb b/carol_liu/week_05/travel_app/app/models/place.rb new file mode 100644 index 0000000..e08cda5 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/models/place.rb @@ -0,0 +1,3 @@ +class Place < ActiveRecord::Base + belongs_to :country, :optional => true +end diff --git a/carol_liu/week_05/travel_app/app/views/countries/_form.html.erb b/carol_liu/week_05/travel_app/app/views/countries/_form.html.erb new file mode 100644 index 0000000..f508637 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/countries/_form.html.erb @@ -0,0 +1,16 @@ +<%= form_for @country do |f| %> + <%= f.label :name %> + <%= f.text_field :name, :required => true, :autofocus => true %> + <%= f.label :capital %> + <%= f.text_field :capital %> + <%= f.label :official_language %> + <%= f.text_field :official_language %> + <%= f.label :area_in_sqkm, 'Area(sqkm)' %> + <%= f.text_field :area_in_sqkm, :placeholder => '232,493,343'%> + <%= f.label :population %> + <%= f.text_field :population, :placeholder => '232,493,343'%> + <%= f.label :flag %> + <%= f.url_field :flag, :placeholder =>'http://...'%> + + <%= f.submit %> +<% end %> diff --git a/carol_liu/week_05/travel_app/app/views/countries/edit.html.erb b/carol_liu/week_05/travel_app/app/views/countries/edit.html.erb new file mode 100644 index 0000000..eb82553 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/countries/edit.html.erb @@ -0,0 +1,3 @@ +

Edit Country

+ +<%= render :partial => 'form' %> diff --git a/carol_liu/week_05/travel_app/app/views/countries/index.html.erb b/carol_liu/week_05/travel_app/app/views/countries/index.html.erb new file mode 100644 index 0000000..4193ae0 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/countries/index.html.erb @@ -0,0 +1,11 @@ +

All Countries

+<% @countries.each do |country| %> + <%= image_tag country.flag, :class => 'thumb' if country.flag.present? %> + +<% end %> diff --git a/carol_liu/week_05/travel_app/app/views/countries/new.html.erb b/carol_liu/week_05/travel_app/app/views/countries/new.html.erb new file mode 100644 index 0000000..590ee5d --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/countries/new.html.erb @@ -0,0 +1,2 @@ +

New Country

+<%= render :partial => 'form' %> diff --git a/carol_liu/week_05/travel_app/app/views/countries/show.html.erb b/carol_liu/week_05/travel_app/app/views/countries/show.html.erb new file mode 100644 index 0000000..6bfee45 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/countries/show.html.erb @@ -0,0 +1,18 @@ +

<%= @country.name %>

+<%= image_tag @country.flag, :class => 'feature' if @country.flag.present? %> + + +<% @country.places.each do |place| %> + <%= link_to image_tag(place.image, :class => 'thumb'), place %> +<% end %> + +
+ <%= link_to 'Edit Country', edit_country_path(@country) %> + <%= button_to 'Delete Country', @country, :method => 'delete' %> +
diff --git a/carol_liu/week_05/travel_app/app/views/layouts/application.html.erb b/carol_liu/week_05/travel_app/app/views/layouts/application.html.erb new file mode 100644 index 0000000..6f49064 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/layouts/application.html.erb @@ -0,0 +1,22 @@ + + + + TravelApp + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + <%= yield %> + + diff --git a/carol_liu/week_05/travel_app/app/views/layouts/mailer.html.erb b/carol_liu/week_05/travel_app/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/carol_liu/week_05/travel_app/app/views/layouts/mailer.text.erb b/carol_liu/week_05/travel_app/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/carol_liu/week_05/travel_app/app/views/places/_form.html.erb b/carol_liu/week_05/travel_app/app/views/places/_form.html.erb new file mode 100644 index 0000000..61c160e --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/places/_form.html.erb @@ -0,0 +1,18 @@ +<%= form_for @place do |f| %> + <%= f.label :name %> + <%= f.text_field :name, :required => true, :autofocus => true %> + <%= f.label :region %> + <%= f.text_field :region %> + <%= f.label :feature %> + <%= f.text_field :feature %> + <%= f.label :period %> + <%= f.text_field :period %> + <%= f.label :altitude_in_m, 'Altitude(m)' %> + <%= f.text_field :altitude_in_m, :placeholder => '3,343'%> + <%= f.label :image %> + <%= f.url_field :image, :placeholder =>'http://...'%> + <%= f.label :country %> + <%= f.select :country_id, Country.pluck(:name, :id), :include_blank => true %> + + <%= f.submit %> +<% end %> diff --git a/carol_liu/week_05/travel_app/app/views/places/edit.html.erb b/carol_liu/week_05/travel_app/app/views/places/edit.html.erb new file mode 100644 index 0000000..001424f --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/places/edit.html.erb @@ -0,0 +1,2 @@ +

Edit Places

+<%= render :partial => 'form' %> diff --git a/carol_liu/week_05/travel_app/app/views/places/index.html.erb b/carol_liu/week_05/travel_app/app/views/places/index.html.erb new file mode 100644 index 0000000..6c71bfc --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/places/index.html.erb @@ -0,0 +1,11 @@ +

All Places

+<% @places.each do |place| %> + <%= image_tag place.image, :class =>'thumb' if place.image.present? %> + +<% end %> diff --git a/carol_liu/week_05/travel_app/app/views/places/new.html.erb b/carol_liu/week_05/travel_app/app/views/places/new.html.erb new file mode 100644 index 0000000..57f9305 --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/places/new.html.erb @@ -0,0 +1,2 @@ +

New Places

+<%= render :partial => 'form' %> diff --git a/carol_liu/week_05/travel_app/app/views/places/show.html.erb b/carol_liu/week_05/travel_app/app/views/places/show.html.erb new file mode 100644 index 0000000..f38d8cd --- /dev/null +++ b/carol_liu/week_05/travel_app/app/views/places/show.html.erb @@ -0,0 +1,17 @@ +

<%= @place.name %>

+<%= image_tag @place.image, :class =>'feature' if @place.image.present? %> + + +
+ <%= link_to 'Edit Place', edit_place_path(@place) %> + <%= button_to 'Delete Place', @place, :method => 'delete' %> +
diff --git a/carol_liu/week_05/travel_app/bin/bundle b/carol_liu/week_05/travel_app/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/carol_liu/week_05/travel_app/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/carol_liu/week_05/travel_app/bin/rails b/carol_liu/week_05/travel_app/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/carol_liu/week_05/travel_app/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/carol_liu/week_05/travel_app/bin/rake b/carol_liu/week_05/travel_app/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/carol_liu/week_05/travel_app/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/carol_liu/week_05/travel_app/bin/setup b/carol_liu/week_05/travel_app/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/carol_liu/week_05/travel_app/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/carol_liu/week_05/travel_app/bin/spring b/carol_liu/week_05/travel_app/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/carol_liu/week_05/travel_app/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/carol_liu/week_05/travel_app/bin/update b/carol_liu/week_05/travel_app/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/carol_liu/week_05/travel_app/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/carol_liu/week_05/travel_app/bin/yarn b/carol_liu/week_05/travel_app/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/carol_liu/week_05/travel_app/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/carol_liu/week_05/travel_app/config.ru b/carol_liu/week_05/travel_app/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/carol_liu/week_05/travel_app/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/carol_liu/week_05/travel_app/config/application.rb b/carol_liu/week_05/travel_app/config/application.rb new file mode 100644 index 0000000..1e7eeb1 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module TravelApp + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/carol_liu/week_05/travel_app/config/boot.rb b/carol_liu/week_05/travel_app/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/carol_liu/week_05/travel_app/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/carol_liu/week_05/travel_app/config/credentials.yml.enc b/carol_liu/week_05/travel_app/config/credentials.yml.enc new file mode 100644 index 0000000..4cb8358 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/credentials.yml.enc @@ -0,0 +1 @@ +7slpakm8Dn9pN9OBicbGV/0Tp1D1sPG5jJiomOoTZ1P7MuOJb1YwBCWh2V3giX14QsEclCvX5jn6UARK/svBjEVNrHqVBh7oteKnMjYgcxPkgxDnnofP3ZkZa+EF6QjriwZn6zRBEde9q2slZswu7TbcqXZLEfZpC0jd5ANVse53Dbi03SvaKYGlQ02aXjs/JgE+vSnRP7NuA5wlcJAJ4Ryz0AIi6ZtIhfhFpqjEA9Vy8PSF01UcxrPNjZWCayEj88KazAJII/n/JShS2eYxomyNHBpgki3pfGMp0fdn+cRxwimKigJDeRVBMxVCa3gJ7BAM3J3nFlOYrjGtFOQimFenckDOi4eo6Uhevowuje+mjKjsASnScowggdlg7laOy8QXqI41iPj5lPJc1/C0M3fdvDQP713gc9E4--6yswVdAvVDDw4vyD--cYWV9PM+dyzjRzzzIqN2Tw== \ No newline at end of file diff --git a/carol_liu/week_05/travel_app/config/database.yml b/carol_liu/week_05/travel_app/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/carol_liu/week_05/travel_app/config/environment.rb b/carol_liu/week_05/travel_app/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/carol_liu/week_05/travel_app/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/carol_liu/week_05/travel_app/config/environments/development.rb b/carol_liu/week_05/travel_app/config/environments/development.rb new file mode 100644 index 0000000..92bfc1d --- /dev/null +++ b/carol_liu/week_05/travel_app/config/environments/development.rb @@ -0,0 +1,58 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/carol_liu/week_05/travel_app/config/environments/production.rb b/carol_liu/week_05/travel_app/config/environments/production.rb new file mode 100644 index 0000000..d9579f0 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/environments/production.rb @@ -0,0 +1,86 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "travel_app_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/carol_liu/week_05/travel_app/config/environments/test.rb b/carol_liu/week_05/travel_app/config/environments/test.rb new file mode 100644 index 0000000..b08fc84 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/environments/test.rb @@ -0,0 +1,43 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/carol_liu/week_05/travel_app/config/initializers/application_controller_renderer.rb b/carol_liu/week_05/travel_app/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/carol_liu/week_05/travel_app/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/carol_liu/week_05/travel_app/config/initializers/assets.rb b/carol_liu/week_05/travel_app/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/carol_liu/week_05/travel_app/config/initializers/backtrace_silencers.rb b/carol_liu/week_05/travel_app/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/carol_liu/week_05/travel_app/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/carol_liu/week_05/travel_app/config/initializers/content_security_policy.rb b/carol_liu/week_05/travel_app/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/carol_liu/week_05/travel_app/config/initializers/cookies_serializer.rb b/carol_liu/week_05/travel_app/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/carol_liu/week_05/travel_app/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/carol_liu/week_05/travel_app/config/initializers/filter_parameter_logging.rb b/carol_liu/week_05/travel_app/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/carol_liu/week_05/travel_app/config/initializers/inflections.rb b/carol_liu/week_05/travel_app/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/carol_liu/week_05/travel_app/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/carol_liu/week_05/travel_app/config/initializers/mime_types.rb b/carol_liu/week_05/travel_app/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/carol_liu/week_05/travel_app/config/initializers/wrap_parameters.rb b/carol_liu/week_05/travel_app/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/carol_liu/week_05/travel_app/config/locales/en.yml b/carol_liu/week_05/travel_app/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/carol_liu/week_05/travel_app/config/master.key b/carol_liu/week_05/travel_app/config/master.key new file mode 100644 index 0000000..936e4ba --- /dev/null +++ b/carol_liu/week_05/travel_app/config/master.key @@ -0,0 +1 @@ +49d5fedbf9a2f6a9604cf96c1545e9e9 \ No newline at end of file diff --git a/carol_liu/week_05/travel_app/config/puma.rb b/carol_liu/week_05/travel_app/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/carol_liu/week_05/travel_app/config/routes.rb b/carol_liu/week_05/travel_app/config/routes.rb new file mode 100644 index 0000000..260fd0b --- /dev/null +++ b/carol_liu/week_05/travel_app/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + resources :countries + resources :places +end diff --git a/carol_liu/week_05/travel_app/config/spring.rb b/carol_liu/week_05/travel_app/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/carol_liu/week_05/travel_app/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/carol_liu/week_05/travel_app/database_info b/carol_liu/week_05/travel_app/database_info new file mode 100644 index 0000000..18c60c7 --- /dev/null +++ b/carol_liu/week_05/travel_app/database_info @@ -0,0 +1,33 @@ +create_table :countries do |t| + t.text :name + t.text :capital + t.text :official_language + t.text :area_in_sqkm + t.text :population + t.text :flag +end + +create_table :places do |t| + t.text :name + t.text :region + t.text :type + t.text :period + t.text :altitude_in_m + t.text :image +end + + +Country.destroy_all +Country.create(:name => 'Republic of Peru', :capital => 'Lima', :official_language =>'Spanish', :area_in_sqkm => '1,285,216', :population => '32,824,358', :flag => 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Flag_of_Peru_%28state%29.svg/1920px-Flag_of_Peru_%28state%29.svg.png') +Country.create(:name => 'Republic of Chile', :capital => 'Santiago', :official_language =>'Spanish', :area_in_sqkm => '756,096.3', :population => '17,574,003', :flag => 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/78/Flag_of_Chile.svg/1920px-Flag_of_Chile.svg.png') +Country.create(:name => 'Plurinational State of Bolivia', :capital => 'Sucre', :official_language =>'Spanish', :area_in_sqkm => '1,098,581', :population => '11,469,896', :flag => 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/Bandera_de_Bolivia_%28Estado%29.svg/1920px-Bandera_de_Bolivia_%28Estado%29.svg.png') +Country.create(:name => 'Federative Republic of Brazil', :capital => 'Brasilia', :official_language =>'Portuguese', :area_in_sqkm => '8,515,767', :population => '210,147,125', :flag => 'https://upload.wikimedia.org/wikipedia/en/thumb/0/05/Flag_of_Brazil.svg/1920px-Flag_of_Brazil.svg.png') +Country.create(:name => 'United States of America', :capital => 'Washington, D.C.', :official_language =>'English', :area_in_sqkm => '9,833,520', :population => '308,745,538', :flag => 'https://upload.wikimedia.org/wikipedia/en/thumb/a/a4/Flag_of_the_United_States.svg/1920px-Flag_of_the_United_States.svg.png') + + +Place.destroy_all +Place.create(:name => 'Salar de Uyuni', :region => 'southwest Bolivia', :type => 'Nature', :period => 'unknown', :altitude_in_m => '3,663', :image => 'https://upload.wikimedia.org/wikipedia/commons/4/4a/Salar_Uyuni_au01.jpg') +Place.create(:name => 'Machu Picchu', :region => 'Cusco', :type => 'Inca civilization', :period => '15th century', :altitude_in_m => '2,430', :image => 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/80_-_Machu_Picchu_-_Juin_2009_-_edit.2.jpg/600px-80_-_Machu_Picchu_-_Juin_2009_-_edit.2.jpg') +Place.create(:name => 'Christ the Redeemer', :region => 'Rio de Janeiro', :type => 'Modern/Nature', :period => '1931', :altitude_in_m => '710', :image => 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Aerial_view_of_the_Statue_of_Christ_the_Redeemer.jpg/440px-Aerial_view_of_the_Statue_of_Christ_the_Redeemer.jpg') + +Place.create(:name => 'Flida Kahlo Museum', :region => 'Mexico City', :type => 'Art', :period => '1920s', :altitude_in_m => '2,250', :image => 'https://www.museeum.com/wp-content/uploads/2018/05/hero_JULIO_Semana-de-Frida_MAIN-3.jpg') diff --git a/carol_liu/week_05/travel_app/db/development.sqlite3 b/carol_liu/week_05/travel_app/db/development.sqlite3 new file mode 100644 index 0000000..d7e119a Binary files /dev/null and b/carol_liu/week_05/travel_app/db/development.sqlite3 differ diff --git a/carol_liu/week_05/travel_app/db/migrate/20200617103123_create_countries.rb b/carol_liu/week_05/travel_app/db/migrate/20200617103123_create_countries.rb new file mode 100644 index 0000000..310cf62 --- /dev/null +++ b/carol_liu/week_05/travel_app/db/migrate/20200617103123_create_countries.rb @@ -0,0 +1,12 @@ +class CreateCountries < ActiveRecord::Migration[5.2] + def change + create_table :countries do |t| + t.text :name + t.text :capital + t.text :official_language + t.text :area_in_sqkm + t.text :population + t.text :flag + end + end +end diff --git a/carol_liu/week_05/travel_app/db/migrate/20200617103130_create_places.rb b/carol_liu/week_05/travel_app/db/migrate/20200617103130_create_places.rb new file mode 100644 index 0000000..ae5fe97 --- /dev/null +++ b/carol_liu/week_05/travel_app/db/migrate/20200617103130_create_places.rb @@ -0,0 +1,12 @@ +class CreatePlaces < ActiveRecord::Migration[5.2] + def change + create_table :places do |t| + t.text :name + t.text :region + t.text :feature + t.text :period + t.text :altitude_in_m + t.text :image + end + end +end diff --git a/carol_liu/week_05/travel_app/db/migrate/20200617131922_add_country_id_to_places.rb b/carol_liu/week_05/travel_app/db/migrate/20200617131922_add_country_id_to_places.rb new file mode 100644 index 0000000..ee4b34d --- /dev/null +++ b/carol_liu/week_05/travel_app/db/migrate/20200617131922_add_country_id_to_places.rb @@ -0,0 +1,5 @@ +class AddCountryIdToPlaces < ActiveRecord::Migration[5.2] + def change + add_column :places, :country_id, :integer + end +end diff --git a/carol_liu/week_05/travel_app/db/schema.rb b/carol_liu/week_05/travel_app/db/schema.rb new file mode 100644 index 0000000..3a27a6f --- /dev/null +++ b/carol_liu/week_05/travel_app/db/schema.rb @@ -0,0 +1,34 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_17_131922) do + + create_table "countries", force: :cascade do |t| + t.text "name" + t.text "capital" + t.text "official_language" + t.text "area_in_sqkm" + t.text "population" + t.text "flag" + end + + create_table "places", force: :cascade do |t| + t.text "name" + t.text "region" + t.text "feature" + t.text "period" + t.text "altitude_in_m" + t.text "image" + t.integer "country_id" + end + +end diff --git a/carol_liu/week_05/travel_app/db/seeds.rb b/carol_liu/week_05/travel_app/db/seeds.rb new file mode 100644 index 0000000..f70f6a6 --- /dev/null +++ b/carol_liu/week_05/travel_app/db/seeds.rb @@ -0,0 +1,14 @@ +Country.destroy_all +Country.create(:name => 'Republic of Peru', :capital => 'Lima', :official_language =>'Spanish', :area_in_sqkm => '1,285,216', :population => '32,824,358', :flag => 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Flag_of_Peru_%28state%29.svg/1920px-Flag_of_Peru_%28state%29.svg.png') +Country.create(:name => 'Republic of Chile', :capital => 'Santiago', :official_language =>'Spanish', :area_in_sqkm => '756,096.3', :population => '17,574,003', :flag => 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/78/Flag_of_Chile.svg/1920px-Flag_of_Chile.svg.png') +Country.create(:name => 'Plurinational State of Bolivia', :capital => 'Sucre', :official_language =>'Spanish', :area_in_sqkm => '1,098,581', :population => '11,469,896', :flag => 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/Bandera_de_Bolivia_%28Estado%29.svg/1920px-Bandera_de_Bolivia_%28Estado%29.svg.png') +Country.create(:name => 'Federative Republic of Brazil', :capital => 'Brasilia', :official_language =>'Portuguese', :area_in_sqkm => '8,515,767', :population => '210,147,125', :flag => 'https://upload.wikimedia.org/wikipedia/en/thumb/0/05/Flag_of_Brazil.svg/1920px-Flag_of_Brazil.svg.png') +Country.create(:name => 'United States of America', :capital => 'Washington, D.C.', :official_language =>'English', :area_in_sqkm => '9,833,520', :population => '308,745,538', :flag => 'https://upload.wikimedia.org/wikipedia/en/thumb/a/a4/Flag_of_the_United_States.svg/1920px-Flag_of_the_United_States.svg.png') +puts "#{ Country.count } works created." + +Place.destroy_all +Place.create(:name => 'Salar de Uyuni', :region => 'southwest Bolivia', :feature => 'National Park', :period => 'unknown', :altitude_in_m => '3,663', :image => 'https://upload.wikimedia.org/wikipedia/commons/4/4a/Salar_Uyuni_au01.jpg') +Place.create(:name => 'Machu Picchu', :region => 'Cusco', :feature => 'Inca civilization', :period => '15th century', :altitude_in_m => '2,430', :image => 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/80_-_Machu_Picchu_-_Juin_2009_-_edit.2.jpg/600px-80_-_Machu_Picchu_-_Juin_2009_-_edit.2.jpg') +Place.create(:name => 'Christ the Redeemer', :region => 'Rio de Janeiro', :feature => 'Modern/Park', :period => '1931', :altitude_in_m => '710', :image => 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Aerial_view_of_the_Statue_of_Christ_the_Redeemer.jpg/440px-Aerial_view_of_the_Statue_of_Christ_the_Redeemer.jpg') +Place.create(:name => 'Flida Kahlo Museum', :region => 'Mexico City', :feature => 'Art', :period => '1920s', :altitude_in_m => '2,250', :image => 'https://www.museeum.com/wp-content/uploads/2018/05/hero_JULIO_Semana-de-Frida_MAIN-3.jpg') +puts "#{ Place.count } works created." diff --git a/carol_liu/week_05/travel_app/db/test.sqlite3 b/carol_liu/week_05/travel_app/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/travel_app/lib/assets/.keep b/carol_liu/week_05/travel_app/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/travel_app/lib/tasks/.keep b/carol_liu/week_05/travel_app/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/travel_app/package.json b/carol_liu/week_05/travel_app/package.json new file mode 100644 index 0000000..d8234d0 --- /dev/null +++ b/carol_liu/week_05/travel_app/package.json @@ -0,0 +1,5 @@ +{ + "name": "travel_app", + "private": true, + "dependencies": {} +} diff --git a/carol_liu/week_05/travel_app/public/404.html b/carol_liu/week_05/travel_app/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/carol_liu/week_05/travel_app/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/carol_liu/week_05/travel_app/public/422.html b/carol_liu/week_05/travel_app/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/carol_liu/week_05/travel_app/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/carol_liu/week_05/travel_app/public/500.html b/carol_liu/week_05/travel_app/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/carol_liu/week_05/travel_app/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/carol_liu/week_05/travel_app/public/apple-touch-icon-precomposed.png b/carol_liu/week_05/travel_app/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/travel_app/public/apple-touch-icon.png b/carol_liu/week_05/travel_app/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/travel_app/public/favicon.ico b/carol_liu/week_05/travel_app/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/carol_liu/week_05/travel_app/public/robots.txt b/carol_liu/week_05/travel_app/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/carol_liu/week_05/travel_app/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/carol_liu/week_05/travel_app/vendor/.keep b/carol_liu/week_05/travel_app/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cesar_sanchez/week05/monopoly_db/.ruby-version b/cesar_sanchez/week05/monopoly_db/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/cesar_sanchez/week05/monopoly_db/Gemfile b/cesar_sanchez/week05/monopoly_db/Gemfile new file mode 100644 index 0000000..2792f24 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/Gemfile @@ -0,0 +1,51 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/cesar_sanchez/week05/monopoly_db/Gemfile.lock b/cesar_sanchez/week05/monopoly_db/Gemfile.lock new file mode 100644 index 0000000..6d1fe69 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/Gemfile.lock @@ -0,0 +1,199 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/cesar_sanchez/week05/monopoly_db/README.md b/cesar_sanchez/week05/monopoly_db/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/cesar_sanchez/week05/monopoly_db/Rakefile b/cesar_sanchez/week05/monopoly_db/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/cesar_sanchez/week05/monopoly_db/app/assets/config/manifest.js b/cesar_sanchez/week05/monopoly_db/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/cesar_sanchez/week05/monopoly_db/app/assets/images/.keep b/cesar_sanchez/week05/monopoly_db/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cesar_sanchez/week05/monopoly_db/app/assets/javascripts/application.js b/cesar_sanchez/week05/monopoly_db/app/assets/javascripts/application.js new file mode 100644 index 0000000..46b2035 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require turbolinks +//= require_tree . diff --git a/cesar_sanchez/week05/monopoly_db/app/assets/stylesheets/application.css b/cesar_sanchez/week05/monopoly_db/app/assets/stylesheets/application.css new file mode 100644 index 0000000..5808c48 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/assets/stylesheets/application.css @@ -0,0 +1,26 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ + + +.container { + max-width: 960px; + margin: 0 auto; +} + +img { + max-width: 50% + +} diff --git a/cesar_sanchez/week05/monopoly_db/app/controllers/application_controller.rb b/cesar_sanchez/week05/monopoly_db/app/controllers/application_controller.rb new file mode 100644 index 0000000..3e1b725 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + skip_before_action :verify_authenticity_token #You only need this for handwritten forms +end diff --git a/cesar_sanchez/week05/monopoly_db/app/controllers/concerns/.keep b/cesar_sanchez/week05/monopoly_db/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cesar_sanchez/week05/monopoly_db/app/controllers/properties_controller.rb b/cesar_sanchez/week05/monopoly_db/app/controllers/properties_controller.rb new file mode 100644 index 0000000..147d802 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/controllers/properties_controller.rb @@ -0,0 +1,37 @@ +class PropertiesController < ApplicationController + def index + @properties = Property.all + end + + def show + @property = Property.find params[:id] + end + + def buy + end + + def create + property = Property.create :name => params[:name], :image => params[:image], :monopoly => params[:monopoly], :rent => params[:rent] + redirect_to property_path(property.id) #show + end + + def edit + @property = Property.find params[:id] + end + + def update + property = Property.find params[:id] + property.name = params[:name] + property.image = params[:image] + property.monopoly = params[:monopoly] + property.rent = params[:rent] + property.save + redirect_to property_path(property.id) + end + + def destroy + property = Property.find params[:id] + property.destroy + redirect_to property_path + end +end diff --git a/cesar_sanchez/week05/monopoly_db/app/helpers/application_helper.rb b/cesar_sanchez/week05/monopoly_db/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/cesar_sanchez/week05/monopoly_db/app/jobs/application_job.rb b/cesar_sanchez/week05/monopoly_db/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/cesar_sanchez/week05/monopoly_db/app/mailers/application_mailer.rb b/cesar_sanchez/week05/monopoly_db/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/cesar_sanchez/week05/monopoly_db/app/models/application_record.rb b/cesar_sanchez/week05/monopoly_db/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/cesar_sanchez/week05/monopoly_db/app/models/concerns/.keep b/cesar_sanchez/week05/monopoly_db/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cesar_sanchez/week05/monopoly_db/app/models/property.rb b/cesar_sanchez/week05/monopoly_db/app/models/property.rb new file mode 100644 index 0000000..77fb6b6 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/models/property.rb @@ -0,0 +1,2 @@ +class Property < ActiveRecord::Base +end diff --git a/cesar_sanchez/week05/monopoly_db/app/views/layouts/application.html.erb b/cesar_sanchez/week05/monopoly_db/app/views/layouts/application.html.erb new file mode 100644 index 0000000..7fd14d1 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/views/layouts/application.html.erb @@ -0,0 +1,25 @@ + + + + Monopoly + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + +
+ + + <%= yield %> + +
+ + + diff --git a/cesar_sanchez/week05/monopoly_db/app/views/layouts/mailer.html.erb b/cesar_sanchez/week05/monopoly_db/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/cesar_sanchez/week05/monopoly_db/app/views/layouts/mailer.text.erb b/cesar_sanchez/week05/monopoly_db/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/cesar_sanchez/week05/monopoly_db/app/views/properties/buy.html.erb b/cesar_sanchez/week05/monopoly_db/app/views/properties/buy.html.erb new file mode 100644 index 0000000..82925ad --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/views/properties/buy.html.erb @@ -0,0 +1,25 @@ +

Buy a new Property

+ +
+ + + + + + + + + +
diff --git a/cesar_sanchez/week05/monopoly_db/app/views/properties/edit.html.erb b/cesar_sanchez/week05/monopoly_db/app/views/properties/edit.html.erb new file mode 100644 index 0000000..876fb34 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/views/properties/edit.html.erb @@ -0,0 +1,25 @@ +

Edit Property

+ +
+ + + + + + + + + +
diff --git a/cesar_sanchez/week05/monopoly_db/app/views/properties/index.html.erb b/cesar_sanchez/week05/monopoly_db/app/views/properties/index.html.erb new file mode 100644 index 0000000..75dbd0c --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/views/properties/index.html.erb @@ -0,0 +1,7 @@ +

Properties Portfolio

+ +<% @properties.each do |property| %> +

+ <%= link_to property.name, property_path(property.id) %> +

+<% end %> diff --git a/cesar_sanchez/week05/monopoly_db/app/views/properties/show.html.erb b/cesar_sanchez/week05/monopoly_db/app/views/properties/show.html.erb new file mode 100644 index 0000000..695d272 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/app/views/properties/show.html.erb @@ -0,0 +1,15 @@ +

<%= @property.name %>

+ + +<%= image_tag @property.image, :class => 'feature' if @property.image.present? %> + + + +
+ <%= link_to 'Edit property', edit_property_path(@property.id) %> + <%= button_to "Sell Property", property_path(@property.id), :method => 'delete' %> +
diff --git a/cesar_sanchez/week05/monopoly_db/bin/bundle b/cesar_sanchez/week05/monopoly_db/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/cesar_sanchez/week05/monopoly_db/bin/rails b/cesar_sanchez/week05/monopoly_db/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/cesar_sanchez/week05/monopoly_db/bin/rake b/cesar_sanchez/week05/monopoly_db/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/cesar_sanchez/week05/monopoly_db/bin/setup b/cesar_sanchez/week05/monopoly_db/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/cesar_sanchez/week05/monopoly_db/bin/spring b/cesar_sanchez/week05/monopoly_db/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/cesar_sanchez/week05/monopoly_db/bin/update b/cesar_sanchez/week05/monopoly_db/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/cesar_sanchez/week05/monopoly_db/bin/yarn b/cesar_sanchez/week05/monopoly_db/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/cesar_sanchez/week05/monopoly_db/config.ru b/cesar_sanchez/week05/monopoly_db/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/cesar_sanchez/week05/monopoly_db/config/application.rb b/cesar_sanchez/week05/monopoly_db/config/application.rb new file mode 100644 index 0000000..e825077 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module MonopolyDb + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/cesar_sanchez/week05/monopoly_db/config/boot.rb b/cesar_sanchez/week05/monopoly_db/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/cesar_sanchez/week05/monopoly_db/config/credentials.yml.enc b/cesar_sanchez/week05/monopoly_db/config/credentials.yml.enc new file mode 100644 index 0000000..ca494fb --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/credentials.yml.enc @@ -0,0 +1 @@ +oqEJrtWUxORe/L5CPrExOGj31tk5Y/WK+OvvQOhnhP6Xn7jUW4rdx9Q/9wbaYx0JsxKU9aro6bkNUdGWUa/NWgQUmMTNhffMTwqyy9H5T/D8LrimKKCy0ovCh/qSsNxoxNUPVRpusp204FF+1Hh62T/dXUiuQXPcRaExBH9ONE0eAcUcszhv8PPM8KVZT5fMRNjx7oH2xf/IfILRwE/thUZQ9LMH3LYBfabYgKZvGw5rKqZQxQAYVRC1XAQXd1cB9tILO/HhiGcfUOGhntnkaDuJPIq6Trt/bLAqWNL/vX08eBt5fCoZD17+Ef6ujSoRa31tRv1do2aWxTzsWMHyX82iWJLorz/JhAHRkSxPx/ZjcEbOdh+ZvZiK9+qJC8NawnBpIS0LLJdx8rdTqpdVr8UYcqjakgGhvM1K--9TNeoXU2Q+3IMuhi--XpC3hIM+r3KDVZOBo6pZfw== \ No newline at end of file diff --git a/cesar_sanchez/week05/monopoly_db/config/database.yml b/cesar_sanchez/week05/monopoly_db/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/cesar_sanchez/week05/monopoly_db/config/environment.rb b/cesar_sanchez/week05/monopoly_db/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/cesar_sanchez/week05/monopoly_db/config/environments/development.rb b/cesar_sanchez/week05/monopoly_db/config/environments/development.rb new file mode 100644 index 0000000..92bfc1d --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/environments/development.rb @@ -0,0 +1,58 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/cesar_sanchez/week05/monopoly_db/config/environments/production.rb b/cesar_sanchez/week05/monopoly_db/config/environments/production.rb new file mode 100644 index 0000000..fcaecbb --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/environments/production.rb @@ -0,0 +1,86 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "monopoly_db_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/cesar_sanchez/week05/monopoly_db/config/environments/test.rb b/cesar_sanchez/week05/monopoly_db/config/environments/test.rb new file mode 100644 index 0000000..b08fc84 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/environments/test.rb @@ -0,0 +1,43 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/cesar_sanchez/week05/monopoly_db/config/initializers/application_controller_renderer.rb b/cesar_sanchez/week05/monopoly_db/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/cesar_sanchez/week05/monopoly_db/config/initializers/assets.rb b/cesar_sanchez/week05/monopoly_db/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/cesar_sanchez/week05/monopoly_db/config/initializers/backtrace_silencers.rb b/cesar_sanchez/week05/monopoly_db/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/cesar_sanchez/week05/monopoly_db/config/initializers/content_security_policy.rb b/cesar_sanchez/week05/monopoly_db/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/cesar_sanchez/week05/monopoly_db/config/initializers/cookies_serializer.rb b/cesar_sanchez/week05/monopoly_db/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/cesar_sanchez/week05/monopoly_db/config/initializers/filter_parameter_logging.rb b/cesar_sanchez/week05/monopoly_db/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/cesar_sanchez/week05/monopoly_db/config/initializers/inflections.rb b/cesar_sanchez/week05/monopoly_db/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/cesar_sanchez/week05/monopoly_db/config/initializers/mime_types.rb b/cesar_sanchez/week05/monopoly_db/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/cesar_sanchez/week05/monopoly_db/config/initializers/wrap_parameters.rb b/cesar_sanchez/week05/monopoly_db/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/cesar_sanchez/week05/monopoly_db/config/locales/en.yml b/cesar_sanchez/week05/monopoly_db/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/cesar_sanchez/week05/monopoly_db/config/master.key b/cesar_sanchez/week05/monopoly_db/config/master.key new file mode 100644 index 0000000..ae44173 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/master.key @@ -0,0 +1 @@ +3d03e495759cf2ea608a6b3b8be43490 \ No newline at end of file diff --git a/cesar_sanchez/week05/monopoly_db/config/puma.rb b/cesar_sanchez/week05/monopoly_db/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/cesar_sanchez/week05/monopoly_db/config/routes.rb b/cesar_sanchez/week05/monopoly_db/config/routes.rb new file mode 100644 index 0000000..b929a93 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/routes.rb @@ -0,0 +1,9 @@ +Rails.application.routes.draw do + get '/properties' => 'properties#index' + get '/properties/buy' => 'properties#buy', :as => 'buy_property' + post '/properties' => 'properties#create' + get '/properties/:id' => 'properties#show', :as => 'property' + get 'properties/:id/edit' => 'properties#edit', :as => 'edit_property' + post '/properties/:id' => 'properties#update' + delete '/properties/:id' => 'properties#destroy' +end diff --git a/cesar_sanchez/week05/monopoly_db/config/spring.rb b/cesar_sanchez/week05/monopoly_db/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/cesar_sanchez/week05/monopoly_db/db/buy_properties.sql b/cesar_sanchez/week05/monopoly_db/db/buy_properties.sql new file mode 100644 index 0000000..181b978 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/db/buy_properties.sql @@ -0,0 +1,7 @@ +CREATE TABLE properties ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + monopoly TEXT, + rent TEXT, + image TEXT +); diff --git a/cesar_sanchez/week05/monopoly_db/db/development.sqlite3 b/cesar_sanchez/week05/monopoly_db/db/development.sqlite3 new file mode 100644 index 0000000..ed1e998 Binary files /dev/null and b/cesar_sanchez/week05/monopoly_db/db/development.sqlite3 differ diff --git a/cesar_sanchez/week05/monopoly_db/db/seeds.rb b/cesar_sanchez/week05/monopoly_db/db/seeds.rb new file mode 100644 index 0000000..e649996 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/db/seeds.rb @@ -0,0 +1,6 @@ +Property.destroy_all + +Property.create :name => 'Electric Company', :monopoly => 'Utility', :rent => 'X4' +Property.create :name => 'Water Works', :monopoly => 'Utility', :rent => 'X4' + +puts "#{ Property.count } properties in your portfolio." diff --git a/cesar_sanchez/week05/monopoly_db/lib/assets/.keep b/cesar_sanchez/week05/monopoly_db/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cesar_sanchez/week05/monopoly_db/lib/tasks/.keep b/cesar_sanchez/week05/monopoly_db/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/cesar_sanchez/week05/monopoly_db/package.json b/cesar_sanchez/week05/monopoly_db/package.json new file mode 100644 index 0000000..fb6f70c --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/package.json @@ -0,0 +1,5 @@ +{ + "name": "monopoly_db", + "private": true, + "dependencies": {} +} diff --git a/cesar_sanchez/week05/monopoly_db/public/404.html b/cesar_sanchez/week05/monopoly_db/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/cesar_sanchez/week05/monopoly_db/public/422.html b/cesar_sanchez/week05/monopoly_db/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/cesar_sanchez/week05/monopoly_db/public/500.html b/cesar_sanchez/week05/monopoly_db/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/cesar_sanchez/week05/monopoly_db/public/apple-touch-icon-precomposed.png b/cesar_sanchez/week05/monopoly_db/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/cesar_sanchez/week05/monopoly_db/public/apple-touch-icon.png b/cesar_sanchez/week05/monopoly_db/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/cesar_sanchez/week05/monopoly_db/public/favicon.ico b/cesar_sanchez/week05/monopoly_db/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/cesar_sanchez/week05/monopoly_db/public/robots.txt b/cesar_sanchez/week05/monopoly_db/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/cesar_sanchez/week05/monopoly_db/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/cesar_sanchez/week05/monopoly_db/vendor/.keep b/cesar_sanchez/week05/monopoly_db/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/.ruby-version b/james_nielsen/week5/rails_authors/wordsmith/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/james_nielsen/week5/rails_authors/wordsmith/Gemfile b/james_nielsen/week5/rails_authors/wordsmith/Gemfile new file mode 100644 index 0000000..c8be185 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/Gemfile @@ -0,0 +1,54 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/james_nielsen/week5/rails_authors/wordsmith/Gemfile.lock b/james_nielsen/week5/rails_authors/wordsmith/Gemfile.lock new file mode 100644 index 0000000..b99a956 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/Gemfile.lock @@ -0,0 +1,195 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.6.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/james_nielsen/week5/rails_authors/wordsmith/README.md b/james_nielsen/week5/rails_authors/wordsmith/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/james_nielsen/week5/rails_authors/wordsmith/Rakefile b/james_nielsen/week5/rails_authors/wordsmith/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/assets/config/manifest.js b/james_nielsen/week5/rails_authors/wordsmith/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/assets/images/.keep b/james_nielsen/week5/rails_authors/wordsmith/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/assets/javascripts/application.js b/james_nielsen/week5/rails_authors/wordsmith/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/assets/javascripts/authors.coffee b/james_nielsen/week5/rails_authors/wordsmith/app/assets/javascripts/authors.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/assets/javascripts/authors.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/assets/javascripts/books.coffee b/james_nielsen/week5/rails_authors/wordsmith/app/assets/javascripts/books.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/assets/javascripts/books.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/assets/stylesheets/application.css b/james_nielsen/week5/rails_authors/wordsmith/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/assets/stylesheets/authors.scss b/james_nielsen/week5/rails_authors/wordsmith/app/assets/stylesheets/authors.scss new file mode 100644 index 0000000..53d794f --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/assets/stylesheets/authors.scss @@ -0,0 +1,15 @@ +// Place all the styles related to the authors controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +body { + background-color: #ccd; +} + +.thumb { + height: 12em; +} + +.feature { + max-height: 30em; +} diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/assets/stylesheets/books.scss b/james_nielsen/week5/rails_authors/wordsmith/app/assets/stylesheets/books.scss new file mode 100644 index 0000000..9fab565 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/assets/stylesheets/books.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Books controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/controllers/application_controller.rb b/james_nielsen/week5/rails_authors/wordsmith/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/controllers/authors_controller.rb b/james_nielsen/week5/rails_authors/wordsmith/app/controllers/authors_controller.rb new file mode 100644 index 0000000..e54b571 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/controllers/authors_controller.rb @@ -0,0 +1,40 @@ +class AuthorsController < ApplicationController + def index + @authors = Author.all + end + + def new + @author = Author.new + end + + def create + author = Author.create author_params + redirect_to author + end + + def edit + @author = Author.find params[:id] + end + + def update + author = Author.find params[:id] + author.update author_params + redirect_to author + end + + def show + @author = Author.find params[:id] + end + + def destroy + author = Author.find params[:id] + author.destroy + redirect_to authors_path + end + + private #the dollowing methods(s) aren't accessible outside this class (so routes can't point to them) + def author_params + #strong params: white list of sanitised input -- stuff we are happy to accept from the user. + params.require(:author).permit(:name, :nationality, :dob, :genre, :image, :wiki) + end +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/controllers/books_controller.rb b/james_nielsen/week5/rails_authors/wordsmith/app/controllers/books_controller.rb new file mode 100644 index 0000000..c6294fe --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/controllers/books_controller.rb @@ -0,0 +1,39 @@ +class BooksController < ApplicationController + def index + @books = Book.all + end + + def new + @book = Book.new + end + + def create + book = Book.create book_params + redirect_to book + end + + def edit + @book = Book.find params[:id] + end + + def update + book = Book.find params[:id] + book.update book_params + redirect_to book + end + + def show + @book = Book.find params[:id] + end + + def destroy + book = Book.find params[:id] + book.destroy + redirect_to books_path + end + + private + def book_params + params.require(:book).permit(:title, :year, :publisher, :image, :bio, :author_id) + end +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/controllers/concerns/.keep b/james_nielsen/week5/rails_authors/wordsmith/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/helpers/application_helper.rb b/james_nielsen/week5/rails_authors/wordsmith/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/helpers/authors_helper.rb b/james_nielsen/week5/rails_authors/wordsmith/app/helpers/authors_helper.rb new file mode 100644 index 0000000..f22e1f9 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/helpers/authors_helper.rb @@ -0,0 +1,2 @@ +module AuthorsHelper +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/helpers/books_helper.rb b/james_nielsen/week5/rails_authors/wordsmith/app/helpers/books_helper.rb new file mode 100644 index 0000000..4b9311e --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/helpers/books_helper.rb @@ -0,0 +1,2 @@ +module BooksHelper +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/jobs/application_job.rb b/james_nielsen/week5/rails_authors/wordsmith/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/mailers/application_mailer.rb b/james_nielsen/week5/rails_authors/wordsmith/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/models/application_record.rb b/james_nielsen/week5/rails_authors/wordsmith/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/models/author.rb b/james_nielsen/week5/rails_authors/wordsmith/app/models/author.rb new file mode 100644 index 0000000..ed1417f --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/models/author.rb @@ -0,0 +1,3 @@ +class Author < ActiveRecord::Base + has_many :books +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/models/book.rb b/james_nielsen/week5/rails_authors/wordsmith/app/models/book.rb new file mode 100644 index 0000000..9bad06d --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/models/book.rb @@ -0,0 +1,3 @@ +class Book true +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/models/concerns/.keep b/james_nielsen/week5/rails_authors/wordsmith/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/_form.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/_form.html.erb new file mode 100644 index 0000000..ef9b64c --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/_form.html.erb @@ -0,0 +1,21 @@ +<%= form_for @author do |f| %> + <%= f.label :name %> + <%= f.text_field :name, :required => true, :autofocus => true%> + + <%= f.label :nationality %> + <%= f.text_field :nationality %> + + <%= f.label :dob, 'Date of Birth' %> + <%= f.text_field :dob, :placeholder => 'YYYY-MM-DD'%> + + <%= f.label :genre %> + <%= f.text_field :genre %> + + <%= f.label :image %> + <%= f.text_field :image %> + + <%= f.label :wiki %> + <%= f.text_field :wiki %> + + <%= f.submit %> +<% end %> diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/edit.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/edit.html.erb new file mode 100644 index 0000000..76ddf7c --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/edit.html.erb @@ -0,0 +1,3 @@ +

Edit Author

+ +<%= render :partial =>'form' %> diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/index.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/index.html.erb new file mode 100644 index 0000000..4edec3b --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/index.html.erb @@ -0,0 +1,12 @@ +

All Authors

+ +<% @authors.each do |author| %> +<%= image_tag author.image, :class => 'thumb' if author.image.present? %> + +<% end %> diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/new.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/new.html.erb new file mode 100644 index 0000000..e6a7036 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/new.html.erb @@ -0,0 +1,3 @@ +

New Author

+ +<%= render :partial =>'form' %> diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/show.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/show.html.erb new file mode 100644 index 0000000..5c11d16 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/authors/show.html.erb @@ -0,0 +1,19 @@ +

<%= @author.name %>

+ +<%= image_tag @author.image, :class =>'feature' if @author.image.present? %> + + + <% @author.books.each do |book| %> + <%= link_to image_tag(book.image, :class => 'thumb'), book %> + <% end %> + +
+ <%= link_to 'Edit Author', edit_author_path(@author) %> + <%= button_to 'Delete Author', @author, :method => 'delete' %> +
diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/books/_form.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/books/_form.html.erb new file mode 100644 index 0000000..f8984cb --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/books/_form.html.erb @@ -0,0 +1,15 @@ +<%= form_for @book do |f| %> +<%= f.label :title %> +<%= f.text_field :title %> +<%= f.label :year%> +<%= f.text_field :year%> +<%= f.label :publisher%> +<%= f.text_field :publisher %> +<%= f.label :image%> +<%= f.url_field :image, :required => true%> +<%= f.label :bio%> +<%= f.text_field :bio %> +<%= f.label :author_id %> +<%= f.select :author_id, Author.pluck(:name, :id), :include_blank => true %> +<%= f.submit %> +<% end %> diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/books/edit.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/books/edit.html.erb new file mode 100644 index 0000000..fdf6ba5 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/books/edit.html.erb @@ -0,0 +1,3 @@ +

Edit Book

+ +<%= render :partial =>'form' %> diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/books/index.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/books/index.html.erb new file mode 100644 index 0000000..83d41e5 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/books/index.html.erb @@ -0,0 +1,15 @@ +

All Books

+ +<% @books.each do |book| %> +<%= image_tag book.image, :class => 'thumb' if book.image.present? %> + +<% end %> + + + diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/books/new.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/books/new.html.erb new file mode 100644 index 0000000..b5ba5b0 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/books/new.html.erb @@ -0,0 +1,3 @@ +

New Books

+ +<%= render :partial => 'form' %> diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/books/show.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/books/show.html.erb new file mode 100644 index 0000000..cd39830 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/books/show.html.erb @@ -0,0 +1,20 @@ +

<%= @book.title %>

+ +<%= image_tag @book.image, :class =>'feature' if @book.image.present? %> + + +
+ <%= link_to 'Edit Book', edit_book_path(@book) %> + <%= button_to 'Delete Book', @book, :method => 'delete' %> + +
diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/layouts/application.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/layouts/application.html.erb new file mode 100644 index 0000000..9c20a4a --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/layouts/application.html.erb @@ -0,0 +1,22 @@ + + + + Wordsmith + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + <%= yield %> + + diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/layouts/mailer.html.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/james_nielsen/week5/rails_authors/wordsmith/app/views/layouts/mailer.text.erb b/james_nielsen/week5/rails_authors/wordsmith/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/james_nielsen/week5/rails_authors/wordsmith/bin/bundle b/james_nielsen/week5/rails_authors/wordsmith/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/james_nielsen/week5/rails_authors/wordsmith/bin/rails b/james_nielsen/week5/rails_authors/wordsmith/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/james_nielsen/week5/rails_authors/wordsmith/bin/rake b/james_nielsen/week5/rails_authors/wordsmith/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/james_nielsen/week5/rails_authors/wordsmith/bin/setup b/james_nielsen/week5/rails_authors/wordsmith/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/bin/spring b/james_nielsen/week5/rails_authors/wordsmith/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/bin/update b/james_nielsen/week5/rails_authors/wordsmith/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/bin/yarn b/james_nielsen/week5/rails_authors/wordsmith/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/config.ru b/james_nielsen/week5/rails_authors/wordsmith/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/application.rb b/james_nielsen/week5/rails_authors/wordsmith/config/application.rb new file mode 100644 index 0000000..f93baf0 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Wordsmith + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/boot.rb b/james_nielsen/week5/rails_authors/wordsmith/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/credentials.yml.enc b/james_nielsen/week5/rails_authors/wordsmith/config/credentials.yml.enc new file mode 100644 index 0000000..a5c8901 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/credentials.yml.enc @@ -0,0 +1 @@ +uME9GP2kGrjSVsqaQmqs4uuH7+XOR+sk8KKq0HUk8qHKZqRkDPeZOh6jgGrJ8iOfSH/0wvh5KTnW3z28gB8Wn5hETrO/ElLkSrm3avazFdL/2a8yaBqI5gADwGGii1E9yXQQfP4P6OqtarSH0K3hSMExzdG75yMgWw9kaKAxxtOhvCRPWq9JAhoqoGvn0nSvtTwu1l0yDAJ5cQZN/66fsJ5oNagXCsenK9kJk63MzEiIqge4sa2ywOXXgJ/51N/KzCM7yVWVeOo9S5giaQ0IGlQedugN3UeizK1QwX7STFpVyvsAUomzHwSFFyhTb4r9iWQDlSayPqy6E2tWfJF5tBj0urO3qFierQQ3Rq+0qLiHCCquCoAyG63RBZ6qsZGMarTbCQfz4GKQZw5hVdXXdC4aMl2NDBvCOgFV--x3tv26gEcq6gFhGp--mVrfqtylhf/capMMAJOCdw== \ No newline at end of file diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/database.yml b/james_nielsen/week5/rails_authors/wordsmith/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/environment.rb b/james_nielsen/week5/rails_authors/wordsmith/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/environments/development.rb b/james_nielsen/week5/rails_authors/wordsmith/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/environments/production.rb b/james_nielsen/week5/rails_authors/wordsmith/config/environments/production.rb new file mode 100644 index 0000000..f40a6d5 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/environments/production.rb @@ -0,0 +1,89 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "wordsmith_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/environments/test.rb b/james_nielsen/week5/rails_authors/wordsmith/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/initializers/application_controller_renderer.rb b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/initializers/assets.rb b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/initializers/backtrace_silencers.rb b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/initializers/content_security_policy.rb b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/initializers/cookies_serializer.rb b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/initializers/filter_parameter_logging.rb b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/initializers/inflections.rb b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/initializers/mime_types.rb b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/initializers/wrap_parameters.rb b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/locales/en.yml b/james_nielsen/week5/rails_authors/wordsmith/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/master.key b/james_nielsen/week5/rails_authors/wordsmith/config/master.key new file mode 100644 index 0000000..3d581f3 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/master.key @@ -0,0 +1 @@ +31e8f64326846e14a40be230046db9c8 \ No newline at end of file diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/puma.rb b/james_nielsen/week5/rails_authors/wordsmith/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/routes.rb b/james_nielsen/week5/rails_authors/wordsmith/config/routes.rb new file mode 100644 index 0000000..bc36f5a --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/routes.rb @@ -0,0 +1,8 @@ +Rails.application.routes.draw do + get 'books/index' + get 'books/new' + get 'books/edit' + get 'books/show' + resources :authors + resources :books + end diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/spring.rb b/james_nielsen/week5/rails_authors/wordsmith/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/james_nielsen/week5/rails_authors/wordsmith/config/storage.yml b/james_nielsen/week5/rails_authors/wordsmith/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/james_nielsen/week5/rails_authors/wordsmith/db/development.sqlite3 b/james_nielsen/week5/rails_authors/wordsmith/db/development.sqlite3 new file mode 100644 index 0000000..6b1dab7 Binary files /dev/null and b/james_nielsen/week5/rails_authors/wordsmith/db/development.sqlite3 differ diff --git a/james_nielsen/week5/rails_authors/wordsmith/db/migrate/20200617105536_create_authors.rb b/james_nielsen/week5/rails_authors/wordsmith/db/migrate/20200617105536_create_authors.rb new file mode 100644 index 0000000..4054048 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/db/migrate/20200617105536_create_authors.rb @@ -0,0 +1,12 @@ +class CreateAuthors < ActiveRecord::Migration[5.2] + def change + create_table :authors do |t| + t.text :name + t.text :nationality + t.date :dob + t.text :genre + t.text :image + t.text :wiki + end + end +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/db/migrate/20200617144335_create_books.rb b/james_nielsen/week5/rails_authors/wordsmith/db/migrate/20200617144335_create_books.rb new file mode 100644 index 0000000..ce5240a --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/db/migrate/20200617144335_create_books.rb @@ -0,0 +1,11 @@ +class CreateBooks < ActiveRecord::Migration[5.2] + def change + create_table :books do |t| + t.text :title + t.text :year + t.text :publisher + t.text :image + t.text :bio + end +end +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/db/migrate/20200619112535_add_author_id_to_books.rb b/james_nielsen/week5/rails_authors/wordsmith/db/migrate/20200619112535_add_author_id_to_books.rb new file mode 100644 index 0000000..320cd7c --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/db/migrate/20200619112535_add_author_id_to_books.rb @@ -0,0 +1,5 @@ +class AddAuthorIdToBooks < ActiveRecord::Migration[5.2] + def change + add_column :books, :author_id, :integer + end +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/db/schema.rb b/james_nielsen/week5/rails_authors/wordsmith/db/schema.rb new file mode 100644 index 0000000..90d5f2c --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/db/schema.rb @@ -0,0 +1,33 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_19_112535) do + + create_table "authors", force: :cascade do |t| + t.text "name" + t.text "nationality" + t.date "dob" + t.text "genre" + t.text "image" + t.text "wiki" + end + + create_table "books", force: :cascade do |t| + t.text "title" + t.text "year" + t.text "publisher" + t.text "image" + t.text "bio" + t.integer "author_id" + end + +end diff --git a/james_nielsen/week5/rails_authors/wordsmith/db/seeds.rb b/james_nielsen/week5/rails_authors/wordsmith/db/seeds.rb new file mode 100644 index 0000000..198f524 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/db/seeds.rb @@ -0,0 +1,18 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) +Author.destroy_all +Author.create(:name => 'J.R.R Tolkien', :nationality => 'English', :dob => '1892-01-03', :genre => 'non-fiction', :image => 'https://images.gr-assets.com/authors/1564399522p5/656983.jpg', :wiki => 'https://en.wikipedia.org/wiki/J._R._R._Tolkien') +Author.create(:name => 'J. K. Rowling', :nationality => 'British', :dob => '1965-07-31', :genre => 'non-fiction', :image => 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSCOOqg_zUm5pAi_ZIbuZu198okQLeuoDaEblNd5AIlvqgkX9QZ&usqp=CAU', :wiki => 'https://en.wikipedia.org/wiki/J._K._Rowling') +Author.create(:name => 'Patrick Rothfuss', :nationality => 'American', :dob => '1973-06-06', :genre => 'Fantasy', :image => 'https://upload.wikimedia.org/wikipedia/commons/7/7f/Patrick-rothfuss-2014-kyle-cassidy.jpg', :wiki => 'https://en.wikipedia.org/wiki/Patrick_Rothfuss') +puts " #{ Author.count } authors created." + +Book.destroy_all +Book.create(:title => 'The Hobbit', :year => '1937', :publisher => 'Harper Collins', :image => 'https://m.media-amazon.com/images/I/5187PQgDScL.jpg', :bio => "The Hobbit, or There and Back Again is a children's fantasy novel by English author J. R. R. Tolkien. ... The Hobbit is set within Tolkien's fictional universe and follows the quest of home-loving Bilbo Baggins, the titular hobbit, to win a share of the treasure guarded by Smaug the dragon.") +Book.create(:title => 'Harry Potter', :year => '1999', :publisher => 'Bloomsbury Publishing', :image => 'https://upload.wikimedia.org/wikipedia/en/thumb/6/6b/Harry_Potter_and_the_Philosopher%27s_Stone_Book_Cover.jpg/220px-Harry_Potter_and_the_Philosopher%27s_Stone_Book_Cover.jpg', :bio => "The first novel in the Harry Potter series and Rowling's debut novel, it follows Harry Potter, a young wizard who discovers his magical heritage on his eleventh birthday, when he receives a letter of acceptance to Hogwarts School of Witchcraft and Wizardry.") +Book.create(:title => 'The Name of the Wind', :year => '2007', :publisher => 'DAW books', :image => 'https://upload.wikimedia.org/wikipedia/en/5/56/TheNameoftheWind_cover.jpg', :bio => "The Name of the Wind, also called The Kingkiller Chronicle: Day One, is a heroic fantasy novel written by American author Patrick Rothfuss. It is the first book in the ongoing fantasy trilogy The Kingkiller Chronicle, followed by The Wise Man's Fear. It was published on March 27, 2007 by DAW Books.") +puts "#{Book.count} books created." diff --git a/james_nielsen/week5/rails_authors/wordsmith/db/test.sqlite3 b/james_nielsen/week5/rails_authors/wordsmith/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/lib/assets/.keep b/james_nielsen/week5/rails_authors/wordsmith/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/lib/tasks/.keep b/james_nielsen/week5/rails_authors/wordsmith/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/package.json b/james_nielsen/week5/rails_authors/wordsmith/package.json new file mode 100644 index 0000000..4b3b87e --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/package.json @@ -0,0 +1,5 @@ +{ + "name": "wordsmith", + "private": true, + "dependencies": {} +} diff --git a/james_nielsen/week5/rails_authors/wordsmith/public/404.html b/james_nielsen/week5/rails_authors/wordsmith/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/james_nielsen/week5/rails_authors/wordsmith/public/422.html b/james_nielsen/week5/rails_authors/wordsmith/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/james_nielsen/week5/rails_authors/wordsmith/public/500.html b/james_nielsen/week5/rails_authors/wordsmith/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/james_nielsen/week5/rails_authors/wordsmith/public/apple-touch-icon-precomposed.png b/james_nielsen/week5/rails_authors/wordsmith/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/public/apple-touch-icon.png b/james_nielsen/week5/rails_authors/wordsmith/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/public/favicon.ico b/james_nielsen/week5/rails_authors/wordsmith/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/public/robots.txt b/james_nielsen/week5/rails_authors/wordsmith/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/james_nielsen/week5/rails_authors/wordsmith/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/james_nielsen/week5/rails_authors/wordsmith/storage/.keep b/james_nielsen/week5/rails_authors/wordsmith/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/james_nielsen/week5/rails_authors/wordsmith/vendor/.keep b/james_nielsen/week5/rails_authors/wordsmith/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/.ruby-version b/jonathan_macmillan/week_05/homework/broadway/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/jonathan_macmillan/week_05/homework/broadway/Gemfile b/jonathan_macmillan/week_05/homework/broadway/Gemfile new file mode 100644 index 0000000..9c61819 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/Gemfile @@ -0,0 +1,56 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/jonathan_macmillan/week_05/homework/broadway/Gemfile.lock b/jonathan_macmillan/week_05/homework/broadway/Gemfile.lock new file mode 100644 index 0000000..a2adb22 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/Gemfile.lock @@ -0,0 +1,199 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.6.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/jonathan_macmillan/week_05/homework/broadway/README.md b/jonathan_macmillan/week_05/homework/broadway/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/jonathan_macmillan/week_05/homework/broadway/Rakefile b/jonathan_macmillan/week_05/homework/broadway/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/jonathan_macmillan/week_05/homework/broadway/app/assets/config/manifest.js b/jonathan_macmillan/week_05/homework/broadway/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/jonathan_macmillan/week_05/homework/broadway/app/assets/images/.keep b/jonathan_macmillan/week_05/homework/broadway/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/application.js b/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/cable.js b/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/channels/.keep b/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/productions.coffee b/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/productions.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/productions.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/theatres.coffee b/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/theatres.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/assets/javascripts/theatres.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/jonathan_macmillan/week_05/homework/broadway/app/assets/stylesheets/application.css b/jonathan_macmillan/week_05/homework/broadway/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/jonathan_macmillan/week_05/homework/broadway/app/assets/stylesheets/productions.scss b/jonathan_macmillan/week_05/homework/broadway/app/assets/stylesheets/productions.scss new file mode 100644 index 0000000..faddf89 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/assets/stylesheets/productions.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Productions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/jonathan_macmillan/week_05/homework/broadway/app/assets/stylesheets/theatres.scss b/jonathan_macmillan/week_05/homework/broadway/app/assets/stylesheets/theatres.scss new file mode 100644 index 0000000..e270bb5 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/assets/stylesheets/theatres.scss @@ -0,0 +1,12 @@ +// Place all the styles related to the Theatres controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + + +body { + background-color: pink; +} + +.thumb { + max-height: 13em; +} diff --git a/jonathan_macmillan/week_05/homework/broadway/app/channels/application_cable/channel.rb b/jonathan_macmillan/week_05/homework/broadway/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/channels/application_cable/connection.rb b/jonathan_macmillan/week_05/homework/broadway/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/controllers/application_controller.rb b/jonathan_macmillan/week_05/homework/broadway/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/controllers/concerns/.keep b/jonathan_macmillan/week_05/homework/broadway/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/app/controllers/productions_controller.rb b/jonathan_macmillan/week_05/homework/broadway/app/controllers/productions_controller.rb new file mode 100644 index 0000000..9bd3666 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/controllers/productions_controller.rb @@ -0,0 +1,39 @@ +class ProductionsController < ApplicationController + def index + @productions = Production.all + end + + def new + @production = Production.new + end + + def create + production = Production.create production_params + redirect_to production + end + + def edit + @production = Production.find params[:id] + end + + def update + production = Production.find params[:id] + production.update production_params + redirect_to production + end + + def show + @production = Production.find params[:id] + end + + def destroy + production = Production.find params[:id] + production.destroy + redirect_to productions_path + end + + private + def production_params + params.require(:production).permit(:title, :director, :opening, :closing, :image, :awards, :theatre_id) + end +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/controllers/theatres_controller.rb b/jonathan_macmillan/week_05/homework/broadway/app/controllers/theatres_controller.rb new file mode 100644 index 0000000..c2918b9 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/controllers/theatres_controller.rb @@ -0,0 +1,39 @@ +class TheatresController < ApplicationController + def index + @theatres = Theatre.all + end + + def new + @theatre = Theatre.new + end + + def create + theatre = Theatre.create theatre_params + redirect_to theatre + end + + def edit + @theatre = Theatre.find params[:id] + end + + def update + theatre = Theatre.find params[:id] + theatre.update theatre_params + redirect_to theatre + end + + def show + @theatre = Theatre.find params[:id] + end + + def destroy + theatre = Theatre.find params[:id] + theatre.destroy + redirect_to theatres_path + end + + private + def theatre_params + params.require(:theatre).permit(:address, :capacity, :owner, :name, :image) + end +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/helpers/application_helper.rb b/jonathan_macmillan/week_05/homework/broadway/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/helpers/productions_helper.rb b/jonathan_macmillan/week_05/homework/broadway/app/helpers/productions_helper.rb new file mode 100644 index 0000000..a62ec09 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/helpers/productions_helper.rb @@ -0,0 +1,2 @@ +module ProductionsHelper +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/helpers/theatres_helper.rb b/jonathan_macmillan/week_05/homework/broadway/app/helpers/theatres_helper.rb new file mode 100644 index 0000000..337f1a6 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/helpers/theatres_helper.rb @@ -0,0 +1,2 @@ +module TheatresHelper +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/jobs/application_job.rb b/jonathan_macmillan/week_05/homework/broadway/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/mailers/application_mailer.rb b/jonathan_macmillan/week_05/homework/broadway/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/models/application_record.rb b/jonathan_macmillan/week_05/homework/broadway/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/models/concerns/.keep b/jonathan_macmillan/week_05/homework/broadway/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/app/models/production.rb b/jonathan_macmillan/week_05/homework/broadway/app/models/production.rb new file mode 100644 index 0000000..50c88d7 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/models/production.rb @@ -0,0 +1,3 @@ +class Production < ActiveRecord::Base + belongs_to :theatre, :optional => true +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/models/theatre.rb b/jonathan_macmillan/week_05/homework/broadway/app/models/theatre.rb new file mode 100644 index 0000000..0457187 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/models/theatre.rb @@ -0,0 +1,3 @@ +class Theatre < ActiveRecord::Base + has_many :productions +end diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/layouts/application.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/layouts/application.html.erb new file mode 100644 index 0000000..1aa0c9b --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/layouts/application.html.erb @@ -0,0 +1,26 @@ + + + + Broadway + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + +
+ + + + <%= yield %> +
+ + diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/layouts/mailer.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/layouts/mailer.text.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/productions/_form.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/productions/_form.html.erb new file mode 100644 index 0000000..caaad32 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/productions/_form.html.erb @@ -0,0 +1,25 @@ +<%= form_for @production do |p| %> + <%= p.label :title %> + <%= p.text_field :title, :required => true, :autofocus => true %> + + <%= p.label :director %> + <%= p.text_field :director %> + + <%= p.label :opening %> + <%= p.date_field :opening %> + + <%= p.label :closing %> + <%= p.date_field :closing %> + + <%= p.label :image %> + <%= p.url_field :image, :required => true %> + + <%= p.label :awards %> + <%= p.text_field :awards %> + + <%= p.label :theatre_id %> + <%= p.select :theatre_id, Theatre.pluck(:name, :id), :include_blank => true %> + + + <%= p.submit %> +<% end %> diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/productions/edit.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/productions/edit.html.erb new file mode 100644 index 0000000..2b973c2 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/productions/edit.html.erb @@ -0,0 +1,4 @@ +

Edit Production

+ + +<%= render :partial => 'form' %> diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/productions/index.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/productions/index.html.erb new file mode 100644 index 0000000..01fe4e5 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/productions/index.html.erb @@ -0,0 +1,11 @@ +

Productions

+ +<% @productions.each do |p| %> + +<% end %> diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/productions/new.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/productions/new.html.erb new file mode 100644 index 0000000..115fdd9 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/productions/new.html.erb @@ -0,0 +1,3 @@ +

New Production

+ +<%= render :partial => 'form' %> diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/productions/show.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/productions/show.html.erb new file mode 100644 index 0000000..602c8eb --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/productions/show.html.erb @@ -0,0 +1,18 @@ +

<%= @production.title %>

+ + +<%= image_tag @production.image, :class => 'feature' %> + + + + +
+ <%= link_to 'Edit Production', edit_production_path(@production) %> + <%= link_to 'Delete Production', @production, :method => 'delete' %> +
diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/_form.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/_form.html.erb new file mode 100644 index 0000000..352ade0 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/_form.html.erb @@ -0,0 +1,19 @@ +<%= form_for @theatre do |t| %> + <%= t.label :name %> + <%= t.text_field :name, :required => true, :autofocus => true %> + + <%= t.label :address %> + <%= t.text_field :address %> + + <%= t.label :owner %> + <%= t.text_field :owner %> + + <%= t.label :capacity %> + <%= t.number_field :capacity %> + + <%= t.label :image %> + <%= t.url_field :image, :required => true %> + + + <%= t.submit %> +<% end %> diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/edit.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/edit.html.erb new file mode 100644 index 0000000..b03aa82 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/edit.html.erb @@ -0,0 +1,4 @@ +

Edit Theatre

+ + +<%= render :partial => 'form' %> diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/index.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/index.html.erb new file mode 100644 index 0000000..0e04a06 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/index.html.erb @@ -0,0 +1,12 @@ +

Broadway Theatres

+ + +<% @theatres.each do |t| %> + <%= image_tag t.image, :class => 'thumb' %> + +<% end %> diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/new.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/new.html.erb new file mode 100644 index 0000000..cd0b81c --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/new.html.erb @@ -0,0 +1,3 @@ +

New Theatre

+ +<%= render :partial => 'form' %> diff --git a/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/show.html.erb b/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/show.html.erb new file mode 100644 index 0000000..7d06d2f --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/app/views/theatres/show.html.erb @@ -0,0 +1,19 @@ +

<%= @theatre.name %>

+ + +<%= image_tag @theatre.image, :class => 'feature' %> + + + + +
+ <%= link_to 'Edit Theatre', edit_theatre_path(@theatre) %> + <%= link_to 'Delete Theatre', @theatre, :method => 'delete' %> +
diff --git a/jonathan_macmillan/week_05/homework/broadway/bin/bundle b/jonathan_macmillan/week_05/homework/broadway/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/jonathan_macmillan/week_05/homework/broadway/bin/rails b/jonathan_macmillan/week_05/homework/broadway/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/jonathan_macmillan/week_05/homework/broadway/bin/rake b/jonathan_macmillan/week_05/homework/broadway/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/jonathan_macmillan/week_05/homework/broadway/bin/setup b/jonathan_macmillan/week_05/homework/broadway/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/jonathan_macmillan/week_05/homework/broadway/bin/spring b/jonathan_macmillan/week_05/homework/broadway/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/jonathan_macmillan/week_05/homework/broadway/bin/update b/jonathan_macmillan/week_05/homework/broadway/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/jonathan_macmillan/week_05/homework/broadway/bin/yarn b/jonathan_macmillan/week_05/homework/broadway/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/jonathan_macmillan/week_05/homework/broadway/config.ru b/jonathan_macmillan/week_05/homework/broadway/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/jonathan_macmillan/week_05/homework/broadway/config/application.rb b/jonathan_macmillan/week_05/homework/broadway/config/application.rb new file mode 100644 index 0000000..151065c --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Broadway + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/jonathan_macmillan/week_05/homework/broadway/config/boot.rb b/jonathan_macmillan/week_05/homework/broadway/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/jonathan_macmillan/week_05/homework/broadway/config/cable.yml b/jonathan_macmillan/week_05/homework/broadway/config/cable.yml new file mode 100644 index 0000000..1900334 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: broadway_production diff --git a/jonathan_macmillan/week_05/homework/broadway/config/credentials.yml.enc b/jonathan_macmillan/week_05/homework/broadway/config/credentials.yml.enc new file mode 100644 index 0000000..d99f84e --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/credentials.yml.enc @@ -0,0 +1 @@ +TZfDmevx3Re3Ph6jazz5cWCu/4p85NbUKV2jf4owQ4d1daGYGn1JTO+LuF5FGeT/HRvHZ/G/VbNGoKbwRDwicLuI3bIbmbL9HErnJprQyrVfYz9+fVTnE30/2Yg83HB06STPfVAWKUXEcDZ5ImJND/WP4qyc1lnYu9K51e0A5Q+hlXqeSPYPDiNnKA564PWa7AlCSx563tmRa/JNx1d00bbmOoTSHM2XNHE+YxFja3c/8FQnwI2laUk5cha9Nv3PnZUXLgwil49SEAYeFVzgQ/cHm2Z/BFAPvbA8pvjCpZrIOv08XYxOoIPkOZU5rVU2IggbYBUCLvyjv6eJyniMZOUVLSCu/K2NUELniTqKc7GyFODQJ57ocNPNu4126reZ/3cRv5VDO6fLsAoqDnjMWKLGkOrNWyvxRpac--j+Gbz/7g98stoIB/--staoOZiuu87eRoZbnlvr+A== \ No newline at end of file diff --git a/jonathan_macmillan/week_05/homework/broadway/config/database.yml b/jonathan_macmillan/week_05/homework/broadway/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/jonathan_macmillan/week_05/homework/broadway/config/environment.rb b/jonathan_macmillan/week_05/homework/broadway/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/jonathan_macmillan/week_05/homework/broadway/config/environments/development.rb b/jonathan_macmillan/week_05/homework/broadway/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/jonathan_macmillan/week_05/homework/broadway/config/environments/production.rb b/jonathan_macmillan/week_05/homework/broadway/config/environments/production.rb new file mode 100644 index 0000000..5d6abaf --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "broadway_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/jonathan_macmillan/week_05/homework/broadway/config/environments/test.rb b/jonathan_macmillan/week_05/homework/broadway/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/jonathan_macmillan/week_05/homework/broadway/config/initializers/application_controller_renderer.rb b/jonathan_macmillan/week_05/homework/broadway/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/jonathan_macmillan/week_05/homework/broadway/config/initializers/assets.rb b/jonathan_macmillan/week_05/homework/broadway/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/jonathan_macmillan/week_05/homework/broadway/config/initializers/backtrace_silencers.rb b/jonathan_macmillan/week_05/homework/broadway/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/jonathan_macmillan/week_05/homework/broadway/config/initializers/content_security_policy.rb b/jonathan_macmillan/week_05/homework/broadway/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/jonathan_macmillan/week_05/homework/broadway/config/initializers/cookies_serializer.rb b/jonathan_macmillan/week_05/homework/broadway/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/jonathan_macmillan/week_05/homework/broadway/config/initializers/filter_parameter_logging.rb b/jonathan_macmillan/week_05/homework/broadway/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/jonathan_macmillan/week_05/homework/broadway/config/initializers/inflections.rb b/jonathan_macmillan/week_05/homework/broadway/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/jonathan_macmillan/week_05/homework/broadway/config/initializers/mime_types.rb b/jonathan_macmillan/week_05/homework/broadway/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/jonathan_macmillan/week_05/homework/broadway/config/initializers/wrap_parameters.rb b/jonathan_macmillan/week_05/homework/broadway/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/jonathan_macmillan/week_05/homework/broadway/config/locales/en.yml b/jonathan_macmillan/week_05/homework/broadway/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/jonathan_macmillan/week_05/homework/broadway/config/master.key b/jonathan_macmillan/week_05/homework/broadway/config/master.key new file mode 100644 index 0000000..642d0cc --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/master.key @@ -0,0 +1 @@ +235754139edd0146c9bf863b9eea019b \ No newline at end of file diff --git a/jonathan_macmillan/week_05/homework/broadway/config/puma.rb b/jonathan_macmillan/week_05/homework/broadway/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/jonathan_macmillan/week_05/homework/broadway/config/routes.rb b/jonathan_macmillan/week_05/homework/broadway/config/routes.rb new file mode 100644 index 0000000..48bbb16 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + resources :productions + resources :theatres +end diff --git a/jonathan_macmillan/week_05/homework/broadway/config/spring.rb b/jonathan_macmillan/week_05/homework/broadway/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/jonathan_macmillan/week_05/homework/broadway/config/storage.yml b/jonathan_macmillan/week_05/homework/broadway/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/jonathan_macmillan/week_05/homework/broadway/db/development.sqlite3 b/jonathan_macmillan/week_05/homework/broadway/db/development.sqlite3 new file mode 100644 index 0000000..9243bc8 Binary files /dev/null and b/jonathan_macmillan/week_05/homework/broadway/db/development.sqlite3 differ diff --git a/jonathan_macmillan/week_05/homework/broadway/db/migrate/20200617084145_create_theatres.rb b/jonathan_macmillan/week_05/homework/broadway/db/migrate/20200617084145_create_theatres.rb new file mode 100644 index 0000000..cd386fe --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/db/migrate/20200617084145_create_theatres.rb @@ -0,0 +1,11 @@ +class CreateTheatres < ActiveRecord::Migration[5.2] + def change + create_table :theatres do |t| + t.text :name + t.text :address + t.text :owner + t.text :image + t.integer :capacity + end + end +end diff --git a/jonathan_macmillan/week_05/homework/broadway/db/migrate/20200617102315_create_productions.rb b/jonathan_macmillan/week_05/homework/broadway/db/migrate/20200617102315_create_productions.rb new file mode 100644 index 0000000..6f5b801 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/db/migrate/20200617102315_create_productions.rb @@ -0,0 +1,12 @@ +class CreateProductions < ActiveRecord::Migration[5.2] + def change + create_table :productions do |p| + p.text :title + p.text :director + p.date :opening + p.date :closing + p.text :image + p.text :awards + end + end +end diff --git a/jonathan_macmillan/week_05/homework/broadway/db/migrate/20200617110810_add_theatre_id_to_productions.rb b/jonathan_macmillan/week_05/homework/broadway/db/migrate/20200617110810_add_theatre_id_to_productions.rb new file mode 100644 index 0000000..0d2deef --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/db/migrate/20200617110810_add_theatre_id_to_productions.rb @@ -0,0 +1,5 @@ +class AddTheatreIdToProductions < ActiveRecord::Migration[5.2] + def change + add_column :productions, :theatre_id, :integer + end +end diff --git a/jonathan_macmillan/week_05/homework/broadway/db/schema.rb b/jonathan_macmillan/week_05/homework/broadway/db/schema.rb new file mode 100644 index 0000000..1b3dcfe --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/db/schema.rb @@ -0,0 +1,33 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_17_110810) do + + create_table "productions", force: :cascade do |t| + t.text "title" + t.text "director" + t.date "opening" + t.date "closing" + t.text "image" + t.text "awards" + t.integer "theatre_id" + end + + create_table "theatres", force: :cascade do |t| + t.text "name" + t.text "address" + t.text "owner" + t.text "image" + t.integer "capacity" + end + +end diff --git a/jonathan_macmillan/week_05/homework/broadway/db/seeds.rb b/jonathan_macmillan/week_05/homework/broadway/db/seeds.rb new file mode 100644 index 0000000..0467054 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/db/seeds.rb @@ -0,0 +1,18 @@ +Theatre.destroy_all + +Theatre.create(:name => 'Vivian Beaumont Theater', :address => '150 W 65th St., New York, NY', :owner => 'Lincoln Center Theater', :image => 'https://d2h3be0wxzd04n.cloudfront.net/uploads/mapplace.images.heroLarge-81c67a7769a931d8cc37620ec0ce8803.jpg', :capacity => 1200) +Theatre.create(:name => 'Broadway Theater', :address => '1681 Broadway, New York, NY', :owner => 'The Schubert Foundation', :image => 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/King_Kong_at_the_Broadway_Theater_%2848047447453%29.jpg/1200px-King_Kong_at_the_Broadway_Theater_%2848047447453%29.jpg', :capacity => 1761) +Theatre.create(:name => 'Winter Garden Theatre', :address => '1634 Broadway, New York, NY', :owner => 'The Schubert Foundation', :image => 'https://live.staticflickr.com/7309/9666337577_fb036b6dd5_b.jpg', :capacity => 1526) + + +puts "#{ Theatre.count } theatres created." + + +Production.destroy_all + +Production.create(:title => 'War Horse', :director => 'Tom Morris and Marianne Elliott', :opening => '2011-04-14', :closing => '2013-01-13', :image => 'https://i.pinimg.com/originals/c9/72/52/c97252c81aed7db6f1c8d2e5225c28a1.jpg', :awards => '5 Tony Awards - including for Best Play') + +Production.create(:title => 'King Kong', :director => 'Drew McOnie', :opening => '2018-11-08', :closing => '2019-08-18', :image => 'https://pyxis.nymag.com/v1/imgs/b43/894/af17285f8e5397e74db95a9a21dd2df99a-26-king-kong-alive-poster-3.2x.w710.jpg', :awards => 'Special Tony Award to Creature Technology Company') + + +puts "#{ Production.count } productions created." diff --git a/jonathan_macmillan/week_05/homework/broadway/db/test.sqlite3 b/jonathan_macmillan/week_05/homework/broadway/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/lib/assets/.keep b/jonathan_macmillan/week_05/homework/broadway/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/lib/tasks/.keep b/jonathan_macmillan/week_05/homework/broadway/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/package.json b/jonathan_macmillan/week_05/homework/broadway/package.json new file mode 100644 index 0000000..1907781 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/package.json @@ -0,0 +1,5 @@ +{ + "name": "broadway", + "private": true, + "dependencies": {} +} diff --git a/jonathan_macmillan/week_05/homework/broadway/public/404.html b/jonathan_macmillan/week_05/homework/broadway/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/jonathan_macmillan/week_05/homework/broadway/public/422.html b/jonathan_macmillan/week_05/homework/broadway/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/jonathan_macmillan/week_05/homework/broadway/public/500.html b/jonathan_macmillan/week_05/homework/broadway/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/jonathan_macmillan/week_05/homework/broadway/public/apple-touch-icon-precomposed.png b/jonathan_macmillan/week_05/homework/broadway/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/public/apple-touch-icon.png b/jonathan_macmillan/week_05/homework/broadway/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/public/favicon.ico b/jonathan_macmillan/week_05/homework/broadway/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/public/robots.txt b/jonathan_macmillan/week_05/homework/broadway/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/jonathan_macmillan/week_05/homework/broadway/storage/.keep b/jonathan_macmillan/week_05/homework/broadway/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/broadway/untitled b/jonathan_macmillan/week_05/homework/broadway/untitled new file mode 100644 index 0000000..0e777fb --- /dev/null +++ b/jonathan_macmillan/week_05/homework/broadway/untitled @@ -0,0 +1,19 @@ +Broadway + +Theatres + +id name address owned_by image capacity +intg text text text text date + LCT + Broadway 1681 Bway, NY, NY Schubert Org 1924 + + + + + + +Productions + +id name opened closed image awards +intg text date date text text + War Horse 2011 2013 6 Tony Awards diff --git a/jonathan_macmillan/week_05/homework/broadway/vendor/.keep b/jonathan_macmillan/week_05/homework/broadway/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/.gitignore b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/.gitignore new file mode 100644 index 0000000..81452db --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/.gitignore @@ -0,0 +1,31 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore uploaded files in development +/storage/* +!/storage/.keep + +/node_modules +/yarn-error.log + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/.ruby-version b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/Gemfile b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/Gemfile new file mode 100644 index 0000000..4420e0e --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/Gemfile @@ -0,0 +1,63 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'pry-rails' + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/Gemfile.lock b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/Gemfile.lock new file mode 100644 index 0000000..651004e --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/Gemfile.lock @@ -0,0 +1,227 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.32.2) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + io-like (0.3.1) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (1.7.1) + ruby_dep (1.5.0) + rubyzip (2.3.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/README.md b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/Rakefile b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/config/manifest.js b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/images/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/javascripts/application.js b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/javascripts/cable.js b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/javascripts/channels/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/stylesheets/application.css b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/channels/application_cable/channel.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/channels/application_cable/connection.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/controllers/application_controller.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/controllers/application_controller.rb new file mode 100644 index 0000000..75f1154 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + skip_before_action :verify_authenticity_token +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/controllers/concerns/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/controllers/oceans_controller.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/controllers/oceans_controller.rb new file mode 100644 index 0000000..732cfc0 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/controllers/oceans_controller.rb @@ -0,0 +1,41 @@ +class OceansController < ApplicationController + + def index + @oceans = Ocean.all + end + + def show + @ocean = Ocean.find params[:id] + end + + def form + end + + def create + ocean = Ocean.create :name => params[:name], :age => params[:age], :image => params[:image], :hustle => params[:hustle] + redirect_to ocean_path(ocean.id) + end + + + def edit + @ocean = Ocean.find params[:id] + end + + + def update + ocean = Ocean.find params[:id] + ocean.name = params[:name] + ocean.age = params[:age] + ocean.image = params[:image] + ocean.hustle = params[:hustle] + ocean.save + redirect_to ocean_path(ocean.id) + end + + def destroy + ocean = Ocean.find params[:id] + ocean.destroy + redirect_to oceans_path + end + +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/helpers/application_helper.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/jobs/application_job.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/mailers/application_mailer.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/models/application_record.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/models/concerns/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/models/ocean.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/models/ocean.rb new file mode 100644 index 0000000..296a08c --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/models/ocean.rb @@ -0,0 +1,2 @@ +class Ocean < ActiveRecord::Base +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/layouts/application.html.erb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/layouts/application.html.erb new file mode 100644 index 0000000..fd9183f --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/layouts/application.html.erb @@ -0,0 +1,22 @@ + + + + OceansApp + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + + + + <%= yield %> + + diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/layouts/mailer.html.erb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/layouts/mailer.text.erb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/edit.html.erb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/edit.html.erb new file mode 100644 index 0000000..cee3acd --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/edit.html.erb @@ -0,0 +1,29 @@ + +

update form

+ +
+ + + + + + + + + + + + +
diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/form.html.erb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/form.html.erb new file mode 100644 index 0000000..d24556b --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/form.html.erb @@ -0,0 +1,29 @@ +

a big fuckin form, make a new ocean

+

hideous form to follow

+ +
+ + + + + + + + + + + + +
diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/index.html.erb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/index.html.erb new file mode 100644 index 0000000..86e1ab6 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/index.html.erb @@ -0,0 +1,9 @@ +

All Oceans

+ + + +<% @oceans.each do |ocean| %> +

+ <%= link_to ocean.name, ocean_path(ocean.id) %> +

+<% end %> diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/show.html.erb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/show.html.erb new file mode 100644 index 0000000..7e39625 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/app/views/oceans/show.html.erb @@ -0,0 +1,18 @@ +

Here should be an individual ocean

+ + + + +<%= image_tag @ocean.image, :class => 'feature' if @ocean.image.present? %> + + +

<%= @ocean.name %>

+

<%= @ocean.age %>

+

<%= @ocean.hustle %>

+ + + +
+ <%= link_to 'Edit Ocean', edit_ocean_path(@ocean.id) %> + <%= button_to 'Delete Ocean', ocean_path(@ocean.id), :method => 'delete' %> +
diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/bundle b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/rails b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/rake b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/setup b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/spring b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/update b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/yarn b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config.ru b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/application.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/application.rb new file mode 100644 index 0000000..f3f2e2d --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/application.rb @@ -0,0 +1,19 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module OceansApp + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/boot.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/cable.yml b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/cable.yml new file mode 100644 index 0000000..0e03272 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: oceans_app_production diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/credentials.yml.enc b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/credentials.yml.enc new file mode 100644 index 0000000..00e961c --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/credentials.yml.enc @@ -0,0 +1 @@ +UmAEx/1SulWKpuG9M+j6/yLF+WZuNiwV9KleslHt3y+nAX9alQTzqXoAoFxIUNYCrxQsawbwYU1o9SGK3sDF5xhAajMnc0NAGVgDVjsTMj4brMlBqNu25ThN07yV1qki/vGdMJ9PH7DLDHWZAH2qsz+vwuRd0nPnuxt1JQ7TN+m+xQs+Q9qYftZa3iCLITHASZXrqtkF4cSwQneK1b/vEiU4KPa/hUx8G9zX2wG/Ft13jHTLYJ6OpcTNe5buRMYXmohUjyi3h3YgTKDKkiDMxHHpiOlXt3QqGJAtSXaCQUgFRuiwSr/BuUdAOEh2GYgWz6f096puxl+4M216+w4d6hLEziYfpVMuuErsyECeDExjkKSOrJhnjNI4txRpP/mPzeERkqjPgI4uu7M2NOcBDCX2tUrsB1P7/3RQ--4WopqoBv68B3D8R8--JILeZulaK1c6bWO1jH7j4A== \ No newline at end of file diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/database.yml b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environment.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environments/development.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environments/production.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environments/production.rb new file mode 100644 index 0000000..cab5e3e --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "oceans_app_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environments/test.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/application_controller_renderer.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/assets.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/backtrace_silencers.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/content_security_policy.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/cookies_serializer.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/filter_parameter_logging.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/inflections.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/mime_types.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/wrap_parameters.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/locales/en.yml b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/puma.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/routes.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/routes.rb new file mode 100644 index 0000000..446f8f3 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/routes.rb @@ -0,0 +1,24 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + + # We're gonna need 7 routes + + root :to => 'oceans#index' + get '/oceans' => 'oceans#index' + post '/oceans' => 'oceans#create' + + get '/oceans/new' => 'oceans#form', :as => 'new_ocean' + + get '/oceans/:id' => 'oceans#show', :as => 'ocean' + post '/oceans/:id' => 'oceans#update' + delete '/oceans/:id' => 'oceans#destroy' + + get '/oceans/:id/edit' => 'oceans#edit', :as => 'edit_ocean' + +end + + + + + +# https://i.insider.com/5a392480d03e2de6028b4574?width=1100&format=jpeg&auto=webp George Clooney image diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/spring.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/storage.yml b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/db/create_oceans.sql b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/db/create_oceans.sql new file mode 100644 index 0000000..1e9188c --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/db/create_oceans.sql @@ -0,0 +1,7 @@ +CREATE TABLE oceans ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + age INTEGER, + image TEXT, + hustle TEXT +); diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/db/seeds.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/db/seeds.rb new file mode 100644 index 0000000..dd08d02 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/db/seeds.rb @@ -0,0 +1,15 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) +Ocean.destroy_all + +Ocean.create :name => 'Danny Ocean', :age => '45', :hustle => 'Con Man' +Ocean.create :name => 'Tess Ocean', :age => '40', :hustle => 'Con Woman' +Ocean.create :name => 'Rusty Ryan', :age => '40', :hustle => 'Operations' + + +puts "#{Ocean.count} planets available." diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/lib/assets/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/lib/tasks/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/package.json b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/package.json new file mode 100644 index 0000000..4ab5623 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/package.json @@ -0,0 +1,5 @@ +{ + "name": "oceans_app", + "private": true, + "dependencies": {} +} diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/404.html b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/422.html b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/500.html b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/apple-touch-icon-precomposed.png b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/apple-touch-icon.png b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/favicon.ico b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/robots.txt b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/storage/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/application_system_test_case.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/controllers/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/fixtures/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/fixtures/files/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/helpers/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/integration/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/mailers/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/models/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/system/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/test_helper.rb b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/test_helper.rb new file mode 100644 index 0000000..3ab84e3 --- /dev/null +++ b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/vendor/.keep b/jonathan_macmillan/week_05/homework/famous_oceans/oceans_app/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/jonathan_macmillan/week_05/homework/games_on_rails/Gemfile.lock b/jonathan_macmillan/week_05/homework/games_on_rails/Gemfile.lock index 12ea763..36b125c 100644 --- a/jonathan_macmillan/week_05/homework/games_on_rails/Gemfile.lock +++ b/jonathan_macmillan/week_05/homework/games_on_rails/Gemfile.lock @@ -108,7 +108,7 @@ GEM mini_portile2 (~> 2.4.0) public_suffix (4.0.5) puma (3.12.6) - rack (2.2.2) + rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.2.4.3) diff --git a/joshua_james_mcdonald/week_04/2020-06-12 weekend homework/database.sqlite3 b/joshua_james_mcdonald/week_04/2020-06-12 weekend homework/database.sqlite3 index 147c715..97604c4 100644 Binary files a/joshua_james_mcdonald/week_04/2020-06-12 weekend homework/database.sqlite3 and b/joshua_james_mcdonald/week_04/2020-06-12 weekend homework/database.sqlite3 differ diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/.ruby-version b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/.ruby-version new file mode 100644 index 0000000..68e042f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.0 \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/Gemfile b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/Gemfile new file mode 100644 index 0000000..205bbe8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/Gemfile @@ -0,0 +1,62 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.0' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/Gemfile.lock b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/Gemfile.lock new file mode 100644 index 0000000..0440ed7 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/Gemfile.lock @@ -0,0 +1,216 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.32.2) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + io-like (0.3.1) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (1.7.1) + ruby_dep (1.5.0) + rubyzip (2.3.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.0p0 + +BUNDLED WITH + 2.1.2 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/README.md b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/Rakefile b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/config/manifest.js b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/images/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/javascripts/application.js b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/javascripts/cable.js b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/javascripts/channels/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/stylesheets/application.css b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/channels/application_cable/channel.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/channels/application_cable/connection.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/application_controller.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/concerns/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/magic8ball_controller.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/magic8ball_controller.rb new file mode 100644 index 0000000..fbd6908 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/magic8ball_controller.rb @@ -0,0 +1,9 @@ +class Magic8ballController < ActionController::Base + def home + render :home + end + def question + @answers = ["Maybe", "Could be", "i dont know","yes","No","Of course","For certain","No way"] + render :result + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/pages_controller.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/pages_controller.rb new file mode 100644 index 0000000..3db409b --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/pages_controller.rb @@ -0,0 +1,5 @@ +class PagesController < ActionController::Base + def home + render :home + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/rockpaperscissors_controller.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/rockpaperscissors_controller.rb new file mode 100644 index 0000000..001b150 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/rockpaperscissors_controller.rb @@ -0,0 +1,5 @@ +class RockpaperscissorsController < ActionController::Base + def home + render :home + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/secretnumber_controller.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/secretnumber_controller.rb new file mode 100644 index 0000000..9efa6ac --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/controllers/secretnumber_controller.rb @@ -0,0 +1,19 @@ +class SecretnumberController < ActionController::Base + def home + @message = "You have not guessed the number yet" + @number = rand(1) # why is this getting called every time check is getting called? + render :home + end + + def check + @message = "thinking..." + if @number.to_s == params[:guess] + @message = "You win!" + puts "YOU WON #####################################################################" + else + puts "YOU DID NOT WIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + end + @otherguessiguess = params[:guess] + render :home + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/helpers/application_helper.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/jobs/application_job.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/mailers/application_mailer.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/models/application_record.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/models/concerns/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/application.html.erb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/application.html.erb new file mode 100644 index 0000000..2056116 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/application.html.erb @@ -0,0 +1,17 @@ + + + + GamesOnRails + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + +
This is the header
+ <%= yield %> + + + diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/mailer.html.erb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/mailer.text.erb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/pages.html.erb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/pages.html.erb new file mode 100644 index 0000000..2056116 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/layouts/pages.html.erb @@ -0,0 +1,17 @@ + + + + GamesOnRails + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + +
This is the header
+ <%= yield %> + + + diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/magic8ball/home.html.erb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/magic8ball/home.html.erb new file mode 100644 index 0000000..1e173e8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/magic8ball/home.html.erb @@ -0,0 +1 @@ +Magic 8 ball page \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/magic8ball/result.html.erb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/magic8ball/result.html.erb new file mode 100644 index 0000000..0d0764c --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/magic8ball/result.html.erb @@ -0,0 +1 @@ +This answer to your question "<%= params[:question] %>" is "<%= @answers.sample %>" \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/pages/home.html.erb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/pages/home.html.erb new file mode 100644 index 0000000..f9df11d --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/pages/home.html.erb @@ -0,0 +1,7 @@ +

Games!Games!Games!

+

Enough games to give the developer carpal tunnel!

+ \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/rockpaperscissors/home.html.erb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/rockpaperscissors/home.html.erb new file mode 100644 index 0000000..8def762 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/rockpaperscissors/home.html.erb @@ -0,0 +1 @@ +rock paper scissors page \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/secretNumber/home.html.erb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/secretNumber/home.html.erb new file mode 100644 index 0000000..442f1b9 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/app/views/secretNumber/home.html.erb @@ -0,0 +1,15 @@ +secret number page +
+ + + +
+message: <%= @message %>
+message done a more annoying way: +<% if @number.to_s == params[:guess] %> +Congrats! you guessed the number +<% end %>
+condition: <%= @number.to_s == params[:guess] %>
+number: <%= @number %>
+guess: <%= params[:guess] %>
+<%= @otherguessiguess %> \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/bundle b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/bundle new file mode 100644 index 0000000..f19acf5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/rails b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/rails new file mode 100644 index 0000000..5badb2f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/rake b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/rake new file mode 100644 index 0000000..d87d5f5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/setup b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/setup new file mode 100644 index 0000000..94fd4d7 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/spring b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/spring new file mode 100644 index 0000000..d89ee49 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/update b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/update new file mode 100644 index 0000000..58bfaed --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/yarn b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/yarn new file mode 100644 index 0000000..460dd56 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config.ru b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/application.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/application.rb new file mode 100644 index 0000000..dfc9199 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/application.rb @@ -0,0 +1,19 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module GamesOnRails + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/boot.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/cable.yml b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/cable.yml new file mode 100644 index 0000000..79625f8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: GamesOnRails_production diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/credentials.yml.enc b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/credentials.yml.enc new file mode 100644 index 0000000..bb43c6a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/credentials.yml.enc @@ -0,0 +1 @@ +kz0xHWCkskGer47OLdlWEX9A/W8HHmI8gF+hOQGmwDtEDe3tf1uzdVIN8++24t9i/EJ9iCp34TItnLXAfNBWHlbjJavJY9xsYUU4ep1z1LihhitJmiFvH62x4wEa7hr9Je4c8KLdozbvm3npUOeYcGD7sieiV6wtgn9u9B3e9PXaXHk80M1JBdYehC831VthSvkTnmc55T2Q5LHpS9TPo3kZp8lbgpC/0xbFvgVLA2qCA9HSLf4erwvRBKLe0CqornXlfUMi1mfOMd24rhMhri8MUUeDR2lGcCj5QRcenF/sgQy5y3dnoY6QO7QlqVztivyTUeg81sXLYGa1we+qtWovbnbYbOjXrION2Qn10EsLMjvjKXF0ex+8SBZWjgbzciLOiGXUkB4w0PHMHMxHMgT75eEN7iufG+z7--q4EwxL5UsbOBNEyZ--zm37Q3dhoEa0Tk+Rv3YmHw== \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/database.yml b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environment.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environments/development.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environments/production.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environments/production.rb new file mode 100644 index 0000000..df6a64b --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "GamesOnRails_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environments/test.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/application_controller_renderer.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/assets.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/backtrace_silencers.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/content_security_policy.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/cookies_serializer.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/filter_parameter_logging.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/inflections.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/mime_types.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/wrap_parameters.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/locales/en.yml b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/master.key b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/master.key new file mode 100644 index 0000000..d62d447 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/master.key @@ -0,0 +1 @@ +d0d7e0ca1ff2ba6b17a379dbafba0d2f \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/puma.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/routes.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/routes.rb new file mode 100644 index 0000000..ef22086 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/routes.rb @@ -0,0 +1,13 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + root :to => 'pages#home' + + get "/magic8ball" => 'magic8ball#home' + get "/magic8ball/:question" => 'magic8ball#question' + + get "/secretnumber" => 'secretnumber#home' + get "/secretnumber/:guess" => 'secretnumber#check' + + + get "/rockpaperscissors" => 'rockpaperscissors#home' +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/spring.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/storage.yml b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/db/development.sqlite3 b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/db/development.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/db/seeds.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/db/seeds.rb new file mode 100644 index 0000000..1beea2a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/lib/assets/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/lib/tasks/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/package.json b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/package.json new file mode 100644 index 0000000..51d60c4 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/package.json @@ -0,0 +1,5 @@ +{ + "name": "GamesOnRails", + "private": true, + "dependencies": {} +} diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/404.html b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/422.html b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/500.html b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/apple-touch-icon-precomposed.png b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/apple-touch-icon.png b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/favicon.ico b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/robots.txt b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/storage/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/application_system_test_case.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/controllers/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/fixtures/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/fixtures/files/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/helpers/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/integration/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/mailers/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/models/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/system/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/test_helper.rb b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/test_helper.rb new file mode 100644 index 0000000..3ab84e3 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/vendor/.keep b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/GamesOnRails/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-15 games on rails/games-on-rails.md b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/games-on-rails.md new file mode 100644 index 0000000..f1eabf5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-15 games on rails/games-on-rails.md @@ -0,0 +1,23 @@ +# Games on Rails + +Games on Rails is a web application with three games + +* Magic 8 Ball +* Secret Number +* Rock Paper Scissors + +__Magic 8 Ball__ + +* Magic 8 ball takes user's questions from the the URL as params and returns a positive or negative answer. + +__Secret Number__ + +* Users click a number between 1 and 10. The controller validates the guess and renders the win or lose view. + +__Rock Paper Scissors__ + +* Create a route that goes from ```/games/rock_paper_scissors/:throw``` to ```games#rock_paper_scissors_play``` +* Use params[:throw] as a user's choice +* Compare the 2! If users throw matches the apps throw, the user wins. +* i.e. If a user throws rock ```http://localhost:3000/games/rock_paper_scissors/rock``` and the server picks rock player wins! (Yes, I know that is not how RPS works) +Bonus: Set the win or lose condition based on the real rules of [Rock Paper Scissors](http://en.wikipedia.org/wiki/Rock-paper-scissors). \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/.gitignore b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/.gitignore new file mode 100644 index 0000000..81452db --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/.gitignore @@ -0,0 +1,31 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore uploaded files in development +/storage/* +!/storage/.keep + +/node_modules +/yarn-error.log + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/.ruby-version b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/.ruby-version new file mode 100644 index 0000000..68e042f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.0 \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/Gemfile b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/Gemfile new file mode 100644 index 0000000..b00f69e --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/Gemfile @@ -0,0 +1,64 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.0' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem 'pry-rails' + diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/Gemfile.lock b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/Gemfile.lock new file mode 100644 index 0000000..0e96bdb --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/Gemfile.lock @@ -0,0 +1,223 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.32.2) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + io-like (0.3.1) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (1.7.1) + ruby_dep (1.5.0) + rubyzip (2.3.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.0p0 + +BUNDLED WITH + 2.1.2 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/README.md b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/Rakefile b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/config/manifest.js b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/images/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/javascripts/application.js b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/javascripts/cable.js b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/javascripts/channels/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/stylesheets/application.css b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/channels/application_cable/channel.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/channels/application_cable/connection.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/controllers/application_controller.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/controllers/concerns/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/controllers/oceans_controller.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/controllers/oceans_controller.rb new file mode 100644 index 0000000..556501a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/controllers/oceans_controller.rb @@ -0,0 +1,3 @@ +class OceansController < ActionController::Base + +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/helpers/application_helper.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/jobs/application_job.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/mailers/application_mailer.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/models/application_record.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/models/concerns/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/models/ocean.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/models/ocean.rb new file mode 100644 index 0000000..4d22e12 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/models/ocean.rb @@ -0,0 +1,5 @@ +class Ocean < ActiveRecord::Base + def home + render :home + end +end \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/views/layouts/application.html.erb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/views/layouts/application.html.erb new file mode 100644 index 0000000..2b4e5a5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/views/layouts/application.html.erb @@ -0,0 +1,15 @@ + + + + Ocean + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + <%= yield %> + + diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/views/layouts/mailer.html.erb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/views/layouts/mailer.text.erb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/bundle b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/bundle new file mode 100644 index 0000000..f19acf5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/rails b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/rails new file mode 100644 index 0000000..5badb2f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/rake b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/rake new file mode 100644 index 0000000..d87d5f5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/setup b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/setup new file mode 100644 index 0000000..94fd4d7 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/spring b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/spring new file mode 100644 index 0000000..d89ee49 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/update b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/update new file mode 100644 index 0000000..58bfaed --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/yarn b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/yarn new file mode 100644 index 0000000..460dd56 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config.ru b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/application.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/application.rb new file mode 100644 index 0000000..006b52f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/application.rb @@ -0,0 +1,19 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Ocean + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/boot.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/cable.yml b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/cable.yml new file mode 100644 index 0000000..ff253ae --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: Ocean_production diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/credentials.yml.enc b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/credentials.yml.enc new file mode 100644 index 0000000..a794295 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/credentials.yml.enc @@ -0,0 +1 @@ +zE9vPdzDI10DpzMWOLB1ZLZ6Rcm+v/X5Rc0HQBLfJfkYlioATV5+cR3FUw6IQ3iYVuj+Wxgyyt8n5I0atS6rLhyMn/Yk+eEmDhxjc/YUtS6kz4IMo31ZFreLEckphIcYjrgFxAZ807Jbs/+v+TNwTwJ0Ena35mTQeDuyfzaEMRl+FXCo4YZXAsszq5eTevJJipvRPpihH4FDrnl75zWjQwv8XDvV8JXii90IqZY4YdEwMlehdpyNuHjp+c2+kKxPUdUF25/iklRteamWlb8cD+w2h6Db9VmXftFogVpf0eqKHArMVSzkaMkXc9efUb5HFhZVBZtleRUaheE/LJYQr9njv3oyGcFK+tq97g2Qp6kmvK/U2WcoMxPaWYjHzo6zUpEcXVGSCbC8hFafRPe3uz5FbPlnl0CfbQEV--SON7UOqX+GWql38f--xyzNNXdaDcTGFzQpyZZGSA== \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/database.yml b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environment.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environments/development.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environments/production.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environments/production.rb new file mode 100644 index 0000000..b57c8f5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "Ocean_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environments/test.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/application_controller_renderer.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/assets.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/backtrace_silencers.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/content_security_policy.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/cookies_serializer.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/filter_parameter_logging.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/inflections.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/mime_types.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/wrap_parameters.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/locales/en.yml b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/puma.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/routes.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/routes.rb new file mode 100644 index 0000000..787824f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/spring.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/storage.yml b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/db/create_oceans.sql b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/db/create_oceans.sql new file mode 100644 index 0000000..2cb123b --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/db/create_oceans.sql @@ -0,0 +1,6 @@ +CREATE TABLE oceans( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + image TEXT, + hemisphere TEXT +); diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/db/seeds.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/db/seeds.rb new file mode 100644 index 0000000..1beea2a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/lib/assets/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/lib/tasks/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/package.json b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/package.json new file mode 100644 index 0000000..a4058a2 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/package.json @@ -0,0 +1,5 @@ +{ + "name": "Ocean", + "private": true, + "dependencies": {} +} diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/404.html b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/422.html b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/500.html b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/apple-touch-icon-precomposed.png b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/apple-touch-icon.png b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/favicon.ico b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/robots.txt b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/storage/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/application_system_test_case.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/controllers/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/fixtures/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/fixtures/files/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/helpers/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/integration/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/mailers/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/models/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/system/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/test_helper.rb b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/test_helper.rb new file mode 100644 index 0000000..3ab84e3 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/vendor/.keep b/joshua_james_mcdonald/week_05/2020-06-16 Rails CRUD/Ocean/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/.ruby-version b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/.ruby-version new file mode 100644 index 0000000..68e042f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.0 \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/Gemfile b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/Gemfile new file mode 100644 index 0000000..638676e --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/Gemfile @@ -0,0 +1,56 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.0' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/Gemfile.lock b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/Gemfile.lock new file mode 100644 index 0000000..6e19cf2 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/Gemfile.lock @@ -0,0 +1,195 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.6.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.0p0 + +BUNDLED WITH + 2.1.4 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/README.md b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/Rakefile b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/config/manifest.js b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/images/.keep b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/application.js b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/cable.js b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/channels/.keep b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/customers.coffee b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/customers.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/customers.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/orders.coffee b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/orders.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/orders.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/products.coffee b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/products.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/javascripts/products.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/application.css b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/customers.scss b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/customers.scss new file mode 100644 index 0000000..b6c7ce5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/customers.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Customers controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/orders.scss b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/orders.scss new file mode 100644 index 0000000..7415069 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/orders.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Orders controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/products.scss b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/products.scss new file mode 100644 index 0000000..bff386e --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/assets/stylesheets/products.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Products controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/channels/application_cable/channel.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/channels/application_cable/connection.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/application_controller.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/concerns/.keep b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/customers_controller.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/customers_controller.rb new file mode 100644 index 0000000..322c3b9 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/customers_controller.rb @@ -0,0 +1,13 @@ +class CustomersController < ApplicationController + def index + end + + def new + end + + def edit + end + + def show + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/orders_controller.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/orders_controller.rb new file mode 100644 index 0000000..766b7b1 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/orders_controller.rb @@ -0,0 +1,13 @@ +class OrdersController < ApplicationController + def index + end + + def new + end + + def edit + end + + def show + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/products_controller.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/products_controller.rb new file mode 100644 index 0000000..0f83df8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/controllers/products_controller.rb @@ -0,0 +1,13 @@ +class ProductsController < ApplicationController + def index + end + + def new + end + + def edit + end + + def show + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/application_helper.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/customers_helper.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/customers_helper.rb new file mode 100644 index 0000000..a07ce29 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/customers_helper.rb @@ -0,0 +1,2 @@ +module CustomersHelper +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/orders_helper.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/orders_helper.rb new file mode 100644 index 0000000..443227f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/orders_helper.rb @@ -0,0 +1,2 @@ +module OrdersHelper +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/products_helper.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/products_helper.rb new file mode 100644 index 0000000..ab5c42b --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/helpers/products_helper.rb @@ -0,0 +1,2 @@ +module ProductsHelper +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/jobs/application_job.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/mailers/application_mailer.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/application_record.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/concerns/.keep b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/customers.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/customers.rb new file mode 100644 index 0000000..04e59aa --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/customers.rb @@ -0,0 +1,2 @@ +class Customers < ActiveRecord::Base +end \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/order_items.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/order_items.rb new file mode 100644 index 0000000..57bf398 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/order_items.rb @@ -0,0 +1,3 @@ +class OrderItems < ActiveRecord::Bases + belongs_to :Order +end \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/orders.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/orders.rb new file mode 100644 index 0000000..7b6fd9b --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/orders.rb @@ -0,0 +1,4 @@ +class Orders < ActiveRecord::Base + belongs_to :customer + has_many :order_items +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/products.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/products.rb new file mode 100644 index 0000000..23e3ec8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/models/products.rb @@ -0,0 +1,2 @@ +class Products < ActiveRecord::Base +end \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/edit.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/edit.html.erb new file mode 100644 index 0000000..b8e5038 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/edit.html.erb @@ -0,0 +1,2 @@ +

Customers#edit

+

Find me in app/views/customers/edit.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/index.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/index.html.erb new file mode 100644 index 0000000..2aa04b9 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/index.html.erb @@ -0,0 +1,2 @@ +

Customers#index

+

Find me in app/views/customers/index.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/new.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/new.html.erb new file mode 100644 index 0000000..c0c74d3 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/new.html.erb @@ -0,0 +1,2 @@ +

Customers#new

+

Find me in app/views/customers/new.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/show.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/show.html.erb new file mode 100644 index 0000000..89bd684 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/customers/show.html.erb @@ -0,0 +1,2 @@ +

Customers#show

+

Find me in app/views/customers/show.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/layouts/application.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/layouts/application.html.erb new file mode 100644 index 0000000..babd0c5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/layouts/application.html.erb @@ -0,0 +1,15 @@ + + + + CoolCompany + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + <%= yield %> + + diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/layouts/mailer.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/layouts/mailer.text.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/edit.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/edit.html.erb new file mode 100644 index 0000000..7de9049 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/edit.html.erb @@ -0,0 +1,2 @@ +

Orders#edit

+

Find me in app/views/orders/edit.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/index.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/index.html.erb new file mode 100644 index 0000000..d63a69f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/index.html.erb @@ -0,0 +1,2 @@ +

Orders#index

+

Find me in app/views/orders/index.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/new.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/new.html.erb new file mode 100644 index 0000000..1bc2760 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/new.html.erb @@ -0,0 +1,2 @@ +

Orders#new

+

Find me in app/views/orders/new.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/show.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/show.html.erb new file mode 100644 index 0000000..22eb495 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/orders/show.html.erb @@ -0,0 +1,2 @@ +

Orders#show

+

Find me in app/views/orders/show.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/edit.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/edit.html.erb new file mode 100644 index 0000000..279b066 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/edit.html.erb @@ -0,0 +1,2 @@ +

Products#edit

+

Find me in app/views/products/edit.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/index.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/index.html.erb new file mode 100644 index 0000000..f8eeb82 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/index.html.erb @@ -0,0 +1,2 @@ +

Products#index

+

Find me in app/views/products/index.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/new.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/new.html.erb new file mode 100644 index 0000000..a14e0d9 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/new.html.erb @@ -0,0 +1,2 @@ +

Products#new

+

Find me in app/views/products/new.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/show.html.erb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/show.html.erb new file mode 100644 index 0000000..5f44ec4 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/app/views/products/show.html.erb @@ -0,0 +1,2 @@ +

Products#show

+

Find me in app/views/products/show.html.erb

diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/bundle b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/bundle new file mode 100644 index 0000000..f19acf5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/rails b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/rails new file mode 100644 index 0000000..5badb2f --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/rake b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/rake new file mode 100644 index 0000000..d87d5f5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/setup b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/setup new file mode 100644 index 0000000..94fd4d7 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/spring b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/spring new file mode 100644 index 0000000..d89ee49 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/update b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/update new file mode 100644 index 0000000..58bfaed --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/yarn b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/yarn new file mode 100644 index 0000000..460dd56 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config.ru b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/application.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/application.rb new file mode 100644 index 0000000..af82720 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module CoolCompany + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/boot.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/cable.yml b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/cable.yml new file mode 100644 index 0000000..1102fd5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: CoolCompany_production diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/credentials.yml.enc b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/credentials.yml.enc new file mode 100644 index 0000000..6837114 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/credentials.yml.enc @@ -0,0 +1 @@ +t4wIqRQrMJxBPFq/bMifH8fQSBVCmRe/pUvkUtWnVbNgey7gHovWIujmqPjCMo/bwZ96vdn6aIVHIJNXtiq+WmV+w1TuG1P1mCT5CZjzkPZGcoRdluUjA1fj84rvZIzVlYVfVBWB9avH5zXQSt5AZXHgU/CzBtspPY1MMVzJHPoBb95iSQEu9jl47bDiTVO0V6rRvswbfb7tuxE040mjRM/mp5vckz6BPvbk9qG+wrevuKfIRkV1MW3MkiOcgjnyOutWiOKP41/tZKiUsZY7Ch2RjuWx0laPfgOfAxu2zCjCkLPv3BrEfK5Vxak48w1tfEbLnWbiet826mqo0uPtasvec0goF4WeokX2soiQqOe0jV7auSyRkN20iE/6ooj0GwD72ykD6r4QMTT8d8t650NCOsB0IZcT7WrI--0uoklgIdIlTZcZbH--tgt8OVyzOfWz0AqkxRuYbQ== \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/database.yml b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environment.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environments/development.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environments/production.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environments/production.rb new file mode 100644 index 0000000..4e0b809 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "CoolCompany_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environments/test.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/application_controller_renderer.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/assets.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/backtrace_silencers.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/content_security_policy.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/cookies_serializer.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/filter_parameter_logging.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/inflections.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/mime_types.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/wrap_parameters.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/locales/en.yml b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/master.key b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/master.key new file mode 100644 index 0000000..d9bb4a5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/master.key @@ -0,0 +1 @@ +5d8a2dfbecf223b3b8cc49bc63f3a6a1 \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/puma.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/routes.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/routes.rb new file mode 100644 index 0000000..306fafe --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/routes.rb @@ -0,0 +1,15 @@ +Rails.application.routes.draw do + get 'products/index' + get 'products/new' + get 'products/edit' + get 'products/show' + get 'customers/index' + get 'customers/new' + get 'customers/edit' + get 'customers/show' + get 'orders/index' + get 'orders/new' + get 'orders/edit' + get 'orders/show' + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/spring.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/storage.yml b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/development.sqlite3 b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/development.sqlite3 new file mode 100644 index 0000000..9626ce7 Binary files /dev/null and b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/development.sqlite3 differ diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617210844_create_customers.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617210844_create_customers.rb new file mode 100644 index 0000000..3331cf5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617210844_create_customers.rb @@ -0,0 +1,10 @@ +class CreateCustomers < ActiveRecord::Migration[5.2] + def change + create_table :customers do |t| + t.text :internetEmail + t.text :name + t.text :phoneMobile + + end + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617212726_create_products.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617212726_create_products.rb new file mode 100644 index 0000000..df0db40 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617212726_create_products.rb @@ -0,0 +1,10 @@ +class CreateProducts < ActiveRecord::Migration[5.2] + def change + create_table :products do |t| + t.number :cost + t.int :stockLevel + t.text :productName + t.text :description + end + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617212815_create_orders.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617212815_create_orders.rb new file mode 100644 index 0000000..a64e2fc --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617212815_create_orders.rb @@ -0,0 +1,10 @@ +class CreateOrders < ActiveRecord::Migration[5.2] + def change + create_table :orders do |t| + t.text :datePlaced + t.text :orderStatus + t.references :customers + + end + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617212823_create_order_items.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617212823_create_order_items.rb new file mode 100644 index 0000000..9b41871 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/migrate/20200617212823_create_order_items.rb @@ -0,0 +1,9 @@ +class CreateOrderItems < ActiveRecord::Migration[5.2] + def change + create_table :order_items do |t| + t.integer :quantity + t.references :orders + t.references :products + end + end +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/schema.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/schema.rb new file mode 100644 index 0000000..c4df7eb --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/schema.rb @@ -0,0 +1,43 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_17_212823) do + + create_table "customers", force: :cascade do |t| + t.text "internetEmail" + t.text "name" + t.text "phoneMobile" + end + + create_table "order_items", force: :cascade do |t| + t.integer "quantity" + t.integer "orders_id" + t.integer "products_id" + t.index ["orders_id"], name: "index_order_items_on_orders_id" + t.index ["products_id"], name: "index_order_items_on_products_id" + end + + create_table "orders", force: :cascade do |t| + t.text "datePlaced" + t.text "orderStatus" + t.integer "customers_id" + t.index ["customers_id"], name: "index_orders_on_customers_id" + end + + create_table "products", force: :cascade do |t| + t.text "cost" + t.text "stockLevel" + t.text "productName" + t.text "description" + end + +end diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/seeds.rb b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/seeds.rb new file mode 100644 index 0000000..4527160 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/seeds.rb @@ -0,0 +1,42 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) + + +Customers.destroy_all +c1 = Customers.create :internetEmail => 'pose_kathlyn@gmail.com', :name => 'Makenna Wuckert', :phoneMobile => '1-613-512-0246' +c2 = Customers.create :internetEmail => 'agree@outlook.com', :name => 'Suzanne Thiel', :phoneMobile => '648-930-7381' +c3 = Customers.create :internetEmail => 'when@hotmail.com', :name => 'Beatrice Jakubowski', :phoneMobile => '339-126-9333' +c4 = Customers.create :internetEmail => 'north97@yahoo.com', :name => 'Nestor Kulas', :phoneMobile => '1-339-033-6586' +c5 = Customers.create :internetEmail => 'molestiae@outlook.com', :name => 'Luis Lehner', :phoneMobile => '1-405-161-8993' +c6 = Customers.create :internetEmail => 'josiane@yahoo.com', :name => 'Kaley Price', :phoneMobile => '870.639.6668' +c7 = Customers.create :internetEmail => 'column_autumn@hotmail.com', :name => 'Elvie Reilly', :phoneMobile => '473.578.7554' +c8 = Customers.create :internetEmail => 'clare@gmail.com', :name => 'Sincere Grimes', :phoneMobile => '1-222-162-0869' +c9 = Customers.create :internetEmail => 'guide28@hotmail.com', :name => 'Lavern Schuppe', :phoneMobile => '(487) 576-4918' +c10 = Customers.create :internetEmail => 'santiago@outlook.com', :name => 'Morton Hettinger', :phoneMobile => '1-922-153-1571' +puts "#{ Customers.count } customers created." + +Products.destroy_all +p1 = Products.create :cost => '614.41', :stockLevel => '209', :productName => 'Unaottax', :description => 'how cheerfully we consignourselves to perdition!' +p2 = Products.create :cost => '454.55', :stockLevel => '746', :productName => 'Transapity', :description => 'True, they rather order me about some, and make me jump from spar tospar, like a grasshopper in a May meadow.' +p3 = Products.create :cost => '935.4', :stockLevel => '131', :productName => 'Biotanzap', :description => 'In much the same way do the commonalty lead their leaders in manyother things, at the same time that the leaders little suspect it.' +p4 = Products.create :cost => '455.45', :stockLevel => '577', :productName => 'Qvo sanflex', :description => 'It came inas a sort of brief interlude and solo between more extensiveperformances.' +p5 = Products.create :cost => '488.63', :stockLevel => '800', :productName => 'Toughcom', :description => 'On the contrary, passengers themselves mustpay.' +p6 = Products.create :cost => '738.06', :stockLevel => '604', :productName => 'Black keydox', :description => 'It is a way I have of driving off the spleen and regulating the circulation.' +p7 = Products.create :cost => '606.07', :stockLevel => '385', :productName => 'X- hotlight', :description => 'What does that indignity amount to, weighed,I mean, in the scales of the New Testament?' +p8 = Products.create :cost => '480.2', :stockLevel => '600', :productName => 'Bam-san', :description => 'Let the most absent-minded of men be plunged in his deepest reveries—stand that man on his legs, set his feet a-going, and he will infallibly lead you to water, if water there be in all that region.' +p9 = Products.create :cost => '806.35', :stockLevel => '873', :productName => 'Tampcandex', :description => 'But look! here come more crowds, pacing straight for the water, and seemingly bound for a dive.' +p10 = Products.create :cost => '255.8', :stockLevel => '242', :productName => 'Ron siltam', :description => 'Take almost any path you please, and ten to one it carries you down in a dale, and leaves you there by a pool in the stream.' +puts "#{ Products.count } Products created." + +# Orders.destroy_all +# o1 = Orders.create :customerId => '1', :orderStatus => 'received', :date => '20200618' +# o2 = Orders.create :customerId => '1', :orderStatus => 'received', :date => '20200618' +# o3 = Orders.create :customerId => '3', :orderStatus => 'sent', :date => '20200618' + +# OrderItems.destroy_all +# oi1 = OrderItems.create : \ No newline at end of file diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/test.sqlite3 b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/lib/assets/.keep b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/lib/tasks/.keep b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/package.json b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/package.json new file mode 100644 index 0000000..1b65ac5 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/package.json @@ -0,0 +1,5 @@ +{ + "name": "CoolCompany", + "private": true, + "dependencies": {} +} diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/404.html b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/422.html b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/500.html b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/apple-touch-icon-precomposed.png b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/apple-touch-icon.png b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/favicon.ico b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/robots.txt b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/storage/.keep b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/vendor/.keep b/joshua_james_mcdonald/week_05/2020-06-16/CoolCompany/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/joshua_james_mcdonald/week_05/2020-06-16/Plan.md b/joshua_james_mcdonald/week_05/2020-06-16/Plan.md new file mode 100644 index 0000000..2894e7b --- /dev/null +++ b/joshua_james_mcdonald/week_05/2020-06-16/Plan.md @@ -0,0 +1,15 @@ +# New rails app + +## Main idea + +need 3 tables connected. Let go for a customers, an orders and a products table. + +## tables schema + + Products Orders Customers OrderItems + =========== ============ ========= ============ + Id int primary key auto increment Id int primary key NOINCREMENT Id int primary key auto increment FOREIGN KEY order Id + Name text FirstName text FOREIGN KEY Product ID + Description text FOREIGN KEY customer.id quantity int + CurrentStock text OrderDate datetime PhoneNumber int + cost number Email text diff --git a/joshua_james_mcdonald/week_07/css/styles.css b/joshua_james_mcdonald/week_07/css/styles.css new file mode 100644 index 0000000..855e3c4 --- /dev/null +++ b/joshua_james_mcdonald/week_07/css/styles.css @@ -0,0 +1,4 @@ +.container{ + margin: 0 auto; + width: 60%; +} \ No newline at end of file diff --git a/joshua_james_mcdonald/week_07/index.html b/joshua_james_mcdonald/week_07/index.html new file mode 100644 index 0000000..39c629b --- /dev/null +++ b/joshua_james_mcdonald/week_07/index.html @@ -0,0 +1,20 @@ + + + + + + Book Lookup + + + + + +
+

Enter book title to search

+ + +
+ + + + \ No newline at end of file diff --git a/joshua_james_mcdonald/week_07/js/script.js b/joshua_james_mcdonald/week_07/js/script.js new file mode 100644 index 0000000..37bcb32 --- /dev/null +++ b/joshua_james_mcdonald/week_07/js/script.js @@ -0,0 +1,25 @@ + +const fetchBook = function(){ + const title = document.getElementById('search').value; + console.log(title); + + const xhr = new XMLHttpRequest(); + xhr.open('GET', `https://www.googleapis.com/books/v1/volumes?q=title:${title}`); + xhr.send(); // asynchronous + xhr.onreadystatechange = function(){ + if (xhr.readyState !== 4) return; // not ready yet + const p =document.createElement('p'); + + const img =document.createElement('img'); + const data = JSON.parse(xhr.responseText); + image = data.items[0].volumeInfo.imageLinks.thumbnail; + img.src = image; + p.innerHTML = data.items[0].volumeInfo.title; + document.body.appendChild(p); + document.body.appendChild(img); + + + } +} + +document.getElementById('search-btn').addEventListener('click', fetchBook) \ No newline at end of file diff --git a/matthew_tudman/week04/rails/books/.ruby-version b/matthew_tudman/week04/rails/books/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/matthew_tudman/week04/rails/books/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/matthew_tudman/week04/rails/books/Gemfile b/matthew_tudman/week04/rails/books/Gemfile new file mode 100644 index 0000000..c78957c --- /dev/null +++ b/matthew_tudman/week04/rails/books/Gemfile @@ -0,0 +1,56 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/matthew_tudman/week04/rails/books/Gemfile.lock b/matthew_tudman/week04/rails/books/Gemfile.lock new file mode 100644 index 0000000..a8c8a99 --- /dev/null +++ b/matthew_tudman/week04/rails/books/Gemfile.lock @@ -0,0 +1,219 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.32.2) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + io-like (0.3.1) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.6.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (1.7.1) + ruby_dep (1.5.0) + rubyzip (2.3.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/matthew_tudman/week04/rails/books/README.md b/matthew_tudman/week04/rails/books/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/matthew_tudman/week04/rails/books/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/matthew_tudman/week04/rails/books/Rakefile b/matthew_tudman/week04/rails/books/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/matthew_tudman/week04/rails/books/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/matthew_tudman/week04/rails/books/app/assets/config/manifest.js b/matthew_tudman/week04/rails/books/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/matthew_tudman/week04/rails/books/app/assets/images/.keep b/matthew_tudman/week04/rails/books/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/app/assets/javascripts/application.js b/matthew_tudman/week04/rails/books/app/assets/javascripts/application.js new file mode 100644 index 0000000..504211e --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/assets/javascripts/application.js @@ -0,0 +1,14 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require_tree . diff --git a/matthew_tudman/week04/rails/books/app/assets/javascripts/authors.coffee b/matthew_tudman/week04/rails/books/app/assets/javascripts/authors.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/assets/javascripts/authors.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/matthew_tudman/week04/rails/books/app/assets/javascripts/novels.coffee b/matthew_tudman/week04/rails/books/app/assets/javascripts/novels.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/assets/javascripts/novels.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/matthew_tudman/week04/rails/books/app/assets/stylesheets/application.css b/matthew_tudman/week04/rails/books/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/matthew_tudman/week04/rails/books/app/assets/stylesheets/authors.scss b/matthew_tudman/week04/rails/books/app/assets/stylesheets/authors.scss new file mode 100644 index 0000000..f0906c7 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/assets/stylesheets/authors.scss @@ -0,0 +1,33 @@ +// Place all the styles related to the Authors controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +.thumb { + width: 10em; + margin: 2em; +} +.feature { + max-height: 30em; + margin-top: 2em; +} +.index { + display: inline-block; + vertical-align: top; + margin-right: 13em; + margin-top: 5em; +} +.submit { + margin-top: 20px; +} + +a { + margin-right: 20px; +} + +#divide { + margin-right: 20px; +} +nav { + margin: 1em; + margin-left: 13em; +} diff --git a/matthew_tudman/week04/rails/books/app/assets/stylesheets/novels.scss b/matthew_tudman/week04/rails/books/app/assets/stylesheets/novels.scss new file mode 100644 index 0000000..9ee1a56 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/assets/stylesheets/novels.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Novels controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/matthew_tudman/week04/rails/books/app/controllers/application_controller.rb b/matthew_tudman/week04/rails/books/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/matthew_tudman/week04/rails/books/app/controllers/authors_controller.rb b/matthew_tudman/week04/rails/books/app/controllers/authors_controller.rb new file mode 100644 index 0000000..019c977 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/controllers/authors_controller.rb @@ -0,0 +1,39 @@ +class AuthorsController < ApplicationController + def index + @authors = Author.all + end + + def new + @author = Author.new + end + + def create + author = Author.create author_params + redirect_to author + end + def edit + @author = Author.find params[:id] + end + + def update + author = Author.find params[:id] + author.update author_params + redirect_to author + end + + def show + @author = Author.find params[:id] + end + + def destroy + author = Author.find params[:id] + author.destroy + redirect_to authors_path + end + + private + def author_params + #STRONG params: white list of sanitised input -- stuff we are happy to accept from the user. + params.require(:author).permit(:name, :nationality, :dob, :genre, :image) + end +end diff --git a/matthew_tudman/week04/rails/books/app/controllers/concerns/.keep b/matthew_tudman/week04/rails/books/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/app/controllers/novels_controller.rb b/matthew_tudman/week04/rails/books/app/controllers/novels_controller.rb new file mode 100644 index 0000000..7c1db55 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/controllers/novels_controller.rb @@ -0,0 +1,40 @@ +class NovelsController < ApplicationController + def index + @novels = Novel.all + end + + def new + @novel = Novel.new + end + + def create + novel = Novel.create novel_params + redirect_to novel + end + + def edit + @novel = Novel.find params[:id] + end + + def update + novel = Novel.find params[:id] + novel.update novel_params + redirect_to novel + end + + def show + @novel = Novel.find params[:id] + end + + def destroy + novel = Novel.find params[:id] + novel.destroy + redirect_to novels_path + end + + private #The Following method(s) aren't accessible outside this class (so routes can't point to them) + def novel_params + #STRONG params: white list of sanitised input -- stuff we are happy to accept from the user. + params.require(:novel).permit(:title, :year, :length, :genre, :image, :author_id) + end +end diff --git a/matthew_tudman/week04/rails/books/app/helpers/application_helper.rb b/matthew_tudman/week04/rails/books/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/matthew_tudman/week04/rails/books/app/helpers/authors_helper.rb b/matthew_tudman/week04/rails/books/app/helpers/authors_helper.rb new file mode 100644 index 0000000..f22e1f9 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/helpers/authors_helper.rb @@ -0,0 +1,2 @@ +module AuthorsHelper +end diff --git a/matthew_tudman/week04/rails/books/app/helpers/novels_helper.rb b/matthew_tudman/week04/rails/books/app/helpers/novels_helper.rb new file mode 100644 index 0000000..503eb78 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/helpers/novels_helper.rb @@ -0,0 +1,2 @@ +module NovelsHelper +end diff --git a/matthew_tudman/week04/rails/books/app/jobs/application_job.rb b/matthew_tudman/week04/rails/books/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/matthew_tudman/week04/rails/books/app/mailers/application_mailer.rb b/matthew_tudman/week04/rails/books/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/matthew_tudman/week04/rails/books/app/models/application_record.rb b/matthew_tudman/week04/rails/books/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/matthew_tudman/week04/rails/books/app/models/author.rb b/matthew_tudman/week04/rails/books/app/models/author.rb new file mode 100644 index 0000000..bdd0a2f --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/models/author.rb @@ -0,0 +1,3 @@ +class Author < ActiveRecord::Base + has_many :novels +end diff --git a/matthew_tudman/week04/rails/books/app/models/concerns/.keep b/matthew_tudman/week04/rails/books/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/app/models/novel.rb b/matthew_tudman/week04/rails/books/app/models/novel.rb new file mode 100644 index 0000000..a1449a0 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/models/novel.rb @@ -0,0 +1,3 @@ +class Novel < ActiveRecord::Base + belongs_to :author, :optional => true +end diff --git a/matthew_tudman/week04/rails/books/app/views/authors/_form.html.erb b/matthew_tudman/week04/rails/books/app/views/authors/_form.html.erb new file mode 100644 index 0000000..8f41490 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/authors/_form.html.erb @@ -0,0 +1,25 @@ + + + +<%= form_for @author do |f| %> + + <%= f.label :name %> + <%= f.text_field :name, :required => true, :autofocus => true %> + + <%= f.label :nationality %> + <%= f.text_field :nationality %> + + <%= f.label :dob, "Date of Birth" %> + <%= f.text_field :dob, :placeholder => "YYYY-MM-DD" %> + + <%= f.label :genre %> + <%= f.text_field :genre %> + + <%= f.label :image %> + <%= f.text_field :image %> + +
+ <%= f.submit %> +
+ +<% end %> diff --git a/matthew_tudman/week04/rails/books/app/views/authors/edit.html.erb b/matthew_tudman/week04/rails/books/app/views/authors/edit.html.erb new file mode 100644 index 0000000..0f02964 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/authors/edit.html.erb @@ -0,0 +1,3 @@ +

Edit Author

+ +<%= render :partial => 'form' %> diff --git a/matthew_tudman/week04/rails/books/app/views/authors/index.html.erb b/matthew_tudman/week04/rails/books/app/views/authors/index.html.erb new file mode 100644 index 0000000..1470afe --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/authors/index.html.erb @@ -0,0 +1,11 @@ +

All Authors

+ +<% @authors.each do |author| %> + <%= image_tag author.image, :class => 'thumb' if author.image.present? %> + +<% end %> diff --git a/matthew_tudman/week04/rails/books/app/views/authors/new.html.erb b/matthew_tudman/week04/rails/books/app/views/authors/new.html.erb new file mode 100644 index 0000000..4a47c0e --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/authors/new.html.erb @@ -0,0 +1,3 @@ +

New Author

+ +<%= render :partial => 'form' %> diff --git a/matthew_tudman/week04/rails/books/app/views/authors/show.html.erb b/matthew_tudman/week04/rails/books/app/views/authors/show.html.erb new file mode 100644 index 0000000..d0abde1 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/authors/show.html.erb @@ -0,0 +1,18 @@ +

<%= @author.name %>

+ +<%= image_tag @author.image, :class => 'feature' if @author.image.present?%> + + +<% @author.novels.each do |novel| %> + <%= link_to image_tag(novel.image, :class => 'thumb'), novel %> +<% end %> + +
+ <%= link_to 'Edit Author', edit_author_path(@author.id) %> + <%= link_to 'Delete Author', @artist, :method => 'delete' %> +
diff --git a/matthew_tudman/week04/rails/books/app/views/layouts/application.html.erb b/matthew_tudman/week04/rails/books/app/views/layouts/application.html.erb new file mode 100644 index 0000000..d181677 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/layouts/application.html.erb @@ -0,0 +1,22 @@ + + + + Books + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all' %> + <%= javascript_include_tag 'application' %> + + + + + <%= yield %> + + diff --git a/matthew_tudman/week04/rails/books/app/views/layouts/mailer.html.erb b/matthew_tudman/week04/rails/books/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/matthew_tudman/week04/rails/books/app/views/layouts/mailer.text.erb b/matthew_tudman/week04/rails/books/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/matthew_tudman/week04/rails/books/app/views/novels/_form.html.erb b/matthew_tudman/week04/rails/books/app/views/novels/_form.html.erb new file mode 100644 index 0000000..c518cf9 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/novels/_form.html.erb @@ -0,0 +1,28 @@ + + + +<%= form_for @novel do |f| %> + + <%= f.label :title %> + <%= f.text_field :title, :required => true, :autofocus => true %> + + <%= f.label :year %> + <%= f.text_field :year %> + + <%= f.label :length, "Word Count" %> + <%= f.text_field :length %> + + <%= f.label :genre %> + <%= f.text_field :genre %> + + <%= f.label :image %> + <%= f.text_field :image %> + + <%= f.label :author_id%> + <%= f.select :author_id, Author.pluck(:name, :id), :include_blank => true%> + +
+ <%= f.submit %> +
+ +<% end %> diff --git a/matthew_tudman/week04/rails/books/app/views/novels/edit.html.erb b/matthew_tudman/week04/rails/books/app/views/novels/edit.html.erb new file mode 100644 index 0000000..f541f04 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/novels/edit.html.erb @@ -0,0 +1,4 @@ +

Edit Novel

+ + +<%= render :partial => 'form'%> diff --git a/matthew_tudman/week04/rails/books/app/views/novels/index.html.erb b/matthew_tudman/week04/rails/books/app/views/novels/index.html.erb new file mode 100644 index 0000000..203a0e5 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/novels/index.html.erb @@ -0,0 +1,12 @@ +

All Novels

+ + +<% @novels.each do |novel| %> + <%= image_tag novel.image, :class => 'thumb' if novel.image.present? %> + +<% end %> diff --git a/matthew_tudman/week04/rails/books/app/views/novels/new.html.erb b/matthew_tudman/week04/rails/books/app/views/novels/new.html.erb new file mode 100644 index 0000000..f6056de --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/novels/new.html.erb @@ -0,0 +1,4 @@ +

New Novel

+ + +<%= render :partial => 'form'%> diff --git a/matthew_tudman/week04/rails/books/app/views/novels/show.html.erb b/matthew_tudman/week04/rails/books/app/views/novels/show.html.erb new file mode 100644 index 0000000..e8d7ef4 --- /dev/null +++ b/matthew_tudman/week04/rails/books/app/views/novels/show.html.erb @@ -0,0 +1,15 @@ +

<%= @novel.title %>

+ + +<%= image_tag @novel.image, :class => 'feature' if @novel.image.present?%> + + +
+ <%= link_to 'Edit Novel', edit_novel_path(@novel.id) %> + <%= link_to 'Delete Novel', @novel, :method => 'delete' %> +
diff --git a/matthew_tudman/week04/rails/books/bin/bundle b/matthew_tudman/week04/rails/books/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/matthew_tudman/week04/rails/books/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/matthew_tudman/week04/rails/books/bin/rails b/matthew_tudman/week04/rails/books/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/matthew_tudman/week04/rails/books/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/matthew_tudman/week04/rails/books/bin/rake b/matthew_tudman/week04/rails/books/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/matthew_tudman/week04/rails/books/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/matthew_tudman/week04/rails/books/bin/setup b/matthew_tudman/week04/rails/books/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/matthew_tudman/week04/rails/books/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/matthew_tudman/week04/rails/books/bin/spring b/matthew_tudman/week04/rails/books/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/matthew_tudman/week04/rails/books/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/matthew_tudman/week04/rails/books/bin/update b/matthew_tudman/week04/rails/books/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/matthew_tudman/week04/rails/books/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/matthew_tudman/week04/rails/books/bin/yarn b/matthew_tudman/week04/rails/books/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/matthew_tudman/week04/rails/books/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/matthew_tudman/week04/rails/books/config.ru b/matthew_tudman/week04/rails/books/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/matthew_tudman/week04/rails/books/config/application.rb b/matthew_tudman/week04/rails/books/config/application.rb new file mode 100644 index 0000000..d0bf709 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/application.rb @@ -0,0 +1,30 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Books + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/matthew_tudman/week04/rails/books/config/boot.rb b/matthew_tudman/week04/rails/books/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/matthew_tudman/week04/rails/books/config/credentials.yml.enc b/matthew_tudman/week04/rails/books/config/credentials.yml.enc new file mode 100644 index 0000000..ed899af --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/credentials.yml.enc @@ -0,0 +1 @@ +kCwR+9UnhPmPuixDQqmbG6MkmZirV0FG8BQaFg9UrBYZvlP1WETYIQCR0hVWwUDZF02G7ffZerc0UDE4SRO4xHG0AF0Q6CWYSztpP3VqKWEaKqS8PRETwoKRjhBy6TUIyI2fYArZnX5C+5kIXcH1vRXMDOyY+J93x/vSPWrvYsq/+Pev2cBOmiYiN8rrMTrAFJOASoOEF1QgQC5jvPhsankLRlo0KzbPoazbiEy8vavhVZIlZUTz0Kv1PXRZ4ACVAsKNidpLgbxG6ah8MkPvHoiGufboLx68ky7kadfobi6fXS7cVk6kuhLjOtu35T52/C9pXgJtby21ltIMVsAjmwdaxPMk8zq6e3NYrG+nKdyGYoG5r7n0abvNiu+Fgv5aBYaLofV7egrVhBeASd6z6hlEsVV/LjU/SGEq--O9RScRTQbfXXJGlF--+4JXoBYKUGaralNd5lKg0w== \ No newline at end of file diff --git a/matthew_tudman/week04/rails/books/config/database.yml b/matthew_tudman/week04/rails/books/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/matthew_tudman/week04/rails/books/config/environment.rb b/matthew_tudman/week04/rails/books/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/matthew_tudman/week04/rails/books/config/environments/development.rb b/matthew_tudman/week04/rails/books/config/environments/development.rb new file mode 100644 index 0000000..92bfc1d --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/environments/development.rb @@ -0,0 +1,58 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/matthew_tudman/week04/rails/books/config/environments/production.rb b/matthew_tudman/week04/rails/books/config/environments/production.rb new file mode 100644 index 0000000..8706f50 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/environments/production.rb @@ -0,0 +1,86 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "books_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/matthew_tudman/week04/rails/books/config/environments/test.rb b/matthew_tudman/week04/rails/books/config/environments/test.rb new file mode 100644 index 0000000..b08fc84 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/environments/test.rb @@ -0,0 +1,43 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/matthew_tudman/week04/rails/books/config/initializers/application_controller_renderer.rb b/matthew_tudman/week04/rails/books/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/matthew_tudman/week04/rails/books/config/initializers/assets.rb b/matthew_tudman/week04/rails/books/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/matthew_tudman/week04/rails/books/config/initializers/backtrace_silencers.rb b/matthew_tudman/week04/rails/books/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/matthew_tudman/week04/rails/books/config/initializers/content_security_policy.rb b/matthew_tudman/week04/rails/books/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/matthew_tudman/week04/rails/books/config/initializers/cookies_serializer.rb b/matthew_tudman/week04/rails/books/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/matthew_tudman/week04/rails/books/config/initializers/filter_parameter_logging.rb b/matthew_tudman/week04/rails/books/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/matthew_tudman/week04/rails/books/config/initializers/inflections.rb b/matthew_tudman/week04/rails/books/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/matthew_tudman/week04/rails/books/config/initializers/mime_types.rb b/matthew_tudman/week04/rails/books/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/matthew_tudman/week04/rails/books/config/initializers/wrap_parameters.rb b/matthew_tudman/week04/rails/books/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/matthew_tudman/week04/rails/books/config/locales/en.yml b/matthew_tudman/week04/rails/books/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/matthew_tudman/week04/rails/books/config/master.key b/matthew_tudman/week04/rails/books/config/master.key new file mode 100644 index 0000000..ab8b4a1 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/master.key @@ -0,0 +1 @@ +1d56bbba6b8f527e8577b7ad480231f3 \ No newline at end of file diff --git a/matthew_tudman/week04/rails/books/config/puma.rb b/matthew_tudman/week04/rails/books/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/matthew_tudman/week04/rails/books/config/routes.rb b/matthew_tudman/week04/rails/books/config/routes.rb new file mode 100644 index 0000000..79d3d8b --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/routes.rb @@ -0,0 +1,13 @@ +Rails.application.routes.draw do + get 'novels/index' + get 'novels/new' + get 'novels/edit' + get 'novels/show' + get 'authors/index' + get 'authors/new' + get 'authors/edit' + get 'authors/show' + resources :authors + resources :novels + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html +end diff --git a/matthew_tudman/week04/rails/books/config/spring.rb b/matthew_tudman/week04/rails/books/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/matthew_tudman/week04/rails/books/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/matthew_tudman/week04/rails/books/db/development.sqlite3 b/matthew_tudman/week04/rails/books/db/development.sqlite3 new file mode 100644 index 0000000..3d56135 Binary files /dev/null and b/matthew_tudman/week04/rails/books/db/development.sqlite3 differ diff --git a/matthew_tudman/week04/rails/books/db/migrate/20200617074840_create_authors.rb b/matthew_tudman/week04/rails/books/db/migrate/20200617074840_create_authors.rb new file mode 100644 index 0000000..cec4ef8 --- /dev/null +++ b/matthew_tudman/week04/rails/books/db/migrate/20200617074840_create_authors.rb @@ -0,0 +1,11 @@ +class CreateAuthors < ActiveRecord::Migration[5.2] + def change + create_table :authors do |t| + t.text :name + t.text :nationality + t.date :dob + t.text :genre + t.text :image + end + end +end diff --git a/matthew_tudman/week04/rails/books/db/migrate/20200617120220_create_novels.rb b/matthew_tudman/week04/rails/books/db/migrate/20200617120220_create_novels.rb new file mode 100644 index 0000000..c4ac3c0 --- /dev/null +++ b/matthew_tudman/week04/rails/books/db/migrate/20200617120220_create_novels.rb @@ -0,0 +1,11 @@ +class CreateNovels < ActiveRecord::Migration[5.2] + def change + create_table :novels do |t| + t.text :title + t.text :year + t.integer :length + t.text :genre + t.text :image + end + end +end diff --git a/matthew_tudman/week04/rails/books/db/migrate/20200617125102_add_author_id_to_novels.rb b/matthew_tudman/week04/rails/books/db/migrate/20200617125102_add_author_id_to_novels.rb new file mode 100644 index 0000000..b522fac --- /dev/null +++ b/matthew_tudman/week04/rails/books/db/migrate/20200617125102_add_author_id_to_novels.rb @@ -0,0 +1,5 @@ +class AddAuthorIdToNovels < ActiveRecord::Migration[5.2] + def change + add_column :novels, :author_id, :integer + end +end diff --git a/matthew_tudman/week04/rails/books/db/schema.rb b/matthew_tudman/week04/rails/books/db/schema.rb new file mode 100644 index 0000000..139e60f --- /dev/null +++ b/matthew_tudman/week04/rails/books/db/schema.rb @@ -0,0 +1,32 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_17_125102) do + + create_table "authors", force: :cascade do |t| + t.text "name" + t.text "nationality" + t.date "dob" + t.text "genre" + t.text "image" + end + + create_table "novels", force: :cascade do |t| + t.text "title" + t.text "year" + t.integer "length" + t.text "genre" + t.text "image" + t.integer "author_id" + end + +end diff --git a/matthew_tudman/week04/rails/books/db/seeds.rb b/matthew_tudman/week04/rails/books/db/seeds.rb new file mode 100644 index 0000000..db11cb4 --- /dev/null +++ b/matthew_tudman/week04/rails/books/db/seeds.rb @@ -0,0 +1,23 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) + +Author.destroy_all + +Author.create(:name => 'J.R.R. Tolkien', :nationality => 'English', :dob => '1892-01-03', :genre => 'Fantasy', :image => 'https://www.harringtonbooks.co.uk/images/upload/authors_9_1.jpg') + +Author.create(:name => 'Brandon Sanderson', :nationality => 'American', :dob => '1975-12-19', :genre => 'Fantasy', :image => 'https://images.gr-assets.com/authors/1394044556p8/38550.jpg') + +Author.create(:name => 'Mary Shelley', :nationality => 'English', :dob => '1797-08-30', :genre => 'Gothic/Science Fiction', :image => 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/RothwellMaryShelley.jpg/1200px-RothwellMaryShelley.jpg') + +Novel.destroy_all + +Novel.create(:title => 'The Lord of the Rings', :year => '1954-1955', :length => 576459 , :genre => 'Fantasy', :image => 'https://upload.wikimedia.org/wikipedia/en/e/e9/First_Single_Volume_Edition_of_The_Lord_of_the_Rings.gif') + +Novel.create(:title => 'The Way of Kings', :year => '2010', :length => 425000, :genre => 'Fantasy', :image => 'https://hungryandfit.com/wp-content/uploads/2014/04/The-Way-of-Kings-by-Brandon-Sanderson.jpg') + +Novel.create(:title => 'Frankenstein', :year => '1818', :length => 90625, :genre => 'Gothic/Science Fiction', :image => 'https://m.media-amazon.com/images/I/41dj+xC+zWL.jpg') diff --git a/matthew_tudman/week04/rails/books/db/test.sqlite3 b/matthew_tudman/week04/rails/books/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/lib/assets/.keep b/matthew_tudman/week04/rails/books/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/lib/tasks/.keep b/matthew_tudman/week04/rails/books/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/package.json b/matthew_tudman/week04/rails/books/package.json new file mode 100644 index 0000000..1d24c3c --- /dev/null +++ b/matthew_tudman/week04/rails/books/package.json @@ -0,0 +1,5 @@ +{ + "name": "books", + "private": true, + "dependencies": {} +} diff --git a/matthew_tudman/week04/rails/books/public/404.html b/matthew_tudman/week04/rails/books/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/matthew_tudman/week04/rails/books/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/matthew_tudman/week04/rails/books/public/422.html b/matthew_tudman/week04/rails/books/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/matthew_tudman/week04/rails/books/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/matthew_tudman/week04/rails/books/public/500.html b/matthew_tudman/week04/rails/books/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/matthew_tudman/week04/rails/books/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/matthew_tudman/week04/rails/books/public/apple-touch-icon-precomposed.png b/matthew_tudman/week04/rails/books/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/public/apple-touch-icon.png b/matthew_tudman/week04/rails/books/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/public/favicon.ico b/matthew_tudman/week04/rails/books/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/public/robots.txt b/matthew_tudman/week04/rails/books/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/matthew_tudman/week04/rails/books/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/matthew_tudman/week04/rails/books/test/application_system_test_case.rb b/matthew_tudman/week04/rails/books/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/matthew_tudman/week04/rails/books/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/matthew_tudman/week04/rails/books/test/controllers/.keep b/matthew_tudman/week04/rails/books/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/test/controllers/authors_controller_test.rb b/matthew_tudman/week04/rails/books/test/controllers/authors_controller_test.rb new file mode 100644 index 0000000..d25e989 --- /dev/null +++ b/matthew_tudman/week04/rails/books/test/controllers/authors_controller_test.rb @@ -0,0 +1,24 @@ +require 'test_helper' + +class AuthorsControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get authors_index_url + assert_response :success + end + + test "should get new" do + get authors_new_url + assert_response :success + end + + test "should get edit" do + get authors_edit_url + assert_response :success + end + + test "should get show" do + get authors_show_url + assert_response :success + end + +end diff --git a/matthew_tudman/week04/rails/books/test/controllers/novels_controller_test.rb b/matthew_tudman/week04/rails/books/test/controllers/novels_controller_test.rb new file mode 100644 index 0000000..f692b23 --- /dev/null +++ b/matthew_tudman/week04/rails/books/test/controllers/novels_controller_test.rb @@ -0,0 +1,24 @@ +require 'test_helper' + +class NovelsControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get novels_index_url + assert_response :success + end + + test "should get new" do + get novels_new_url + assert_response :success + end + + test "should get edit" do + get novels_edit_url + assert_response :success + end + + test "should get show" do + get novels_show_url + assert_response :success + end + +end diff --git a/matthew_tudman/week04/rails/books/test/fixtures/.keep b/matthew_tudman/week04/rails/books/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/test/fixtures/files/.keep b/matthew_tudman/week04/rails/books/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/test/helpers/.keep b/matthew_tudman/week04/rails/books/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/test/integration/.keep b/matthew_tudman/week04/rails/books/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/test/mailers/.keep b/matthew_tudman/week04/rails/books/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/test/models/.keep b/matthew_tudman/week04/rails/books/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/test/system/.keep b/matthew_tudman/week04/rails/books/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/matthew_tudman/week04/rails/books/test/test_helper.rb b/matthew_tudman/week04/rails/books/test/test_helper.rb new file mode 100644 index 0000000..3ab84e3 --- /dev/null +++ b/matthew_tudman/week04/rails/books/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/matthew_tudman/week04/rails/books/vendor/.keep b/matthew_tudman/week04/rails/books/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shahwaiz_nadeem/week_05/mon/games-on-rails/Gemfile.lock b/shahwaiz_nadeem/week_05/mon/games-on-rails/Gemfile.lock index 3de0944..129b9e9 100644 --- a/shahwaiz_nadeem/week_05/mon/games-on-rails/Gemfile.lock +++ b/shahwaiz_nadeem/week_05/mon/games-on-rails/Gemfile.lock @@ -108,7 +108,7 @@ GEM mini_portile2 (~> 2.4.0) public_suffix (4.0.5) puma (3.12.6) - rack (2.2.2) + rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.2.4.3) diff --git a/soojin_hong/05week/day1/games_on_rails/.ruby-version b/soojin_hong/05week/day1/games_on_rails/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/soojin_hong/05week/day1/games_on_rails/Gemfile b/soojin_hong/05week/day1/games_on_rails/Gemfile new file mode 100644 index 0000000..8737e66 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/Gemfile @@ -0,0 +1,62 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/soojin_hong/05week/day1/games_on_rails/Gemfile.lock b/soojin_hong/05week/day1/games_on_rails/Gemfile.lock new file mode 100644 index 0000000..361735c --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/Gemfile.lock @@ -0,0 +1,220 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.32.2) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + io-like (0.3.1) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1-x86_64-darwin-19) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.2) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (1.7.1) + ruby_dep (1.5.0) + rubyzip (2.3.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/soojin_hong/05week/day1/games_on_rails/README.md b/soojin_hong/05week/day1/games_on_rails/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/soojin_hong/05week/day1/games_on_rails/Rakefile b/soojin_hong/05week/day1/games_on_rails/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/soojin_hong/05week/day1/games_on_rails/app/assets/config/manifest.js b/soojin_hong/05week/day1/games_on_rails/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/soojin_hong/05week/day1/games_on_rails/app/assets/images/.keep b/soojin_hong/05week/day1/games_on_rails/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/app/assets/javascripts/application.js b/soojin_hong/05week/day1/games_on_rails/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/soojin_hong/05week/day1/games_on_rails/app/assets/javascripts/cable.js b/soojin_hong/05week/day1/games_on_rails/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/soojin_hong/05week/day1/games_on_rails/app/assets/javascripts/channels/.keep b/soojin_hong/05week/day1/games_on_rails/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/app/assets/stylesheets/application.css b/soojin_hong/05week/day1/games_on_rails/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/soojin_hong/05week/day1/games_on_rails/app/assets/stylesheets/games.css b/soojin_hong/05week/day1/games_on_rails/app/assets/stylesheets/games.css new file mode 100644 index 0000000..437644c --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/assets/stylesheets/games.css @@ -0,0 +1,7 @@ +body { + background-color: lightyellow; +} +.container { + max-width: 960px; + margin: 0 auto; +} diff --git a/soojin_hong/05week/day1/games_on_rails/app/channels/application_cable/channel.rb b/soojin_hong/05week/day1/games_on_rails/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/channels/application_cable/connection.rb b/soojin_hong/05week/day1/games_on_rails/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/controllers/application_controller.rb b/soojin_hong/05week/day1/games_on_rails/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/controllers/concerns/.keep b/soojin_hong/05week/day1/games_on_rails/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/app/controllers/magiceight_controller.rb b/soojin_hong/05week/day1/games_on_rails/app/controllers/magiceight_controller.rb new file mode 100644 index 0000000..55f2e37 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/controllers/magiceight_controller.rb @@ -0,0 +1,37 @@ +class MagiceightController < ApplicationController + def play + render :play + end + + def result + @messages = { + 1 => 'It is certain.', + 2 => 'It is decidedly so.', + 3 => 'Without a doubt.', + 4 => 'Yes - definitely.', + 5 => 'You may rely on it.', + 6 => 'As i see it, yes.', + 7 => 'Most likely.', + 8 => 'Outlook good.', + 9 => 'Yes.', + 10 => 'Signs point to yes.', + 11 => 'Reply hazy, try again.', + 12 => 'Ask again later.', + 13 => 'Better not tell you now.', + 14 => 'Cannot predict now.', + 15 => 'Concentrate and ask again.', + 16 => 'Do not count on it.', + 17 => 'My reply is no.', + 18 => 'My sources say no.', + 19 => 'Outlook not so good.', + 20 => 'Very doubtful.' + } + @random = Random.rand(1..20) + @random_message = @messages[@random] + render :result + end + + def again + render :play + end +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/controllers/pages_controller.rb b/soojin_hong/05week/day1/games_on_rails/app/controllers/pages_controller.rb new file mode 100644 index 0000000..b0df01d --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/controllers/pages_controller.rb @@ -0,0 +1,5 @@ +class PagesController < ApplicationController + def home + render :home + end +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/controllers/rockpaperscissors_controller.rb b/soojin_hong/05week/day1/games_on_rails/app/controllers/rockpaperscissors_controller.rb new file mode 100644 index 0000000..b1eaa6c --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/controllers/rockpaperscissors_controller.rb @@ -0,0 +1,31 @@ +class RockpaperscissorsController < ApplicationController + def play + render :play + end + + def throw + "Throw" + end + + def result + @option = ['Rock', 'Paper', 'Scissors'] + + @computer_random = Random.rand(0..2) + @computer_choice = @option[@computer_random] + + @user_random = Random.rand(0..2) + @user_choice = @option[@user_random] + + @result = if @computer_random == 0 && @user_random == 2 || + @computer_random == 1 && @user_random == 0 || + @computer_random == 2 && @user_random == 1 + "Lost" + elsif @computer_random == @user_random + "Draw" + else + "Won" + end + + render :result + end +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/controllers/secretnumber_controller.rb b/soojin_hong/05week/day1/games_on_rails/app/controllers/secretnumber_controller.rb new file mode 100644 index 0000000..bcd1d0a --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/controllers/secretnumber_controller.rb @@ -0,0 +1,12 @@ +class SecretnumberController < ApplicationController + def play + render :play + end + + def result + @computer_choice = Random.rand(1..10) + @user_choice = params[:number].to_i + @answer = @computer_choice == @user_choice? "Correct!" : "Wrong!" + render :result + end +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/helpers/application_helper.rb b/soojin_hong/05week/day1/games_on_rails/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/jobs/application_job.rb b/soojin_hong/05week/day1/games_on_rails/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/mailers/application_mailer.rb b/soojin_hong/05week/day1/games_on_rails/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/models/application_record.rb b/soojin_hong/05week/day1/games_on_rails/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/soojin_hong/05week/day1/games_on_rails/app/models/concerns/.keep b/soojin_hong/05week/day1/games_on_rails/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/app/views/layouts/application.html.erb b/soojin_hong/05week/day1/games_on_rails/app/views/layouts/application.html.erb new file mode 100644 index 0000000..26bfe7d --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/views/layouts/application.html.erb @@ -0,0 +1,23 @@ + + + + GamesOnRails + + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + +
+ + <%= yield %> + +
+ + diff --git a/soojin_hong/05week/day1/games_on_rails/app/views/layouts/mailer.html.erb b/soojin_hong/05week/day1/games_on_rails/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/soojin_hong/05week/day1/games_on_rails/app/views/layouts/mailer.text.erb b/soojin_hong/05week/day1/games_on_rails/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/soojin_hong/05week/day1/games_on_rails/app/views/magiceight/play.html.erb b/soojin_hong/05week/day1/games_on_rails/app/views/magiceight/play.html.erb new file mode 100644 index 0000000..1a0afef --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/views/magiceight/play.html.erb @@ -0,0 +1,8 @@ +

Magic 8 Ball

+ +
+ +
diff --git a/soojin_hong/05week/day1/games_on_rails/app/views/magiceight/result.html.erb b/soojin_hong/05week/day1/games_on_rails/app/views/magiceight/result.html.erb new file mode 100644 index 0000000..6dd3b56 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/views/magiceight/result.html.erb @@ -0,0 +1,6 @@ +

Magic 8 Ball Result

+ +

<%= params[:question] %>

+

<%= @random_message %>

+ + diff --git a/soojin_hong/05week/day1/games_on_rails/app/views/pages/home.html.erb b/soojin_hong/05week/day1/games_on_rails/app/views/pages/home.html.erb new file mode 100644 index 0000000..d9db8a2 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/views/pages/home.html.erb @@ -0,0 +1,5 @@ +

Games on Rails

+ +

Let's play Magic 8 Ball

+

Let's play Secret Number

+

Let's play Rock Paper Scissors

diff --git a/soojin_hong/05week/day1/games_on_rails/app/views/rockpaperscissors/play.html.erb b/soojin_hong/05week/day1/games_on_rails/app/views/rockpaperscissors/play.html.erb new file mode 100644 index 0000000..bbc26db --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/views/rockpaperscissors/play.html.erb @@ -0,0 +1,7 @@ +

Rock Paper Scissors

+ +
+ +
diff --git a/soojin_hong/05week/day1/games_on_rails/app/views/rockpaperscissors/result.html.erb b/soojin_hong/05week/day1/games_on_rails/app/views/rockpaperscissors/result.html.erb new file mode 100644 index 0000000..34fb006 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/views/rockpaperscissors/result.html.erb @@ -0,0 +1,6 @@ +

Rock Paper Scissors Result

+ +

You <%= @result %>

+ +

Computer chose <%= @computer_choice %>

+

You chose <%= @user_choice %>

diff --git a/soojin_hong/05week/day1/games_on_rails/app/views/secretnumber/play.html.erb b/soojin_hong/05week/day1/games_on_rails/app/views/secretnumber/play.html.erb new file mode 100644 index 0000000..8bd50dd --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/views/secretnumber/play.html.erb @@ -0,0 +1,9 @@ +

Secret Number

+ +
+ +
diff --git a/soojin_hong/05week/day1/games_on_rails/app/views/secretnumber/result.html.erb b/soojin_hong/05week/day1/games_on_rails/app/views/secretnumber/result.html.erb new file mode 100644 index 0000000..0619d2b --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/app/views/secretnumber/result.html.erb @@ -0,0 +1,5 @@ +

Secret Number Result

+ +

You chose <%= @user_choice %>

+

Your guess is <%= @answer %>

+

Computer guessed <%= @computer_choice %>

diff --git a/soojin_hong/05week/day1/games_on_rails/bin/bundle b/soojin_hong/05week/day1/games_on_rails/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/soojin_hong/05week/day1/games_on_rails/bin/rails b/soojin_hong/05week/day1/games_on_rails/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/soojin_hong/05week/day1/games_on_rails/bin/rake b/soojin_hong/05week/day1/games_on_rails/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/soojin_hong/05week/day1/games_on_rails/bin/setup b/soojin_hong/05week/day1/games_on_rails/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/soojin_hong/05week/day1/games_on_rails/bin/spring b/soojin_hong/05week/day1/games_on_rails/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/soojin_hong/05week/day1/games_on_rails/bin/update b/soojin_hong/05week/day1/games_on_rails/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/soojin_hong/05week/day1/games_on_rails/bin/yarn b/soojin_hong/05week/day1/games_on_rails/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/soojin_hong/05week/day1/games_on_rails/config.ru b/soojin_hong/05week/day1/games_on_rails/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/soojin_hong/05week/day1/games_on_rails/config/application.rb b/soojin_hong/05week/day1/games_on_rails/config/application.rb new file mode 100644 index 0000000..dfc9199 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/application.rb @@ -0,0 +1,19 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module GamesOnRails + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/soojin_hong/05week/day1/games_on_rails/config/boot.rb b/soojin_hong/05week/day1/games_on_rails/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/soojin_hong/05week/day1/games_on_rails/config/cable.yml b/soojin_hong/05week/day1/games_on_rails/config/cable.yml new file mode 100644 index 0000000..f456b2d --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: games_on_rails_production diff --git a/soojin_hong/05week/day1/games_on_rails/config/credentials.yml.enc b/soojin_hong/05week/day1/games_on_rails/config/credentials.yml.enc new file mode 100644 index 0000000..8e3a4cc --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/credentials.yml.enc @@ -0,0 +1 @@ +T5znaTnuBYW76Buz49flJucipyHWRaDulVeFNcQK7bbyJcNPbMVULuOFyYSVmOW/ZBx7AWPgu/8ODB9l6uwNF5211HB+LbKLApFwczNjuC3xMpfg/uyb12e9jG44BFY1+Cvj8hvuY0G5vFZwC2APM5G2zl2srrZMlBx+QvNFE8lCrTKBasomseLUzvsaWzTJKyj1mHiPy7AlgaofimqRzb2xMBrl87ce+PxtuMjf227RmSvGtFGV26guqu3n5s4zDKG+X6rVlvlhY+W0uPZjWymNQsnQFHSgN9qaDDTmeFyAMvikohfpy9hNwWjPbVYmfOj29XERW0711ONsZ08BFLmBdVYxOQKIDLCCIpiLB9WWJubx/VXl4rXjSFwW+RoNCAioU24HZ59PRKKdkBJUWWLRRZU+N4EYsbd8--qcAjAMZLEpyVmA72--pRF/pH5dp9KyWGSIbn1bww== \ No newline at end of file diff --git a/soojin_hong/05week/day1/games_on_rails/config/database.yml b/soojin_hong/05week/day1/games_on_rails/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/soojin_hong/05week/day1/games_on_rails/config/environment.rb b/soojin_hong/05week/day1/games_on_rails/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/soojin_hong/05week/day1/games_on_rails/config/environments/development.rb b/soojin_hong/05week/day1/games_on_rails/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/soojin_hong/05week/day1/games_on_rails/config/environments/production.rb b/soojin_hong/05week/day1/games_on_rails/config/environments/production.rb new file mode 100644 index 0000000..4e7370d --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "games_on_rails_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/soojin_hong/05week/day1/games_on_rails/config/environments/test.rb b/soojin_hong/05week/day1/games_on_rails/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/soojin_hong/05week/day1/games_on_rails/config/initializers/application_controller_renderer.rb b/soojin_hong/05week/day1/games_on_rails/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/soojin_hong/05week/day1/games_on_rails/config/initializers/assets.rb b/soojin_hong/05week/day1/games_on_rails/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/soojin_hong/05week/day1/games_on_rails/config/initializers/backtrace_silencers.rb b/soojin_hong/05week/day1/games_on_rails/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/soojin_hong/05week/day1/games_on_rails/config/initializers/content_security_policy.rb b/soojin_hong/05week/day1/games_on_rails/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/soojin_hong/05week/day1/games_on_rails/config/initializers/cookies_serializer.rb b/soojin_hong/05week/day1/games_on_rails/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/soojin_hong/05week/day1/games_on_rails/config/initializers/filter_parameter_logging.rb b/soojin_hong/05week/day1/games_on_rails/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/soojin_hong/05week/day1/games_on_rails/config/initializers/inflections.rb b/soojin_hong/05week/day1/games_on_rails/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/soojin_hong/05week/day1/games_on_rails/config/initializers/mime_types.rb b/soojin_hong/05week/day1/games_on_rails/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/soojin_hong/05week/day1/games_on_rails/config/initializers/wrap_parameters.rb b/soojin_hong/05week/day1/games_on_rails/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/soojin_hong/05week/day1/games_on_rails/config/locales/en.yml b/soojin_hong/05week/day1/games_on_rails/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/soojin_hong/05week/day1/games_on_rails/config/master.key b/soojin_hong/05week/day1/games_on_rails/config/master.key new file mode 100644 index 0000000..7df7cac --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/master.key @@ -0,0 +1 @@ +a50eaebbbd5ec6beee77a47fe6dfac44 \ No newline at end of file diff --git a/soojin_hong/05week/day1/games_on_rails/config/puma.rb b/soojin_hong/05week/day1/games_on_rails/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/soojin_hong/05week/day1/games_on_rails/config/routes.rb b/soojin_hong/05week/day1/games_on_rails/config/routes.rb new file mode 100644 index 0000000..238f03d --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/routes.rb @@ -0,0 +1,14 @@ +Rails.application.routes.draw do + root :to => 'pages#home' + get '/home' => 'pages#home' + + get '/magiceight' => 'magiceight#play' + get '/magiceight/result' => 'magiceight#result' + get '/magiceight/result/again' => 'magiceight#play' + + get '/secretnumber' => 'secretnumber#play' + get '/secretnumber/result' => 'secretnumber#result' + + get '/rockpaperscissors' => 'rockpaperscissors#play' + get '/rockpaperscissors/result' => 'rockpaperscissors#result' +end diff --git a/soojin_hong/05week/day1/games_on_rails/config/spring.rb b/soojin_hong/05week/day1/games_on_rails/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/soojin_hong/05week/day1/games_on_rails/config/storage.yml b/soojin_hong/05week/day1/games_on_rails/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/soojin_hong/05week/day1/games_on_rails/db/development.sqlite3 b/soojin_hong/05week/day1/games_on_rails/db/development.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/db/seeds.rb b/soojin_hong/05week/day1/games_on_rails/db/seeds.rb new file mode 100644 index 0000000..1beea2a --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) diff --git a/soojin_hong/05week/day1/games_on_rails/lib/assets/.keep b/soojin_hong/05week/day1/games_on_rails/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/lib/tasks/.keep b/soojin_hong/05week/day1/games_on_rails/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/package.json b/soojin_hong/05week/day1/games_on_rails/package.json new file mode 100644 index 0000000..55cf4b4 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/package.json @@ -0,0 +1,5 @@ +{ + "name": "games_on_rails", + "private": true, + "dependencies": {} +} diff --git a/soojin_hong/05week/day1/games_on_rails/public/404.html b/soojin_hong/05week/day1/games_on_rails/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/soojin_hong/05week/day1/games_on_rails/public/422.html b/soojin_hong/05week/day1/games_on_rails/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/soojin_hong/05week/day1/games_on_rails/public/500.html b/soojin_hong/05week/day1/games_on_rails/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/soojin_hong/05week/day1/games_on_rails/public/apple-touch-icon-precomposed.png b/soojin_hong/05week/day1/games_on_rails/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/public/apple-touch-icon.png b/soojin_hong/05week/day1/games_on_rails/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/public/favicon.ico b/soojin_hong/05week/day1/games_on_rails/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/public/robots.txt b/soojin_hong/05week/day1/games_on_rails/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/soojin_hong/05week/day1/games_on_rails/storage/.keep b/soojin_hong/05week/day1/games_on_rails/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/test/application_system_test_case.rb b/soojin_hong/05week/day1/games_on_rails/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/soojin_hong/05week/day1/games_on_rails/test/controllers/.keep b/soojin_hong/05week/day1/games_on_rails/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/test/fixtures/.keep b/soojin_hong/05week/day1/games_on_rails/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/test/fixtures/files/.keep b/soojin_hong/05week/day1/games_on_rails/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/test/helpers/.keep b/soojin_hong/05week/day1/games_on_rails/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/test/integration/.keep b/soojin_hong/05week/day1/games_on_rails/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/test/mailers/.keep b/soojin_hong/05week/day1/games_on_rails/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/test/models/.keep b/soojin_hong/05week/day1/games_on_rails/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/test/system/.keep b/soojin_hong/05week/day1/games_on_rails/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day1/games_on_rails/test/test_helper.rb b/soojin_hong/05week/day1/games_on_rails/test/test_helper.rb new file mode 100644 index 0000000..3ab84e3 --- /dev/null +++ b/soojin_hong/05week/day1/games_on_rails/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/soojin_hong/05week/day1/games_on_rails/vendor/.keep b/soojin_hong/05week/day1/games_on_rails/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/.ruby-version b/soojin_hong/05week/day2/island_app/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/soojin_hong/05week/day2/island_app/Gemfile b/soojin_hong/05week/day2/island_app/Gemfile new file mode 100644 index 0000000..9c716e1 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/Gemfile @@ -0,0 +1,58 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/soojin_hong/05week/day2/island_app/Gemfile.lock b/soojin_hong/05week/day2/island_app/Gemfile.lock new file mode 100644 index 0000000..3917870 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/Gemfile.lock @@ -0,0 +1,227 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.32.2) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + io-like (0.3.1) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1-x86_64-darwin-19) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.5.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + public_suffix (4.0.5) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (1.7.1) + ruby_dep (1.5.0) + rubyzip (2.3.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/soojin_hong/05week/day2/island_app/README.md b/soojin_hong/05week/day2/island_app/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/soojin_hong/05week/day2/island_app/Rakefile b/soojin_hong/05week/day2/island_app/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/soojin_hong/05week/day2/island_app/app/assets/config/manifest.js b/soojin_hong/05week/day2/island_app/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/soojin_hong/05week/day2/island_app/app/assets/images/.keep b/soojin_hong/05week/day2/island_app/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/app/assets/javascripts/application.js b/soojin_hong/05week/day2/island_app/app/assets/javascripts/application.js new file mode 100644 index 0000000..46b2035 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require turbolinks +//= require_tree . diff --git a/soojin_hong/05week/day2/island_app/app/assets/stylesheets/application.css b/soojin_hong/05week/day2/island_app/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/soojin_hong/05week/day2/island_app/app/assets/stylesheets/style.css b/soojin_hong/05week/day2/island_app/app/assets/stylesheets/style.css new file mode 100644 index 0000000..7e31461 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/assets/stylesheets/style.css @@ -0,0 +1,24 @@ +body { + margin: 0 auto; + +} +.container { + max-width: 960px; + min-height: 500px; + margin: auto; + background-color: honeydew; + text-align: center; +} + +.feature { + width: 80% +} + +ul { + list-style-type: none; +} + +label { + display: flex; + justify-content: center; +} diff --git a/soojin_hong/05week/day2/island_app/app/controllers/application_controller.rb b/soojin_hong/05week/day2/island_app/app/controllers/application_controller.rb new file mode 100644 index 0000000..75f1154 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + skip_before_action :verify_authenticity_token +end diff --git a/soojin_hong/05week/day2/island_app/app/controllers/concerns/.keep b/soojin_hong/05week/day2/island_app/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/app/controllers/islands_controller.rb b/soojin_hong/05week/day2/island_app/app/controllers/islands_controller.rb new file mode 100644 index 0000000..ffec7c2 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/controllers/islands_controller.rb @@ -0,0 +1,36 @@ +class IslandsController < ApplicationController + def index + @islands = Island.all + end + + def show + @island = Island.find params[:id] + end + + def new + end + + def create + island = Island.create :name => params[:name], :country => params[:country], :image => params[:image] + redirect_to island_path(island.id) + end + + def edit + @island = Island.find params[:id] + end + + def update + island = Island.find params[:id] + island.name = params[:name] + island.country = params[:country] + island.image = params[:image] + island.save + redirect_to island_path(island.id) + end + + def destroy + island = Island.find params[:id] + island.destroy + redirect_to islands_path + end +end diff --git a/soojin_hong/05week/day2/island_app/app/helpers/application_helper.rb b/soojin_hong/05week/day2/island_app/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/soojin_hong/05week/day2/island_app/app/jobs/application_job.rb b/soojin_hong/05week/day2/island_app/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/soojin_hong/05week/day2/island_app/app/mailers/application_mailer.rb b/soojin_hong/05week/day2/island_app/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/soojin_hong/05week/day2/island_app/app/models/application_record.rb b/soojin_hong/05week/day2/island_app/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/soojin_hong/05week/day2/island_app/app/models/concerns/.keep b/soojin_hong/05week/day2/island_app/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/app/models/island.rb b/soojin_hong/05week/day2/island_app/app/models/island.rb new file mode 100644 index 0000000..c031ebd --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/models/island.rb @@ -0,0 +1,2 @@ +class Island < ActiveRecord::Base +end diff --git a/soojin_hong/05week/day2/island_app/app/views/islands/edit.html.erb b/soojin_hong/05week/day2/island_app/app/views/islands/edit.html.erb new file mode 100644 index 0000000..45c4897 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/views/islands/edit.html.erb @@ -0,0 +1,20 @@ +

Edit Island

+ +
+ + + + + + + +
diff --git a/soojin_hong/05week/day2/island_app/app/views/islands/index.html.erb b/soojin_hong/05week/day2/island_app/app/views/islands/index.html.erb new file mode 100644 index 0000000..96060ac --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/views/islands/index.html.erb @@ -0,0 +1,7 @@ +

All Islands

+ +<% @islands.each do |island| %> +

+ <%= link_to island.name, island_path(island.id) %> +

+<% end %> diff --git a/soojin_hong/05week/day2/island_app/app/views/islands/new.html.erb b/soojin_hong/05week/day2/island_app/app/views/islands/new.html.erb new file mode 100644 index 0000000..eb91502 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/views/islands/new.html.erb @@ -0,0 +1,20 @@ +

New Island

+ +
+ + + + + + + +
diff --git a/soojin_hong/05week/day2/island_app/app/views/islands/show.html.erb b/soojin_hong/05week/day2/island_app/app/views/islands/show.html.erb new file mode 100644 index 0000000..98c7e0b --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/views/islands/show.html.erb @@ -0,0 +1,13 @@ +

<%= @island.name %>

+ +<%= image_tag @island.image, :class => 'feature' if @island.image.present? %> + + + +
+ <%= link_to "Edit Island", edit_island_path(@island.id) %> + <%= button_to "Delete Island", island_path(@island.id), :method => 'delete' %> +
diff --git a/soojin_hong/05week/day2/island_app/app/views/layouts/application.html.erb b/soojin_hong/05week/day2/island_app/app/views/layouts/application.html.erb new file mode 100644 index 0000000..6811375 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/views/layouts/application.html.erb @@ -0,0 +1,24 @@ + + + + IslandApp + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + +
+ + + <%= yield %> +
+ + + diff --git a/soojin_hong/05week/day2/island_app/app/views/layouts/mailer.html.erb b/soojin_hong/05week/day2/island_app/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/soojin_hong/05week/day2/island_app/app/views/layouts/mailer.text.erb b/soojin_hong/05week/day2/island_app/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/soojin_hong/05week/day2/island_app/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/soojin_hong/05week/day2/island_app/bin/bundle b/soojin_hong/05week/day2/island_app/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/soojin_hong/05week/day2/island_app/bin/rails b/soojin_hong/05week/day2/island_app/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/soojin_hong/05week/day2/island_app/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/soojin_hong/05week/day2/island_app/bin/rake b/soojin_hong/05week/day2/island_app/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/soojin_hong/05week/day2/island_app/bin/setup b/soojin_hong/05week/day2/island_app/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/soojin_hong/05week/day2/island_app/bin/spring b/soojin_hong/05week/day2/island_app/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/soojin_hong/05week/day2/island_app/bin/update b/soojin_hong/05week/day2/island_app/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/soojin_hong/05week/day2/island_app/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/soojin_hong/05week/day2/island_app/bin/yarn b/soojin_hong/05week/day2/island_app/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/soojin_hong/05week/day2/island_app/config.ru b/soojin_hong/05week/day2/island_app/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/soojin_hong/05week/day2/island_app/config/application.rb b/soojin_hong/05week/day2/island_app/config/application.rb new file mode 100644 index 0000000..4f3f718 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/application.rb @@ -0,0 +1,30 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module IslandApp + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/soojin_hong/05week/day2/island_app/config/boot.rb b/soojin_hong/05week/day2/island_app/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/soojin_hong/05week/day2/island_app/config/credentials.yml.enc b/soojin_hong/05week/day2/island_app/config/credentials.yml.enc new file mode 100644 index 0000000..33e2afd --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/credentials.yml.enc @@ -0,0 +1 @@ +Q2nfwvBf1+Oaphg9HYH2TiQpbiMOTXuRhXM0i5fZ31bI1ZOdb4MsV3LAsyi6tEwrb7XCTe9MTV+XJTUpiy058sbgLKmlhjMbUmmQMJtGc+9X49sk4JW5Bm1joOMkyHI4ESKPDPMm0AyIHu7ea0lT1Ayb1rAz+OeRgCJmzhB5Bo0Ex9eTDzGreYoPMF+1MPF4ry0ULNmVcXsJdhexRVTefP3xFyHUq44J/OcSRDktbZC9m0+7t7WHG4ZUdZvokQaKh4pcIVuhhKPNn+xTcbyd7gHA3R7QmMVUD4SWp3RA4VhSZF2ef4hGflwesvDBaHYXnzP4xFIRnDwM79PD3w7lDOArIijTz71a6kWKnZSHEharNbG+5tto8SXUjzZZ6igeW2hJRyspWr2ophI2fKWw+Yl7Jyz5RK3O2GPx--MQCyOsRpA9RJ/FmD--tdkImNQqL2DiOBWua7huDQ== \ No newline at end of file diff --git a/soojin_hong/05week/day2/island_app/config/database.yml b/soojin_hong/05week/day2/island_app/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/soojin_hong/05week/day2/island_app/config/environment.rb b/soojin_hong/05week/day2/island_app/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/soojin_hong/05week/day2/island_app/config/environments/development.rb b/soojin_hong/05week/day2/island_app/config/environments/development.rb new file mode 100644 index 0000000..92bfc1d --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/environments/development.rb @@ -0,0 +1,58 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/soojin_hong/05week/day2/island_app/config/environments/production.rb b/soojin_hong/05week/day2/island_app/config/environments/production.rb new file mode 100644 index 0000000..db0e5cb --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/environments/production.rb @@ -0,0 +1,86 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "island_app_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/soojin_hong/05week/day2/island_app/config/environments/test.rb b/soojin_hong/05week/day2/island_app/config/environments/test.rb new file mode 100644 index 0000000..b08fc84 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/environments/test.rb @@ -0,0 +1,43 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/soojin_hong/05week/day2/island_app/config/initializers/application_controller_renderer.rb b/soojin_hong/05week/day2/island_app/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/soojin_hong/05week/day2/island_app/config/initializers/assets.rb b/soojin_hong/05week/day2/island_app/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/soojin_hong/05week/day2/island_app/config/initializers/backtrace_silencers.rb b/soojin_hong/05week/day2/island_app/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/soojin_hong/05week/day2/island_app/config/initializers/content_security_policy.rb b/soojin_hong/05week/day2/island_app/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/soojin_hong/05week/day2/island_app/config/initializers/cookies_serializer.rb b/soojin_hong/05week/day2/island_app/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/soojin_hong/05week/day2/island_app/config/initializers/filter_parameter_logging.rb b/soojin_hong/05week/day2/island_app/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/soojin_hong/05week/day2/island_app/config/initializers/inflections.rb b/soojin_hong/05week/day2/island_app/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/soojin_hong/05week/day2/island_app/config/initializers/mime_types.rb b/soojin_hong/05week/day2/island_app/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/soojin_hong/05week/day2/island_app/config/initializers/wrap_parameters.rb b/soojin_hong/05week/day2/island_app/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/soojin_hong/05week/day2/island_app/config/locales/en.yml b/soojin_hong/05week/day2/island_app/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/soojin_hong/05week/day2/island_app/config/master.key b/soojin_hong/05week/day2/island_app/config/master.key new file mode 100644 index 0000000..5852807 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/master.key @@ -0,0 +1 @@ +352ad28bdb41f26ef1241e31355fa551 \ No newline at end of file diff --git a/soojin_hong/05week/day2/island_app/config/puma.rb b/soojin_hong/05week/day2/island_app/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/soojin_hong/05week/day2/island_app/config/routes.rb b/soojin_hong/05week/day2/island_app/config/routes.rb new file mode 100644 index 0000000..5d0d69f --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/routes.rb @@ -0,0 +1,11 @@ +Rails.application.routes.draw do + root :to => 'islands#index' + get '/islands' => 'islands#index' + get '/islands/new' => 'islands#new', :as => 'new_island' + post '/islands/' => 'islands#create' + get '/islands/:id' => 'islands#show', :as => 'island' + get '/islands/:id/edit' => 'islands#edit', :as => 'edit_island' + post '/islands/:id' => 'islands#update' + delete '/islands/:id' => 'islands#destroy' + +end diff --git a/soojin_hong/05week/day2/island_app/config/spring.rb b/soojin_hong/05week/day2/island_app/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/soojin_hong/05week/day2/island_app/db/create_islands.sql b/soojin_hong/05week/day2/island_app/db/create_islands.sql new file mode 100644 index 0000000..2887b24 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/db/create_islands.sql @@ -0,0 +1,6 @@ +CREATE TABLE islands ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + country TEXT, + image TEXT +); diff --git a/soojin_hong/05week/day2/island_app/db/development.sqlite3 b/soojin_hong/05week/day2/island_app/db/development.sqlite3 new file mode 100644 index 0000000..eea119c Binary files /dev/null and b/soojin_hong/05week/day2/island_app/db/development.sqlite3 differ diff --git a/soojin_hong/05week/day2/island_app/db/seeds.rb b/soojin_hong/05week/day2/island_app/db/seeds.rb new file mode 100644 index 0000000..46e560e --- /dev/null +++ b/soojin_hong/05week/day2/island_app/db/seeds.rb @@ -0,0 +1,7 @@ +Island.destroy_all + +Island.create :name => 'Bali', :country => 'Indonesia' +Island.create :name => 'Santorini', :country => 'Greece' +Island.create :name => 'Hawaii', :country => 'US' + +puts "#{ Island.count } islands available." diff --git a/soojin_hong/05week/day2/island_app/db/test.sqlite3 b/soojin_hong/05week/day2/island_app/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/lib/assets/.keep b/soojin_hong/05week/day2/island_app/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/lib/tasks/.keep b/soojin_hong/05week/day2/island_app/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/package.json b/soojin_hong/05week/day2/island_app/package.json new file mode 100644 index 0000000..2ccb5c2 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/package.json @@ -0,0 +1,5 @@ +{ + "name": "island_app", + "private": true, + "dependencies": {} +} diff --git a/soojin_hong/05week/day2/island_app/public/404.html b/soojin_hong/05week/day2/island_app/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/soojin_hong/05week/day2/island_app/public/422.html b/soojin_hong/05week/day2/island_app/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/soojin_hong/05week/day2/island_app/public/500.html b/soojin_hong/05week/day2/island_app/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/soojin_hong/05week/day2/island_app/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/soojin_hong/05week/day2/island_app/public/apple-touch-icon-precomposed.png b/soojin_hong/05week/day2/island_app/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/public/apple-touch-icon.png b/soojin_hong/05week/day2/island_app/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/public/favicon.ico b/soojin_hong/05week/day2/island_app/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/public/robots.txt b/soojin_hong/05week/day2/island_app/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/soojin_hong/05week/day2/island_app/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/soojin_hong/05week/day2/island_app/test/application_system_test_case.rb b/soojin_hong/05week/day2/island_app/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/soojin_hong/05week/day2/island_app/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/soojin_hong/05week/day2/island_app/test/controllers/.keep b/soojin_hong/05week/day2/island_app/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/test/fixtures/.keep b/soojin_hong/05week/day2/island_app/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/test/fixtures/files/.keep b/soojin_hong/05week/day2/island_app/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/test/helpers/.keep b/soojin_hong/05week/day2/island_app/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/test/integration/.keep b/soojin_hong/05week/day2/island_app/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/test/mailers/.keep b/soojin_hong/05week/day2/island_app/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/test/models/.keep b/soojin_hong/05week/day2/island_app/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/test/system/.keep b/soojin_hong/05week/day2/island_app/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day2/island_app/test/test_helper.rb b/soojin_hong/05week/day2/island_app/test/test_helper.rb new file mode 100644 index 0000000..3ab84e3 --- /dev/null +++ b/soojin_hong/05week/day2/island_app/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/soojin_hong/05week/day2/island_app/vendor/.keep b/soojin_hong/05week/day2/island_app/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day3/ballet_app/.ruby-version b/soojin_hong/05week/day3/ballet_app/.ruby-version new file mode 100644 index 0000000..f0a47c1 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.1 \ No newline at end of file diff --git a/soojin_hong/05week/day3/ballet_app/Gemfile b/soojin_hong/05week/day3/ballet_app/Gemfile new file mode 100644 index 0000000..2792f24 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/Gemfile @@ -0,0 +1,51 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.4', '>= 5.2.4.3' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +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] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'pry-rails' +end + + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/soojin_hong/05week/day3/ballet_app/Gemfile.lock b/soojin_hong/05week/day3/ballet_app/Gemfile.lock new file mode 100644 index 0000000..512d5aa --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/Gemfile.lock @@ -0,0 +1,199 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + bindex (0.8.1) + bootsnap (1.4.6) + msgpack (~> 1.0) + builder (3.2.4) + byebug (11.1.3) + coderay (1.1.3) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.13.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.3) + concurrent-ruby (~> 1.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) + libv8 (7.3.492.27.1-x86_64-darwin-19) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.6.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mini_racer (0.2.14) + libv8 (> 7.3) + minitest (5.14.1) + msgpack (1.3.3) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + puma (3.12.6) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + ruby_dep (1.5.0) + sass (3.7.4) + 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.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.4.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.7) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.2) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + mini_racer + pry-rails + puma (~> 3.11) + rails (~> 5.2.4, >= 5.2.4.3) + sass-rails (~> 5.0) + spring + spring-watcher-listen (~> 2.0.0) + sqlite3 + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.7.1p83 + +BUNDLED WITH + 2.1.4 diff --git a/soojin_hong/05week/day3/ballet_app/README.md b/soojin_hong/05week/day3/ballet_app/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/soojin_hong/05week/day3/ballet_app/Rakefile b/soojin_hong/05week/day3/ballet_app/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/soojin_hong/05week/day3/ballet_app/app/assets/config/manifest.js b/soojin_hong/05week/day3/ballet_app/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/soojin_hong/05week/day3/ballet_app/app/assets/images/.keep b/soojin_hong/05week/day3/ballet_app/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day3/ballet_app/app/assets/javascripts/application.js b/soojin_hong/05week/day3/ballet_app/app/assets/javascripts/application.js new file mode 100644 index 0000000..46b2035 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// 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, 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. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require turbolinks +//= require_tree . diff --git a/soojin_hong/05week/day3/ballet_app/app/assets/javascripts/composers.coffee b/soojin_hong/05week/day3/ballet_app/app/assets/javascripts/composers.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/assets/javascripts/composers.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/soojin_hong/05week/day3/ballet_app/app/assets/javascripts/works.coffee b/soojin_hong/05week/day3/ballet_app/app/assets/javascripts/works.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/assets/javascripts/works.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/soojin_hong/05week/day3/ballet_app/app/assets/stylesheets/application.css b/soojin_hong/05week/day3/ballet_app/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/soojin_hong/05week/day3/ballet_app/app/assets/stylesheets/composers.scss b/soojin_hong/05week/day3/ballet_app/app/assets/stylesheets/composers.scss new file mode 100644 index 0000000..8c2af49 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/assets/stylesheets/composers.scss @@ -0,0 +1,32 @@ +body { + background-color: ghostwhite; + margin: 0 auto; +} + +.container { + max-width: 960px; + margin: 0 auto; + text-align: center; +} + +.thumb { + height: 12em; +} + +ul { + list-style-type: none; +} + +nav { + display: flex; + justify-content: space-between; + padding: 1em 0; +} + +.feature { + max-height: 30em; +} + +input, select { + margin: 1em auto; +} diff --git a/soojin_hong/05week/day3/ballet_app/app/assets/stylesheets/works.scss b/soojin_hong/05week/day3/ballet_app/app/assets/stylesheets/works.scss new file mode 100644 index 0000000..8c84be8 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/assets/stylesheets/works.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the works controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/soojin_hong/05week/day3/ballet_app/app/controllers/application_controller.rb b/soojin_hong/05week/day3/ballet_app/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/soojin_hong/05week/day3/ballet_app/app/controllers/composers_controller.rb b/soojin_hong/05week/day3/ballet_app/app/controllers/composers_controller.rb new file mode 100644 index 0000000..f691fa0 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/controllers/composers_controller.rb @@ -0,0 +1,39 @@ +class ComposersController < ApplicationController + def index + @composers = Composer.all + end + + def new + @composer = Composer.new + end + + def create + composer = Composer.create composer_params + redirect_to composer + end + + def edit + @composer = Composer.find params[:id] + end + + def update + composer = Composer.find params[:id] + composer.update composer_params + redirect_to composer + end + + def show + @composer = Composer.find params[:id] + end + + def destroy + composer = Composer.find params[:id] + composer.destroy + redirect_to composers_path + end + + private + def composer_params + params.require(:composer).permit(:name, :nationality, :dob, :image) + end +end diff --git a/soojin_hong/05week/day3/ballet_app/app/controllers/concerns/.keep b/soojin_hong/05week/day3/ballet_app/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day3/ballet_app/app/controllers/works_controller.rb b/soojin_hong/05week/day3/ballet_app/app/controllers/works_controller.rb new file mode 100644 index 0000000..48e9aae --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/controllers/works_controller.rb @@ -0,0 +1,39 @@ +class WorksController < ApplicationController + def index + @works = Work.all + end + + def new + @work = Work.new + end + + def create + work = Work.create work_params + redirect_to work + end + + def edit + @work = Work.find params[:id] + end + + def update + work = Work.find params[:id] + work.update work_params + redirect_to work + end + + def show + @work = Work.find params[:id] + end + + def destroy + work = Work.find params[:id] + work.destroy + redirect_to works_path + end + + private + def work_params + params.require(:work).permit(:title, :plot, :premiere, :place, :image, :composer_id) + end +end diff --git a/soojin_hong/05week/day3/ballet_app/app/helpers/application_helper.rb b/soojin_hong/05week/day3/ballet_app/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/soojin_hong/05week/day3/ballet_app/app/helpers/composers_helper.rb b/soojin_hong/05week/day3/ballet_app/app/helpers/composers_helper.rb new file mode 100644 index 0000000..fd38d1c --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/helpers/composers_helper.rb @@ -0,0 +1,2 @@ +module ComposersHelper +end diff --git a/soojin_hong/05week/day3/ballet_app/app/helpers/works_helper.rb b/soojin_hong/05week/day3/ballet_app/app/helpers/works_helper.rb new file mode 100644 index 0000000..ccb78c2 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/helpers/works_helper.rb @@ -0,0 +1,2 @@ +module WorksHelper +end diff --git a/soojin_hong/05week/day3/ballet_app/app/jobs/application_job.rb b/soojin_hong/05week/day3/ballet_app/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/soojin_hong/05week/day3/ballet_app/app/mailers/application_mailer.rb b/soojin_hong/05week/day3/ballet_app/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/soojin_hong/05week/day3/ballet_app/app/models/application_record.rb b/soojin_hong/05week/day3/ballet_app/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/soojin_hong/05week/day3/ballet_app/app/models/composer.rb b/soojin_hong/05week/day3/ballet_app/app/models/composer.rb new file mode 100644 index 0000000..d4d709e --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/models/composer.rb @@ -0,0 +1,3 @@ +class Composer < ActiveRecord::Base + has_many :works +end diff --git a/soojin_hong/05week/day3/ballet_app/app/models/concerns/.keep b/soojin_hong/05week/day3/ballet_app/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day3/ballet_app/app/models/work.rb b/soojin_hong/05week/day3/ballet_app/app/models/work.rb new file mode 100644 index 0000000..8016752 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/models/work.rb @@ -0,0 +1,3 @@ +class Work < ActiveRecord::Base + belongs_to :composer, :optional => true +end diff --git a/soojin_hong/05week/day3/ballet_app/app/views/composers/_form.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/composers/_form.html.erb new file mode 100644 index 0000000..f848948 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/composers/_form.html.erb @@ -0,0 +1,15 @@ +<%= form_for @composer do |f| %> + <%= f.label :name %> + <%= f.text_field :name, :required => true, :autofocus => true %> + + <%= f.label :nationality %> + <%= f.text_field :nationality %> + + <%= f.label :dob, 'Date of birth' %> + <%= f.text_field :dob, :placeholder => 'YYYY-MM-DD' %> + + <%= f.label :image %> + <%= f.url_field :image %> + + <%= f.submit %> +<% end %> diff --git a/soojin_hong/05week/day3/ballet_app/app/views/composers/edit.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/composers/edit.html.erb new file mode 100644 index 0000000..8223b57 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/composers/edit.html.erb @@ -0,0 +1,2 @@ +

Edit Composer

+<%= render :partial => 'form' %> diff --git a/soojin_hong/05week/day3/ballet_app/app/views/composers/index.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/composers/index.html.erb new file mode 100644 index 0000000..e065e9e --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/composers/index.html.erb @@ -0,0 +1,10 @@ +

All Composers

+ +<% @composers.each do |composer| %> + <%= image_tag composer.image, :class => 'thumb' if composer.image.present? %> + +<% end %> diff --git a/soojin_hong/05week/day3/ballet_app/app/views/composers/new.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/composers/new.html.erb new file mode 100644 index 0000000..e5ce6fd --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/composers/new.html.erb @@ -0,0 +1,3 @@ +

New Composer

+ +<%= render :partial => 'form' %> diff --git a/soojin_hong/05week/day3/ballet_app/app/views/composers/show.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/composers/show.html.erb new file mode 100644 index 0000000..27b329c --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/composers/show.html.erb @@ -0,0 +1,17 @@ +

<%= @composer.name %>

+ +<%= image_tag @composer.image, :class => 'feature' if @composer.image.present? %> + + +<% @composer.works.each do |work| %> + <%= link_to image_tag(work.image, :class => 'thumb'), work %> +<% end %> + +
+ <%= link_to 'Edit Composer', edit_composer_path(@composer.id) %> + <%= link_to 'Delete Composer', @composer, :method => 'delete' %> +
diff --git a/soojin_hong/05week/day3/ballet_app/app/views/layouts/application.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/layouts/application.html.erb new file mode 100644 index 0000000..2b66574 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/layouts/application.html.erb @@ -0,0 +1,26 @@ + + + + BalletApp + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + +
+ + + <%= yield %> +
+ + + diff --git a/soojin_hong/05week/day3/ballet_app/app/views/layouts/mailer.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/soojin_hong/05week/day3/ballet_app/app/views/layouts/mailer.text.erb b/soojin_hong/05week/day3/ballet_app/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/soojin_hong/05week/day3/ballet_app/app/views/works/_form.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/works/_form.html.erb new file mode 100644 index 0000000..5f009c8 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/works/_form.html.erb @@ -0,0 +1,21 @@ +<%= form_for @work do |f| %> + <%= f.label :title %> + <%= f.text_field :title, :required => true, :autofocus => true %> + + <%= f.label :plot %> + <%= f.number_field :plot %> + + <%= f.label :premiere %> + <%= f.text_field :premiere, :placeholder => 'YYYY-MM-DD' %> + + <%= f.label :place %> + <%= f.text_field :place %> + + <%= f.label :image %> + <%= f.url_field :image %> + + <%= f.label :composer_id %> + <%= f.select :composer_id, Composer.pluck(:name, :id), :include_blank => true %> + + <%= f.submit %> +<% end %> diff --git a/soojin_hong/05week/day3/ballet_app/app/views/works/edit.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/works/edit.html.erb new file mode 100644 index 0000000..dca44ef --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/works/edit.html.erb @@ -0,0 +1,2 @@ +

Edit Work

+<%= render :partial => 'form' %> diff --git a/soojin_hong/05week/day3/ballet_app/app/views/works/index.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/works/index.html.erb new file mode 100644 index 0000000..6ca1c55 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/works/index.html.erb @@ -0,0 +1,4 @@ +

All Works

+<% @works.each do |work| %> + <%= link_to image_tag(work.image, :class => 'thumb', :alt => work.title), work %> +<% end %> diff --git a/soojin_hong/05week/day3/ballet_app/app/views/works/new.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/works/new.html.erb new file mode 100644 index 0000000..69ad67f --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/works/new.html.erb @@ -0,0 +1,2 @@ +

New Work

+<%= render :partial => 'form' %> diff --git a/soojin_hong/05week/day3/ballet_app/app/views/works/show.html.erb b/soojin_hong/05week/day3/ballet_app/app/views/works/show.html.erb new file mode 100644 index 0000000..e9831d2 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/app/views/works/show.html.erb @@ -0,0 +1,18 @@ +

<%= @work.title %>

+ +<%= image_tag @work.image, :class => 'feature', :alt => @work.title if @work.image.present? %> + + + +
+ <%= link_to 'Edit work', edit_work_path(@work) %> + <%= link_to 'Delete work', @work, :method => 'delete' %> +
diff --git a/soojin_hong/05week/day3/ballet_app/bin/bundle b/soojin_hong/05week/day3/ballet_app/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/soojin_hong/05week/day3/ballet_app/bin/rails b/soojin_hong/05week/day3/ballet_app/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/soojin_hong/05week/day3/ballet_app/bin/rake b/soojin_hong/05week/day3/ballet_app/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/soojin_hong/05week/day3/ballet_app/bin/setup b/soojin_hong/05week/day3/ballet_app/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/soojin_hong/05week/day3/ballet_app/bin/spring b/soojin_hong/05week/day3/ballet_app/bin/spring new file mode 100755 index 0000000..d89ee49 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads Spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == 'spring' } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/soojin_hong/05week/day3/ballet_app/bin/update b/soojin_hong/05week/day3/ballet_app/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/soojin_hong/05week/day3/ballet_app/bin/yarn b/soojin_hong/05week/day3/ballet_app/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/soojin_hong/05week/day3/ballet_app/config.ru b/soojin_hong/05week/day3/ballet_app/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/soojin_hong/05week/day3/ballet_app/config/application.rb b/soojin_hong/05week/day3/ballet_app/config/application.rb new file mode 100644 index 0000000..757227f --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/application.rb @@ -0,0 +1,33 @@ +require_relative 'boot' + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module BalletApp + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/soojin_hong/05week/day3/ballet_app/config/boot.rb b/soojin_hong/05week/day3/ballet_app/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/soojin_hong/05week/day3/ballet_app/config/credentials.yml.enc b/soojin_hong/05week/day3/ballet_app/config/credentials.yml.enc new file mode 100644 index 0000000..38bec9d --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/credentials.yml.enc @@ -0,0 +1 @@ +rIVJZB8CJXcF8afKwbYIiAjFHumzViW/4XhzCIucVL87bSXBaVv85+XT9RyzJjmBHJPgzEo/XlaGcVV7Z+V6HylpliaWjClFR8tuWbNdeu3Kmqzfskq/29aHuWRxsHXcM+7yrXb+3B8AiqOf+IysiQyKwJp6RYrWO1HBB2Bzrunr4c8iBSVbiGT9XvC5NPDc6jrsowAc/RXbL8vx6qP5RU8whb+/t68KZfy7XmTELmTH1CSmoD7ghz8luvJy1scBD8Ki7HudbdQGnOd4dqLTwrEL8GNRNBIot2bQ3s7rl1kCYCGlgeabCcjYX3cdGXJ7NhtdIgpAcemSOJe8Fiij/6SIUxXMZDfnjzlwhP4W44MlqqtuHroxs22aTcLlMUvlcIiT58+3fWSuEHa3QoIWpt/dlJbjAYNVcoEZ--Feo6sB6PIawDvFzT--5tnhzIkSMCSKJzILG44lrg== \ No newline at end of file diff --git a/soojin_hong/05week/day3/ballet_app/config/database.yml b/soojin_hong/05week/day3/ballet_app/config/database.yml new file mode 100644 index 0000000..0d02f24 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/soojin_hong/05week/day3/ballet_app/config/environment.rb b/soojin_hong/05week/day3/ballet_app/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/soojin_hong/05week/day3/ballet_app/config/environments/development.rb b/soojin_hong/05week/day3/ballet_app/config/environments/development.rb new file mode 100644 index 0000000..92bfc1d --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/environments/development.rb @@ -0,0 +1,58 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/soojin_hong/05week/day3/ballet_app/config/environments/production.rb b/soojin_hong/05week/day3/ballet_app/config/environments/production.rb new file mode 100644 index 0000000..f85cf83 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/environments/production.rb @@ -0,0 +1,86 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "ballet_app_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/soojin_hong/05week/day3/ballet_app/config/environments/test.rb b/soojin_hong/05week/day3/ballet_app/config/environments/test.rb new file mode 100644 index 0000000..b08fc84 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/environments/test.rb @@ -0,0 +1,43 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/soojin_hong/05week/day3/ballet_app/config/initializers/application_controller_renderer.rb b/soojin_hong/05week/day3/ballet_app/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/soojin_hong/05week/day3/ballet_app/config/initializers/assets.rb b/soojin_hong/05week/day3/ballet_app/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/soojin_hong/05week/day3/ballet_app/config/initializers/backtrace_silencers.rb b/soojin_hong/05week/day3/ballet_app/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/soojin_hong/05week/day3/ballet_app/config/initializers/content_security_policy.rb b/soojin_hong/05week/day3/ballet_app/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/soojin_hong/05week/day3/ballet_app/config/initializers/cookies_serializer.rb b/soojin_hong/05week/day3/ballet_app/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/soojin_hong/05week/day3/ballet_app/config/initializers/filter_parameter_logging.rb b/soojin_hong/05week/day3/ballet_app/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/soojin_hong/05week/day3/ballet_app/config/initializers/inflections.rb b/soojin_hong/05week/day3/ballet_app/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/soojin_hong/05week/day3/ballet_app/config/initializers/mime_types.rb b/soojin_hong/05week/day3/ballet_app/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/soojin_hong/05week/day3/ballet_app/config/initializers/wrap_parameters.rb b/soojin_hong/05week/day3/ballet_app/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/soojin_hong/05week/day3/ballet_app/config/locales/en.yml b/soojin_hong/05week/day3/ballet_app/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/soojin_hong/05week/day3/ballet_app/config/master.key b/soojin_hong/05week/day3/ballet_app/config/master.key new file mode 100644 index 0000000..f172e89 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/master.key @@ -0,0 +1 @@ +99d05da1d9457130e853c69d2c7701c9 \ No newline at end of file diff --git a/soojin_hong/05week/day3/ballet_app/config/puma.rb b/soojin_hong/05week/day3/ballet_app/config/puma.rb new file mode 100644 index 0000000..b210207 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/puma.rb @@ -0,0 +1,37 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/soojin_hong/05week/day3/ballet_app/config/routes.rb b/soojin_hong/05week/day3/ballet_app/config/routes.rb new file mode 100644 index 0000000..2fd7885 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + resources :composers + resources :works +end diff --git a/soojin_hong/05week/day3/ballet_app/config/spring.rb b/soojin_hong/05week/day3/ballet_app/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/soojin_hong/05week/day3/ballet_app/db/development.sqlite3 b/soojin_hong/05week/day3/ballet_app/db/development.sqlite3 new file mode 100644 index 0000000..19aefb3 Binary files /dev/null and b/soojin_hong/05week/day3/ballet_app/db/development.sqlite3 differ diff --git a/soojin_hong/05week/day3/ballet_app/db/migrate/20200617101641_create_composers.rb b/soojin_hong/05week/day3/ballet_app/db/migrate/20200617101641_create_composers.rb new file mode 100644 index 0000000..2b7b3a4 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/db/migrate/20200617101641_create_composers.rb @@ -0,0 +1,10 @@ +class CreateComposers < ActiveRecord::Migration[5.2] + def change + create_table :composers do |t| + t.text :name + t.text :nationality + t.date :dob + t.text :image + end + end +end diff --git a/soojin_hong/05week/day3/ballet_app/db/migrate/20200617131921_create_works.rb b/soojin_hong/05week/day3/ballet_app/db/migrate/20200617131921_create_works.rb new file mode 100644 index 0000000..0de2493 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/db/migrate/20200617131921_create_works.rb @@ -0,0 +1,11 @@ +class CreateWorks < ActiveRecord::Migration[5.2] + def change + create_table :works do |t| + t.text :title + t.integer :plot + t.date :premiere + t.text :place + t.text :image + end + end +end diff --git a/soojin_hong/05week/day3/ballet_app/db/migrate/20200617144504_add_composer_id_to_works.rb b/soojin_hong/05week/day3/ballet_app/db/migrate/20200617144504_add_composer_id_to_works.rb new file mode 100644 index 0000000..dfcd930 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/db/migrate/20200617144504_add_composer_id_to_works.rb @@ -0,0 +1,5 @@ +class AddComposerIdToWorks < ActiveRecord::Migration[5.2] + def change + add_column :works, :composer_id, :integer + end +end diff --git a/soojin_hong/05week/day3/ballet_app/db/schema.rb b/soojin_hong/05week/day3/ballet_app/db/schema.rb new file mode 100644 index 0000000..0064411 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/db/schema.rb @@ -0,0 +1,31 @@ +# 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. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_17_144504) do + + create_table "composers", force: :cascade do |t| + t.text "name" + t.text "nationality" + t.date "dob" + t.text "image" + end + + create_table "works", force: :cascade do |t| + t.text "title" + t.integer "plot" + t.date "premiere" + t.text "place" + t.text "image" + t.integer "composer_id" + end + +end diff --git a/soojin_hong/05week/day3/ballet_app/db/seeds.rb b/soojin_hong/05week/day3/ballet_app/db/seeds.rb new file mode 100644 index 0000000..e097f08 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/db/seeds.rb @@ -0,0 +1,19 @@ +Composer.destroy_all + +Composer.create(:name => 'Pyotr Tchaikovsky', :nationality => 'Russian', :dob => '1840-5-7', :image => 'https://legacyprojectchicago.org/sites/default/files/2019-08/Pyotr%20Tchaikovsky.jpg') +Composer.create(:name => 'Adolphe Adam', :nationality => 'French', :dob => '1803-7-24', :image => 'https://www.ovationpress.com/images/category/descriptionpics/composers/Adolphe_Adam.jpg') +Composer.create(:name => 'Ludwig Minkus', :nationality => 'Austrian', :dob => '1826-3-23', :image => 'https://petipasociety.files.wordpress.com/2016/08/ludwig-minkus.jpg?w=476&h=593') +Composer.create(:name => 'Leo Delibes', :nationality => 'French', :dob => '1846-1-1', :image => 'https://upload.wikimedia.org/wikipedia/commons/2/24/Delibes_Leo_Luckhard.png') + +puts "#{ Composer.count } composers created." + + +Work.destroy_all + +Work.create(:title => 'The Nutcracker', :plot => 2, :premiere => '1892-12-18', :place => 'Mariinsky Theatre', :image => 'https://i2.wp.com/www.columbusonthecheap.com/lotc-cms/wp-content/uploads/2017/10/Nutcracker-2_Clara_smaller_preview-e1509419566517.jpeg?fit=849%2C1054&ssl=1') +Work.create(:title => 'Swan Lake', :plot => 2, :premiere => '1877-3-4', :place => 'Bolshoi Theatre', :image => 'https://149359931.v2.pressablecdn.com/wp-content/uploads/2015/01/jv-swan-lake-andrei-yermakov-profile-corps_1000.jpg') +Work.create(:title => 'Giselle', :plot => 2, :premiere => '1841-6-28', :place => 'Paris Opera', :image => 'https://dancemagazine.com.au/wp-content/uploads/2017/10/The-Australian-Ballet-Regional-Tour-of-Giselle.-Photo-by-Jeff-Busby..jpg') +Work.create(:title => 'La Bayadere', :plot => 3, :premiere => '1877-2-4', :place => 'Imperial Theatre', :image => 'https://mikhailovsky.ru/upload/iblock/8ad/bayadere_02.jpg') +Work.create(:title => 'Coppelia', :plot => 3, :premiere => '1870-5-25', :place => 'Paris Opera', :image => 'https://media.timeout.com/images/105295858/630/472/image.jpg') + +puts "#{ Work.count } works created." diff --git a/soojin_hong/05week/day3/ballet_app/db/test.sqlite3 b/soojin_hong/05week/day3/ballet_app/db/test.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day3/ballet_app/lib/assets/.keep b/soojin_hong/05week/day3/ballet_app/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day3/ballet_app/lib/tasks/.keep b/soojin_hong/05week/day3/ballet_app/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day3/ballet_app/package.json b/soojin_hong/05week/day3/ballet_app/package.json new file mode 100644 index 0000000..ba97d33 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/package.json @@ -0,0 +1,5 @@ +{ + "name": "ballet_app", + "private": true, + "dependencies": {} +} diff --git a/soojin_hong/05week/day3/ballet_app/public/404.html b/soojin_hong/05week/day3/ballet_app/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/soojin_hong/05week/day3/ballet_app/public/422.html b/soojin_hong/05week/day3/ballet_app/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/soojin_hong/05week/day3/ballet_app/public/500.html b/soojin_hong/05week/day3/ballet_app/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/soojin_hong/05week/day3/ballet_app/public/apple-touch-icon-precomposed.png b/soojin_hong/05week/day3/ballet_app/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day3/ballet_app/public/apple-touch-icon.png b/soojin_hong/05week/day3/ballet_app/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day3/ballet_app/public/favicon.ico b/soojin_hong/05week/day3/ballet_app/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/05week/day3/ballet_app/public/robots.txt b/soojin_hong/05week/day3/ballet_app/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/soojin_hong/05week/day3/ballet_app/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/soojin_hong/05week/day3/ballet_app/vendor/.keep b/soojin_hong/05week/day3/ballet_app/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/soojin_hong/07week/index.html b/soojin_hong/07week/index.html new file mode 100644 index 0000000..f4566ea --- /dev/null +++ b/soojin_hong/07week/index.html @@ -0,0 +1,24 @@ + + + + + + + + AJAX Book Search + + + +

AJAX Book Search

+ + + + + +
+ +
+ + + + diff --git a/soojin_hong/07week/js/booksearch.js b/soojin_hong/07week/js/booksearch.js new file mode 100644 index 0000000..d1345b5 --- /dev/null +++ b/soojin_hong/07week/js/booksearch.js @@ -0,0 +1,18 @@ +const fetchBook = function () { + const xhr = new XMLHttpRequest(); + + xhr.onreadystatechange = function () { + if ( xhr.readyState !== 4 ) return; + + const book = JSON.parse(xhr.responseText); + const img = document.getElementById('book_img'); + img.src = book.items[0].volumeInfo.imageLinks.thumbnail; + }; + + const bookTitle = document.getElementById('title').value + xhr.open('GET', `https://www.googleapis.com/books/v1/volumes?q=title:${ bookTitle }`); + xhr.send(); +} + +document.getElementById('fetch').addEventListener('click', fetchBook); +fetchBook(); diff --git a/warmups/5week/1day/binary_seq.rb b/warmups/5week/1day/binary_seq.rb index ce2198b..8c71f59 100644 --- a/warmups/5week/1day/binary_seq.rb +++ b/warmups/5week/1day/binary_seq.rb @@ -1,6 +1,10 @@ def longest num, long = 0, best = 0 + + return best if num == 1 + converted = num.to_s(2) zero_count = 0 + converted.split('').each do |x| if x == '0' zero_count += 1 @@ -8,11 +12,13 @@ def longest num, long = 0, best = 0 if long < zero_count long = zero_count best = num + puts converted, num, long, best, '========' end zero_count = 0 end end - num == 0 ? num : longest(num - 1, long, best) + + longest(num - 1, long, best) end -puts longest 4 \ No newline at end of file +puts longest 100 \ No newline at end of file diff --git a/warmups/5week/3day/main.rb b/warmups/5week/3day/main.rb new file mode 100644 index 0000000..44d6564 --- /dev/null +++ b/warmups/5week/3day/main.rb @@ -0,0 +1,20 @@ +memory = [] +guessed = true + +while guessed + memory.push rand 1..4 + puts memory.join ' ' + sleep 1 + puts `clear` + memory.map do |x| + if x == gets.to_i + puts `clear` + else + guessed = false + break + end + end +end + +# puts "wowowowo you got #{memory.size}" +puts memory.size > 5 ? "Hot digidi damn you got #{memory.size}" : "Huh, lame. You got #{memory.size}" \ No newline at end of file diff --git a/warmups/5week/3day/readme.md b/warmups/5week/3day/readme.md new file mode 100644 index 0000000..481d686 --- /dev/null +++ b/warmups/5week/3day/readme.md @@ -0,0 +1,14 @@ +# Simon says + +Implement a game of Simon Says. + +- Game first prints a random number between 1-4. +- The person has to repeat it. +- The game repeats the same number and adds another one after it +- Person then repeats the sequence. +- This goes on until a player cant repeat the sequence. +- Game then prints a message, saying how much player scored. + +Implement that game however you want, here is how my plays. + +![Simon Says](simon.gif) diff --git a/warmups/5week/3day/roman.md b/warmups/5week/3day/roman.md new file mode 100644 index 0000000..7200828 --- /dev/null +++ b/warmups/5week/3day/roman.md @@ -0,0 +1,51 @@ +# Roman Numerals + +The Romans were a clever bunch. They conquered most of Europe and ruled it for hundreds of years. They invented concrete and straight roads and even bikinis. One thing they never discovered though was the number zero. This made writing and dating extensive histories of their exploits slightly more challenging, but the system of numbers they came up with is still in use today. For example, the BBC uses Roman numerals to date their programmes. + +The Romans wrote numbers using letters - I, V, X, L, C, D, M. (notice these letters have lots of straight lines and are hence easy to hack into stone tablets using a chisel). + +```plain + 1 => I +10 => X + 7 => VII +``` + +Write a program that will convert Arabic numerals to Roman numerals. + +There is no need to be able to convert numbers larger than about 3000. (The Romans themselves didn't tend to go any higher) + +Wikipedia says: "Modern Roman numerals ... are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero." + +To see this in practice, consider the example of 1990. + +``` +In Roman numerals 1990 is MCMXC: + +1000=M 900=CM 90=XC + +2008 is written as MMVIII: + +2000=MM 8=VIII +``` + +See [this website](http://www.romannumerals.co.uk/roman-numerals/numerals-chart.html) for the table of Roman Numbers you will need to check for. + +Do this in Ruby. + +```ruby +roman = { +1000 => 'M', +900 => 'CM', +500 => 'D', +400 => 'CD', +100 => 'C', +90 => 'XC', +50 => 'L', +40 => 'XL', +10 => 'X', +9 => 'IX', +5 => 'V', +4 => 'IV', +1 => 'I' +} +``` diff --git a/warmups/5week/3day/roman.rb b/warmups/5week/3day/roman.rb new file mode 100644 index 0000000..c86c903 --- /dev/null +++ b/warmups/5week/3day/roman.rb @@ -0,0 +1,36 @@ +def convert year + roman = { + 1000 => 'M', + 900 => 'CM', + 500 => 'D', + 400 => 'CD', + 100 => 'C', + 90 => 'XC', + 50 => 'L', + 40 => 'XL', + 10 => 'X', + 9 => 'IX', + 5 => 'V', + 4 => 'IV', + 1 => 'I' + } + + output = '' + + roman.each do |key, value| + puts "Key: #{key}, value: #{value}" + while year >= key + output += value + year -= key + puts "==== There is a match for #{key}" + puts "==== Current value of year is #{year}" + end + break if year.zero? + end + + output +end + +puts convert 2100 +puts '=======' +puts convert 1999 \ No newline at end of file diff --git a/warmups/5week/3day/simon.gif b/warmups/5week/3day/simon.gif new file mode 100644 index 0000000..e49021f Binary files /dev/null and b/warmups/5week/3day/simon.gif differ diff --git a/warmups/5week/4day/main.rb b/warmups/5week/4day/main.rb new file mode 100644 index 0000000..c6ba40d --- /dev/null +++ b/warmups/5week/4day/main.rb @@ -0,0 +1,50 @@ +class Luhn + def initialize num + @number = num + end + + def prepare_digits + processed_digits = [] + @number.digits.reverse.map.with_index do |digit, index| + digit *= 2 if index.even? + digit -= 9 if digit >= 10 + processed_digits << digit + end + processed_digits + end + + def valid? + digits = prepare_digits + total = digits.sum + + if total % 10 == 0 + puts "Number #{@number} is valid" + true + else + puts "Number #{@number} is invalid" + check_digit = @number + (10 - total % 10) + puts "#{check_digit} would be a valid Luhn number" + false + end + end +end + +some_num = Luhn.new 8763 +other_num = Luhn.new 3554 + +some_num.valid? +other_num.valid? + +def short_luhn num + processed_digits = [] + num.digits.reverse.map.with_index do |digit, index| + digit *= 2 if index.even? + digit -= 9 if digit >= 10 + processed_digits << digit + end + processed_digits.sum % 10 == 0 ? true : false +end + +puts '='*20 +puts short_luhn 8763 +puts short_luhn 2554 \ No newline at end of file diff --git a/warmups/5week/4day/readme.md b/warmups/5week/4day/readme.md new file mode 100644 index 0000000..e3f473c --- /dev/null +++ b/warmups/5week/4day/readme.md @@ -0,0 +1,33 @@ +# Luhn Formula + +Write a program that can take a number and determine whether or not it is valid per the Luhn formula. + +The Luhn formula is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers and Canadian Social Insurance Numbers. + +This number must pass the following test: + +Counting from rightmost digit (which is the check digit) and moving left, double the value of every second digit. For any digits that thus become 10 or more, subtract 9 from the result. + +E.g., 1111 becomes 2121, while 8763 becomes 7733 (from 2×6=12 → 12-9=3 and 2×8=16 → 16-9=7). + +Add all these digits together. For example, if 1111 becomes 2121, then 2+1+2+1 is 6; and 8763 becomes 7733, so 7+7+3+3 is 20. + +If the total ends in 0 (put another way, if the total modulus 10 is 0), then the number is valid according to the Luhn formula; otherwise it is not valid. So, 1111 is not valid (as shown above, it comes out to 6), while 8763 is valid (as shown above, it comes out to 20). + +Write a program that, given a number, can check if it is valid per the Luhn formula. + +BONUS: + +For an invalid number, add a check digit to make the number valid. + +```ruby +l = Luhn.new(3554) +l.valid? +# => false + +l = Luhn.new(8763) +l.valid? +# => true +``` + +Do this in Ruby. diff --git a/warmups/7week/1day/index.html b/warmups/7week/1day/index.html new file mode 100644 index 0000000..e40da26 --- /dev/null +++ b/warmups/7week/1day/index.html @@ -0,0 +1,11 @@ + + + + + + Document + + + + + diff --git a/warmups/7week/1day/main.js b/warmups/7week/1day/main.js new file mode 100644 index 0000000..6b012f3 --- /dev/null +++ b/warmups/7week/1day/main.js @@ -0,0 +1,44 @@ +// const allergies = function (score) { +// const scorecard = { +// 1: 'eggs', +// 2: 'peanuts', +// 4: 'shellfish', +// 8: 'strawberries', +// 16: 'tomatoes', +// 32: 'chocolate', +// 64: 'pollen', +// 128: 'cats', +// }; + +// const out = []; +// const keys = Object.keys(scorecard).reverse(); +// for (let i = 0; i <= keys.length; i++) { +// const current = keys[i]; +// if (current <= score) { +// score -= current; +// out.push(scorecard[current]); +// } +// if (score === 0) break; +// } +// return out; +// }; + +const scorecard = [ + 'eggs', + 'peanuts', + 'shellfish', + 'strawberries', + 'tomatoes', + 'chocolate', + 'pollen', + 'cats', +]; + +const allergies = (score, out = [], index = scorecard.length) => + score === 0 + ? out + : score >= 2 ** index + ? allergies(score - 2 ** index, [...out, scorecard[index]], index - 1) + : allergies(score, out, index - 1); + +console.log(allergies(34)); diff --git a/warmups/7week/1day/readme.md b/warmups/7week/1day/readme.md new file mode 100644 index 0000000..68a2819 --- /dev/null +++ b/warmups/7week/1day/readme.md @@ -0,0 +1,34 @@ +# Allergies Warmup + +An allergy test produces a single numeric score which contains the information about all the allergies the person has (that they were tested for). + +The list of items (and their value) that were tested are: + +- eggs (1) +- peanuts (2) +- shellfish (4) +- strawberries (8) +- tomatoes (16) +- chocolate (32) +- pollen (64) +- cats (128) + +So if Tom is allergic to peanuts and chocolate, he gets a score of 34. + +Now, given just that score of 34, your program should be able to say: + +- Whether Tom is allergic to any one of those allergens listed above. +- All the allergens Tom is allergic to. + +```js +scorecard: { + 1: "eggs", + 2: "peanuts", + 4: "shellfish", + 8: "strawberries", + 16: "tomatoes", + 32: "chocolate", + 64: "pollen", + 128: "cats" +} +``` diff --git a/warmups/7week/2day/main.js b/warmups/7week/2day/main.js new file mode 100644 index 0000000..d142e7e --- /dev/null +++ b/warmups/7week/2day/main.js @@ -0,0 +1,44 @@ +const reverse = function (arr) { + const out = []; + for (let i = arr.length - 1; i >= 0; i--) { + out.push(arr[i]); + } + return out; +}; + +const flatten = function (arr) { + let out = []; + arr.forEach(function (el) { + if (Array.isArray(el)) { + out = out.concat(el); + } else { + out.push(el); + } + }); + return out; +}; + +const flattenBonus = function (arr, out = []) { + arr.forEach(function (el) { + if (Array.isArray(el)) { + flattenBonus(el, out); + } else { + out.push(el); + } + }); + return out; +}; + +console.log(reverse([1, 2, 3, 4])); +console.log(flatten(['Hello', ['World', 42]])); +console.log( + flattenBonus([ + 'hello', + [ + [true, false, true], + 'world', + 42, + [1, 2, ['a', 'b', ['A', [0, 1, 2], 'C']]], + ], + ]), +); diff --git a/warmups/7week/2day/readme.md b/warmups/7week/2day/readme.md new file mode 100644 index 0000000..00ff69a --- /dev/null +++ b/warmups/7week/2day/readme.md @@ -0,0 +1,20 @@ +## Arrays - Flatten and Reverse + +The goal of this exercise is to manipulate arrays by creating a function that can reverse an array and by creating a function that can flatten an array. Do not use any libraries to complete this task - write this stuff from scratch using standard JS methods and objects. + +- Make two functions + - reverse + - flatten + +```js +reverse( [1, 2, 3, 4] ); +// => [ 4, 3, 2, 1 ] +flatten( ["Hello", ["World", 42] ] ); +// => [ "Hello", "World", 42 ] +``` + +You only need to make flatten work to one level deep! You should be able to flatten this - ` ["Hello", ["World"]] ` - but not this - ` ["Hello", [[["World"]]]] ` + +## Bonus + +Make one that flattens any array that you pass into it: ` ["Hello", [[["World"], 42]]] ` -> `[ "Hello", "World", 42 ]` \ No newline at end of file diff --git a/yonathan_marlow/week-5/Railsv1/project/Gemfile.lock b/yonathan_marlow/week-5/Railsv1/project/Gemfile.lock index 67d23ec..759fe0e 100644 --- a/yonathan_marlow/week-5/Railsv1/project/Gemfile.lock +++ b/yonathan_marlow/week-5/Railsv1/project/Gemfile.lock @@ -109,7 +109,7 @@ GEM method_source (~> 1.0) public_suffix (4.0.5) puma (3.12.6) - rack (2.2.2) + rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.2.4.3)