From 7d4e2ea9dfa0dbe0b30e77167e3631d836676a57 Mon Sep 17 00:00:00 2001 From: ger619 Date: Wed, 20 Mar 2024 12:19:59 +0300 Subject: [PATCH] Add type of news at the news add --- .idea/mseals.iml | 17 +++++++++++++++++ Gemfile | 3 +++ Gemfile.lock | 22 ++++++++++++++++++++++ app/javascript/activestorage.js | 1 + app/javascript/application.js | 2 +- app/views/news/new.html.erb | 4 +++- config/cloudinary.yml | 6 ++++++ config/environments/development.rb | 5 ++++- config/storage.yml | 3 +++ 9 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 app/javascript/activestorage.js create mode 100644 config/cloudinary.yml diff --git a/.idea/mseals.iml b/.idea/mseals.iml index e40da2b14..57991e063 100644 --- a/.idea/mseals.iml +++ b/.idea/mseals.iml @@ -43,6 +43,7 @@ + @@ -50,11 +51,13 @@ + + @@ -63,6 +66,8 @@ + + @@ -75,6 +80,8 @@ + + @@ -83,6 +90,7 @@ + @@ -108,6 +116,7 @@ + @@ -125,6 +134,8 @@ + + @@ -744,6 +755,12 @@ + + + + + + diff --git a/Gemfile b/Gemfile index a2bac7f4c..e12c49d0a 100644 --- a/Gemfile +++ b/Gemfile @@ -86,3 +86,6 @@ gem 'pagy', '~> 6.0' gem 'tinymce-rails' gem 'hotwire-rails', '~> 0.1.3' + +gem 'cloudinary' + diff --git a/Gemfile.lock b/Gemfile.lock index e36f292b9..d6b4748f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,6 +74,7 @@ GEM audited (5.3.3) activerecord (>= 5.0, < 7.1) request_store (~> 1.2) + aws_cf_signer (0.1.3) bcrypt (3.1.19) bindex (0.8.1) bootsnap (1.17.0) @@ -89,6 +90,9 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + cloudinary (1.29.0) + aws_cf_signer + rest-client (>= 2.0.0) concurrent-ruby (1.2.2) crass (1.0.6) date (3.3.4) @@ -101,6 +105,8 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) erubi (1.12.0) et-orbi (1.2.7) tzinfo @@ -118,6 +124,9 @@ GEM rails (>= 6.0.0) stimulus-rails turbo-rails + http-accept (1.7.0) + http-cookie (1.0.5) + domain_name (~> 0.5) i18n (1.14.1) concurrent-ruby (~> 1.0) importmap-rails (1.2.3) @@ -144,6 +153,9 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2023.0218.1) mini_mime (1.1.5) minitest (5.20.0) motor-admin (0.4.21) @@ -162,6 +174,7 @@ GEM timeout net-smtp (0.4.0) net-protocol + netrc (0.11.0) nio4r (2.5.9) nokogiri (1.15.4-x86_64-darwin) racc (~> 1.4) @@ -224,6 +237,11 @@ GEM responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) rexml (3.2.6) rubocop (1.57.2) json (~> 2.3) @@ -270,6 +288,9 @@ GEM railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.8.2) unicode-display_width (2.5.0) warden (1.2.9) rack (>= 2.0.9) @@ -298,6 +319,7 @@ DEPENDENCIES bootsnap cancancan capybara + cloudinary debug devise (~> 4.9, >= 4.9.2) faker (~> 3.2) diff --git a/app/javascript/activestorage.js b/app/javascript/activestorage.js new file mode 100644 index 000000000..e285255c3 --- /dev/null +++ b/app/javascript/activestorage.js @@ -0,0 +1 @@ +//= require activestorage \ No newline at end of file diff --git a/app/javascript/application.js b/app/javascript/application.js index f4fbb4d6f..284165a77 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -3,4 +3,4 @@ import "@hotwired/turbo-rails" import "controllers" import "fortawesome/fontawesome-free" -//= require tinymce \ No newline at end of file +//= require tinymce diff --git a/app/views/news/new.html.erb b/app/views/news/new.html.erb index 809407e88..bd32d4c1a 100644 --- a/app/views/news/new.html.erb +++ b/app/views/news/new.html.erb @@ -23,7 +23,9 @@
-1 <%= f.text_field :header_news, class: "h-[50px] flex items-center p-2 w-[45%] border-b bg-[#F7F3ED] border-black focus:outline-none" ,placeholder: "Header of News"%> + <%= f.text_field :header_news, class: "h-[50px] flex items-center p-2 w-[45%] border-b bg-[#F7F3ED] border-black focus:outline-none" ,placeholder: "Header of News"%> + <%= f.text_field :type_of_news, class: "h-[50px] flex items-center p-2 w-[45%] border-b bg-[#F7F3ED] border-black focus:outline-none" ,placeholder: "Type of News"%> +
<%= f.file_field :image, class: 'w-full', required: true %> diff --git a/config/cloudinary.yml b/config/cloudinary.yml new file mode 100644 index 000000000..3cdde5bf1 --- /dev/null +++ b/config/cloudinary.yml @@ -0,0 +1,6 @@ +development: + cloud_name: "dsib9klin" + api_key: "144329726239136" + api_secret: "aJofmyviar6Q4p7UCGDvYmTWKIYU" + secure: true + cdn_subdomain: true \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 89b9753d4..8f1c64a48 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -70,6 +70,9 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } - + + config.active_storage.service = :cloudinary + + end diff --git a/config/storage.yml b/config/storage.yml index 4942ab669..49323220a 100644 --- a/config/storage.yml +++ b/config/storage.yml @@ -6,6 +6,9 @@ local: service: Disk root: <%= Rails.root.join("storage") %> +cloudinary: + service: Cloudinary + # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) # amazon: # service: S3