diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/library/.gitignore b/library/.gitignore new file mode 100755 index 0000000..18b43c9 --- /dev/null +++ b/library/.gitignore @@ -0,0 +1,27 @@ +# 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 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/library/.ruby-version b/library/.ruby-version new file mode 100755 index 0000000..b8d12d7 --- /dev/null +++ b/library/.ruby-version @@ -0,0 +1 @@ +2.6.1 \ No newline at end of file diff --git a/library/Gemfile b/library/Gemfile new file mode 100755 index 0000000..198f844 --- /dev/null +++ b/library/Gemfile @@ -0,0 +1,62 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.6.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.2' +# Use postgresql as the database for Active Record +gem 'pg', '>= 0.18', '< 2.0' +# 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/library/Gemfile.lock b/library/Gemfile.lock new file mode 100755 index 0000000..07b2143 --- /dev/null +++ b/library/Gemfile.lock @@ -0,0 +1,220 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.2) + actionpack (= 5.2.2) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.2) + actionview (= 5.2.2) + activesupport (= 5.2.2) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.2) + activesupport (= 5.2.2) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.2) + activesupport (= 5.2.2) + globalid (>= 0.3.6) + activemodel (5.2.2) + activesupport (= 5.2.2) + activerecord (5.2.2) + activemodel (= 5.2.2) + activesupport (= 5.2.2) + arel (>= 9.0) + activestorage (5.2.2) + actionpack (= 5.2.2) + activerecord (= 5.2.2) + marcel (~> 0.3.1) + activesupport (5.2.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.6.0) + public_suffix (>= 2.0.2, < 4.0) + archive-zip (0.11.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.5.0) + bootsnap (1.4.1) + msgpack (~> 1.0) + builder (3.2.3) + byebug (11.0.0) + capybara (3.14.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.2) + xpath (~> 3.2) + childprocess (0.9.0) + ffi (~> 1.0, >= 1.0.11) + chromedriver-helper (2.1.0) + 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.4) + crass (1.0.4) + erubi (1.8.0) + execjs (2.7.0) + ffi (1.10.0) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.5.3) + concurrent-ruby (~> 1.0) + io-like (0.3.0) + jbuilder (2.8.0) + activesupport (>= 4.2.0) + multi_json (>= 1.2) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.2.3) + 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 (0.9.2) + mimemagic (0.3.3) + mini_mime (1.0.1) + mini_portile2 (2.4.0) + minitest (5.11.3) + msgpack (1.2.6) + multi_json (1.13.1) + nio4r (2.3.1) + nokogiri (1.10.1) + mini_portile2 (~> 2.4.0) + pg (1.1.4) + public_suffix (3.0.3) + puma (3.12.0) + rack (2.0.6) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.2) + actioncable (= 5.2.2) + actionmailer (= 5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) + activemodel (= 5.2.2) + activerecord (= 5.2.2) + activestorage (= 5.2.2) + activesupport (= 5.2.2) + bundler (>= 1.3.0) + railties (= 5.2.2) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) + railties (5.2.2) + actionpack (= 5.2.2) + activesupport (= 5.2.2) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (12.3.2) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + regexp_parser (1.3.0) + ruby_dep (1.5.0) + rubyzip (1.2.2) + sass (3.7.3) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.0.7) + railties (>= 4.0.0, < 6) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.141.0) + childprocess (~> 0.5) + rubyzip (~> 1.2, >= 1.2.2) + spring (2.0.2) + activesupport (>= 4.2) + 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) + thor (0.20.3) + thread_safe (0.3.6) + tilt (2.0.9) + turbolinks (5.2.0) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.5) + thread_safe (~> 0.1) + uglifier (4.1.20) + 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.0) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) + 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) + pg (>= 0.18, < 2.0) + puma (~> 3.11) + rails (~> 5.2.2) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.6.1p33 + +BUNDLED WITH + 1.17.2 diff --git a/library/README.md b/library/README.md new file mode 100755 index 0000000..7db80e4 --- /dev/null +++ b/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/library/Rakefile b/library/Rakefile new file mode 100755 index 0000000..e85f913 --- /dev/null +++ b/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/library/app/assets/config/manifest.js b/library/app/assets/config/manifest.js new file mode 100755 index 0000000..b16e53d --- /dev/null +++ b/library/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/library/app/assets/images/.keep b/library/app/assets/images/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/app/assets/javascripts/application.js b/library/app/assets/javascripts/application.js new file mode 100755 index 0000000..82e6f0f --- /dev/null +++ b/library/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/library/app/assets/javascripts/articles.coffee b/library/app/assets/javascripts/articles.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/library/app/assets/javascripts/articles.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/library/app/assets/javascripts/cable.js b/library/app/assets/javascripts/cable.js new file mode 100755 index 0000000..739aa5f --- /dev/null +++ b/library/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/library/app/assets/javascripts/channels/.keep b/library/app/assets/javascripts/channels/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/app/assets/javascripts/comments.coffee b/library/app/assets/javascripts/comments.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/library/app/assets/javascripts/comments.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/library/app/assets/javascripts/paintings.coffee b/library/app/assets/javascripts/paintings.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/library/app/assets/javascripts/paintings.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/library/app/assets/stylesheets/application.css b/library/app/assets/stylesheets/application.css new file mode 100755 index 0000000..d05ea0f --- /dev/null +++ b/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/library/app/assets/stylesheets/articles.scss b/library/app/assets/stylesheets/articles.scss new file mode 100644 index 0000000..cca5487 --- /dev/null +++ b/library/app/assets/stylesheets/articles.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the articles controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/library/app/assets/stylesheets/comments.scss b/library/app/assets/stylesheets/comments.scss new file mode 100644 index 0000000..e730912 --- /dev/null +++ b/library/app/assets/stylesheets/comments.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Comments controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/library/app/assets/stylesheets/paintings.scss b/library/app/assets/stylesheets/paintings.scss new file mode 100644 index 0000000..a1e9084 --- /dev/null +++ b/library/app/assets/stylesheets/paintings.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the paintings controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/library/app/assets/stylesheets/scaffolds.scss b/library/app/assets/stylesheets/scaffolds.scss new file mode 100644 index 0000000..6045188 --- /dev/null +++ b/library/app/assets/stylesheets/scaffolds.scss @@ -0,0 +1,84 @@ +body { + background-color: #fff; + color: #333; + margin: 33px; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + + &:visited { + color: #666; + } + + &:hover { + color: #fff; + background-color: #000; + } +} + +th { + padding-bottom: 5px; +} + +td { + padding: 0 5px 7px; +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px 7px 0; + margin-bottom: 20px; + background-color: #f0f0f0; + + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px -7px 0; + background-color: #c00; + color: #fff; + } + + ul li { + font-size: 12px; + list-style: square; + } +} + +label { + display: block; +} diff --git a/library/app/channels/application_cable/channel.rb b/library/app/channels/application_cable/channel.rb new file mode 100755 index 0000000..d672697 --- /dev/null +++ b/library/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/library/app/channels/application_cable/connection.rb b/library/app/channels/application_cable/connection.rb new file mode 100755 index 0000000..0ff5442 --- /dev/null +++ b/library/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/library/app/controllers/application_controller.rb b/library/app/controllers/application_controller.rb new file mode 100755 index 0000000..09705d1 --- /dev/null +++ b/library/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/library/app/controllers/articles_controller.rb b/library/app/controllers/articles_controller.rb new file mode 100644 index 0000000..4536962 --- /dev/null +++ b/library/app/controllers/articles_controller.rb @@ -0,0 +1,74 @@ +class ArticlesController < ApplicationController + before_action :set_article, only: [:show, :edit, :update, :destroy] + + # GET /articles + # GET /articles.json + def index + @articles = Article.all + end + + # GET /articles/1 + # GET /articles/1.json + def show + end + + # GET /articles/new + def new + @article = Article.new + end + + # GET /articles/1/edit + def edit + end + + # POST /articles + # POST /articles.json + def create + @article = Article.new(article_params) + + respond_to do |format| + if @article.save + format.html { redirect_to @article, notice: 'Article was successfully created.' } + format.json { render :show, status: :created, location: @article } + else + format.html { render :new } + format.json { render json: @article.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /articles/1 + # PATCH/PUT /articles/1.json + def update + respond_to do |format| + if @article.update(article_params) + format.html { redirect_to @article, notice: 'Article was successfully updated.' } + format.json { render :show, status: :ok, location: @article } + else + format.html { render :edit } + format.json { render json: @article.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /articles/1 + # DELETE /articles/1.json + def destroy + @article.destroy + respond_to do |format| + format.html { redirect_to articles_url, notice: 'Article was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_article + @article = Article.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def article_params + params.require(:article).permit(:title, :text) + end +end diff --git a/library/app/controllers/books_controller.rb b/library/app/controllers/books_controller.rb new file mode 100755 index 0000000..2f6e972 --- /dev/null +++ b/library/app/controllers/books_controller.rb @@ -0,0 +1,50 @@ +class BooksController < ApplicationController + def index +@books = Book.all + + end +def show + @book = Book.find(params[:id]) + +end + +def destroy + @book = Book.find(params[:id]) + @book.destroy + redirect_to books_path #to see that actully delete it +end + + +def new + #dont need to go to db +end + +def edit + @book = Book.find(params[:id]) + +end + +def update + @book = Book.find(params[:id]) +if @book.update(book_params) + redirect_to books_path +else + render 'edit' +end +end + +def create + # book.create(params[:book]) + @book = Book.new(book_params) #only copy + if @book.save + redirect_to books_path + else + render "new" # the new view + end +end + +def book_params + params.require(:book).permit(:title , :author) +end + +end \ No newline at end of file diff --git a/library/app/controllers/comments_controller.rb b/library/app/controllers/comments_controller.rb new file mode 100644 index 0000000..9bb309d --- /dev/null +++ b/library/app/controllers/comments_controller.rb @@ -0,0 +1,20 @@ + +class CommentsController < ApplicationController + def create + @article = Article.find(params[:article_id]) + @comment = @article.comments.create(comment_params) + redirect_to article_path(@article) + end + + def destroy + @article = Article.find(params[:article_id]) + @comment = @article.comments.find(params[:id]) + @comment.destroy + redirect_to article_path(@article) + end + + private + def comment_params + params.require(:comment).permit(:commenter, :body) + end + end \ No newline at end of file diff --git a/library/app/controllers/concerns/.keep b/library/app/controllers/concerns/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/app/controllers/ingredients_controller.rb b/library/app/controllers/ingredients_controller.rb new file mode 100755 index 0000000..e9a06e0 --- /dev/null +++ b/library/app/controllers/ingredients_controller.rb @@ -0,0 +1,10 @@ +class IngredientsController < ApplicationController + def index +@ingredients = Ingredient.all + + end +def show + @ingredient= Ingredient.find(params[:id]) + +end +end \ No newline at end of file diff --git a/library/app/controllers/movies_controller.rb b/library/app/controllers/movies_controller.rb new file mode 100755 index 0000000..052aae8 --- /dev/null +++ b/library/app/controllers/movies_controller.rb @@ -0,0 +1,48 @@ +class MoviesController < ApplicationController + def index +@movies = Movie.all + + end +def show + @movie = Movie.find(params[:id]) + +end +def destroy + @movie = Movie.find(params[:id]) + @movie.destroy + redirect_to movies_path #to see that actully delete it +end + +def new + #dont need to go to db +end +def edit + @movie = Movie.find(params[:id]) + +end + +def update + @movie = Movie.find(params[:id]) +if @movie.update(movie_params) + redirect_to movies_path +else + render 'edit' +end +end + + +def create + # movie.create(params[:movie]) + @movie = Movie.new(movie_params) #only copy + if @movie.save + redirect_to movies_path + else + render "new" # the new view + end +end + +def movie_params #protection + params.require(:movie).permit(:title , :dirctor , :rating) +end + +end \ No newline at end of file diff --git a/library/app/controllers/paintings_controller.rb b/library/app/controllers/paintings_controller.rb new file mode 100644 index 0000000..d801653 --- /dev/null +++ b/library/app/controllers/paintings_controller.rb @@ -0,0 +1,74 @@ +class PaintingsController < ApplicationController + before_action :set_painting, only: [:show, :edit, :update, :destroy] + + # GET /paintings + # GET /paintings.json + def index + @paintings = Painting.all + end + + # GET /paintings/1 + # GET /paintings/1.json + def show + end + + # GET /paintings/new + def new + @painting = Painting.new + end + + # GET /paintings/1/edit + def edit + end + + # POST /paintings + # POST /paintings.json + def create + @painting = Painting.new(painting_params) + + respond_to do |format| + if @painting.save + format.html { redirect_to @painting, notice: 'Painting was successfully created.' } + format.json { render :show, status: :created, location: @painting } + else + format.html { render :new } + format.json { render json: @painting.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /paintings/1 + # PATCH/PUT /paintings/1.json + def update + respond_to do |format| + if @painting.update(painting_params) + format.html { redirect_to @painting, notice: 'Painting was successfully updated.' } + format.json { render :show, status: :ok, location: @painting } + else + format.html { render :edit } + format.json { render json: @painting.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /paintings/1 + # DELETE /paintings/1.json + def destroy + @painting.destroy + respond_to do |format| + format.html { redirect_to paintings_url, notice: 'Painting was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_painting + @painting = Painting.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def painting_params + params.require(:painting).permit(:title, :artist) + end +end diff --git a/library/app/helpers/application_helper.rb b/library/app/helpers/application_helper.rb new file mode 100755 index 0000000..de6be79 --- /dev/null +++ b/library/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/library/app/helpers/articles_helper.rb b/library/app/helpers/articles_helper.rb new file mode 100644 index 0000000..2968277 --- /dev/null +++ b/library/app/helpers/articles_helper.rb @@ -0,0 +1,2 @@ +module ArticlesHelper +end diff --git a/library/app/helpers/comments_helper.rb b/library/app/helpers/comments_helper.rb new file mode 100644 index 0000000..0ec9ca5 --- /dev/null +++ b/library/app/helpers/comments_helper.rb @@ -0,0 +1,2 @@ +module CommentsHelper +end diff --git a/library/app/helpers/paintings_helper.rb b/library/app/helpers/paintings_helper.rb new file mode 100644 index 0000000..cfbc294 --- /dev/null +++ b/library/app/helpers/paintings_helper.rb @@ -0,0 +1,2 @@ +module PaintingsHelper +end diff --git a/library/app/jobs/application_job.rb b/library/app/jobs/application_job.rb new file mode 100755 index 0000000..a009ace --- /dev/null +++ b/library/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/library/app/mailers/application_mailer.rb b/library/app/mailers/application_mailer.rb new file mode 100755 index 0000000..286b223 --- /dev/null +++ b/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/library/app/models/application_record.rb b/library/app/models/application_record.rb new file mode 100755 index 0000000..10a4cba --- /dev/null +++ b/library/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/library/app/models/article.rb b/library/app/models/article.rb new file mode 100644 index 0000000..f0471de --- /dev/null +++ b/library/app/models/article.rb @@ -0,0 +1,6 @@ + +class Article < ApplicationRecord + has_many :comments, dependent: :destroy + validates :title, presence: true, + length: { minimum: 5 } + end \ No newline at end of file diff --git a/library/app/models/book.rb b/library/app/models/book.rb new file mode 100755 index 0000000..a38868f --- /dev/null +++ b/library/app/models/book.rb @@ -0,0 +1,2 @@ +class Book < ApplicationRecord +end \ No newline at end of file diff --git a/library/app/models/comment.rb b/library/app/models/comment.rb new file mode 100644 index 0000000..889a476 --- /dev/null +++ b/library/app/models/comment.rb @@ -0,0 +1,3 @@ +class Comment < ApplicationRecord + belongs_to :article +end diff --git a/library/app/models/concerns/.keep b/library/app/models/concerns/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/app/models/ingredient.rb b/library/app/models/ingredient.rb new file mode 100755 index 0000000..1213236 --- /dev/null +++ b/library/app/models/ingredient.rb @@ -0,0 +1,2 @@ +class Ingredient < ApplicationRecord +end \ No newline at end of file diff --git a/library/app/models/movie.rb b/library/app/models/movie.rb new file mode 100755 index 0000000..ef1593b --- /dev/null +++ b/library/app/models/movie.rb @@ -0,0 +1,2 @@ +class Movie < ApplicationRecord +end \ No newline at end of file diff --git a/library/app/models/painting.rb b/library/app/models/painting.rb new file mode 100644 index 0000000..9daeb53 --- /dev/null +++ b/library/app/models/painting.rb @@ -0,0 +1,2 @@ +class Painting < ApplicationRecord +end diff --git a/library/app/views/articles/_article.json.jbuilder b/library/app/views/articles/_article.json.jbuilder new file mode 100644 index 0000000..8f4e2e8 --- /dev/null +++ b/library/app/views/articles/_article.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! article, :id, :title, :text, :created_at, :updated_at +json.url article_url(article, format: :json) diff --git a/library/app/views/articles/_form.html.erb b/library/app/views/articles/_form.html.erb new file mode 100644 index 0000000..7ece14a --- /dev/null +++ b/library/app/views/articles/_form.html.erb @@ -0,0 +1,27 @@ +<%= form_with(model: article, local: true) do |form| %> + <% if article.errors.any? %> +
+

