From fcbb4a1eb19187169058485ca7478a4df189c5cf Mon Sep 17 00:00:00 2001 From: crespire Date: Fri, 11 Oct 2024 21:21:18 -0400 Subject: [PATCH 1/3] Update application to use rich text for Location and Description --- Gemfile | 2 +- Gemfile.lock | 12 ++++ Procfile.dev | 1 - app/assets/config/manifest.js | 1 + app/assets/stylesheets/actiontext.css | 31 ++++++++++ .../stylesheets/application.tailwind.css | 1 + app/controllers/admin/base_controller.rb | 4 +- app/controllers/admin/events_controller.rb | 3 +- app/javascript/application.js | 3 + app/models/calendar.rb | 15 ++--- app/models/event.rb | 5 +- app/views/active_storage/blobs/_blob.html.erb | 14 +++++ app/views/admin/events/_form.html.erb | 10 +--- app/views/events/_event.html.erb | 8 +-- app/views/layouts/_event_layout.html.erb | 2 +- .../action_text/contents/_content.html.erb | 3 + app/views/layouts/application.html.erb | 2 +- ...te_active_storage_tables.active_storage.rb | 57 +++++++++++++++++++ ...0_create_action_text_tables.action_text.rb | 26 +++++++++ ...54_migrate_event_content_to_action_text.rb | 27 +++++++++ db/schema.rb | 45 +++++++++++++-- package-lock.json | 33 ++++++++++- package.json | 4 +- .../admin/events_controller_test.rb | 2 +- test/controllers/events_controller_test.rb | 2 +- yarn.lock | 24 ++++++++ 26 files changed, 299 insertions(+), 38 deletions(-) create mode 100644 app/assets/stylesheets/actiontext.css create mode 100644 app/views/active_storage/blobs/_blob.html.erb create mode 100644 app/views/layouts/action_text/contents/_content.html.erb create mode 100644 db/migrate/20241012002909_create_active_storage_tables.active_storage.rb create mode 100644 db/migrate/20241012002910_create_action_text_tables.action_text.rb create mode 100644 db/migrate/20241012003354_migrate_event_content_to_action_text.rb diff --git a/Gemfile b/Gemfile index 5029e0d..cc6d8df 100644 --- a/Gemfile +++ b/Gemfile @@ -44,7 +44,7 @@ gem 'tzinfo-data', platforms: %i[windows jruby] 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" # Internet calendaring, Ruby style gem 'icalendar', '~> 2.10' diff --git a/Gemfile.lock b/Gemfile.lock index 8636b16..3ce6d5c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -92,6 +92,9 @@ GEM reline (>= 0.3.8) drb (2.2.1) erubi (1.13.0) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) globalid (1.2.1) activesupport (>= 6.1) honeybadger (5.11.2) @@ -100,6 +103,9 @@ GEM icalendar (2.10.2) ice_cube (~> 0.16) ice_cube (0.17.0) + image_processing (1.13.0) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) io-console (0.7.2) irb (1.13.1) rdoc (>= 4.0.0) @@ -109,6 +115,7 @@ GEM activesupport (>= 5.0.0) jsbundling-rails (1.3.0) railties (>= 6.0.0) + logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -118,6 +125,7 @@ GEM net-pop net-smtp marcel (1.0.4) + mini_magick (4.13.2) mini_mime (1.1.5) minitest (5.23.1) msgpack (1.7.2) @@ -190,6 +198,9 @@ GEM connection_pool reline (0.5.9) io-console (~> 0.5) + ruby-vips (2.2.2) + ffi (~> 1.12) + logger sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -230,6 +241,7 @@ DEPENDENCIES debug honeybadger (~> 5.6) icalendar (~> 2.10) + image_processing (~> 1.2) jbuilder jsbundling-rails pg diff --git a/Procfile.dev b/Procfile.dev index c1cb248..fdd6baa 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,3 +1,2 @@ -web: env RUBY_DEBUG_OPEN=true bin/rails server js: yarn build --watch css: yarn build:css --watch diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 9a99757..8dcbe20 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1,2 +1,3 @@ +//= link actiontext.css //= link_tree ../images //= link_tree ../builds diff --git a/app/assets/stylesheets/actiontext.css b/app/assets/stylesheets/actiontext.css new file mode 100644 index 0000000..3cfcb2b --- /dev/null +++ b/app/assets/stylesheets/actiontext.css @@ -0,0 +1,31 @@ +/* + * Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and + * the trix-editor content (whether displayed or under editing). Feel free to incorporate this + * inclusion directly in any other asset bundle and remove this file. + * + *= require trix +*/ + +/* + * We need to override trix.css’s image gallery styles to accommodate the + * element we wrap around attachments. Otherwise, + * images in galleries will be squished by the max-width: 33%; rule. +*/ +.trix-content .attachment-gallery > action-text-attachment, +.trix-content .attachment-gallery > .attachment { + flex: 1 0 33%; + padding: 0 0.5em; + max-width: 33%; +} + +.trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment, +.trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment, +.trix-content .attachment-gallery.attachment-gallery--4 > .attachment { + flex-basis: 50%; + max-width: 50%; +} + +.trix-content action-text-attachment .attachment { + padding: 0 !important; + max-width: 100% !important; +} diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index 3c1f20c..f13eac5 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -13,3 +13,4 @@ @apply text-lg font-medium; } } + diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index a457645..5d421f7 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -1,8 +1,8 @@ module Admin class BaseController < ApplicationController http_basic_authenticate_with( - name: Rails.env.test? ? "admin" : Rails.application.credentials.auth.user, - password: Rails.env.test? ? "admin" : Rails.application.credentials.auth.password + name: Rails.env.production? ? Rails.application.credentials.auth.user : 'admin', + password: Rails.env.production? ? Rails.application.credentials.auth.password : 'admin' ) end end diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index 56e3144..a58feb9 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -37,6 +37,7 @@ def create def update @event.assign_attributes(event_params) @event.start_at = ActiveSupport::TimeZone.new('Eastern Time (US & Canada)').local_to_utc(@event.start_at) + binding.irb respond_to do |format| if @event.save @@ -68,7 +69,7 @@ def set_event # Only allow a list of trusted parameters through. def event_params - params.require(:event).permit(:name, :rsvp_link, :location, :presentation, :presenter, :sponsor, :sponsor_link, + params.require(:event).permit(:name, :rsvp_link, :location, :description, :sponsor, :sponsor_link, :sponsor_logo, :start_at, :status) end diff --git a/app/javascript/application.js b/app/javascript/application.js index d933293..7d6647e 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,3 +1,6 @@ // Entry point for the build script in your package.json import "@hotwired/turbo-rails" import "./controllers" + +import "trix" +import "@rails/actiontext" diff --git a/app/models/calendar.rb b/app/models/calendar.rb index 8879632..133d877 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -1,4 +1,4 @@ -require "icalendar" +require 'icalendar' class Calendar include Rails.application.routes.url_helpers @@ -17,7 +17,7 @@ def publish @events.each do |event| calendar.event do |e| e.dtstart = ical_time(event.start_at) - e.dtend = ical_time(event.start_at + 2.hours) + e.dtend = ical_time(event.start_at + 3.hours) e.summary = "Toronto Ruby - #{event.name}" e.location = event.city e.url = event.rsvp_link || event_url(event) @@ -34,15 +34,10 @@ def publish e.description = <<~DESCRIPTION Toronto Ruby - #{event.name} + #{event.description.to_plain_text} Location: - #{event.location} - - Presenter: - #{event.presenter} - - Presentation: - #{event.presentation} + #{event.location.to_plain_text} Event-Site: #{event_url(event)} @@ -63,7 +58,7 @@ def to_ical private def timezone_identifier - "America/Toronto" + 'America/Toronto' end def timezone diff --git a/app/models/event.rb b/app/models/event.rb index e89100d..011bac7 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,11 +1,14 @@ class Event < ApplicationRecord - validates :start_at, :name, :location, :presentation, presence: true + validates :start_at, :name, :location, :description, presence: true enum :status, { draft: 0, published: 1 }, default: :draft scope :upcoming, -> { published.where(start_at: Time.zone.now...).order(start_at: :asc) } scope :past, -> { published.where(start_at: ...Time.zone.now).order(start_at: :desc) } + has_rich_text :description + has_rich_text :location + def start_time start_at.in_time_zone('Eastern Time (US & Canada)').to_fs(:long_at) end diff --git a/app/views/active_storage/blobs/_blob.html.erb b/app/views/active_storage/blobs/_blob.html.erb new file mode 100644 index 0000000..49ba357 --- /dev/null +++ b/app/views/active_storage/blobs/_blob.html.erb @@ -0,0 +1,14 @@ +
attachment--<%= blob.filename.extension %>"> + <% if blob.representable? %> + <%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %> + <% end %> + +
+ <% if caption = blob.try(:caption) %> + <%= caption %> + <% else %> + <%= blob.filename %> + <%= number_to_human_size blob.byte_size %> + <% end %> +
+
diff --git a/app/views/admin/events/_form.html.erb b/app/views/admin/events/_form.html.erb index ccbd93b..b3961bc 100644 --- a/app/views/admin/events/_form.html.erb +++ b/app/views/admin/events/_form.html.erb @@ -15,16 +15,12 @@ <%= form.label :name %> <%= form.text_field :name, required: true %> <%= form.label :location %> - <%= form.text_area :location, required: true %> + <%= form.rich_text_area :location, required: true %> <%= form.label :rsvp_link %> <%= form.text_field :rsvp_link, required: true %> - <%= form.label :presentation %> - <%= form.text_area :presentation %> - <%= form.label :presenter %> - <%= form.text_area :presenter %> + <%= form.label :description %> + <%= form.rich_text_area :description %> <%= form.label :sponsor %> - <%= form.text_field :sponsor %> - <%= form.label :sponsor_link %> <%= form.text_field :sponsor_link %> <%= form.label :sponsor_logo %> <%= form.text_field :sponsor_logo %> diff --git a/app/views/events/_event.html.erb b/app/views/events/_event.html.erb index a0b3dbe..6b221ea 100644 --- a/app/views/events/_event.html.erb +++ b/app/views/events/_event.html.erb @@ -5,8 +5,8 @@

<%= link_to event.name, event %>

<%= event.start_time %>

- <%= simple_format(event.location) %> -

Pizza and drinks provided by our sponsor.

+ <%= event.location %> +

Food and drinks provided by our sponsor.

@@ -21,9 +21,7 @@

7pm

-

Presentation:

-

<%= event.presentation %>

-

by <%= event.presenter&.html_safe %>

+ <%= event.description %>
diff --git a/app/views/layouts/_event_layout.html.erb b/app/views/layouts/_event_layout.html.erb index 24bfa9b..846bcf7 100644 --- a/app/views/layouts/_event_layout.html.erb +++ b/app/views/layouts/_event_layout.html.erb @@ -2,7 +2,7 @@

- Monthly meetups for Toronto's Ruby community + Meetups for Toronto's Ruby community

We're a group of Ruby developers who meet up to talk about programming, the industry, and life. We're working to strengthen the local Ruby community and provide a positive space for everyone to connect.

diff --git a/app/views/layouts/action_text/contents/_content.html.erb b/app/views/layouts/action_text/contents/_content.html.erb new file mode 100644 index 0000000..9e3c0d0 --- /dev/null +++ b/app/views/layouts/action_text/contents/_content.html.erb @@ -0,0 +1,3 @@ +
+ <%= yield -%> +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 00cbbdb..64186b5 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -8,7 +8,7 @@ <%= render "layouts/common/opengraph" %> - <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> + <%= stylesheet_link_tag "application", "actiontext", "data-turbo-track": "reload" %> <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> diff --git a/db/migrate/20241012002909_create_active_storage_tables.active_storage.rb b/db/migrate/20241012002909_create_active_storage_tables.active_storage.rb new file mode 100644 index 0000000..e4706aa --- /dev/null +++ b/db/migrate/20241012002909_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/migrate/20241012002910_create_action_text_tables.action_text.rb b/db/migrate/20241012002910_create_action_text_tables.action_text.rb new file mode 100644 index 0000000..1be48d7 --- /dev/null +++ b/db/migrate/20241012002910_create_action_text_tables.action_text.rb @@ -0,0 +1,26 @@ +# This migration comes from action_text (originally 20180528164100) +class CreateActionTextTables < ActiveRecord::Migration[6.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 :action_text_rich_texts, id: primary_key_type do |t| + t.string :name, null: false + t.text :body, size: :long + t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type + + t.timestamps + + t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true + 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/migrate/20241012003354_migrate_event_content_to_action_text.rb b/db/migrate/20241012003354_migrate_event_content_to_action_text.rb new file mode 100644 index 0000000..5d8e3c0 --- /dev/null +++ b/db/migrate/20241012003354_migrate_event_content_to_action_text.rb @@ -0,0 +1,27 @@ +class MigrateEventContentToActionText < ActiveRecord::Migration[7.1] + include ActionView::Helpers::TextHelper + + def up + rename_column :events, :location, :location_plain + Event.find_each do |event| + event.update_attribute(:location, simple_format(event.location_plain)) + event.update_attribute(:description, "#{event.presentation} by #{event.presenter}") + end + remove_column :events, :location_plain + remove_column :events, :presenter + remove_column :events, :presentation + end + + def down + puts 'WARNING, YOU MUST MANUALLY UPDATE INFORMATION THAT IS PRINTED BELOW.' + add_column :events, :location_plain, :text + add_column :events, :presenter, :text + add_column :events, :presentation, :text + Event.find_each do |event| + event.update_attribute(:location_plain, event.location.body.to_plain_text) + puts "Event #{event.id} Description" + puts event.description.body.to_plain_text + end + rename_column :events, :location_plain, :location + end +end diff --git a/db/schema.rb b/db/schema.rb index 058a076..b782457 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,16 +10,51 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_09_03_203347) do +ActiveRecord::Schema[7.1].define(version: 2024_10_12_003354) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "action_text_rich_texts", force: :cascade do |t| + t.string "name", null: false + t.text "body" + t.string "record_type", null: false + t.bigint "record_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true + end + + 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 + create_table "events", force: :cascade do |t| t.string "name" t.string "rsvp_link" - t.text "location" - t.text "presentation" - t.text "presenter" t.string "sponsor" t.string "sponsor_link" t.string "sponsor_logo" @@ -32,4 +67,6 @@ t.index ["slug"], name: "index_events_on_slug", 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 diff --git a/package-lock.json b/package-lock.json index bf42d60..e3958f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,10 +8,12 @@ "dependencies": { "@hotwired/stimulus": "^3.2.2", "@hotwired/turbo-rails": "^8.0.0-beta.1", + "@rails/actiontext": "^7.2.100", "@tailwindcss/typography": "^0.5.10", "autoprefixer": "^10.4.16", "esbuild": "^0.19.9", - "postcss": "^8.4.32" + "postcss": "^8.4.32", + "trix": "^2.1.6" }, "devDependencies": { "tailwindcss": "^3.4.13" @@ -500,6 +502,25 @@ "resolved": "https://registry.npmjs.org/@rails/actioncable/-/actioncable-7.1.3.tgz", "integrity": "sha512-ojNvnoZtPN0pYvVFtlO7dyEN9Oml1B6IDM+whGKVak69MMYW99lC2NOWXWeE3bmwEydbP/nn6ERcpfjHVjYQjA==" }, + "node_modules/@rails/actiontext": { + "version": "7.2.100", + "resolved": "https://registry.npmjs.org/@rails/actiontext/-/actiontext-7.2.100.tgz", + "integrity": "sha512-46oDEZdkxpbM/7+3GwSHTRyIkH3LRZRC9OE35rMIt0FcRbjXW+2Q7RL1YYjoy7megqnoCUDZglFISJQxJ/HBZg==", + "dependencies": { + "@rails/activestorage": ">= 7.2.0-alpha" + }, + "peerDependencies": { + "trix": "^2.0.0" + } + }, + "node_modules/@rails/activestorage": { + "version": "7.2.100", + "resolved": "https://registry.npmjs.org/@rails/activestorage/-/activestorage-7.2.100.tgz", + "integrity": "sha512-gohCilm1E10W51Hc9iT960xX9TP11L5TJ4W1ufs9f3h5Ncsw01S/eHgVUfcdfszqw3G+28Z0MFu999+iSpgdTg==", + "dependencies": { + "spark-md5": "^3.0.1" + } + }, "node_modules/@tailwindcss/typography": { "version": "0.5.13", "resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.13.tgz", @@ -1540,6 +1561,11 @@ "node": ">=0.10.0" } }, + "node_modules/spark-md5": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/spark-md5/-/spark-md5-3.0.2.tgz", + "integrity": "sha512-wcFzz9cDfbuqe0FZzfi2or1sgyIrsDwmPwfZC4hiNidPdPINjeUwNfv5kldczoEAcjl9Y1L3SM7Uz2PUEQzxQw==" + }, "node_modules/string-width": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", @@ -1738,6 +1764,11 @@ "node": ">=8.0" } }, + "node_modules/trix": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/trix/-/trix-2.1.6.tgz", + "integrity": "sha512-NHX69IkQz/JEQWI++sRryleXWo1PuN8GKjvU+jYgMX6UbN2Pzfg6k46RpmdRl+1q0SyoGbyOZDoFUpNwEdjtXA==" + }, "node_modules/ts-interface-checker": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", diff --git a/package.json b/package.json index 073a022..6dfcc48 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,12 @@ "dependencies": { "@hotwired/stimulus": "^3.2.2", "@hotwired/turbo-rails": "^8.0.0-beta.1", + "@rails/actiontext": "^7.2.100", "@tailwindcss/typography": "^0.5.10", "autoprefixer": "^10.4.16", "esbuild": "^0.19.9", - "postcss": "^8.4.32" + "postcss": "^8.4.32", + "trix": "^2.1.6" }, "scripts": { "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=/assets", diff --git a/test/controllers/admin/events_controller_test.rb b/test/controllers/admin/events_controller_test.rb index dff6f21..2d7572a 100644 --- a/test/controllers/admin/events_controller_test.rb +++ b/test/controllers/admin/events_controller_test.rb @@ -11,7 +11,7 @@ def setup name: "Event #{date.strftime('%B %Y')}", location: 'Some Office', city: 'Toronto, Canada', - presentation: "Presentation #{date}", + description: "Presentation #{date}", status: :published, sponsor: 'Some Sponsor', sponsor_link: 'https://example.com' diff --git a/test/controllers/events_controller_test.rb b/test/controllers/events_controller_test.rb index 4fde462..fff6001 100644 --- a/test/controllers/events_controller_test.rb +++ b/test/controllers/events_controller_test.rb @@ -11,7 +11,7 @@ def setup name: "Event #{date.strftime('%B %Y')}", location: 'Some Office', city: 'Toronto, Canada', - presentation: "Presentation #{date}", + description: "Presentation #{date}", status: :published, sponsor: 'Some Sponsor', sponsor_link: 'https://example.com' diff --git a/yarn.lock b/yarn.lock index 838179e..bef4a2c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -215,6 +215,20 @@ resolved "https://registry.npmjs.org/@rails/actioncable/-/actioncable-7.1.3.tgz" integrity sha512-ojNvnoZtPN0pYvVFtlO7dyEN9Oml1B6IDM+whGKVak69MMYW99lC2NOWXWeE3bmwEydbP/nn6ERcpfjHVjYQjA== +"@rails/actiontext@^7.2.100": + version "7.2.100" + resolved "https://registry.npmjs.org/@rails/actiontext/-/actiontext-7.2.100.tgz" + integrity sha512-46oDEZdkxpbM/7+3GwSHTRyIkH3LRZRC9OE35rMIt0FcRbjXW+2Q7RL1YYjoy7megqnoCUDZglFISJQxJ/HBZg== + dependencies: + "@rails/activestorage" ">= 7.2.0-alpha" + +"@rails/activestorage@>= 7.2.0-alpha": + version "7.2.100" + resolved "https://registry.npmjs.org/@rails/activestorage/-/activestorage-7.2.100.tgz" + integrity sha512-gohCilm1E10W51Hc9iT960xX9TP11L5TJ4W1ufs9f3h5Ncsw01S/eHgVUfcdfszqw3G+28Z0MFu999+iSpgdTg== + dependencies: + spark-md5 "^3.0.1" + "@tailwindcss/typography@^0.5.10": version "0.5.13" resolved "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.13.tgz" @@ -826,6 +840,11 @@ source-map-js@^1.2.0: resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz" integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg== +spark-md5@^3.0.1: + version "3.0.2" + resolved "https://registry.npmjs.org/spark-md5/-/spark-md5-3.0.2.tgz" + integrity sha512-wcFzz9cDfbuqe0FZzfi2or1sgyIrsDwmPwfZC4hiNidPdPINjeUwNfv5kldczoEAcjl9Y1L3SM7Uz2PUEQzxQw== + "string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0: version "4.2.3" resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" @@ -925,6 +944,11 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +trix@^2.1.6: + version "2.1.6" + resolved "https://registry.npmjs.org/trix/-/trix-2.1.6.tgz" + integrity sha512-NHX69IkQz/JEQWI++sRryleXWo1PuN8GKjvU+jYgMX6UbN2Pzfg6k46RpmdRl+1q0SyoGbyOZDoFUpNwEdjtXA== + ts-interface-checker@^0.1.9: version "0.1.13" resolved "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz" From 6d5e7b1ad68bd7e6af89a0069a36b60510bc7b34 Mon Sep 17 00:00:00 2001 From: crespire Date: Fri, 11 Oct 2024 21:34:39 -0400 Subject: [PATCH 2/3] Fix seeds --- db/seeds.rb | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 049976d..d094239 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -15,8 +15,7 @@ location: "Workplace One\n51 Wolseley St, Toronto ON\nLower level, enter through doors on Wolseley St.", rsvp_link: nil, status: :published, - presentation: "Integer#even?\nGoing stupidly deep on pointless performance questions, but hopefully learning something fun along the way", - presenter: 'Matt Eagar', + description: "Integer#even?\nGoing stupidly deep on pointless performance questions, but hopefully learning something fun along the way\nby Matt Eagar", sponsor: 'Switch Growth', sponsor_logo: 'switch.png', sponsor_link: 'https://switchgrowth.com/', @@ -27,8 +26,7 @@ location: "Loop Financial\n500-410 Adelaide Street West, Toronto, ON M5V 1S8", rsvp_link: nil, status: :published, - presentation: 'Rails and the Ruby Garbage Collector: How to Speed Up Your Rails App', - presenter: 'Peter Zhu, Senior Developer at Shopify', + description: 'Rails and the Ruby Garbage Collector: How to Speed Up Your Rails App by Peter Zhu, Senior Developer at Shopify', sponsor: 'Loop Financial', sponsor_logo: 'loop.png', sponsor_link: 'https://bankonloop.com/', @@ -39,8 +37,7 @@ location: "Workplace One\n51 Wolseley St, Toronto ON\nLower level, enter through doors on Wolseley St.", rsvp_link: nil, status: :published, - presentation: 'All About the Ruby LSP', - presenter: 'Vinicius Stock, Staff Developer at Shopify', + description: 'All About the Ruby LSP by Vinicius Stock, Staff Developer at Shopify', sponsor: 'Switch Growth', sponsor_logo: 'switch.png', sponsor_link: 'https://switchgrowth.com/', @@ -52,8 +49,7 @@ location: "FinanceIt @ The Well\n8 Spadina Ave\nSuite 2400\nToronto, ON M5V 2H6\nPlease note that public access to the building is restricted at 7pm! Please arrive before then.\nWhen you arrive at The Well, please take the high rise elevators (19-38) to the 214th floor to get to reception.", rsvp_link: nil, status: :published, - presentation: 'Using Rails introspection to supercharge your editor', - presenter: 'Andy Waite, Senior Developer at Shopify', + description: 'Using Rails introspection to supercharge your editor by Andy Waite, Senior Developer at Shopify', sponsor: 'Financeit', sponsor_logo: 'financeit.png', sponsor_link: 'https://www.financeit.io/', @@ -64,8 +60,7 @@ location: "Workplace One\n51 Wolseley St, Toronto ON\nLower level, enter through doors on Wolseley St.", rsvp_link: 'https://radius.to/groups/toronto-ruby/events/pkgvym5ecyuc', status: :published, - presentation: 'Concurrency in Ruby', - presenter: 'Raj Kumart, Director of Software Engineering at Stealth', + description: 'Concurrency in Ruby by Raj Kumart, Director of Software Engineering at Stealth', sponsor: 'Switch Growth', sponsor_logo: 'switch.png', sponsor_link: 'https://switchgrowth.com/', @@ -76,8 +71,7 @@ location: "Workplace One\n51 Wolseley St, Toronto ON\nLower level, enter through doors on Wolseley St.", rsvp_link: 'https://radius.to/groups/toronto-ruby/events/s1tczn2usqf5', status: :published, - presentation: 'Creating A Dev Container Ecosystem For Rails 8', - presenter: 'Andrew Novoselac, Senior Software Developer at Shopify', + description: 'Creating A Dev Container Ecosystem For Rails 8 by Andrew Novoselac, Senior Software Developer at Shopify', sponsor: 'Switch Growth', sponsor_logo: 'switch.png', sponsor_link: 'https://switchgrowth.com/', @@ -86,5 +80,8 @@ ] events.each do |event| - Event.find_or_create_by!(event) + e = Event.find_or_initialize_by(event.except(:location, :description)) + e.location = event[:location] + e.description = event[:description] + e.save! end From bb6cd1b3577639270a584add22fcab4679b62977 Mon Sep 17 00:00:00 2001 From: crespire Date: Fri, 11 Oct 2024 21:36:30 -0400 Subject: [PATCH 3/3] Remove debug statement --- app/controllers/admin/events_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index a58feb9..8c0568c 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -37,7 +37,6 @@ def create def update @event.assign_attributes(event_params) @event.start_at = ActiveSupport::TimeZone.new('Eastern Time (US & Canada)').local_to_utc(@event.start_at) - binding.irb respond_to do |format| if @event.save