SimplePortal

Development => Feature Requests => Topic started by: TigPT on January 13, 2010, 08:29:41 PM

Title: Auto tiny urls in chat
Post by: TigPT on January 13, 2010, 08:29:41 PM
First of all, gratz for your great work.

Would be great if you could add a auto tiny url converter like tiny url or goo.gl service so che urls past in the chat box don't become so borring in space and sometimes breaking the layout.

Anyone else think that this will be a interesting feature?

Anyone know if it will be easy to implement and want to start it?

(sadly i don't have know-how for that so i do my best with brainstorming :))
Title: Re: Auto tiny urls in chat
Post by: H on January 14, 2010, 02:55:21 PM
Really there is no need to use an external service like tinyurl. Instead you could just replace the link with the text link (e.g link (http://www.simpleportal.net))

I think this'd be a good idea though
Title: Re: Auto tiny urls in chat
Post by: Robbo on January 18, 2010, 11:33:42 AM
Making a mod for this now. Will most likely be added to the next version of SP.
Title: Re: Auto tiny urls in chat
Post by: TigPT on January 18, 2010, 11:35:44 AM
thanks for the feedback. Think it will be a lot interesting.
Title: Re: Auto tiny urls in chat
Post by: Robbo on January 18, 2010, 01:44:28 PM
This should work fine. The only thing it doesn't do is update with AJAX. So when you first post with AJAX you won't see the link converted however everyone else would and you will once the page is loaded again.

Package attached.

EDIT: removed package, was broken.
Title: Re: Auto tiny urls in chat
Post by: TigPT on January 18, 2010, 02:06:32 PM
Think that will be very good for now. Just bad that i installed it and it seems to not be working.

Installed all fine but when i past a big url like this one it keeps the same.
http://lusorobotica.com/index.php/topic,1908.0.html
Title: Re: Auto tiny urls in chat
Post by: Robbo on January 18, 2010, 02:11:32 PM
You need to set it in the shoutbox settings btw.

I probably should have mentioned that...
Title: Re: Auto tiny urls in chat
Post by: TigPT on January 18, 2010, 02:12:58 PM
You need to set it in the shoutbox settings btw.

I probably should have mentioned that...

I did inserted the url "link" in the settings, but it replaces de url too.

Check out our checkbox:
http://lusorobotica.com/index.php

And as i can look at code, it looks like it only will work for inside links, and not for external ones. Am i right?
Title: Re: Auto tiny urls in chat
Post by: Robbo on January 18, 2010, 02:14:44 PM
Ah crap. I have the same problem. I'll quickly fix it...
Title: Re: Auto tiny urls in chat
Post by: TigPT on January 18, 2010, 02:24:50 PM
No problem. Thats why we are a community, to help each others.

Thanks a lot for being development a feature that i would like but can't do myself :P
Title: Re: Auto tiny urls in chat
Post by: Robbo on January 18, 2010, 02:32:42 PM
It is a problem with my REGEX. I'm too tired to fix it now, I'll just make more mistakes. Should be done by this time tomorrow though.

*goes to sleep*
Title: Re: Auto tiny urls in chat
Post by: TigPT on January 18, 2010, 02:33:43 PM
Sure, sleep well.
Title: Re: Auto tiny urls in chat
Post by: Robbo on January 19, 2010, 05:54:00 PM
Ok this should work fine now...

Attached.
Title: Re: Auto tiny urls in chat
Post by: TigPT on January 19, 2010, 06:06:01 PM
I'm getting a error installing the package:
Quote
.   Adicionar Depois   ./Sources/Subs-Portal.php   Teste falhado
Quote
Encontrar [Seleccione]
while ($row = mysql_fetch_assoc($request))
      {
Adicionar Depois [Seleccione]

            // Convert links...
            if (!empty($parameters['link']))
                $row['body'] = preg_replace('#(([a-zA-Z]+://)([a-zA-Z0-9?&%.;:/=+_-]*))#', '' . $parameters['link'] . ' (http://$1)', $row['body']);
Title: Re: Auto tiny urls in chat
Post by: Robbo on January 19, 2010, 07:01:56 PM
*sigh*

Can you translate that for me?
Title: Re: Auto tiny urls in chat
Post by: TigPT on January 19, 2010, 07:05:37 PM
Translation
Quote
.   Add after   ./Sources/Subs-Portal.php   Test Faild
Quote
Find [Seleccione]
while ($row = mysql_fetch_assoc($request))
      {
Add after [Seleccione]

            // Convert links...
            if (!empty($parameters['link']))
                $row['body'] = preg_replace('#(([a-zA-Z]+://)([a-zA-Z0-9?&%.;:/=+_-]*))#', '' . $parameters['link'] . ' (http://$1)', $row['body']);
Title: Re: Auto tiny urls in chat
Post by: Robbo on January 19, 2010, 07:12:05 PM
Oh you are on an old version of Simple Portal? This mod is only tested on SMF 2.0 RC2 + SP 2.3.1 and SMF 1.1.11 + SP 2.3.1
Title: Re: Auto tiny urls in chat
Post by: TigPT on January 19, 2010, 07:17:23 PM
I'm running SMF 2.0 RC2 and SP 2.3.1

http://lusorobotica.com/
Title: Re: Auto tiny urls in chat
Post by: Robbo on January 19, 2010, 11:22:57 PM
Hmmm, I will have another look at it tonight. Actually looking at your post I think it might be a simple typo. I'll get onto it as soon as possible.

*hates making stupid mistakes*
Title: Re: Auto tiny urls in chat
Post by: [SiNaN] on January 20, 2010, 02:09:08 PM
Although it can be optimized more, this should do it:

./Sources/Subs-Portal.php

Code: (Find) [Select]
$shouts[$shout['id']]['text'] = censorText($shouts[$shout['id']]['text']);
Code: (Replace) [Select]
$shouts[$shout['id']]['text'] = censorText($shouts[$shout['id']]['text']);
$shouts[$shout['id']]['text'] = preg_replace('~<a([^>]+>)([^<]+)</a>~', '<a$1[link]</a>', $shouts[$shout['id']]['text']);
Title: Re: Auto tiny urls in chat
Post by: TigPT on January 20, 2010, 06:40:55 PM
it looks like that ajax was in infinit loop and my hosting team shouted down the server due to the extreme bandwith consuption. :|

Any help on how to remove it is apreciated ;)
Title: Re: Auto tiny urls in chat
Post by: TigPT on January 20, 2010, 08:02:24 PM
HostGator worked very well and the server is back on. I disabled the shoutbox for now, and backuped everything in order to format and reinstall.

Need it as fresh as possible so i will not be testing this new mod in the working copy of it :P

By the way, don't use it for now since it have that bug in the ajax causing a infinit loop of calls.
Title: Re: Auto tiny urls in chat
Post by: Robbo on January 20, 2010, 10:58:06 PM
Although it can be optimized more, this should do it:

./Sources/Subs-Portal.php

Code: (Find) [Select]
$shouts[$shout['id']]['text'] = censorText($shouts[$shout['id']]['text']);
Code: (Replace) [Select]
$shouts[$shout['id']]['text'] = censorText($shouts[$shout['id']]['text']);
$shouts[$shout['id']]['text'] = preg_replace('~<a([^>]+>)([^<]+)</a>~', '<a$1[link]</a>', $shouts[$shout['id']]['text']);
Yeah I was going to do that but I am shit at regex and took the lazy way out.
Title: Re: Auto tiny urls in chat
Post by: [SiNaN] on January 21, 2010, 03:00:49 AM
HostGator worked very well and the server is back on. I disabled the shoutbox for now, and backuped everything in order to format and reinstall.

Need it as fresh as possible so i will not be testing this new mod in the working copy of it :P

By the way, don't use it for now since it have that bug in the ajax causing a infinit loop of calls.

I don't think it is infinite AJAX loops, but might be this:

http://simpleportal.net/index.php?topic=4126.msg26219#msg26219

In any case, please start a new topic about your issue.
SimplePortal 2.3.8 © 2008-2024, SimplePortal