diff --git a/Gemfile b/Gemfile index 61515a3045..7ac7d46736 100644 --- a/Gemfile +++ b/Gemfile @@ -27,10 +27,11 @@ gem "rqrcode" gem "redcarpet" gem "rouge" gem "jbuilder" -gem "actiontext-lexical", bc: "actiontext-lexical" +gem "actiontext-lexical", bc: "actiontext-lexical", branch: "flavorjones/unfurl-url" gem "image_processing", "~> 1.14" gem "platform_agent" gem "aws-sdk-s3", require: false +gem "rich_link", bc: "rich_link" # 37id and Queenbee integration gem "signal_id", bc: "signal_id", branch: "rails4" diff --git a/Gemfile.lock b/Gemfile.lock index bcd1970995..3325a3e184 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,7 @@ GIT remote: https://github.com/basecamp/actiontext-lexical - revision: 109735daa044233236cf7a72f30043e5c790e853 + revision: 9f47937e22e1f374bf43215d9f62a2a29fe19728 + branch: flavorjones/unfurl-url specs: actiontext-lexical (0.1.0) rails (>= 8.0.2) @@ -73,6 +74,17 @@ GIT json rails (>= 6.0.0) +GIT + remote: https://github.com/basecamp/rich_link + revision: ef56fd6aaa10ade1fc5e0865b1426bd5446e5533 + specs: + rich_link (0.1.0) + faraday + faraday-follow_redirects + nokogiri + rails (>= 8.0.2) + signal_id + GIT remote: https://github.com/basecamp/service_concurrency_prevention revision: 320da99431718615ed86f8723e8b9d3259c602a3 @@ -291,6 +303,8 @@ GEM faraday-net_http (>= 2.0, < 3.5) json logger + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) faraday-multipart (1.1.1) multipart-post (~> 2.0) faraday-net_http (3.4.1) @@ -607,6 +621,7 @@ DEPENDENCIES rails! rails_structured_logging! redcarpet + rich_link! rouge rqrcode rubocop-rails-omakase diff --git a/app/controllers/concerns/authentication.rb b/app/controllers/concerns/authentication.rb index db21f5c7e2..4e6b85ae43 100644 --- a/app/controllers/concerns/authentication.rb +++ b/app/controllers/concerns/authentication.rb @@ -2,6 +2,8 @@ module Authentication extend ActiveSupport::Concern included do + include RichLink::Authentication + # Checking for tenant must happen first so we redirect before trying to access the db. before_action :require_tenant @@ -39,7 +41,7 @@ def require_tenant end def require_authentication - resume_session || request_authentication + resume_session || authenticate_by_rich_link_token || request_authentication end def resume_session diff --git a/app/helpers/rich_text_helper.rb b/app/helpers/rich_text_helper.rb index 986e24fd01..216f576cdc 100644 --- a/app/helpers/rich_text_helper.rb +++ b/app/helpers/rich_text_helper.rb @@ -18,4 +18,8 @@ def commands_prompt def cards_prompt content_tag "lexical-prompt", "", trigger: "#", src: prompts_cards_path, name: "card", "insert-editable-text": true, "remote-filtering": true end + + def rich_link_unfurl_url + File.join(request.script_name, RichLink::Engine.routes.url_helpers.unfurl_path) + end end diff --git a/app/models/current.rb b/app/models/current.rb index 5a85b2e16c..e921e8582e 100644 --- a/app/models/current.rb +++ b/app/models/current.rb @@ -1,7 +1,14 @@ class Current < ActiveSupport::CurrentAttributes - attribute :session + attribute :session, :user attribute :http_method, :request_id, :user_agent, :ip_address, :referrer attribute :account - delegate :user, to: :session, allow_nil: true + def session=(session) + super + Current.user = session&.user + end + + def signal_user=(signal_user) + self.user = signal_user&.peer + end end diff --git a/app/views/cards/comments/_new.html.erb b/app/views/cards/comments/_new.html.erb index 07802b0f0b..63f16e8aed 100644 --- a/app/views/cards/comments/_new.html.erb +++ b/app/views/cards/comments/_new.html.erb @@ -10,7 +10,8 @@ local_save_key_value: "comment-#{card.id}", action: "turbo:submit-end->local-save#submit keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do |form| %> <%= form.rich_textarea :body, required: true, placeholder: new_comment_placeholder(card), - data: { local_save_target: "input", action: "actiontext:change->local-save#save turbo:morph-element->local-save#restoreContent" } do %> + data: { local_save_target: "input", unfurl_url: rich_link_unfurl_url, + action: "actiontext:change->local-save#save turbo:morph-element->local-save#restoreContent" } do %> <%= mentions_prompt(@card.collection) %> <%= cards_prompt %> <% end %> diff --git a/app/views/cards/comments/edit.html.erb b/app/views/cards/comments/edit.html.erb index d236e1b790..9ad49ea617 100644 --- a/app/views/cards/comments/edit.html.erb +++ b/app/views/cards/comments/edit.html.erb @@ -8,7 +8,8 @@
<%= form_with model: [ @card, @comment ], class: "flex flex-column gap full-width", data: { controller: "form", action: "keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do |form| %> - <%= form.rich_textarea :body, required: true, autofocus: true, placeholder: new_comment_placeholder(@card) do %> + <%= form.rich_textarea :body, required: true, autofocus: true, placeholder: new_comment_placeholder(@card), + data: { unfurl_url: rich_link_unfurl_url } do %> <%= mentions_prompt(@card.collection) %> <%= cards_prompt %> <% end %> diff --git a/app/views/cards/container/_title.html.erb b/app/views/cards/container/_title.html.erb index 3f2ff79c76..c884238c4b 100644 --- a/app/views/cards/container/_title.html.erb +++ b/app/views/cards/container/_title.html.erb @@ -20,7 +20,7 @@
<%= form.rich_textarea :description, class: "card-field__description", placeholder: "Add some notes, context, pictures, or video about this…", - data: { action: "actiontext:change->auto-save#change focusout->auto-save#submit keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do %> + data: { unfurl_url: rich_link_unfurl_url, action: "actiontext:change->auto-save#change focusout->auto-save#submit keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do %> <%= mentions_prompt(card.collection) %> <%= cards_prompt %> <% end %> diff --git a/app/views/cards/edit.html.erb b/app/views/cards/edit.html.erb index 8cf623422d..b7c07c8f83 100644 --- a/app/views/cards/edit.html.erb +++ b/app/views/cards/edit.html.erb @@ -10,7 +10,7 @@ <%= form.rich_textarea :description, class: "card-field__description rich-text-content", placeholder: "Add some notes, context, pictures, or video about this…", - data: { action: "keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do %> + data: { unfurl_url: rich_link_unfurl_url, action: "keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do %> <%= mentions_prompt(@card.collection) %> <%= cards_prompt %> <% end %> diff --git a/app/views/collections/edit/_publication.html.erb b/app/views/collections/edit/_publication.html.erb index 32299fe880..51c166f838 100644 --- a/app/views/collections/edit/_publication.html.erb +++ b/app/views/collections/edit/_publication.html.erb @@ -31,7 +31,7 @@ <%= form_with model: collection, class: "txt-align-start", data: { controller: "form" } do |form| %> <%= form.rich_textarea :public_description, class: "rich-text-content txt-small", placeholder: "Add a public note about this collection…", - data: { action: "keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } %> + data: { unfurl_url: rich_link_unfurl_url, action: "keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } %> <%= form.button "Save changes", type: :submit, class: "btn txt-small" %> <% end %>
diff --git a/config/routes.rb b/config/routes.rb index 07290777b3..81b475c20c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -174,6 +174,7 @@ root "events#index" Queenbee.routes(self) + mount RichLink::Engine => "/rich_link" namespace :admin do mount MissionControl::Jobs::Engine, at: "/jobs"