Embedding Discourse Comments via Javascript

embedding

(Robin Ward) #27

If that works for you it sounds correct!


(Barry Parr) #28

My CMS automatically turns some characters into HTML entities. Any of the HTML entities show up in my forum headline, rather than the characters. so this headline:

First annual Half Moon Bay Fish & Fleet Festival, Sunday, Sept 27 

Shows up as:

First annual Half Moon Bay Fish & Fleet Festival, Sunday, Sept 27 

… as a topic title. This is not a problem with the text of the of the body, in which the entities are translated in the the correct characters, only with the topic titles.


(John ) #30

w00t.

Can I also apply styling to the embedded content from the custom CSS/HTML settings at /admin/customize/css_html?


(Jeff Atwood) #31

It’s under Admin, Customize, CSS/Html, Embedded CSS


(Jeff Atwood) split this topic #32

24 posts were split to a new topic: Embedding, but not automatically create a topic until a user chooses to comment


Embedding, but don't automatically create a topic until a user chooses to comment
Embedding, but don't automatically create a topic until a user chooses to comment
(Puneet Goel) #46

I am trying to embed comments into my middleman based blog. My discourse installation is on SSL and uses subfolder. After going through all the installation steps, I get the following error in the logs when I visit the blog page. And nothing shows up in the comments part of the blog.

Uncaught TypeError: Cannot read property 'forEach' of undefined Url: https://example.com/forum/embed/comments?embed_url=http%3A%2F%2Fmyblog.com%2Finitial-commit%2F

What could be wrong? Are embedded comments supported for a subfolder Discourse installation?


Subfolder support with Docker
(Robin Ward) #49

I just tested out embedding with a subfolder and it worked. Make sure your discourseUrl variable includes the path. For example:

discourseUrl: 'http://your-site.com/folder/'

(Guillaume Lapierre) #57

Is it possible to add the category in the DiscourseEmbed object? Something like:

  DiscourseEmbed = { discourseUrl: 'http://discourse.example.com/',
                     discourseEmbedUrl: 'http://example.com/blog/entry-123.html' 
                     discourseCategory: ['blog'] };

The category could be already existing ou created on the fly as a sub-category of the category specified in the embed configuration.

Why would this be great?
Many blogs have a category system for blog posts and this could map blog entrie’s category (categories!) to discourse ones. If automatic creation of sub-categories is not possible I still wish to have a way to specify a category as I have 3 main sections on my website (blog entries, DVD database, other media database) and this would be great to categorize them automatically.

Thanks!


Embedding: How to post to different categories from one site?
(Felix Freiberger) #58

I might be mistaken, but this sounds terribly insecure: Every visitor of the site could manipulate this data and miscategorize your posts or create new categories.


(Guillaume Lapierre) #59

This would be indeed fairly insecure. To securize things we could have different (hopefully complementary) approches:

  • the category should exists beforehand. This is the first approach I had when I though of this system to put appart posts from different sections of my website (the blog being only one of those)
  • when parsing the Atom feed Discourse could parse the <category/> tags to add to the corresponding posts. Ideally discourse would let me specify a scheme filter for those tags as my Atom feed add categories and keywords as categories under two different schemes (movable type). Parsing a RSS feed on the server, the categories cannot be compromised (well… not easily) and so creating inexisting one should not be an issue. Still I would prefer if those could be child of a parent category (specified on the Atom feed settings maybe)

(Robin Ward) #60

I am definitely wary of putting the category into the embed code for the security reasons @fefrei just brought up.

Having said that, adding it to the feed as a parameter (like embed_by_username) sounds secure and might work for you?


(Guillaume Lapierre) #61

embed_by_username could work if I could add multiple atom feeds with different settings which does not seem to be an option. I can externally merge the 3 different atom feeds to give to discourse but this would involve having something more like embed-username-key-from-feed


(Robin Ward) #62

Sorry I wrote the wrong field name there. embed_username_key_from_feed does exactly that, but you want it for a category right?


(Guillaume Lapierre) #63

Exactly. As i wrote earlier if it had some kind of xpath syntax to match only some catégories based on scheme attribute value it would be perfect


(Jesse Perry) #77

I read this whole thread and couldn’t find an answer, so apologies if it’s already been stated… but is there a way to reverse the order of comments that appear? Specifically, have the latest comment at the top? The first post of a topic isn’t necessarily the best :stuck_out_tongue_winking_eye:

Or better yet… sort the posts that appear by number of likes to the post. Really whet the visitor’s appetite to click over to Discourse :yum: (but that’s more/different work, so in the interim showing latest at the top would be great)


(omfg) #78

Sorting by likes would show disjointed random stuff.


(Robin Ward) #79

Unfortunately not! Our Wordpress plugin offers a “best” filter but the embedding engine does not. I’d definitely support a pull request that added this functionality if someone wants to take a stab at it.


#84

Hey, its a great feature and it worked like a charm, but i ran into a strange error as I am new to this I am not able to find a workaround it…
The comments that are shown on my blog site are being cropped and this is because iframe in <div id="discourse-comments"></div> is not taking the desired height.

I tried using discourse-embed-comments plugin for discourse but in vain.
Any suggestions… ??


#85

I’ve run into quick a puzzler.

My client has their website hosted on Tumblr and I’m trying to implement the embedded comments. I built everything on an alternate account before overwriting their current design and it worked flawlessly. However, when I moved everything over to their account using the exact same code, it won’t generate topics. It’s just stuck on the “loading discussion” bit and the console throws me this:

Refused to display 'http://board.ttvpodcast.com/embed/comments?embed_url=http%3A%2F%2Fttvpodcas…2Fpost%2F135892237137%2Fttv-no-longer-reporting-on-confidential-leaks-this' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.


(Kane York) #86

You need to make sure the domain is permitted in the embedding settings. Go to /admin/customize/embedding and add the second domain.