<%= pluralize(article.errors.count, "error") %> prohibited this article from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :title %> + <%= form.text_field :title %> +
+ +
+ <%= form.label :text %> + <%= form.text_field :text %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/library/app/views/articles/edit.html.erb b/library/app/views/articles/edit.html.erb new file mode 100644 index 0000000..65565c0 --- /dev/null +++ b/library/app/views/articles/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Article

+ +<%= render 'form', article: @article %> + +<%= link_to 'Show', @article %> | +<%= link_to 'Back', articles_path %> diff --git a/library/app/views/articles/index.html.erb b/library/app/views/articles/index.html.erb new file mode 100644 index 0000000..172e578 --- /dev/null +++ b/library/app/views/articles/index.html.erb @@ -0,0 +1,29 @@ +

<%= notice %>

+ +

Articles

+ + + + + + + + + + + + <% @articles.each do |article| %> + + + + + + + + <% end %> + +
TitleText
<%= article.title %><%= article.text %><%= link_to 'Show', article %><%= link_to 'Edit', edit_article_path(article) %><%= link_to 'Destroy', article, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Article', new_article_path %> diff --git a/library/app/views/articles/index.json.jbuilder b/library/app/views/articles/index.json.jbuilder new file mode 100644 index 0000000..4b23e9e --- /dev/null +++ b/library/app/views/articles/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @articles, partial: 'articles/article', as: :article diff --git a/library/app/views/articles/new.html.erb b/library/app/views/articles/new.html.erb new file mode 100644 index 0000000..056f863 --- /dev/null +++ b/library/app/views/articles/new.html.erb @@ -0,0 +1,5 @@ +

New Article

+ +<%= render 'form', article: @article %> + +<%= link_to 'Back', articles_path %> diff --git a/library/app/views/articles/show.html.erb b/library/app/views/articles/show.html.erb new file mode 100644 index 0000000..b88fa8a --- /dev/null +++ b/library/app/views/articles/show.html.erb @@ -0,0 +1,19 @@ + +

+Title: +<%= @article.title %> +

+ +

+Text: +<%= @article.text %> +

+ +

Comments

+<%= render @article.comments %> + +

Add a comment:

+<%= render 'comments/form' %> + +<%= link_to 'Edit', edit_article_path(@article) %> | +<%= link_to 'Back', articles_path %> \ No newline at end of file diff --git a/library/app/views/articles/show.json.jbuilder b/library/app/views/articles/show.json.jbuilder new file mode 100644 index 0000000..dd1fbb4 --- /dev/null +++ b/library/app/views/articles/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "articles/article", article: @article diff --git a/library/app/views/books/edit.html.erb b/library/app/views/books/edit.html.erb new file mode 100644 index 0000000..5086bfa --- /dev/null +++ b/library/app/views/books/edit.html.erb @@ -0,0 +1,16 @@ +

Edit a book

+ +

<%= link_to 'view all book', books_path %>

+ +<%= form_for @book, local: true do|form|%> +

+<%= form.text_field :title %> +

+

+<%= form.text_field :author %> +

+ +

+<%= form.submit %> +

+<%end%> \ No newline at end of file diff --git a/library/app/views/books/index.html.erb b/library/app/views/books/index.html.erb new file mode 100755 index 0000000..52ae12d --- /dev/null +++ b/library/app/views/books/index.html.erb @@ -0,0 +1,12 @@ +

hello

+ +

<%= link_to 'Create new book', new_book_path %>

+ + +<% @books.each do |book| %> +

<%= book.title%>

+

<%= link_to 'View', book_path(book) %>

+

<%= link_to 'Edit', edit_book_path(book) %>

+

<%= link_to 'Delete', book_path(book) , method: :delete , data: {confirm: 'Are you sure you want to delete ?'} %>

+ + <% end %> \ No newline at end of file diff --git a/library/app/views/books/new.html.erb b/library/app/views/books/new.html.erb new file mode 100644 index 0000000..b65e6f2 --- /dev/null +++ b/library/app/views/books/new.html.erb @@ -0,0 +1,16 @@ +

Create a new book

+ +

<%= link_to 'create new book', books_path %>

+ +<%= form_with scope: :book, url:'/books', local: true do|form|%> +

+<%= form.text_field :title %> +

+

+<%= form.text_field :author %> +

+ +

+<%= form.submit %> +

+<%end%> \ No newline at end of file diff --git a/library/app/views/books/show.html.erb b/library/app/views/books/show.html.erb new file mode 100755 index 0000000..0bf4863 --- /dev/null +++ b/library/app/views/books/show.html.erb @@ -0,0 +1,8 @@ + + +

<%= link_to 'View All Books', books_path %>

+ + diff --git a/library/app/views/comments/_comment.html.erb b/library/app/views/comments/_comment.html.erb new file mode 100644 index 0000000..77eb04a --- /dev/null +++ b/library/app/views/comments/_comment.html.erb @@ -0,0 +1,15 @@ +

+ Commenter: + <%= comment.commenter %> +

+ +

+ Comment: + <%= comment.body %> +

+ +

+ <%= link_to 'Destroy Comment', [comment.article, comment], + method: :delete, + data: { confirm: 'Are you sure?' } %> +

\ No newline at end of file diff --git a/library/app/views/comments/_form.html.erb b/library/app/views/comments/_form.html.erb new file mode 100644 index 0000000..c5a94c7 --- /dev/null +++ b/library/app/views/comments/_form.html.erb @@ -0,0 +1,14 @@ + +<%= form_with(model: [ @article, @article.comments.build ], local: true) do |form| %> +

+ <%= form.label :commenter %>
+ <%= form.text_field :commenter %> +

+

+ <%= form.label :body %>
+ <%= form.text_area :body %> +

+

+ <%= form.submit %> +

+ <% end %> \ No newline at end of file diff --git a/library/app/views/ingredients/index.html.erb b/library/app/views/ingredients/index.html.erb new file mode 100755 index 0000000..73b5272 --- /dev/null +++ b/library/app/views/ingredients/index.html.erb @@ -0,0 +1,8 @@ +

hello

+ + + +<% @ingredients.each do |ingredient| %> +

<%= ingredient.name%>

+

<%= link_to 'View', ingredient_path(ingredient) %>

+ <% end %> \ No newline at end of file diff --git a/library/app/views/ingredients/show.html.erb b/library/app/views/ingredients/show.html.erb new file mode 100755 index 0000000..103a0c6 --- /dev/null +++ b/library/app/views/ingredients/show.html.erb @@ -0,0 +1,11 @@ + + +

<%= link_to 'View All Ingredients', ingredients_path %>

+ + diff --git a/library/app/views/layouts/application.html.erb b/library/app/views/layouts/application.html.erb new file mode 100755 index 0000000..871b419 --- /dev/null +++ b/library/app/views/layouts/application.html.erb @@ -0,0 +1,15 @@ + + + + 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/library/app/views/layouts/mailer.html.erb b/library/app/views/layouts/mailer.html.erb new file mode 100755 index 0000000..cbd34d2 --- /dev/null +++ b/library/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/library/app/views/layouts/mailer.text.erb b/library/app/views/layouts/mailer.text.erb new file mode 100755 index 0000000..37f0bdd --- /dev/null +++ b/library/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/library/app/views/movies/edit.html.erb b/library/app/views/movies/edit.html.erb new file mode 100644 index 0000000..19cac03 --- /dev/null +++ b/library/app/views/movies/edit.html.erb @@ -0,0 +1,18 @@ +

Edit a movie

+ +

<%= link_to 'view all movies', movies_path %>

+ +<%= form_for @movie, local: true do|form|%> +

+<%= form.text_field :title %> +

+

+<%= form.text_field :dirctor %> +

+

+<%= form.text_field :rating %> +

+

+<%= form.submit %> +

+<%end%> \ No newline at end of file diff --git a/library/app/views/movies/index.html.erb b/library/app/views/movies/index.html.erb new file mode 100755 index 0000000..a9e141e --- /dev/null +++ b/library/app/views/movies/index.html.erb @@ -0,0 +1,13 @@ +

