ElkArte Community

Extending Elk => Addons => Topic started by: Spuds on April 17, 2014, 12:35:53 pm

Title: [ADDON] Titled / Descriptive Links
Post by: Spuds on April 17, 2014, 12:35:53 pm
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
Title: Re: Titled / Descriptive Links
Post by: emanuele on April 17, 2014, 03:16:15 pm
/me likes what he is seeing in this board! :D
Title: Re: [ADDON] Titled / Descriptive Links
Post by: radu81 on October 01, 2014, 03:03:55 am
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?
Title: Re: [ADDON] Titled / Descriptive Links
Post by: emanuele on October 01, 2014, 03:25:49 am
http://www.elkarte.net/community/index.php?topic=1419.0 O:-)
Title: Re: [ADDON] Titled / Descriptive Links
Post by: radu81 on October 01, 2014, 03:38:47 am
Perfect! I missed that topic ;)
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Joshua Dickerson on October 02, 2014, 07:47:52 pm
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.
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Spuds on October 02, 2014, 08:26:18 pm
Thanks, I'll take another look at this one  :)
Title: Re: [ADDON] Titled / Descriptive Links
Post by: ahrasis on October 07, 2014, 08:12:00 am
Nice one @Spuds.
Title: Re: [ADDON] Titled / Descriptive Links
Post by: emanuele on April 08, 2015, 10:37:45 am
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
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Spuds on April 08, 2015, 10:59:30 am
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.
Title: Re: [ADDON] Titled / Descriptive Links
Post by: emanuele on April 08, 2015, 11:53:03 am
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
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Spuds on April 08, 2015, 03:23:38 pm
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?

Title: Re: [ADDON] Titled / Descriptive Links
Post by: emanuele on April 08, 2015, 03:36:44 pm
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
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Jorin on July 21, 2016, 01:32:43 am
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.
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Jorin on August 09, 2016, 02:25:25 am
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]
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Ruth on August 09, 2016, 05:05:22 am

He was kidnapped...I am sure. ;)
Title: Re: [ADDON] Titled / Descriptive Links
Post by: ahrasis on August 09, 2016, 05:41:12 am
LOL. He is on holiday I supposed. He'll be back soon, I think.
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Jorin on August 09, 2016, 05:42:33 am
Granted!  ;)
Title: Re: [ADDON] Titled / Descriptive Links
Post by: emanuele on August 09, 2016, 04:49:57 pm
Quote from: Jorin – 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]
http://www.elkarte.it/community/index.php?topic=13.msg48#msg48
Seems to work as expected.
Is it the only one giving issues?
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Jorin on August 12, 2016, 12:55:13 am

No. Yesterday a user posted this link:

[url=http://www.mak-boerse.de/fahrzeug/toyota-yaris-hybrid-comfort-klimaautom-8-fach-bereift-/abea660aece0427084fc28042a7a2049#/][/url]

It is invisible, only visible when editing the post.

Test it here:
(http://www.mak-boerse.de/fahrzeug/toyota-yaris-hybrid-comfort-klimaautom-8-fach-bereift-/abea660aece0427084fc28042a7a2049#/)

Also not working. So not a problem of the addon but of Elk. Can you split the posts about these URLs please?

Forgot the Chrome check. Will make it tomorrow.  :-[
Title: Re: [ADDON] Titled / Descriptive Links
Post by: radu81 on August 12, 2016, 06:05:11 am
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#/)
Title: Re: [ADDON] Titled / Descriptive Links
Post by: radu81 on August 12, 2016, 06:07:11 am
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#/)
Title: Re: [ADDON] Titled / Descriptive Links
Post by: emanuele on August 12, 2016, 07:50:43 am
@radu81 this problem is likely a problem with the addon. ;)
Title: Re: [ADDON] Titled / Descriptive Links
Post by: radu81 on August 12, 2016, 07:30:57 pm
QuoteTest it here:
(http://www.mak-boerse.de/fahrzeug/toyota-yaris-hybrid-comfort-klimaautom-8-fach-bereift-/abea660aece0427084fc28042a7a2049#/)

Also not working. So not a problem of the addon but of Elk. Can you split the posts about these URLs please?
that's why I did the test, try to edit or quote this message to see the missing link.
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Spuds on September 06, 2016, 09:32:59 am
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
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Jorin on September 12, 2016, 05:31:38 am
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#/
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Spuds on September 12, 2016, 07:11:00 am
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.
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Jorin on September 12, 2016, 07:28:28 am
Thank you very mutch!  :)
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Bodacious on October 27, 2017, 09:47:36 am
Not working in v1.1
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Spuds on October 27, 2017, 07:56:47 pm
Try the version attached, it should install and work fine.  That said, a couple of notes

Title: Re: [ADDON] Titled / Descriptive Links
Post by: Bodacious on October 28, 2017, 09:07:23 am
Thank you Spuds, it's working great now   :)
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Spuds on November 26, 2017, 05:14:27 pm
Updated package to support ElkArte 1.1
Title: Re: [ADDON] Titled / Descriptive Links
Post by: Spuds on November 06, 2022, 10:51:37 am
Minor update to ensure it works with ElkArte 1.1.9 and PHP 8.1 etc.  Should not break anything, but ...


To get the addon you can do one of two things: