Google docs onebox gem requires a "published" document


(Michael Downey) #1

Embedding a Google document via the onebox gem seems to be broken. All that displays is a blank placeholder. When trying new posts, I get the following error in the console:

Load denied by X-Frame-Options: (Google Doc URL) does not permit cross-origin framing.

I’ll paste the URL of a sample document, https://docs.google.com/document/d/1IQGdx-1X-E_W3O5PSiV9RF1hhjI5hryWZF9FFYNv4Oc/edit?usp=sharing, in a line by itself here:

https://docs.google.com/document/d/1IQGdx-1X-E_W3O5PSiV9RF1hhjI5hryWZF9FFYNv4Oc/edit?usp=sharing


(Arpit Jalan) #2

Added on my list. :pencil:


(Arpit Jalan) #3

Michael, are you sure you published the Google Doc you are trying to onebox?

Google Doc needs to be published (not shared) for embedding. More info here.

In my testing the published Google Doc is getting embedded.



Embed Google Spreadsheet plugin
(Kane York) #4

Can we convert the URLs into the publish form automatically?

May want to build on top of FEATURE: Add placeholder for google docs oneboxes by riking · Pull Request #307 · discourse/onebox · GitHub so we don’t get iframe flashing.


(Arpit Jalan) #5

I don’t think so. I believe only the document owner has the rights to publish that document.

Simply appending /pub at the end of the URL will not allow embedding of that document.


(Michael Downey) #6

:+1: That worked. Thanks for the insight!

That said, I don’t know that people would automatically think to do this. Is there any way to get around the limitation so that a “share” works? Alternatively, is it possible to display some type of useful error message rather than just empty space?


(Arpit Jalan) #7

Good point. I’ll see what I can do, added on my list.


(Philipp Wolfer) #8

Best solution would IMHO be to just disable the onebox for docs that were only shared and not published, not sure how to detect this. But I noticed that for documents I share all URL paths end with /edit, e.g. justtesting - Google Docs, while the published URL ends with /pub, e.g. justtesting

Another issue with the Google Docs Onebox is that they do not provide any link to the actual document, which often would make viewing easier instead of only relying on the embedded version.


(Alex Armstrong) #9

In my community, we post a lot of Google Docs & Sheets that have been shared but not published. According to this topic, this results in a broken onebox.

Until there’s a better solution, I would like to disable oneboxes for Google Docs. Is this possible?


(Michael Downey) #10

I’m not aware of any way to disable it.


(Alex Armstrong) #11

In this case, I’d like to request a setting to blacklist domains – the inverse of this:

(I’m not entirely sure if there’s a formal way of initiating feature requests, short of becoming a paying customer. I just type here and hope for the best.)


(Alex Armstrong) #12

Apologies for repeating myself, but I’m getting quite a bit of flak about this from my community. The Google Docs onebox is kind of half-baked and I would very much like to be able to turn it off.

The only workaround I’ve found is to run the link along with the previous paragraph of text. (I.e., not putting it on a line of its own.) I found this by trial and error and I’m pretty techie. It’s not really feasible to instruct users We refer to Google Docs a lot, and I’ve gotten into the habit of editing people’s posts in this manner to prevent the onebox from appearing.

In any case, I think embedding the document is overkill and should be optional. I much prefer Slack’s approach:

An attractive link is sufficient. It’s a spreadsheet, after all. I’m not going to try and view it in a tiny window.


Google Spreadsheet only showing as link
(Jeff Atwood) #13

Just put a space in front of the link. Not sure how that’s too “techie” of a workaround, for now…


(Alex Armstrong) #14

Ah, the space is useful as well for me. I meant “techie” in the sense that my users (mostly academics and higher ed staff) generally don’t actively look for ways to thwart their technology. If they don’t like how something works they just put up with it and/or complain :smiley:


(Jeff Atwood) #15

I agree with this @techAPJ

Can you add that to your list? Embedding a full Google spreadsheet, doc, etc is kind of insane when you think about it…


(Sam Saffron) #16

Yeah, if anything it should be optional, opt-in. I would hold off for 1.7 though and just have it use the generic default onebox support (after mini onebox is built)


(Arpit Jalan) #17

Okay, this is now done.

Sheet:

Document:

Form:

Slide:


Oneboxed Google Docs break scroll position
Google Sheet Embed post in topic always jumps to focus
Difficult to find way to open oneboxed google doc
(Dave McClure) #18

When the doc is not public, the title and contents can’t be pulled in by the onebox, so the click target is a lot less obvious. Here’s a screenshot of an example:

Perhaps that “title” should be rendered in bold blue text as “Google Sheets” or “Google Docs” or “Google Slides” when the title content can’t be retrieved?

Eg:


(Arpit Jalan) #19

Yes, good point! I’ll make it so.


(Dave McClure) #20

While you’re at it, would it be possible to make the large icon clickable as well?