Tech Note: Embedded Tweets in Comments and Pages
We have some new features to announce, designed to make it much simpler to place embedded tweets from Twitter in comments and LGF Pages.
All you have to do to insert an embedded tweet is paste in the URL of the tweet’s ‘Details’ page at Twitter. For example, here’s the page for my tweet about the previous article.
You get to these individual tweet pages at Twitter by clicking the time/date on any tweet, or by expanding it (by clicking inside it) and then clicking the ‘Details’ link.
When your comment or Page is posted, the URL of the tweet will be automatically transformed by the LGF Blog Engine (through the magic of regular expressions and Twitter’s oEmbed API) into the HTML code that shows the full text of the tweet. This HTML code can then be further transformed into the actual Twitter-formatted embedded tweet, with links for following, replying, retweeting, etc.
Unfortunately, that final step can only happen at page load time; the Twitter API doesn’t have a method of rendering the embedded tweet dynamically yet. This means that if you post a comment through our Ajax system, you won’t see the final Twitter-formatted tweet — but you will see the full text of the tweet with a credit line and links to the author, so it’s still useful. You’ll see the final embedded tweet the next time you reload the entire page.
For LGF Pages authors, there’s another nice feature. When you use the LGF Pages bookmarklet on any Twitter details page, the Pages posting form will open up with the code for the embedded tweet already inserted in the editing box — you don’t even have to copy or paste anything.