This addon will beautify links by displaying the page title instead of the url. Should also work on internal links by changing the link to the thread title. This one does make 2 source edits :-X since it adds a checkbox to the post template advanced option section to disable the function for a particular post as some links are better left as URL's
Descriptive Links v1.0.4
License
o This ElkArte Addon is subject to the terms of the Mozilla Public License version 1.1 (the "License"). You can obtain a copy of the License at http://mozilla.org/MPL/1.1/
Introduction
o Adds capability to automatically update links in posts to display the links website/page title instead of the url.
o Converts internal links to show the topic subject or board name as appropriate, external links to website title
o Optional length and generic name protection to avoid changing links to things like Login, Welcome, etc
o Optionally convert links contained inside of BBC URL codes
o Permissions to allow users to disable link conversion on a per post basis (under post additional options)
o Only converts links when the post is saved or modified, ensuring no performance impact during normal message viewing.
Repository / Download
https://addons.elkarte.net/enhancement/Descriptive-Links.html
/me likes what he is seeing in this board! :D
simple and nice addon, I like it ;)
not a critique but a little advice to make it looking better: is it possible to get the favicon of the domain near the link?
http://www.elkarte.net/community/index.php?topic=1419.0 O:-)
Perfect! I missed that topic ;)
Looking at places where hooks can be added. I think the edit in Post.controller.php could be done with a hook. I think it would be integrate_post_after. Maybe the JS edit as well.
Thanks, I'll take another look at this one :)
Nice one @Spuds.
I guess it may be relevant here. :P
I've been asked on the Italian board if there was a way (in SMF) to incorporate moar stuff in the body (the detailed description was "like facebook", but I'm not very expert of FB so I took G+ as example) and I modified Descriptive links to obtain:
http://testing.elkarte.it/smf20/index.php?topic=3.0
/me wonders if teh Spuds thinks it's something that fits the Elk addon. O:-)
Of course done a little bit better. LOL
Interesting ... could add that for sure! ... maybe an option for compact or extended descriptions.
What data did you pull from the page scrape, or is it some other data that you are getting. As you know the default is just the page title.
I took inspiration from G+ and first analysed the og:* meta tag title, description, url and image. Then as fallback the title tag and the first image in the page. This last one in particular is very prone to errors and may require some "informed decision" (in the form of avoid images smaller than, avoid images with some particular name, etc.).
I was also thinking about a max-image-size (with either cropping or just scaling) and maybe a tag to better format the whole stuff (at the moment I'm encapsulating everything into a table and... well, the result is not really up to the expectations. lol
Suppose one could also look for twitter:* but Google docs don't seem to mention those. They do talk about Schema.org data as well, but that looks like a lot to try and parse, but we would only look for it in the body tags I'd guess.
Seems just doing og: and then title as the fallback is a good choice. I don't think you would want all of that info for a normal post where you add a link. Maybe the option would be in the "additional" area where its something like use enhanced link snippet if available?
Or: do it in a tooltip and/or only if the link is the only thing posted?
There are few variants that could be considered, yep.
Regarding what to try... well, once you have the body of the page, do one or two tests shouldn't be much of an overhead. :P
Is there a way to run a script on the database to change all previously saved links in posts like the addon does? I installed it, but I wish all links till now could be changed.
Thank you, I will test it.
It seems the addon has another problem with links.
http://www.sueddeutsche.de/auto/abgaswerte-renault-ruft-wegen-zu-hoher-abgaswerte-autos-zurueck-1.2824623
If I post this link in a post, it is invisible. If I edit the post then, the code is:
[url=http://www.sueddeutsche.de/auto/abgaswerte-renault-ruft-wegen-zu-hoher-abgaswerte-autos-zurueck-1.2824623][/url]
He was kidnapped...I am sure. ;)
LOL. He is on holiday I supposed. He'll be back soon, I think.
Granted! ;)
http://www.elkarte.it/community/index.php?topic=13.msg48#msg48
Seems to work as expected.
Is it the only one giving issues?
test copy/paste link
http://www.mak-boerse.de/fahrzeug/toyota-yaris-hybrid-comfort-klimaautom-8-fach-bereift-/abea660aece0427084fc28042a7a2049#/
test insert link from editor
test (http://www.mak-boerse.de/fahrzeug/toyota-yaris-hybrid-comfort-klimaautom-8-fach-bereift-/abea660aece0427084fc28042a7a2049#/)
another test with visual editor enabled:
copy/paste link
http://www.mak-boerse.de/fahrzeug/toyota-yaris-hybrid-comfort-klimaautom-8-fach-bereift-/abea660aece0427084fc28042a7a2049#/with button "Insert link" from editor:test (http://www.mak-boerse.de/fahrzeug/toyota-yaris-hybrid-comfort-klimaautom-8-fach-bereift-/abea660aece0427084fc28042a7a2049#/)
@radu81 this problem is likely a problem with the addon. ;)
that's why I did the test, try to edit or quote this message to see the missing link.
I tried the two links on my local and they both worked fine, returning the title from the website.
I'm not sure why it would add a blank link, there is a check for that condition. But somehow when the site page fetch occurs and fails its inserting the blank.
I've added a couple of additional checks to perhaps catch this condition, so replace your old file with this one (in your sources/subs directory) and see if you still get blank ones.
Note its not going to fix/prevent someone from adding blank ones, thats really a bit of a elkarte bug IMO
Tried, thanks. With this file the link is showing the URL (not the page title), but that's better then before!
http://www.mak-boerse.de/fahrzeug/toyota-yaris-hybrid-comfort-klimaautom-8-fach-bereift-/abea660aece0427084fc28042a7a2049#/
Good :D ... that is what is supposed to happen (showing of the original link) should it be unable to fetch the page.
As to why it failed .... This generally indicates a timeout or page fetch error (40x, 50x) that occurred when your server attempted to fetching the remote page that the link points to.
I did try the link on two different sites / servers and it resolved fine, so the timeout or other is something with your server, but at least now the addon is not leaving it blank when that happens.
Thank you very mutch! :)
Not working in v1.1
Try the version attached, it should install and work fine. That said, a couple of notes
- Its going to be more robust in converting links if you have curl installed (PHP extension). In updating this I found a couple of small improvements that we can make in 1.0.11 / 1.1.1 for sites that don't have curl but instead rely on old methods to work.
- In 1.1 it will convert links inside of code tags. I could fix this in the addon, but instead want to fix it in 1.1.1, so be aware of that limitation.
Thank you Spuds, it's working great now :)
Updated package to support ElkArte 1.1
Minor update to ensure it works with ElkArte 1.1.9 and PHP 8.1 etc. Should not break anything, but ...
- Minor updates to support ElkArte 1.1.9
- Improved several regex constructs to reduce the number of "steps" to find links
- Updated some language strings
- Updated package links to use httpS
To get the addon you can do one of two things: