A partial archive of meta.discourse.org as of Tuesday July 18, 2017.

Embedding Discourse on Ghost Blog

larsiusprime

I'm trying to do the embed-discourse-on-a-static-page thing, like @codinghorror and @eviltrout have done. I've followed all the instructions I can find (and searched all the previous suggested posts here on meta), and it doesn't seem to be working.

I'm using ghost, here's my blog: http://www.fortressofdoors.com

Here's my discourse embed settings:


I'm using the default Ghost theme, casper. I've modified post.hbs, and added this bit after the footer closing tag:

<script type="text/javascript">
    var discourseUrl = "http://discourse.leveluplabs.com ",
        discourseEmbedUrl = "http://www.fortressofdoors.com{{url}}";
(function() {
    var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
    d.src = discourseUrl + 'javascripts/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
})();
</script>

Furthermore, here's what I've got set up on the Ghost side of things:

I was able to get this working a long time ago, before I had set up the domain redirects. Back then, I was just using my raw digital ocean IP address instead of "discourse.leveluplabs.com" and I was using "fortressofdoors.ghost.io" for the ghost blog -- and this worked, I was able to import the blog posts, as well as see the embedded comments on the blog.

When the DNS for the redirects propagated, I switched to the new URL's and sometime after that everything stopped working.

Any thoughts?

UPDATE:
Not sure if it's relevant, but I noticed that I have duplicate entries for all my blog posts. I'm sorting that out manually now. Perhaps this is part of the problem?

eviltrout

Are there any errors in the logs? On your discussion server /logs might offer a hint as to what's not wired up properly!

larsiusprime

There's no /logs/ in /var/www/discourse, but there is a /log/ -- I assume that's what you meant and not itself a symptom that something's wrong?

production_errors.log has 2 long error dumps, both related to mail sending, and both dated May 23rd, I assume that was related to this previous (now fixed) issue of mine with mail-sending (turns out Mandrill was blocking my account).

Here's some spew from unicorn.stderr.log:

I, [2014-05-09T02:49:51.417329 #50]  INFO -- : Refreshing Gem list
I, [2014-05-09T02:50:11.833910 #50]  INFO -- : listening on addr=0.0.0.0:3000 fd=14
Loading Sidekiq in process id 90
I, [2014-05-09T02:50:15.775062 #117]  INFO -- : worker=0 ready
I, [2014-05-09T02:50:16.848710 #162]  INFO -- : worker=1 ready
I, [2014-05-09T02:50:17.810905 #50]  INFO -- : master process ready
I, [2014-05-09T02:50:17.831831 #182]  INFO -- : worker=2 ready
find: `/var/www/discourse/public/tombstone/default': No such file or directory
I, [2014-05-09T17:20:42.331619 #52]  INFO -- : Refreshing Gem list
I, [2014-05-09T17:20:54.147086 #52]  INFO -- : listening on addr=0.0.0.0:3000 fd=14
Loading Sidekiq in process id 81
I, [2014-05-09T17:20:56.619255 #128]  INFO -- : worker=0 ready
I, [2014-05-09T17:20:57.623547 #134]  INFO -- : worker=1 ready
I, [2014-05-09T17:20:58.623708 #52]  INFO -- : master process ready
I, [2014-05-09T17:20:58.632684 #139]  INFO -- : worker=2 ready
X-Accel-Mapping header missing
X-Accel-Mapping header missing
X-Accel-Mapping header missing
X-Accel-Mapping header missing
X-Accel-Mapping header missing
X-Accel-Mapping header missing
X-Accel-Mapping header missing
X-Accel-Mapping header missing
X-Accel-Mapping header missing
X-Accel-Mapping header missing
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
D, [2014-05-17T02:19:04.539762 #52] DEBUG -- : waiting 16.0s after suspend/hibernation
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
find: `/var/www/discourse/public/tombstone/default': No such file or directory
Error during failsafe response: invalid byte sequence in UTF-8
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/utils.rb:104:in `normalize_params'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/utils.rb:96:in `block in parse_nested_query'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/utils.rb:93:in `each'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/utils.rb:93:in `parse_nested_query'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/request.rb:373:in `parse_query'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/http/request.rb:313:in `parse_query'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/request.rb:188:in `GET'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/http/request.rb:274:in `GET'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/http/parameters.rb:16:in `parameters'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/http/filter_parameters.rb:37:in `filtered_parameters'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:22:in `process_action'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:136:in `process'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.1/lib/action_view/rendering.rb:30:in `process'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiling_methods.rb:79:in `block in profile_method'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_controller/metal.rb:195:in `dispatch'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_controller/metal.rb:231:in `block in action'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:80:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/routing> /route_set.rb:48:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/journey/router.rb:71:in `block in call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/journey/router.rb:59:in `each'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/journey/router.rb:59:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:676:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/show_exceptions.rb:46:in `render_exception'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/show_exceptions.rb:35:in `rescue in call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:38:in `call_app'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:22:in `call'
  /var/www/discourse/config/initializers/quiet_logger.rb:10:in `call_with_quiet_assets'
  /var/www/discourse/config/initializers/silence_logger.rb:24:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiler.rb:193:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/engine.rb:514:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/application.rb:144:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/railtie.rb:194:in `public_send'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/railtie.rb:194:in `method_missing'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:65:in `block 

in call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `each'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `call'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:572:in `process_client'
  /var/www/discourse/lib/middleware/unicorn_oobgc.rb:95:in `process_client'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:666:in `worker_loop'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:521:in `spawn_missing_workers'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:140:in `start'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/bin/unicorn:126:in `<top (required)>'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
  /var/www/discourse/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
D, [2014-05-21T15:38:41.896176 #52] DEBUG -- : waiting 16.0s after suspend/hibernation
find: `/var/www/discourse/public/tombstone/default': No such file or directory
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:206:in `pid=': Already running on PID:52 (or pid=/var/www/discourse/tmp/pi$
        from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:135:in `start'
        from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/bin/unicorn:126:in `<top (required)>'
        from /var/www/discourse/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
        from /var/www/discourse/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
I, [2014-05-22T19:01:54.940548 #59]  INFO -- : Refreshing Gem list
I, [2014-05-22T19:02:08.653515 #59]  INFO -- : listening on addr=0.0.0.0:3000 fd=11
Attempting to kill pid 81
Loading Sidekiq in process id 90
I, [2014-05-22T19:02:13.165951 #59]  INFO -- : master process ready
I, [2014-05-22T19:02:13.166531 #59]  INFO -- : reaped #<Process::Status: pid 137 exit 0> worker=0
I, [2014-05-22T19:02:13.166658 #59]  INFO -- : reaped #<Process::Status: pid 141 exit 0> worker=1
I, [2014-05-22T19:02:13.267569 #59]  INFO -- : reaped #<Process::Status: pid 145 exit 0> worker=2
I, [2014-05-22T19:02:13.267864 #59]  INFO -- : master complete
I, [2014-05-22T19:02:14.690944 #154]  INFO -- : Refreshing Gem list
E, [2014-05-22T19:02:24.551945 #154] ERROR -- : adding listener failed addr=0.0.0.0:3000 (in use)
E, [2014-05-22T19:02:24.552164 #154] ERROR -- : retrying in 0.5 seconds (4 tries left)
E, [2014-05-22T19:02:25.052683 #154] ERROR -- : adding listener failed addr=0.0.0.0:3000 (in use)
E, [2014-05-22T19:02:25.052897 #154] ERROR -- : retrying in 0.5 seconds (3 tries left)
E, [2014-05-22T19:02:25.553373 #154] ERROR -- : adding listener failed addr=0.0.0.0:3000 (in use)
E, [2014-05-22T19:02:25.553577 #154] ERROR -- : retrying in 0.5 seconds (2 tries left)
E, [2014-05-22T19:02:26.054088 #154] ERROR -- : adding listener failed addr=0.0.0.0:3000 (in use)
E, [2014-05-22T19:02:26.054282 #154] ERROR -- : retrying in 0.5 seconds (1 tries left)
E, [2014-05-22T19:02:26.554722 #154] ERROR -- : adding listener failed addr=0.0.0.0:3000 (in use)
E, [2014-05-22T19:02:26.554912 #154] ERROR -- : retrying in 0.5 seconds (0 tries left)
E, [2014-05-22T19:02:27.055480 #154] ERROR -- : adding listener failed addr=0.0.0.0:3000 (in use)
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/socket_helper.rb:185:in `bind': Address already in use - bind(2) (Errno::EADDRINUSE)
Lee_Ars

If you've got a current docker install, you can actually navigate to http://yourforum.whatever/logs now.

larsiusprime

oh neat! Lemme see if there's anything useful there.
Link for everybody:
http://discourse.leveluplabs.com/logs

EDIT 1: hey, I bet that's only visible to me when I'm logged in, right?

EDIT 2: A-ha! Perhaps this is the culprit:




exception: No such file or directory - www.fortressofdoors.com/rss/
context: {:current_db=>"default", :current_hostname=>"discourse.leveluplabs.com"}
backtrace: /usr/local/lib/ruby/2.0.0/open-uri.rb:36:in `initialize'
/usr/local/lib/ruby/2.0.0/open-uri.rb:36:in `open'
/usr/local/lib/ruby/2.0.0/open-uri.rb:36:in `open'
/var/www/discourse/app/jobs/scheduled/poll_feed.rb:30:in `poll_feed'
/var/www/discourse/app/jobs/scheduled/poll_feed.rb:16:in `execute'
/var/www/discourse/app/jobs/base.rb:131:in `block (2 levels) in perform'

But not sure what I would do about that? That location totally exists:
http://www.fortressofdoors.com/rss/

There's also a whole bunch of exceptions and errors about not being able to pull hotlinked images. Is that typical?

trident

Does the configuration item (sorry, I can't check the name at the moment) still havehttp:// in front? It looks like it's trying to read the RSS as a directory on your server and not a URL.

larsiusprime

It did not. It was www.fortressofdoors.com (no http) -- I just added the http.

I have www.fortressofdoors.com for "embeddable host")

I don't see any change as of right now, two questions:

  1. Do I have to restart Discourse?
  2. Is this prone to "cache" hell where I have to clear a bunch of cookies and reset everything before I check the Ghost page to purge false negatives?
trident

You shouldn't have to restart after making that change... of course by restarting you'll force the task that polls the feed to run.

Taking a look at your blog, it looks like you also don't have a trailing slash at the end of
discourseUrl = "http://discourse.leveluplabs.com"

Which is causing URLs like:
http://discourse.leveluplabs.comjavascripts/embed.js

Maybe that would fix it up?

larsiusprime

Yay!

That was the last thing apparently. It shows up in blog posts now! Though the little ms counter shows up in the upper left, is that normal?

EDIT: Artifact shows up in firefox, but not in chrome. Does it show up for any of you?

trident

Yes; you are actually logged in still so you will see anything an admin sees. Regular visitors won't see that, and you can always turn it off via the configuration page.

larsiusprime

Brilliant, so I should be good to go from here on out?

trident

I don't see any issues with it, of course if there are issues please let us know!

larsiusprime

Just posted a new blog post, and everything seems to work just fine! Discussion link shows up, and appears in the forum like it should.

I did notice that two old posts from the blog got dragged in (causing duplicates), but I deleted them. I'll see if that happens again, might be an artifact of getting this working then having it break and starting it up again.

larsiusprime

I am still getting more posts being pulled in from my blog. At first I was getting duplicates because some (but not all) had been pulled in before, but now the ones being pulled in every few hours seem to be ones that were never imported the first time. So that's fine, I assume it'll eventually get all of them (it seems to be working its way backwards).

One thing that is consistent is that all imported blog posts are time-stamped from when they were imported (ie today), so I have to manually reset the timestep to match the date the blog was originally posted, as in this thread:

Now, the embed settings are probably pretty content-agnostic so I'm not sure how they would know what timestamp to infer. That said, this use-case seems like a feature that a lot of people will want, especially if they have a bunch of legacy blog content, and hopefully some standard blog formats / rss feeds could be targeted. It's weird to have a blog post from 3 years ago pop onto the front page of my forum as if I just wrote it today. Short of that, being able to set a timestamp from the admin menu would be swell.

riking

I suggest you load every single blog post in your web browser (just keep following your next/prev links), then you can fix the dates of all of them in one shot.

(Non-imported posts will be imported the first time someone visits them and runs the embed script, if I understand it correctly.)

larsiusprime

Alrighty, that seems to work. Lot of posts to manually reset!

I'm also noticing that images aren't always loading correctly, I see errors like this in my /logs/, and I'm not seeing images in many of the imported posts:

Failed to pull hotlinked image: http://files.fortressofdoors.com/images/openfl.png
undefined method `close!' for #<StringIO:0x007f215293fe98>
/var/www/discourse/lib/file_helper.rb:21:in `block in download'
/var/www/discourse/lib/file_helper.rb:16:in `open'
/var/www/discourse/lib/file_helper.rb:16:in `download'
/var/www/discourse/app/jobs/regular/pull_hotlinked_images.rb:37:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:237:in `block in each'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `upto'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `each'
/var/www/discourse/app/jobs/regular/pull_hotlinked_images.rb:27:in `execute'
/var/www/discourse/app/jobs/base.rb:131:in `block (2 levels) in perform'

wassimseif

Hello,
Can someone please tell me if what i’m thinking about is doable or not ?
I have a ghost blog running. for each post i publish i want a discussion to be created with the same name of the post. add the discussion replies to be available in the comments section in the blog post. with a ‘continue discussion’ button that would redirect to the discussion on discourse instance

oblakeerickson

I’m pretty sure that is how https://blog.codinghorror.com/ works.