hello

+ + +

<%= link_to 'Create new movie', new_movie_path %>

+ +<% @movies.each do |movie| %> +

<%= movie.title%>

+

<%= link_to 'View', movie_path(movie) %>

+

<%= link_to 'Edit', edit_movie_path(movie) %>

+ +

<%= link_to 'Delete', movie_path(movie) , method: :delete , data: {confirm: 'Are you sure you want to delete ?'} %>

+ + <% end %> \ No newline at end of file diff --git a/library/app/views/movies/new.html.erb b/library/app/views/movies/new.html.erb new file mode 100644 index 0000000..14f7816 --- /dev/null +++ b/library/app/views/movies/new.html.erb @@ -0,0 +1,18 @@ +

Create a new movie

+ +

<%= link_to 'create new movie', movies_path %>

+ +<%= form_with scope: :movie, url:'/movies', local: true do|form|%> +

+<%= form.text_field :title %> +

+

+<%= form.text_field :dirctor %> +

+

+<%= form.text_field :rating %> +

+

+<%= form.submit %> +

+<%end%> \ No newline at end of file diff --git a/library/app/views/movies/show.html.erb b/library/app/views/movies/show.html.erb new file mode 100755 index 0000000..a197f78 --- /dev/null +++ b/library/app/views/movies/show.html.erb @@ -0,0 +1,9 @@ + + +

<%= link_to 'View All Movies', movies_path %>

+ + diff --git a/library/app/views/paintings/_form.html.erb b/library/app/views/paintings/_form.html.erb new file mode 100644 index 0000000..58887c0 --- /dev/null +++ b/library/app/views/paintings/_form.html.erb @@ -0,0 +1,27 @@ +<%= form_with(model: painting, local: true) do |form| %> + <% if painting.errors.any? %> +
+

<%= pluralize(painting.errors.count, "error") %> prohibited this painting from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :title %> + <%= form.text_field :title %> +
+ +
+ <%= form.label :artist %> + <%= form.text_field :artist %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/library/app/views/paintings/_painting.json.jbuilder b/library/app/views/paintings/_painting.json.jbuilder new file mode 100644 index 0000000..aee1413 --- /dev/null +++ b/library/app/views/paintings/_painting.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! painting, :id, :title, :artist, :created_at, :updated_at +json.url painting_url(painting, format: :json) diff --git a/library/app/views/paintings/edit.html.erb b/library/app/views/paintings/edit.html.erb new file mode 100644 index 0000000..048e187 --- /dev/null +++ b/library/app/views/paintings/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Painting

+ +<%= render 'form', painting: @painting %> + +<%= link_to 'Show', @painting %> | +<%= link_to 'Back', paintings_path %> diff --git a/library/app/views/paintings/index.html.erb b/library/app/views/paintings/index.html.erb new file mode 100644 index 0000000..6076046 --- /dev/null +++ b/library/app/views/paintings/index.html.erb @@ -0,0 +1,29 @@ +

<%= notice %>

+ +

Paintings

+ + + + + + + + + + + + <% @paintings.each do |painting| %> + + + + + + + + <% end %> + +
TitleArtist
<%= painting.title %><%= painting.artist %><%= link_to 'Show', painting %><%= link_to 'Edit', edit_painting_path(painting) %><%= link_to 'Destroy', painting, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Painting', new_painting_path %> diff --git a/library/app/views/paintings/index.json.jbuilder b/library/app/views/paintings/index.json.jbuilder new file mode 100644 index 0000000..bf67c58 --- /dev/null +++ b/library/app/views/paintings/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @paintings, partial: 'paintings/painting', as: :painting diff --git a/library/app/views/paintings/new.html.erb b/library/app/views/paintings/new.html.erb new file mode 100644 index 0000000..f0415bb --- /dev/null +++ b/library/app/views/paintings/new.html.erb @@ -0,0 +1,5 @@ +

New Painting

+ +<%= render 'form', painting: @painting %> + +<%= link_to 'Back', paintings_path %> diff --git a/library/app/views/paintings/show.html.erb b/library/app/views/paintings/show.html.erb new file mode 100644 index 0000000..5907763 --- /dev/null +++ b/library/app/views/paintings/show.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

+ Title: + <%= @painting.title %> +

+ +

+ Artist: + <%= @painting.artist %> +

