Embedding a book from Google Books

(Christoph) #1

What’s the best practice for embedding an book preview from Google Books?

Google books provides both a plain link and an iframe, but neither of them work out of the box:

By “don’t work” I mean they don’t give me a onebox when pasted into discourse.

The only solution I see at the moment is to whitelist google.books.com using @Simon_Cossar’s whitelist-iframe plugin. Is this the best/only way forward?

(Daniela) #2

Take a look here https://discussbook.com/ and here view-source:https://discussbook.com/assets/plugin-third-party-6ae2c6dcefb0b7bf8b18b7b7f6c91a8882c9cde5f35e429cf3c2cb85fe77e855.js .

I think that site add a js script and a script src to include the API library Developer's Guide  |  Google Books APIs  |  Google Developers

(Christoph) #3

That books integration looks fascinating (though the previews don’t seem to work, I just get an empty lightbox). What I had in mind was oneboxing the preview, but this might also work (when it works), maybe even better.

I will have to look into that source code later to see what in those 1383 lines is relevant here (I am not a programmer).

Are you saying that the whole integration is done only via JS, no discourse plugin?

(Daniela) #4

I’m not sure, but you can ask to @net_deamon (see Discussbook on discourse, anybody interested? Not paid, but collaboration).

If he wrote a plugin you can ask him to share it

(Christoph) #5

I have successfully added google books to the iframe whitelist using the whitelist-iframe plugin. :tada: and it works just perfectly when pasting the iframe code that google books provides by default.

(Daniela) #6

A plugin has been released today:

(Christoph) #7

I know, I ordered some customizations for it :stuck_out_tongue_winking_eye: