Communities with embedded Twitter Feeds

Not working for me. I only see a link test timeline. I did add both scripts to <\head> & css desktop.

Try the theme component smartey linked a few posts up instead.

I installed the theme component, but, for some reason it is still showing me only link for time line on the side bar not the tweets.

image

Don’t know what to tell you. I had some issues with it loading the feed until I added

<script type="text/discourse-plugin" version="0.8">
    api.onPageChange(() => {
        twttr.widgets.load( document.getElementById("sidebar") );
    });
</script>

But that’s in the component so if it’s not working for you the only thing I can think of is look in your Security Settings for the content security policy setting and if you have this checked
image
I don’t think the twitter scripts will work.

This is pretty neat. I tried it out and it works well. Nice job!

When I first saw this topic I thought it was going to be a bit different. In my community, many members also have Twitter. It is a challenge to encourage them to have deeper, longer term conversations on the forum about things they tweet about. An interface to see a feed and start a topic about a tweet would be interesting! Maybe the feed could be a hashtag? Or they could see their own twitter feed on their profile and start topics from there.

1 Like

Thanks Smertey, I unchecked content security policy it seems to be working now. Unchecking this option has any security risks ?

Yes, unchecking that setting is not recommended. CSP - content security policy - is on by default for very good reasons. If you need to whitelist some scripts that would normally be flagged by CSP, you can add them to the content_security_policy_script_src setting on your site and they would then work without issue. You can read

if you want to learn more about this.

2 Likes

Doesn’t that setting come unchecked by default?

No, that setting has been on by default for a while now.

https://github.com/discourse/discourse/pull/6873

2 Likes

Weird, our site didn’t even exist in Jan but our default is not checked

Thanks Joe,
I white listed scripts for twitter time line, It works now with CSP option checked.

Is it possible to change background color of twitter time line to match with the forum background ?

Not easily because it’s in an iFrame so you can’t just add CSS but there are various suggestions on stackexchange, but not sure which work, for example

html - Styling a Twitter feed - CSS won't target .timeline-Tweet-text - Stack Overflow.

Because of lazy loading (sorry if this isn’t the correct term) on discourse, I think any js solution will require

<script type="text/discourse-plugin" version="0.8">
    api.onPageChange(() => {
       Do Stuff Here
    });
</script>

Hi,

After installing twiiter sidebar to production we are having issues with Dashboard cannot load “Signups” or any individual report it just keeps loading never loads. Discourse version is 2.4.1 recently upgraded. When I remove Twitter side bar component it works fine. Any ideas why this would happen ?

Thanks

Do you have content security policy enabled? I have it working with these settings

I’m running 2.5.0.beta2. No idea what it could have to do with reports but I can generate all the reports on my sites

I have the same settings as you for security policy. When I remove Twitter Sidebar reports start working for some reason.

Sorry, I really have no idea how to go about troubleshooting something involving a conflict with site reports

The error is TypeError: document.getElementById(…) is null

image

Apparently the #sidebar div is not inserted on every page?

It can be fixed by properly checking if the element is not null.

api.onPageChange(() => {
    if (Discourse.User.current() !== null){ 
        var sb = document.getElementById("sidebar")
        if (sb) { 
            sb.style.display = "block"; 
        }
    } 
});
api.onPageChange(() => { 
    var is_iPad = navigator.userAgent.match(/iPad/i) != null;
    if(is_iPad)  {
        var sb = document.getElementById("sidebar")
        if (sb) { 
            sb.style.display = "none"; 
        }
    }
});
3 Likes

Is there any one, who can help me to embedd Twitter feed, like they have on the sidebar?

I fully support this idea. Has anyone tried with success to get rid of twitter addiction from their community ?

1 Like