Google docs onebox gem requires a "published" document

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

3 Likes

Added on my list. :pencil:

4 Likes

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.


2 Likes

Can we convert the URLs into the publish form automatically?

May want to build on top of https://github.com/discourse/onebox/pull/307 so we don’t get iframe flashing.

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.

:+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?

2 Likes

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

1 Like

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.

3 Likes

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?

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

1 Like

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.)

4 Likes

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.

4 Likes

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

1 Like

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:

1 Like

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…

7 Likes

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)

3 Likes

Okay, this is now done.

Sheet:

Document:

Form:

Slide:

11 Likes

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:

11 Likes

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

5 Likes

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

5 Likes