ElkArte Community

Elk Development => Feature Discussion => Topic started by: meetdilip on April 13, 2016, 07:52:10 am

Title: Link Preview
Post by: meetdilip on April 13, 2016, 07:52:10 am
I like the way Facebook interprets when a link is posted on their editor. Instead of giving a plain line of text it give a preview of what the link contains. In case of ElkArte, may be we can offer it on hover. But it looks like an interesting idea to have on board

Title: Re: Link Preview
Post by: Frenzie on April 13, 2016, 08:00:00 am
Facebook uses something they call OpenGraph.

https://davidwalsh.name/facebook-meta-tags

A quick search based on that knowledge suggests you could probably stick https://github.com/markserbol/urlive on your page.

As a default I think such a thing would probably be too heavy.
Title: Re: Link Preview
Post by: nend on April 14, 2016, 11:59:35 pm
LOL, funny thing is I made this for SMF and it isn't as popular as I thought it would be.

The code is a little sloppy because I was planning it for only Open Graph, but then I had to add oEmbed and Meta support.

SMF Mod Site
http://custom.simplemachines.org/mods/index.php?mod=4075

GitHub
https://github.com/sicommnend/SMF-Open-Embed

Some Demos
http://dev.sicomm.us/index.php?board=2.0;sort=subject

Considering the nature of the license, if any one wants to adapt or improve upon it, go ahead. Also if you don't mind push me some commits of any improvements.  ;)
Title: Re: Link Preview
Post by: meetdilip on April 15, 2016, 06:50:42 am
@nend , the intension is to give preview of plain links not media links. That's what the mod does ?
Title: Re: Link Preview
Post by: emanuele on April 15, 2016, 07:21:02 am
What irks me about this "stuff" is that posting a link on FB/TW/G+/WhatEver it is likely to be the only thing you are ever going to post, so it kind of make sense to have a preview of the content, but if you put an url in a message on a forum, it's unlikely to be the only thing posted in the body of the text, let's take nend's post as an example, using this approach, the final result would be something like:
Quote from: nend – LOL, funny thing is I made this for SMF and it isn't as popular as I thought it would be.

The code is a little sloppy because I was planning it for only Open Graph, but then I had to add oEmbed and Meta support.

SMF Mod Site
(http://www.ElkArte.net/community/index.php?action=dlattach;topic=3476.0;attach=3521;image)

GitHub
(http://www.ElkArte.net/community/index.php?action=dlattach;topic=3476.0;attach=3521;image)

Some Demos
(http://www.ElkArte.net/community/index.php?action=dlattach;topic=3476.0;attach=3521;image)

Considering the nature of the license, if any one wants to adapt or improve upon it, go ahead. Also if you don't mind push me some commits of any improvements.  ;)

that, it kind of... sucks, IMO.
Anyway, addons are possible, so go for it! :P
Title: Re: Link Preview
Post by: meetdilip on April 15, 2016, 07:22:29 am
I would suggest " Preview on Hover " in that case. Just like some forum software gives preview of content when you hover on topic in topic index.
Title: Re: Link Preview
Post by: emanuele on April 15, 2016, 07:49:30 am
Oops, missed that part.
Then, another "problem"[1] is with mobile devices where hovering basically doesn't exist.
I'm not trying to sink the idea, I'm just pointing out edge cases that may (or may not, up to you proposing it and to those that will implement it) be relevant or source of discussion/improvements.
Title: Re: Link Preview
Post by: meetdilip on April 15, 2016, 08:09:32 am
Ok :)
Title: Re: Link Preview
Post by: meetdilip on April 15, 2016, 08:30:55 am
Now that I think of it, how about a custom BB code which will give link preview to a link ? In that case, we can posters can themselves decide whether or not to add a " Link Preview ".
Title: Re: Link Preview
Post by: nend on April 15, 2016, 08:38:10 am
Quote from: meetdilip – @nend , the intension is to give preview of plain links not media links. That's what the mod does ?
It does both, Emanuele's posted example is what it does. If OG information doesn't exist it tries oEmbed and Meta. If the webmaster is lazy and doesn't supply any information in the head then it falls through to a normal link.

Main inspiration when creating this was the sloppy embed mods, you know the ones "Embed something BBC". Then they usually have a huge array just to parse the content. It's like why would I want to go that route to embed stuff when there are frameworks and standards available.
Title: Re: Link Preview
Post by: nend on April 15, 2016, 08:59:11 am
Quote from: meetdilip – Now that I think of it, how about a custom BB code which will give link preview to a link ? In that case, we can posters can themselves decide whether or not to add a " Link Preview ".
Sort of posted at same time. That's what this modification does.

Quote from: emanuele – that, it kind of... sucks, IMO.
Anyway, addons are possible, so go for it! :P
Missed this. Due to my current situation at SM, I'll not be rewriting it for Elk. However if someone is wanting to use any bit of it or use it as a reference...
Title: Re: Link Preview
Post by: emanuele on April 15, 2016, 09:14:08 am
Quote from: nend – Due to my current situation at SM
Noticed only now, should I say congratz? :P
Title: Re: Link Preview
Post by: meetdilip on April 15, 2016, 10:15:29 am
What's wrong ? Elk developers are not welcome at SM ?
Title: Re: Link Preview
Post by: emanuele on April 15, 2016, 11:14:07 am
Well, I know how it feels, and not because it's SMF, but just because it is strange to contribute to two projects that shared what Elk and SMF share.
On the other hands, others like live627 have ported their mods even while being on the SMF team, so it's not that stranage, just a personal choice. Completely understandable. ;)
Title: Re: Link Preview
Post by: nend on April 15, 2016, 11:25:18 am
Yeah it's more personal. I haven't looked at what changed in the two systems, so there's the learning curve. If I take on something else, then I have to take time away from other things.