Log In
Interaction Multiplier IconGround Weather Castform Don't have an account yet? Register now!
.

Forum Thread

Automatic hyperlinks

Forum-Index Suggestions Automatic hyperlinks
SwampFall
OFFLINE
Trainerlevel: 59

Forum Posts: 601
Posted: Tue, 18/09/2018 21:18 (6 Years ago)
Sharing clickable links without having to type the BBcode for it would be a useful feature in palpad and in feeds since in these places it's not possible to share images anyway.
This will make sharing links easier in general but especially for people who don't know about BBcode yet and perhaps for mobile users.

A link such as https://google.com would be changed into google.com while
[url=https://google.com]a useful site[/url] would be a useful site as you'd expect.
If you don't include the http(s):// it won't change into a link.

Implementation (For Riako)
In PHP before inserting into database: (The random links in $text are to test different scenarios)
$text = "https://google.com?test Use [url=https://google.com/]google[/url] if youhttps://google.com/ don't https://google.com/ know it. https://google.com/ \ n https://google.com/";
$url_pattern = "/([^=\]\w]|^)(https?:\/\/([\w|\.]+)([\/|\?]\S*)?)(\s?)/m";
$url_replace = "$1[url=$2]$3[/url]$5";
$text = preg_replace($url_pattern, $url_replace, $text);

Result:
[url=https://google.com?test]google.com[/url] Use [url=https://google.com/]google[/url] if youhttps://google.com/ don't [url=https://google.com/test?test]google.com[/url] know it. [url=https://google.com/]google.com[/url]
[url=https://google.com/]google.com[/url]

which is equal to the following in feeds / palpad
google.com Use google if youhttps://google.com/ don't google.com know it. google.com
google.com

So all links without BBcode are changed into links except the one where there's no space between "you" and the link (this can easily be changed if desirable).
The link with BBcode was untouched, if someone writes [img]https://example.com/img.png[/img] the link will also not change.
Zarkesh
OFFLINE
Trainerlevel: 154

Forum Posts: 15,329
Posted: Wed, 19/09/2018 05:55 (6 Years ago)
That would be great (especially for mobile users) since it makes creating links much easier

Support :)
ShiftingStreamsyt
OFFLINE
Trainerlevel: 29

Forum Posts: 30
Posted: Tue, 25/08/2020 18:37 (4 Years ago)
And would be easy for those who didn't know how to code
ShiftingStreamsyt
Train with my best accomplishments

This made by me hopefully an new PH banner?
Jaeger
OFFLINE
Trainerlevel: 64

Forum Posts: 207
Posted: Tue, 25/08/2020 18:44 (4 Years ago)
im not sure how to feel about this suggestion...it's a good idea in theory, but some links are really long (for example, deviantart's image links). this would cause really long feeds and/or comments if you want to link to a website/image that has a really long URL (such as the link for one of my drawings uploaded to DA shown below)
Show hidden content
https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/e95f5a57-899e-4c5b-b1fa-833423838322/de3leep-7ac3dbed-b547-4ee1-a1df-348c741b8644.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOiIsImlzcyI6InVybjphcHA6Iiwib2JqIjpbW3sicGF0aCI6IlwvZlwvZTk1ZjVhNTctODk5ZS00YzViLWIxZmEtODMzNDIzODM4MzIyXC9kZTNsZWVwLTdhYzNkYmVkLWI1NDctNGVlMS1hMWRmLTM0OGM3NDFiODY0NC5wbmcifV1dLCJhdWQiOlsidXJuOnNlcnZpY2U6ZmlsZS5kb3dubG9hZCJdfQ.PrSYOTlAGHGIHHJdKxrKuKpYiuhDfAaIoVPk8r8b0jA

the only way i would see around this is if the links are automatically shortened (not sure if you mentioned that n i just missed it lol)

typing [img] and [url=] only takes a few extra seconds, so i don't really see a necessity for this. i wont vote against it tho...just not voting on it for now