diff --git a/Gemfile b/Gemfile index 4a99b86..628b25e 100644 --- a/Gemfile +++ b/Gemfile @@ -2,44 +2,48 @@ source "https://rubygems.org" ruby "3.3.0" +gem 'dotenv-rails' + # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" gem "rails", "~> 7.1.3", ">= 7.1.3.2" # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] -gem "sprockets-rails" +# gem "sprockets-rails" +gem 'turbo-rails' +gem 'stimulus-rails' +gem "propshaft" +gem "importmap-rails" + # Use postgresql as the database for Active Record gem "pg", "~> 1.1" +gem 'pg_search' # Use the Puma web server [https://github.com/puma/puma] gem "puma", ">= 5.0" - -# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] -gem "importmap-rails" - -# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] -gem "turbo-rails" - -# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] -gem "stimulus-rails" +gem 'sidekiq' +gem "redis", ">= 4.0.1" # Build JSON APIs with ease [https://github.com/rails/jbuilder] gem "jbuilder" +gem 'mobility', '~> 1.3.0.rc1' +gem 'kaminari' +gem 'ancestry' +gem 'acts_as_list' + + # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] # gem "kredis" # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ windows jruby ] +gem "bcrypt", "~> 3.1.7" # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] -# gem "image_processing", "~> 1.2" +gem "image_processing", "~> 1.2" group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem diff --git a/Gemfile.lock b/Gemfile.lock index 91e119f..afcb1ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,9 +75,14 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) + acts_as_list (1.1.0) + activerecord (>= 4.2) addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) + ancestry (4.3.3) + activerecord (>= 5.2.6) base64 (0.2.0) + bcrypt (3.1.20) bigdecimal (3.1.7) bindex (0.8.1) bootsnap (1.18.3) @@ -99,12 +104,20 @@ GEM debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) + dotenv (3.1.0) + dotenv-rails (3.1.0) + dotenv (= 3.1.0) + railties (>= 6.1) drb (2.2.1) erubi (1.12.0) + ffi (1.16.3) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.4) concurrent-ruby (~> 1.0) + image_processing (1.12.2) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) importmap-rails (2.0.1) actionpack (>= 6.0.0) activesupport (>= 6.0.0) @@ -116,6 +129,18 @@ GEM jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) + kaminari (1.2.2) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.2.2) + kaminari-activerecord (= 1.2.2) + kaminari-core (= 1.2.2) + kaminari-actionview (1.2.2) + actionview + kaminari-core (= 1.2.2) + kaminari-activerecord (1.2.2) + activerecord + kaminari-core (= 1.2.2) + kaminari-core (1.2.2) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -126,8 +151,12 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.2) + mini_magick (4.12.0) mini_mime (1.1.5) minitest (5.22.3) + mobility (1.3.0.rc3) + i18n (>= 0.6.10, < 2) + request_store (~> 1.0) msgpack (1.7.2) mutex_m (0.2.0) net-imap (0.4.10) @@ -153,6 +182,14 @@ GEM nokogiri (1.16.4-x86_64-linux) racc (~> 1.4) pg (1.5.6) + pg_search (2.3.6) + activerecord (>= 5.2) + activesupport (>= 5.2) + propshaft (0.8.0) + actionpack (>= 7.0.0) + activesupport (>= 7.0.0) + rack + railties (>= 7.0.0) psych (5.1.2) stringio public_suffix (5.0.5) @@ -199,23 +236,29 @@ GEM rake (13.2.1) rdoc (6.6.3.1) psych (>= 4.0.0) + redis (5.2.0) + redis-client (>= 0.22.0) + redis-client (0.22.1) + connection_pool regexp_parser (2.9.0) reline (0.5.2) io-console (~> 0.5) + request_store (1.6.0) + rack (>= 1.4) rexml (3.2.6) + ruby-vips (2.2.1) + ffi (~> 1.12) rubyzip (2.3.2) selenium-webdriver (4.19.0) base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - sprockets (>= 3.0.0) + sidekiq (7.2.2) + concurrent-ruby (< 2) + connection_pool (>= 2.3.0) + rack (>= 2.2.4) + redis-client (>= 0.19.0) stimulus-rails (1.3.3) railties (>= 6.0.0) stringio (3.1.0) @@ -250,19 +293,28 @@ PLATFORMS x86_64-linux DEPENDENCIES + acts_as_list + ancestry + bcrypt (~> 3.1.7) bootsnap capybara debug + dotenv-rails + image_processing (~> 1.2) importmap-rails jbuilder + kaminari + mobility (~> 1.3.0.rc1) pg (~> 1.1) + pg_search + propshaft puma (>= 5.0) rails (~> 7.1.3, >= 7.1.3.2) + redis (>= 4.0.1) selenium-webdriver - sprockets-rails + sidekiq stimulus-rails turbo-rails - tzinfo-data web-console RUBY VERSION diff --git a/README.txt b/README.txt index 5147326..fcaa3ef 100644 --- a/README.txt +++ b/README.txt @@ -4,9 +4,9 @@ RAILS_ENV=production bundle exec rake assets:precompile RAILS_ENV=production bundle exec rake assets:clean -git clone https://mattias:zibxa7-qozsej-qoksaM@git.oncotype.dk/hirschsprung/hirschsprung.dk.2024.git +git clone https://git.oncotype.dk/ikea_foundation/week_2024.git -rails new --skip-docker --skip-action-mailbox --skip-action-text --skip-action-cable --database=postgresql hirschsprung.dk.2024 +rails new --skip-docker --skip-action-mailbox --skip-action-text --skip-action-cable --database=postgresql week_2024 Credentials @@ -18,174 +18,3 @@ Gem ------------------- bundle config set --local without 'development test' -https://www.youtube.com/playlist?list=PL3mtAHT_eRex1sJI2uoTBgFT3qAXFbEcy -https://www.youtube.com/watch?v=X7H1N6pMYzg&list=PL3mtAHT_eRex1sJI2uoTBgFT3qAXFbEcy&index=6 - - -Captcha -------------------- -https://blog.cloudflare.com/turnstile-ga - -Utils -------------------------------- -RAILS_ENV=production bundle exec rake utils:delete_old_verification_codes - - -# Delete old verification codes -10 3 * * * cd /home/hirschsprung/hirschsprung.dk && RAILS_ENV=production /home/hirschsprung/.rbenv/shims/bundle exec rake utils:delete_old_verification_codes - - -Mailer -------------------------------- -http://localhost:3000/rails/mailers/user_mailer/verify_email.html - - - -curl -L -X GET 'https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJh3wvJx1TUkYRsBM5GKdGnxs&fields=opening_hours&key=AIzaSyD6ERQbg8j--n4RV8QiaRLqR792m9LRSrk' - -curl -L -X GET 'https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Hirschsprung+Collection&inputtype=textquery&fields=formatted_address%2Cname%2Ccurrent_opening_hours%2Cplace_id%2Cgeometry&key=AIzaSyD6ERQbg8j--n4RV8QiaRLqR792m9LRSrk' - -curl -L -X GET 'https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJh3wvJx1TUkYRsBM5GKdGnxs&fields=name%2Cbusiness_status%2Copening_hours/open_now&key=AIzaSyD6ERQbg8j--n4RV8QiaRLqR792m9LRSrk' -CLOSED_TEMPORARILY - -Louisianna -Louisiana Museum of Modern Art -ChIJq5pUwwc3UkYRTpARr0S5L2o -curl -L -X GET 'https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Louisiana+Museum+of+Modern+Art&inputtype=textquery&fields=formatted_address%2Cname%2Ccurrent_opening_hours%2Cplace_id%2Cgeometry&key=AIzaSyD6ERQbg8j--n4RV8QiaRLqR792m9LRSrk' - -curl -L -X GET 'https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJq5pUwwc3UkYRTpARr0S5L2o&fields=name%2Cbusiness_status%2Copening_hours/open_now&key=AIzaSyD6ERQbg8j--n4RV8QiaRLqR792m9LRSrk' - -/home/hs/hirschsprung.dk.2024/log/*.log { - weekly - missingok - rotate 4 - compress - delaycompress - notifempty - copytruncate -} - -{ - "html_attributions" : [], - "result" : - { - "business_status" : "OPERATIONAL", - "name" : "Louisiana Museum of Modern Art", - "opening_hours" : - { - "open_now" : false, - "periods" : - [ - { - "close" : - { - "day" : 0, - "time" : "1800" - }, - "open" : - { - "day" : 0, - "time" : "1100" - } - }, - { - "close" : - { - "day" : 2, - "time" : "2200" - }, - "open" : - { - "day" : 2, - "time" : "1100" - } - }, - { - "close" : - { - "day" : 3, - "time" : "2200" - }, - "open" : - { - "day" : 3, - "time" : "1100" - } - }, - { - "close" : - { - "day" : 4, - "time" : "2200" - }, - "open" : - { - "day" : 4, - "time" : "1100" - } - }, - { - "close" : - { - "day" : 5, - "time" : "2200" - }, - "open" : - { - "day" : 5, - "time" : "1100" - } - }, - { - "close" : - { - "day" : 6, - "time" : "1800" - }, - "open" : - { - "day" : 6, - "time" : "1100" - } - } - ], - "weekday_text" : - [ - "Monday: Closed", - "Tuesday: 11:00 AM – 10:00 PM", - "Wednesday: 11:00 AM – 10:00 PM", - "Thursday: 11:00 AM – 10:00 PM", - "Friday: 11:00 AM – 10:00 PM", - "Saturday: 11:00 AM – 6:00 PM", - "Sunday: 11:00 AM – 6:00 PM" - ] - } - }, - "status" : "OK" -}% - - -#curl -L -X GET 'https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJq5pUwwc3UkYRTpARr0S5L2o& -#fields=name%2Cbusiness_status%2Copening_hours/open_now&key=AIzaSyD6ERQbg8j--n4RV8QiaRLqR792m9LRSrk' - -{"html_attributions"=>[], - "result"=> - {"business_status"=>"OPERATIONAL", - "name"=>"Hirschsprung Collection", - "opening_hours"=> - {"open_now"=>true, - "periods"=> - [{"close"=>{"day"=>0, "time"=>"1700"}, "open"=>{"day"=>0, "time"=>"1000"}}, - {"close"=>{"day"=>3, "time"=>"1700"}, "open"=>{"day"=>3, "time"=>"1000"}}, - {"close"=>{"day"=>4, "time"=>"1700"}, "open"=>{"day"=>4, "time"=>"1000"}}, - {"close"=>{"day"=>5, "time"=>"1700"}, "open"=>{"day"=>5, "time"=>"1000"}}, - {"close"=>{"day"=>6, "time"=>"1700"}, "open"=>{"day"=>6, "time"=>"1000"}}], - "weekday_text"=> - ["Monday: Closed", - "Tuesday: Closed", - "Wednesday: 10:00 AM – 5:00 PM", - "Thursday: 10:00 AM – 5:00 PM", - "Friday: 10:00 AM – 5:00 PM", - "Saturday: 10:00 AM – 5:00 PM", - "Sunday: 10:00 AM – 5:00 PM"]}}, - "status"=>"OK"} \ No newline at end of file diff --git a/db/migrate/20240419142316_create_active_storage_tables.active_storage.rb b/db/migrate/20240419142316_create_active_storage_tables.active_storage.rb new file mode 100644 index 0000000..e4706aa --- /dev/null +++ b/db/migrate/20240419142316_create_active_storage_tables.active_storage.rb @@ -0,0 +1,57 @@ +# This migration comes from active_storage (originally 20170806125915) +class CreateActiveStorageTables < ActiveRecord::Migration[7.0] + def change + # Use Active Record's configured type for primary and foreign keys + primary_key_type, foreign_key_type = primary_and_foreign_key_types + + create_table :active_storage_blobs, id: primary_key_type do |t| + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.string :service_name, null: false + t.bigint :byte_size, null: false + t.string :checksum + + if connection.supports_datetime_with_precision? + t.datetime :created_at, precision: 6, null: false + else + t.datetime :created_at, null: false + end + + t.index [ :key ], unique: true + end + + create_table :active_storage_attachments, id: primary_key_type do |t| + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type + t.references :blob, null: false, type: foreign_key_type + + if connection.supports_datetime_with_precision? + t.datetime :created_at, precision: 6, null: false + else + t.datetime :created_at, null: false + end + + t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + + create_table :active_storage_variant_records, id: primary_key_type do |t| + t.belongs_to :blob, null: false, index: false, type: foreign_key_type + t.string :variation_digest, null: false + + t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_and_foreign_key_types + config = Rails.configuration.generators + setting = config.options[config.orm][:primary_key_type] + primary_key_type = setting || :primary_key + foreign_key_type = setting || :bigint + [primary_key_type, foreign_key_type] + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..8077199 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,47 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[7.1].define(version: 2024_04_19_142316) do + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "active_storage_attachments", force: :cascade do |t| + t.string "name", null: false + t.string "record_type", null: false + t.bigint "record_id", null: false + t.bigint "blob_id", null: false + t.datetime "created_at", null: false + t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" + t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true + end + + create_table "active_storage_blobs", force: :cascade do |t| + t.string "key", null: false + t.string "filename", null: false + t.string "content_type" + t.text "metadata" + t.string "service_name", null: false + t.bigint "byte_size", null: false + t.string "checksum" + t.datetime "created_at", null: false + t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true + end + + create_table "active_storage_variant_records", force: :cascade do |t| + t.bigint "blob_id", null: false + t.string "variation_digest", null: false + t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true + end + + add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" +end