Embedded Tweets

Avatar

By bem 18 August 2016 16:20

Member · 118 comments

Is there any plans to include this in the forum software? Seen it with a few now where you can and it's quite cool. Saves linking to it off page and looks better than just a quote. Should even be easy enough to do through the current parser.

Avatar

By Yannick 18 August 2016 20:15

Administrator · 1,390 comments

I'm planning support for a number of embeds for Luna 3.0. Might look into it for 2.1, but I can't promise that yet.


You can do anything

Avatar

By bem 18 August 2016 20:20

Member · 118 comments

ooh... what embeds are you planning for Lina 3?

No worries if it's not in 2.1, it's not an important one. More a nice one.

Avatar

By Yannick 18 August 2016 21:02

Administrator · 1,390 comments

Besides a better implementation for the DailyMotion, Vimeo and YouTube embed, I'm considering embeds for Twitter, Instagram, Facebook and Vine. These 4 are currently under consideration, if anything changes, it will be noted on the Luna Glitter ship list and scroll all the way down to "Ideas under consideration".


You can do anything

Avatar

By bem 27 September 2016 17:32

Member · 118 comments

In case anyone wants to embed tweets in their forums, this is how I've done it for now. The following is added into parser.php in the appropriate places.

$pattern[] = '%\[tweet\](.*?)\[/tweet\]%ms';
$replace[] = '<script type="text/javascript"> function loadx(data) { document.write(data.html); } </script> <script type="text/javascript" src="https://api.twitter.com/1/statuses/oembed.json?id=$1&callback=loadx"></script><div class="twitter" onLoad="loadx().html"/></div>';

You open a tweet, and you take the end part that I've bolded: https://twitter.com/2000AD/status/780820297876254721 and put it in between the new [tweet] tags. Was the easiest way I could find to do it.

Avatar

By Yannick 27 September 2016 20:08

Administrator · 1,390 comments

Just that all of you are aware of this too, Luna 3 will likely use the following convention:

[embed]https://twitter.com/GetLunadotorg/status/692741159890853892[/embed]

So that might be something to keep in mind for backwards compatibility.


You can do anything

Avatar

By bem 27 September 2016 21:00

Member · 118 comments

Oooh, that's interesting. I could't work out how to do it like that, as that's how I initially wanted it. I might hold of deploying it properly on mine then for now whilst I continue looking at it.

It's a great thing to add though. Haven't looked at the others yet... I'm okay at adding one in, but not sure I'd be able to work many to work with one tag. Something that I need to look into really as it's fun to learn.

Avatar

By Yannick 30 September 2016 10:15

Administrator · 1,390 comments

Perhaps it's useful to take a look at the code behind the video-tag which should be basically the same. That tag is also able to handle DailyMotion, Vimeo and YouTube.


You can do anything

Avatar

By bem 30 September 2016 21:43

Member · 118 comments

I got it working with the following:

$pattern[] = '%\[embed\](\[url\])?([^\[<]*?)/status/([^_\[<]*?)(_([^\[<]*?))?(\[/url\])?\[/embed\]%ms';
$replace[] = '<script type="text/javascript"> function loadx(data) { document.write(data.html); } </script> <script type="text/javascript" src="https://api.twitter.com/1/statuses/oembed.json?id=$3&callback=loadx"></script><div class="twitter" onLoad="loadx().html"/></div>';

Not perfect I'm sure, but it works. I tried getting it so that you have to put in the whole twitter.com domain, but couldn't get that to work at all. Doesn't matter though really, since it will only work with the right URL.

Got Instagram to work as well. Not sure how you'd add do it through the standard way of embedding. Best I could do was to just embed the image - with no text, no indication that it's from Instagra,m etc. Their standard embedding code is an absolute mess though.

And Facebook doesn't look like it will be fun. Might wait for this one 😉

Last edited by bem (30 September 2016 23:02)

Avatar

By bem 2 October 2016 17:03

Member · 118 comments

Facebook was easier than I thought. Instragram is the only one where it doesn't look right, as it's essentially just adding an image by using the URL of the post. You don't get the text or anything like that... unless there's another way of embedding an Instagram post that I don't know about (not using the embeded option which just looks an absolute mess). Not too fussed on Instagram though. Happy with the Twitter and Facebook ones.

$pattern[] = '%\[embed\](\[url\])?([^\[<]*?)/posts/([^_\[<]*?)(_([^\[<]*?))?(\[/url\])?\[/embed\]%ms';

$replace[] = '<div class="fb-post" data-href="$2/posts/$3/" data-show-text="true"><blockquote cite="$2/posts/$3/" class="fb-xfbml-parse-ignore">Posted by <a href="$2">Facebook</a> on&nbsp;<a href="$2/posts/$3/">Thursday, 27 August 2015</a></blockquote></div>';

Last edited by bem (2 October 2016 17:30)