Embedding Tweets

zoogs..

OK, the js order thing I had in my head doesn't really make sense after all.

We're writing the script tag right after the blockquote tag in the media tag so it should execute when it's encountered. If every block quote has a script tag right after it, it should work.

I wonder if there is something else going on with your browser. can you check at home too?

Also, what browser are you using at work?

 
Last edited by a moderator:
Is there a shortcut to getting the URL that I'm missing? If I see a tweet in my Home page (from someone I follow) that I want to post, I have to click on the user to go to their feed then click on the tweet I want to get to the URL for that particular tweet. It's not bad but I was just wondering if there was a shorter way.
https://support.twitter.com/articles/80586-linking-to-an-individual-tweet#

You can click Details, that will go right to that tweet. Then just copy the URL out of the address bar

 
zoogs..

OK, the js order thing I had in my head doesn't really make sense after all.

We're writing the script tag right after the blockquote tag in the media tag so it should execute when it's encountered. If every block quote has a script tag right after it, it should work.
I'm a little confused here, but I haven't been keeping up with the implementation. There shouldn't be a script tag after every instance of the blockquote tag, should there? In other words, if one page of a thread has 20 embedded tweets, there are 20 script tags sourcing the same file?

Wouldn't it make more sense to serve the script tag to every page via, say the includeJS template?

Unable to see anything in Chrome.

 
Last edited by a moderator:
Also, what browser are you using at work?
Was this directed at me? If so:

Firefox 35.0.1 and IE 9.0.35

I'm on a PC (HP)

If that wasn't directed at me.... nevermind.
default_biggrin.png


 
zoogs..

OK, the js order thing I had in my head doesn't really make sense after all.

We're writing the script tag right after the blockquote tag in the media tag so it should execute when it's encountered. If every block quote has a script tag right after it, it should work.
I'm a little confused here, but I haven't been keeping up with the implementation. There shouldn't be a script tag after every instance of the blockquote tag, should there? In other words, if one page of a thread has 20 embedded tweets, there are 20 script tags sourcing the same file?

Wouldn't it make more sense to serve the script tag to every page via, say the includeJS template?

Unable to see anything in Chrome.
You're right, it would be more optimal to have the JS execute after the DOM is ready, then it would change all the blockquotes. The guy who put the media tag in just did it every time.

It's not optimal, but I was thinking that it should technically work. If the JS file is already loaded on the page it shouldn't load again. The browser should be smarter than that.

I'll shove the JS into the includeJS template and see what happens.

Oh and one thing I've learned too through this is that the post cache is a b!^@h
default_smile.png


 
Last edited by a moderator:
Zoogs, can you open the developer tools in chrome (F12), go to the console and reload a page that has tweets on it? Do you get any console output that relates to not being able to load the widget.js file?

 
What's the post cache?

It looks to me like this isn't something that transforms the twitter links upon post submission. (Not the [media] tag, right? That was for videos, I thought). When I click edit on your post, I see the post content is just a link. So it seems like the script goes through every post on a page, scans for twitter links, and then fetches the content somehow and displays them properly. Is that what it's doing? It's weird, the link in the OP suggests it works on all browsers. Odd, this sort of thing should be working out of box then.

 
Zoogs, can you open the developer tools in chrome (F12), go to the console and reload a page that has tweets on it? Do you get any console output that relates to not being able to load the widget.js file?
Aha! Yes. It was being blocked by client -- in my case, the Ghostery plugin for Chrome.

I unblocked the Twitter Widget (which I am guessing is how it gets the post content) and can see it now. However, it seems like there should be a failsafe built in, so that if widgets.js isn't being loaded, we're left with the original post content (i.e, the link) instead of nothing.

 
What's the post cache?

It looks to me like this isn't something that transforms the twitter links upon post submission. (Not the [media] tag, right? That was for videos, I thought). When I click edit on your post, I see the post content is just a link. So it seems like the script goes through every post on a page, scans for twitter links, and then fetches the content somehow and displays them properly. Is that what it's doing? It's weird, the link in the OP suggests it works on all browsers. Odd, this sort of thing should be working out of box then.
When a post is rendered, the board software takes the raw post content and translates the "BBCode" into HTML. It stores this HTML in a table in the database called ibf_content_cache_posts. It will fetch the HTML from this table if a post is there in order to save time and resources. Pretty typical in web apps.

The media tag works like this. It looks in your post and if it finds text of a certain format, like

https://twitter.com/{user}/status/{statusID}.

It replaces that with some HTML. In this case..

Code:
<blockquote class="twitter-tweet"><a href="[URL="https://twitter.com/%241/status/%242"]https://twitter.com/$1/status/$2[/URL]"></a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
 
Last edited by a moderator:
Also, what browser are you using at work?
Was this directed at me? If so:

Firefox 35.0.1 and IE 9.0.35

I'm on a PC (HP)

If that wasn't directed at me.... nevermind.
default_biggrin.png
If it's not working for you, we need to figure out why too
default_smile.png
Do you have any ad blocking or other plugins enabled? Can you get to twitter.com?

I haven't tried it in IE 9, but Firefox should work.

 
Forgive me if it's already been explained but does the embed display the Twitter link at the bottom on purpose? Other than that, perfect.

 
Last edited by a moderator:
Try the F12 thing knapp. Firefox should have a similar Console that might give a message if widgets.js is being blocked *somehow*.

Addict, yeah, the link thing is new in case the widget won't display otherwise.

 
Last edited by a moderator:
Back
Top