+ +<%= link_to 'Edit', edit_painting_path(@painting) %> | +<%= link_to 'Back', paintings_path %> diff --git a/library/app/views/paintings/show.json.jbuilder b/library/app/views/paintings/show.json.jbuilder new file mode 100644 index 0000000..d06beba --- /dev/null +++ b/library/app/views/paintings/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "paintings/painting", painting: @painting diff --git a/library/bin/bundle b/library/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/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/library/bin/rails b/library/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/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/library/bin/rake b/library/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/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/library/bin/setup b/library/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/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/library/bin/spring b/library/bin/spring new file mode 100755 index 0000000..fb2ec2e --- /dev/null +++ b/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/library/bin/update b/library/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/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/library/bin/yarn b/library/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/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/library/config.ru b/library/config.ru new file mode 100755 index 0000000..f7ba0b5 --- /dev/null +++ b/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/library/config/application.rb b/library/config/application.rb new file mode 100755 index 0000000..493beb8 --- /dev/null +++ b/library/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 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. + end +end diff --git a/library/config/boot.rb b/library/config/boot.rb new file mode 100755 index 0000000..b9e460c --- /dev/null +++ b/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/library/config/cable.yml b/library/config/cable.yml new file mode 100755 index 0000000..8e41465 --- /dev/null +++ b/library/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: library_production diff --git a/library/config/credentials.yml.enc b/library/config/credentials.yml.enc new file mode 100755 index 0000000..559ee88 --- /dev/null +++ b/library/config/credentials.yml.enc @@ -0,0 +1 @@ +BbItuE9U4uuoHId5CXkrBF+evYT+eZ4N0P5TZG/s3dElLPz2TQYMh9Y7kyWcWhtQ8knRZ7E0z+lZdhNTDP86DvncuumS7gfCgUGKXa5BJaQKqvcpqVha/jmUxFe7RZKim7GMwyKx6mj8QYOQB0M59NFxmKf1TJgkBpfJgUniQS5akaLWMb8Av+/BNV1D5KS/ctroNZgSODmwgXn18gkOgL9Av4a16DWXnLZn7POVhT+EGFM+vous+So87Fc5+X79Cb9JT1o6jIzzz58n9QkkVHWCinbbTG+UkXg38YuQmrBp6EnG5jeA/bq5OtapKdIuie7Ysk26EUhhpkmGqQuSgn0FuO6Dr+ZmVvSlvz9+RMt/c6BQisV73WOXWWUcbQxfLEBhVzyYv2BthYzpG+B+ROLKdYraCJ9YFBwx--U9+sUcVWDgOqvJOZ--cuYjihyMwDpPwUWf1Fwc9w== \ No newline at end of file diff --git a/library/config/database.yml b/library/config/database.yml new file mode 100755 index 0000000..0265599 --- /dev/null +++ b/library/config/database.yml @@ -0,0 +1,85 @@ +# PostgreSQL. Versions 9.1 and up are supported. +# +# Install the pg driver: +# gem install pg +# On OS X with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On OS X with MacPorts: +# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config +# On Windows: +# gem install pg +# Choose the win32 build. +# Install PostgreSQL and put its /bin directory on your path. +# +# Configure Using Gemfile +# gem 'pg' +# +default: &default + adapter: postgresql + encoding: unicode + # For details on connection pooling, see Rails configuration guide + # http://guides.rubyonrails.org/configuring.html#database-pooling + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + +development: + <<: *default + database: library_development + + # The specified database role being used to connect to postgres. + # To create additional roles in postgres see `$ createuser --help`. + # When left blank, postgres will use the default role. This is + # the same name as the operating system user that initialized the database. + #username: library + + # The password associated with the postgres role (username). + #password: + + # Connect on a TCP socket. Omitted by default since the client uses a + # domain socket that doesn't need configuration. Windows does not have + # domain sockets, so uncomment these lines. + #host: localhost + + # The TCP port the server listens on. Defaults to 5432. + # If your server runs on a different port number, change accordingly. + #port: 5432 + + # Schema search path. The server defaults to $user,public + #schema_search_path: myapp,sharedapp,public + + # Minimum log levels, in increasing order: + # debug5, debug4, debug3, debug2, debug1, + # log, notice, warning, error, fatal, and panic + # Defaults to warning. + #min_messages: notice + +# 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: library_test + +# As with config/secrets.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password as a unix environment variable when you boot +# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full rundown on how to provide these environment variables in a +# production deployment. +# +# On Heroku and other platform providers, you may have a full connection URL +# available as an environment variable. For example: +# +# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" +# +# You can use this database configuration with: +# +# production: +# url: <%= ENV['DATABASE_URL'] %> +# +production: + <<: *default + database: library_production + username: library + password: <%= ENV['LIBRARY_DATABASE_PASSWORD'] %> diff --git a/library/config/environment.rb b/library/config/environment.rb new file mode 100755 index 0000000..426333b --- /dev/null +++ b/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/library/config/environments/development.rb b/library/config/environments/development.rb new file mode 100755 index 0000000..1311e3e --- /dev/null +++ b/library/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/library/config/environments/production.rb b/library/config/environments/production.rb new file mode 100755 index 0000000..7dec21a --- /dev/null +++ b/library/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 = "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/library/config/environments/test.rb b/library/config/environments/test.rb new file mode 100755 index 0000000..0a38fd3 --- /dev/null +++ b/library/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/library/config/initializers/application_controller_renderer.rb b/library/config/initializers/application_controller_renderer.rb new file mode 100755 index 0000000..89d2efa --- /dev/null +++ b/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/library/config/initializers/assets.rb b/library/config/initializers/assets.rb new file mode 100755 index 0000000..4b828e8 --- /dev/null +++ b/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/library/config/initializers/backtrace_silencers.rb b/library/config/initializers/backtrace_silencers.rb new file mode 100755 index 0000000..59385cd --- /dev/null +++ b/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/library/config/initializers/content_security_policy.rb b/library/config/initializers/content_security_policy.rb new file mode 100755 index 0000000..d3bcaa5 --- /dev/null +++ b/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/library/config/initializers/cookies_serializer.rb b/library/config/initializers/cookies_serializer.rb new file mode 100755 index 0000000..5a6a32d --- /dev/null +++ b/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/library/config/initializers/filter_parameter_logging.rb b/library/config/initializers/filter_parameter_logging.rb new file mode 100755 index 0000000..4a994e1 --- /dev/null +++ b/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/library/config/initializers/inflections.rb b/library/config/initializers/inflections.rb new file mode 100755 index 0000000..ac033bf --- /dev/null +++ b/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/library/config/initializers/mime_types.rb b/library/config/initializers/mime_types.rb new file mode 100755 index 0000000..dc18996 --- /dev/null +++ b/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/library/config/initializers/wrap_parameters.rb b/library/config/initializers/wrap_parameters.rb new file mode 100755 index 0000000..bbfc396 --- /dev/null +++ b/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/library/config/locales/en.yml b/library/config/locales/en.yml new file mode 100755 index 0000000..decc5a8 --- /dev/null +++ b/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/library/config/puma.rb b/library/config/puma.rb new file mode 100755 index 0000000..a5eccf8 --- /dev/null +++ b/library/config/puma.rb @@ -0,0 +1,34 @@ +# 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 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/library/config/routes.rb b/library/config/routes.rb new file mode 100755 index 0000000..c75237b --- /dev/null +++ b/library/config/routes.rb @@ -0,0 +1,32 @@ +Rails.application.routes.draw do + # resources :articles + + +resources :articles do + resources :comments +end + resources :paintings + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + +# get '/books' => "books#index", as: 'books' #retrun path +# get '/books/new' => "books#new", as: 'new_book' +# get '/books/:id/edit' => "books#edit", as: 'edit_book' +# get '/books/:id' => "books#show", as: 'book' +# post '/books' => "books#create" +# patch '/books/:id' => "books#update" +# delete '/books/:id' => "books#destroy" +resources :books + + +get 'movies' => "movies#index" , as: 'movies' +get '/movies/new' => "movies#new", as: 'new_movie' +get '/movies/:id/edit' => "movies#edit", as: 'edit_movie' +get 'movies/:id' => "movies#show" , as: 'movie' +post '/movies' => "movies#create" +patch '/movies/:id' => "movies#update" +delete '/movies/:id' => "movies#destroy" + + +get 'ingredients' => "ingredients#index" , as: 'ingredients' +get 'ingredients/:id' => "ingredients#show" , as: 'ingredient' +end diff --git a/library/config/spring.rb b/library/config/spring.rb new file mode 100755 index 0000000..9fa7863 --- /dev/null +++ b/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/library/config/storage.yml b/library/config/storage.yml new file mode 100755 index 0000000..d32f76e --- /dev/null +++ b/library/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/library/db/migrate/000_create_books.rb b/library/db/migrate/000_create_books.rb new file mode 100755 index 0000000..9b1faed --- /dev/null +++ b/library/db/migrate/000_create_books.rb @@ -0,0 +1,9 @@ +class CreateBooks < ActiveRecord::Migration[5.2] + def change + create_table :books do |t| + t.string :title + t.string :author + t.timestamps + end + end + end \ No newline at end of file diff --git a/library/db/migrate/001_create_movies.rb b/library/db/migrate/001_create_movies.rb new file mode 100755 index 0000000..bed2604 --- /dev/null +++ b/library/db/migrate/001_create_movies.rb @@ -0,0 +1,10 @@ +class CreateMovies < ActiveRecord::Migration[5.2] + def change + create_table :movies do |t| + t.string :title + t.string :dirctor + t.integer :rating + t.timestamps + end + end + end \ No newline at end of file diff --git a/library/db/migrate/002_create_ingredients.rb b/library/db/migrate/002_create_ingredients.rb new file mode 100755 index 0000000..60500ee --- /dev/null +++ b/library/db/migrate/002_create_ingredients.rb @@ -0,0 +1,12 @@ +class CreateIngredients < ActiveRecord::Migration[5.2] + def change + create_table :ingredients do |t| + t.string :name + t.string :unit + t.integer :amount + t.date :purchased_on + t.boolean :is_rotten + t.timestamps + end + end + end \ No newline at end of file diff --git a/library/db/migrate/20190303122357_create_paintings.rb b/library/db/migrate/20190303122357_create_paintings.rb new file mode 100644 index 0000000..727b520 --- /dev/null +++ b/library/db/migrate/20190303122357_create_paintings.rb @@ -0,0 +1,10 @@ +class CreatePaintings < ActiveRecord::Migration[5.2] + def change + create_table :paintings do |t| + t.string :title + t.string :artist + + t.timestamps + end + end +end diff --git a/library/db/migrate/20190303132732_create_articles.rb b/library/db/migrate/20190303132732_create_articles.rb new file mode 100644 index 0000000..b9c6306 --- /dev/null +++ b/library/db/migrate/20190303132732_create_articles.rb @@ -0,0 +1,10 @@ +class CreateArticles < ActiveRecord::Migration[5.2] + def change + create_table :articles do |t| + t.string :title + t.string :text + + t.timestamps + end + end +end diff --git a/library/db/migrate/20190303133145_create_comments.rb b/library/db/migrate/20190303133145_create_comments.rb new file mode 100644 index 0000000..09c4485 --- /dev/null +++ b/library/db/migrate/20190303133145_create_comments.rb @@ -0,0 +1,11 @@ +class CreateComments < ActiveRecord::Migration[5.2] + def change + create_table :comments do |t| + t.string :commenter + t.text :body + t.references :article, foreign_key: true + + t.timestamps + end + end +end diff --git a/library/db/schema.rb b/library/db/schema.rb new file mode 100755 index 0000000..28fdd9e --- /dev/null +++ b/library/db/schema.rb @@ -0,0 +1,67 @@ +# 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: 2019_03_03_133145) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "articles", force: :cascade do |t| + t.string "title" + t.string "text" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "books", force: :cascade do |t| + t.string "title" + t.string "author" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "comments", force: :cascade do |t| + t.string "commenter" + t.text "body" + t.bigint "article_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["article_id"], name: "index_comments_on_article_id" + end + + create_table "ingredients", force: :cascade do |t| + t.string "name" + t.string "unit" + t.integer "amount" + t.date "purchased_on" + t.boolean "is_rotten" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "movies", force: :cascade do |t| + t.string "title" + t.string "dirctor" + t.integer "rating" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "paintings", force: :cascade do |t| + t.string "title" + t.string "artist" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_foreign_key "comments", "articles" +end diff --git a/library/db/seeds.rb b/library/db/seeds.rb new file mode 100755 index 0000000..1beea2a --- /dev/null +++ b/library/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/library/lib/assets/.keep b/library/lib/assets/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/lib/tasks/.keep b/library/lib/tasks/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/log/.keep b/library/log/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/package.json b/library/package.json new file mode 100755 index 0000000..7562efd --- /dev/null +++ b/library/package.json @@ -0,0 +1,5 @@ +{ + "name": "library", + "private": true, + "dependencies": {} +} diff --git a/library/public/404.html b/library/public/404.html new file mode 100755 index 0000000..2be3af2 --- /dev/null +++ b/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/library/public/422.html b/library/public/422.html new file mode 100755 index 0000000..c08eac0 --- /dev/null +++ b/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/library/public/500.html b/library/public/500.html new file mode 100755 index 0000000..78a030a --- /dev/null +++ b/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/library/public/apple-touch-icon-precomposed.png b/library/public/apple-touch-icon-precomposed.png new file mode 100755 index 0000000..e69de29 diff --git a/library/public/apple-touch-icon.png b/library/public/apple-touch-icon.png new file mode 100755 index 0000000..e69de29 diff --git a/library/public/favicon.ico b/library/public/favicon.ico new file mode 100755 index 0000000..e69de29 diff --git a/library/public/robots.txt b/library/public/robots.txt new file mode 100755 index 0000000..37b576a --- /dev/null +++ b/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/library/storage/.keep b/library/storage/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/test/application_system_test_case.rb b/library/test/application_system_test_case.rb new file mode 100755 index 0000000..d19212a --- /dev/null +++ b/library/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/library/test/controllers/.keep b/library/test/controllers/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/test/controllers/articles_controller_test.rb b/library/test/controllers/articles_controller_test.rb new file mode 100644 index 0000000..c3c5ba1 --- /dev/null +++ b/library/test/controllers/articles_controller_test.rb @@ -0,0 +1,48 @@ +require 'test_helper' + +class ArticlesControllerTest < ActionDispatch::IntegrationTest + setup do + @article = articles(:one) + end + + test "should get index" do + get articles_url + assert_response :success + end + + test "should get new" do + get new_article_url + assert_response :success + end + + test "should create article" do + assert_difference('Article.count') do + post articles_url, params: { article: { text: @article.text, title: @article.title } } + end + + assert_redirected_to article_url(Article.last) + end + + test "should show article" do + get article_url(@article) + assert_response :success + end + + test "should get edit" do + get edit_article_url(@article) + assert_response :success + end + + test "should update article" do + patch article_url(@article), params: { article: { text: @article.text, title: @article.title } } + assert_redirected_to article_url(@article) + end + + test "should destroy article" do + assert_difference('Article.count', -1) do + delete article_url(@article) + end + + assert_redirected_to articles_url + end +end diff --git a/library/test/controllers/comments_controller_test.rb b/library/test/controllers/comments_controller_test.rb new file mode 100644 index 0000000..a812dda --- /dev/null +++ b/library/test/controllers/comments_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/library/test/controllers/paintings_controller_test.rb b/library/test/controllers/paintings_controller_test.rb new file mode 100644 index 0000000..99dbbc4 --- /dev/null +++ b/library/test/controllers/paintings_controller_test.rb @@ -0,0 +1,48 @@ +require 'test_helper' + +class PaintingsControllerTest < ActionDispatch::IntegrationTest + setup do + @painting = paintings(:one) + end + + test "should get index" do + get paintings_url + assert_response :success + end + + test "should get new" do + get new_painting_url + assert_response :success + end + + test "should create painting" do + assert_difference('Painting.count') do + post paintings_url, params: { painting: { artist: @painting.artist, title: @painting.title } } + end + + assert_redirected_to painting_url(Painting.last) + end + + test "should show painting" do + get painting_url(@painting) + assert_response :success + end + + test "should get edit" do + get edit_painting_url(@painting) + assert_response :success + end + + test "should update painting" do + patch painting_url(@painting), params: { painting: { artist: @painting.artist, title: @painting.title } } + assert_redirected_to painting_url(@painting) + end + + test "should destroy painting" do + assert_difference('Painting.count', -1) do + delete painting_url(@painting) + end + + assert_redirected_to paintings_url + end +end diff --git a/library/test/fixtures/.keep b/library/test/fixtures/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/test/fixtures/articles.yml b/library/test/fixtures/articles.yml new file mode 100644 index 0000000..d644cad --- /dev/null +++ b/library/test/fixtures/articles.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + text: MyString + +two: + title: MyString + text: MyString diff --git a/library/test/fixtures/comments.yml b/library/test/fixtures/comments.yml new file mode 100644 index 0000000..9ee605c --- /dev/null +++ b/library/test/fixtures/comments.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + commenter: MyString + body: MyText + article: one + +two: + commenter: MyString + body: MyText + article: two diff --git a/library/test/fixtures/files/.keep b/library/test/fixtures/files/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/test/fixtures/paintings.yml b/library/test/fixtures/paintings.yml new file mode 100644 index 0000000..e2eeb2d --- /dev/null +++ b/library/test/fixtures/paintings.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + artist: MyString + +two: + title: MyString + artist: MyString diff --git a/library/test/helpers/.keep b/library/test/helpers/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/test/integration/.keep b/library/test/integration/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/test/mailers/.keep b/library/test/mailers/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/test/models/.keep b/library/test/models/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/test/models/article_test.rb b/library/test/models/article_test.rb new file mode 100644 index 0000000..11c8abe --- /dev/null +++ b/library/test/models/article_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ArticleTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/library/test/models/comment_test.rb b/library/test/models/comment_test.rb new file mode 100644 index 0000000..b6d6131 --- /dev/null +++ b/library/test/models/comment_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/library/test/models/painting_test.rb b/library/test/models/painting_test.rb new file mode 100644 index 0000000..6f0053e --- /dev/null +++ b/library/test/models/painting_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PaintingTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/library/test/system/.keep b/library/test/system/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/test/system/articles_test.rb b/library/test/system/articles_test.rb new file mode 100644 index 0000000..80b6085 --- /dev/null +++ b/library/test/system/articles_test.rb @@ -0,0 +1,45 @@ +require "application_system_test_case" + +class ArticlesTest < ApplicationSystemTestCase + setup do + @article = articles(:one) + end + + test "visiting the index" do + visit articles_url + assert_selector "h1", text: "Articles" + end + + test "creating a Article" do + visit articles_url + click_on "New Article" + + fill_in "Text", with: @article.text + fill_in "Title", with: @article.title + click_on "Create Article" + + assert_text "Article was successfully created" + click_on "Back" + end + + test "updating a Article" do + visit articles_url + click_on "Edit", match: :first + + fill_in "Text", with: @article.text + fill_in "Title", with: @article.title + click_on "Update Article" + + assert_text "Article was successfully updated" + click_on "Back" + end + + test "destroying a Article" do + visit articles_url + page.accept_confirm do + click_on "Destroy", match: :first + end + + assert_text "Article was successfully destroyed" + end +end diff --git a/library/test/system/paintings_test.rb b/library/test/system/paintings_test.rb new file mode 100644 index 0000000..28fb49d --- /dev/null +++ b/library/test/system/paintings_test.rb @@ -0,0 +1,45 @@ +require "application_system_test_case" + +class PaintingsTest < ApplicationSystemTestCase + setup do + @painting = paintings(:one) + end + + test "visiting the index" do + visit paintings_url + assert_selector "h1", text: "Paintings" + end + + test "creating a Painting" do + visit paintings_url + click_on "New Painting" + + fill_in "Artist", with: @painting.artist + fill_in "Title", with: @painting.title + click_on "Create Painting" + + assert_text "Painting was successfully created" + click_on "Back" + end + + test "updating a Painting" do + visit paintings_url + click_on "Edit", match: :first + + fill_in "Artist", with: @painting.artist + fill_in "Title", with: @painting.title + click_on "Update Painting" + + assert_text "Painting was successfully updated" + click_on "Back" + end + + test "destroying a Painting" do + visit paintings_url + page.accept_confirm do + click_on "Destroy", match: :first + end + + assert_text "Painting was successfully destroyed" + end +end diff --git a/library/test/test_helper.rb b/library/test/test_helper.rb new file mode 100755 index 0000000..3ab84e3 --- /dev/null +++ b/library/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/library/tmp/.keep b/library/tmp/.keep new file mode 100755 index 0000000..e69de29 diff --git a/library/vendor/.keep b/library/vendor/.keep new file mode 100755 index 0000000..e69de29