Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Archives
  3. » [dropped] rah_urltolink

#16 2009-09-06 02:24:55

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [dropped] rah_urltolink

mapu wrote:

It would be nice if you could consider that this plugin will also render http://j.mp shortlinks (a new service from bit.ly) in a future version!

Thank you for your interest in the project, Marcus. Unfortunately, probably not going to be implemented in rah_urltolink. There are drawbacks in that behaviour, which are not the best parts of this plugin – mostly caching and the link submitting.

Altho, I might in some point implement it, but ofcourse without caching. Caching is left to the user.

Last edited by Gocom (2009-09-06 02:26:07)

Offline

#17 2009-09-06 10:03:05

txpnisti
Member
Registered: 2009-02-25
Posts: 23

Re: [dropped] rah_urltolink

For funtoosh; I fixed the missing space simply by adding it in the plugin code editing tab. Find the row where you can see this ($url) ? ‘<a href=”’.$url…, then add the missing space before the link opening tag. Jukka, can you see this missing space fault yourself, or does this just happen for some of us? It was not in previous version, I’m 99% sure.

Other question, I tried to add the rel=“nofollow” when showing comments, but it gives me this kind error, and rest of the page is not shown at all:

Parse error: syntax error, unexpected T_STRING in /************/textpattern/lib/txplib_misc.php(570) : eval()’d code(63) : regexp code on line 1

Fatal error: preg_replace() [<a href=‘function.preg-replace’>function.preg-replace</a>]: Failed evaluating code: rah_urltolink_build(&quot;www.&quot;,&quot;example.com&quot;,&quot; rel=&quot;nofollof&quot;&quot;,&quot;&quot;,&quot; www.example.com&quot;) in /************/textpattern/lib/txplib_misc.php(570) : eval()’d code on line 63

Offline

#18 2009-09-06 18:33:23

mapu
Member
From: Munich, Germany
Registered: 2004-03-16
Posts: 141

Re: [dropped] rah_urltolink

Gocom wrote:

Thank you for your interest in the project, Marcus. Unfortunately, probably not going to be implemented in rah_urltolink. There are drawbacks in that behaviour, which are not the best parts of this plugin – mostly caching and the link submitting.

Altho, I might in some point implement it, but ofcourse without caching. Caching is left to the user.

Caching is not on my wishlist ;-) It just seems that at the moment the plugin is not able to render domains with only one letter. My PHP skills are very limited so I’m not able to alter the plugin myself.

I will wait patiently for a next release of it. ;-)

Btw, nice work!

Offline

#19 2009-09-07 08:20:33

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [dropped] rah_urltolink

Two updates released in a row. First we got version 0.4, and almost directly after release (20 minutes after) was patched up to 0.4.1. Changelog:

Version 0.4.1

  • Fixed: Now additional attributes (rel, label etc) are escaped correctly. Thanks txpnisti.

Version 0.4

  • Added protocols attribute. Now you can select what type of URL to turn into link.
  • Fixed: Now won’t eat pending spaces before links.
  • Fixed: Now URLs right after (X)HTML tags (> char), dots, and so on, are turned into links: No more requires appending space. Even link middle of a word is turned into link.

More info and downloads

Mapu wrote:

It just seems that at the moment the plugin is not able to render domains with only one letter.

Oh, you meant that. Sorry not for understanding your fine post. Yes, that is correct. The minimum character count (including the dot before tld) is three characters.

Last edited by Gocom (2009-09-07 08:29:17)

Offline

#20 2009-09-07 08:48:39

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [dropped] rah_urltolink

Again, new version released. Version 0.4.2 changelog:

Version 0.4.2

  • Changed: Removed two letter domain requirement. Thanks mapu.

You probably already know it, but downloads are still located @Rahforum.biz. ;)

Btw, I don’t even know why I added that “feature”. Must be left overs from 0.2 cleaning.

Offline

#21 2009-09-07 08:56:27

mapu
Member
From: Munich, Germany
Registered: 2004-03-16
Posts: 141

Re: [dropped] rah_urltolink

Gocom wrote:

Again, new version released. Version 0.4.2 changelog:

Version 0.4.2

  • Changed: Removed two letter domain requirement. Thanks mapu.

Great work! Thank you so much! :-)

Offline

#22 2009-09-07 08:59:27

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [dropped] rah_urltolink

mapu wrote:

Great work! Thank you so much! :-)

Thanks, mapu :-)

Last edited by Gocom (2009-09-07 09:00:07)

Offline

#23 2009-09-07 09:35:33

txpnisti
Member
Registered: 2009-02-25
Posts: 23

Re: [dropped] rah_urltolink

Working great now! Thanks for the good job!

Offline

#24 2009-09-07 10:40:32

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [dropped] rah_urltolink

This turns to be a bad day. Gosh, more updates:

Version 0.4.4

  • Fixed the issue from 0.4.3 to 0.4.1. Now URLs in links are not turned into links, only links right after > or space are converted.

