FEATURE: Google Drive onebox engine

FEATURE: Google Drive onebox engine

diff --git a/lib/onebox/engine.rb b/lib/onebox/engine.rb
index 398ad84..72af7ed 100644
--- a/lib/onebox/engine.rb
+++ b/lib/onebox/engine.rb
@@ -187,3 +187,4 @@ require_relative "engine/gitlab_blob_onebox"
 require_relative "engine/google_photos_onebox"
 require_relative "engine/kaltura_onebox"
 require_relative "engine/reddit_image_onebox"
+require_relative "engine/google_drive_onebox"
diff --git a/lib/onebox/engine/google_drive_onebox.rb b/lib/onebox/engine/google_drive_onebox.rb
new file mode 100644
index 0000000..e38d76d
--- /dev/null
+++ b/lib/onebox/engine/google_drive_onebox.rb
@@ -0,0 +1,28 @@
+module Onebox
+  module Engine
+    class GoogleDriveOnebox
+      include Engine
+      include StandardEmbed
+      include LayoutSupport
+
+      matches_regexp /^(https?:)?\/\/(drive\.google\.com)\/file\/d\/(?<key>[\w-]*)\/.+$/
+      always_https
+
+      protected
+
+      def data
+        og_data = get_opengraph
+        title = og_data.title || "Google Drive"
+        title = "#{og_data.title} (video)" if og_data.type =~ /^video[\/\.]/
+        description = og_data.description || "Google Drive file."
+
+        result = { link: link,
+                   title: title,
+                   description: Onebox::Helpers.truncate(description, 250),
+                   image: og_data.image
+                 }
+        result
+      end
+    end
+  end
+end
diff --git a/lib/onebox/version.rb b/lib/onebox/version.rb
index f56de9b..6c9b497 100644
--- a/lib/onebox/version.rb
+++ b/lib/onebox/version.rb
@@ -1,5 +1,5 @@
 # frozen_string_literal: true
 
 module Onebox
-  VERSION = "1.8.83"
+  VERSION = "1.8.84"
 end
diff --git a/templates/googledrive.mustache b/templates/googledrive.mustache
new file mode 100644
index 0000000..6b795d1
--- /dev/null
+++ b/templates/googledrive.mustache
@@ -0,0 +1,9 @@
+{{^image}}
+  <a href='{{link}}' target="_blank"><span class='googledocs-onebox-logo g-drive-logo'></span></a>
+{{/image}}
+
+{{#image}}<img src="{{image}}" class="thumbnail"/>{{/image}}
+
+<h3><a href='{{link}}' target="_blank">{{title}}</a></h3>
+
+<p>{{description}}</p>

GitHub sha: 79033b85

Should we add a spec for this given that all the other engines do?

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there: