mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 13:08:40 +08:00
Render Meet links as static onebox cards instead of generic embeds. Include localized labels, styling, SVG icon support, lookup-link handling, and specs for matching and rendering. <img width="916" height="296" alt="image" src="https://github.com/user-attachments/assets/e88e7046-d456-4883-9d03-c0423a152a0b" />
48 lines
1.2 KiB
Ruby
Vendored
48 lines
1.2 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module Onebox
|
|
module Engine
|
|
class GoogleMeetOnebox
|
|
include Engine
|
|
include LayoutSupport
|
|
|
|
MEETING_CODE_PATH = %r{\A/(?<code>[a-z]{3}-[a-z]{4}-[a-z]{3})/?\z}i
|
|
LOOKUP_PATH = %r{\A/lookup/[a-z0-9_-]{3,64}/?\z}i
|
|
|
|
matches_domain("meet.google.com")
|
|
always_https
|
|
|
|
def self.matches_path(path)
|
|
path.match?(MEETING_CODE_PATH) || path.match?(LOOKUP_PATH)
|
|
end
|
|
|
|
def inline_data
|
|
{ title: I18n.t("onebox.google_meet.title") }
|
|
end
|
|
|
|
private
|
|
|
|
def data
|
|
@data ||=
|
|
begin
|
|
meeting_code = parsed_meeting_code
|
|
|
|
{
|
|
link: link,
|
|
domain: "Google Meet",
|
|
title: I18n.t("onebox.google_meet.title"),
|
|
description: meeting_code.blank? ? I18n.t("onebox.google_meet.description") : nil,
|
|
meeting_code: meeting_code,
|
|
meeting_code_label: I18n.t("onebox.google_meet.meeting_code"),
|
|
join_label: I18n.t("onebox.google_meet.join"),
|
|
}
|
|
end
|
|
end
|
|
|
|
def parsed_meeting_code
|
|
match = uri.path.match(MEETING_CODE_PATH)
|
|
match&.[](:code)&.downcase
|
|
end
|
|
end
|
|
end
|
|
end
|