Links without sub-folder path in embedded comments (Continue Discussion and user links)


(Sergei Petrunin) #1

I’ve just found a bug with combination of embedded comments and sub-folder installation:
‘Continue Discussion’ button and user links does not respect subfolder path.
But ‘Start Discussion’ button does respect subfolder path.
So I can only post once on embedded thread.

Here is the example: http://nsr24.com/football/game/705041
Discourse installed into: http://nsr24.com/social/en/
‘Start Discussion’ url is http://nsr24.com/social/en/t/bournemouth-west-ham-united-new-sports-rating/13
’Continue Discussion’ url is just /t/bournemouth-west-ham-united-new-sports-rating/13

Discourse Version v1.5.0.beta8 +11 (Docker + subfolder official guide)


Embedding Discourse Comments via Javascript
(Sergei Petrunin) #2

A quick and dirty work-around I can come up with is the following:
add this javascript to Discourse embedded code so the full Discourse code will be:

DiscourseEmbed = { discourseUrl: 'http://nsr24.com/social/en/',
                   discourseEmbedUrl: window.location.href };

(function() {
    var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
    d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);

    // Temporary work around
    setTimeout(function () {
        $('#discourse-embed-frame').contents().find("a").each(function () {
            var value = $(this).attr('href');
            if (!value.startsWith('http')) {
                $(this).attr('href', 'http://nsr24.com/social/en' + value);
            }
        })
    }, 3000);
})();

Hope this help later in debugging this problem.


(Robin Ward) #3

I think this commit should fix you up:


(Jeff Atwood) #4

(Jeff Atwood) #5

(Sergei Petrunin) #6

Thank you very much!
I apply this patch in my installation, and during application figured out two more places with similar problems:
You forget to fix /users/ links at app/views/embed/comments.html.erb lines 19 and 23


(Sergei Petrunin) #7

I created a Pull Request, it should completely fix this issue.


(Robin Ward) #8

Merged it in, thanks!


(Robin Ward) #9