More info and downloads

I hope this is the last “patch” for now. Megoingtodrinksomecoffee.

Offline

#25 2010-02-05 15:21:51

funtoosh
Member
From: Münster, Germany
Registered: 2006-10-09
Posts: 153
Website

Re: [dropped] rah_urltolink

hola jukka,
concerning your last update:

Fixed: Now URLs right after (X)HTML tags (> char), dots, and so on, are turned into links: No more requires appending space. Even link middle of a word is turned into link.

is this still in the code, or did you throw it out so as to not convert links that are already wrapped in [a]-tags?
could i switch this on again, by modifying the code?

cheers from germany,
thx for the great plugin!!
-f

Offline

#26 2010-02-05 15:29:38

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [dropped] rah_urltolink

funtoosh wrote:

is this still in the code, or did you throw it out so as to not convert links that are already wrapped in [a]-tags?

Yep. It just doesn’t work.

could i switch this on again, by modifying the code?

Probably. Removing the tab and space (the line 62) from the regular expression should do it.

Last edited by Gocom (2010-02-05 15:36:28)

Offline

#27 2010-02-05 15:40:54

funtoosh
Member
From: Münster, Germany
Registered: 2006-10-09
Posts: 153
Website

Re: [dropped] rah_urltolink

damn … this really is pretty complicated ;—(

(wouldn’t it be possible to convert links not after every >, but only after <br /> and <p>?
mhm, might be too complex though …)

best, -f

Offline

#28 2012-08-27 01:37:31

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [dropped] rah_urltolink

I’m having an issue with v0.4.4.
URLs next to a > aren’t converted into links.

Test cases:

<h2>www.google.com</h2>
<p>http://example.com</p>

Putting a leading space (ie. between > and the URL) will make rah_urltolink to do its magic, but it’s not a desired workaround.

I tried this fix:

$content = preg_replace(
                        "/".
-                        "(^| |  )".
+                        "(^| |  |>)".
                        "(".$ereg.")".
                        "(([a-zA-Z0-9-]+\.)+".
                        "[a-zA-Z0-9-\.\/\_\?\%\#\&\=\;\~\!\(\)]+)/e",
                        "rah_urltolink_build(\"$1\",\"$2\",\"$3\",\"$link\",\"$label\",\"$0\")"
                        ,
                        ' '.$content.' '

and it seems to work fine for me.

As in the plugin changelog there are one or two mentions about this (see changelog for 0.4.4, 0.4.3 and 0.4), it surprised me that I’ve to explicitly add the > to the regex to fix it. Am I missing anything?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#29 2012-08-27 01:41:35

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [dropped] rah_urltolink

Oh, it seems there is an unreleased WIP (looks like a refactored version) here


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#30 2012-08-27 03:43:59

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [dropped] rah_urltolink

maniqui wrote:

Am I missing anything?

If you do that it will add links inside any tag, including links itself, buttons, options, select fields and so. That’s the reason why it doesn’t add links right after a closing tag. Plus links don’t have a real set end, which makes it eat stuff too.

looks like a refactored version

Yep, but that has issues. Those same as above. I wouldn’t use it in production where clients add the content.

Don’t want to scare but consider that as a “maybe never coming out” or deprecated. Rah_urltolink is one of those I want to drop and find a better alternative. The plugin is uninteresting, shouldn’t exist. It has wrong approach, too much issues. Creating auto-linker requires way-more-code. Tons more – or something else than regular expressions.

Regular expressions as the name suggests are regulated, while a markup language is not. If you do use the plugin, please try to avoid wrapping markup inside the rah_urltolink as much as possible. I can admit that it will most certainly break. To make the plugin work with a markup even in the sightliest, the code should be broken into multiple segments, a regular expression that select the nodes that can be modified as done in common hackish markup compressors.

To be honest, I would recommend looking at other alternatives than this for such usage cases if you want to ensure valid markup. Like for instance something that actually parses XML/HTML markup and understands it. This plugin’s super simple regex doesn’t really even need a plugin, but a mere regular expression run from a rah_function would suffice, I suppose. E.g.

<txp:rah_function call="preg_replace" pattern="#([>\s\A]+)(((http://|https://|ftp://|ftps://)([a-zA-Z0-9-]+\.){0,}([a-zA-Z0-9-\./\_\?\%\#\&\=\;\~\!\(\)]+))([^?\s<>,.!]))#" replacement="$1<a href=""$2"">$0</a>" thing="here">
	Some content with text links as http://www.example.com/. Some content here.
</txp:rah_function>

Which does the same stuff. It doesn’t automatically highlight www. or emails as those would require conditions, if a single regex is needed. But you could just use separate instances rather than callbacks, which would also allow writing a more proper email regex too. The one used by the plugin is way too incorrect.

Last edited by Gocom (2012-08-27 03:56:06)

Offline

  1. Index
  2. » Archives
  3. » [dropped] rah_urltolink

Board footer

Powered by FluxBB