Dale's Weblog

looking back it was easy.
Friday 12 March

Automatic text to URL

Posted by dale on Sun, 15 Aug 2004 08:48:40 EST

Okay I’ve just spent about 15 minutes fixing up the backend code (more to do later). Now the main news entry is passed through htmlentities so there is no chance of breaking my lovely XHTML. I’ve also found a nice text to url ereg_replace piece of code. I understand WHAT is it, but I don’t get all those extra slashes and crap. I mean I get the \\1 etc but not the rest. I’ll learn about "regular expression" later this week. I’ve also fixed up the word wrapping for comments. Soifsomeonedecidedsthattheywanttopostsomethingwithoutanyspacesitwontscrewupthelayout.

Another plan is to move this database. Currently all the data stored on this site is in the same database as my main site. I want to change that as this site is going to use different code etc (better, faster etc). I’ve also deleted some code that wasn’t used, so this site should run faster now too.

Okay time to test this new stuff:
Bold
lalalalal
[u]:):):)[/u]

this stuff will be my quote text

and now for a url: http://blog.dalegroup.net

Let’s post this and see if it works!

This posted was edited: Sun, 15 Aug 2004 16:50:14 EST
Below are the comments for this news item

Iiiiinteresting. So, your URL detection… is that actually detection? Or just… you know… [url]asdfasdfasdf[/url] or something like that?

As an unrelated aside, I'm using Konqueror to type this, and I just discovered it SPELLCHECKS forms!!!! HOW COOL IS THAT!??!!?

1: Comment by Josh - Sun, 15 Aug 2004 09:00:53 EST


$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $text);

Seems to do it all. No crappy [url] thing.

Hey I need that spell checking. I always open up word :|

2: Comment by dale - Sun, 15 Aug 2004 09:04:42 EST


Thanks for sharing :) Now I'm out to break it…

Does it apply to comments?

http://www.example.com
www.example.com
example.com
example.com?asdfasdf.asdf&asdfasdf=asdf

…did that break it?

Heh, you need to install Linux on a blogging box just so you get Konqueror ;)

3: Comment by Josh - Sun, 15 Aug 2004 09:21:08 EST


Ooooh, I understand that now. Okay. Hmm…

Sweet… I can make links to my local filesystem on your website:P

file:///home/josh/monkey.gif

As long as there aren't any non-alphabet characters before "://" it detects as a URL… what does this mean in terms of BreakingStuff™?

http://example.com/?://proxytestmuntsthings/

I don't even know if that's a valid URI, mind…

4: Comment by Josh - Sun, 15 Aug 2004 09:24:59 EST


Sorry about the comment spam, feel free to delete…

One concern with your doing things this way; how do you have named URL's? As opposed to link as link in text (e.g. http://address/)…; how do you get "Address" to be a link to "http://address/&quot;?

I haven't really thought about it too hard, but it's something you might want to consider… that's what's stopped me from implementing detection code already – my URL's marked as such by [url]asdf[/url] or [url=asdf]text[/url are RE-detected by link auto detection code, and everything winds up one big mess (kind of like my "breaking stuff" link above…)

5: Comment by Josh - Sun, 15 Aug 2004 11:02:27 EST


One concern with your doing things this way; how do you have named URL's?

Well pretty much you don't ;) Although I've never really used it. It doesn't really matter. I *could* do something. But it isn't high on my list :)

6: Comment by dale - Sun, 15 Aug 2004 16:13:46 EST


BBCode:

urls become clickable

[b]place text in bold[/b]

[i]place text in italics[/i]

[quote]place text in a quote[/quote]

Comments? Please note that all HTML tags are removed from your post.

The URI to TrackBack this entry is: http://www.dalegroup.net//early05/archive/blog/newsid/trackback/79

Comments

Message:

Name (optional):

Email (not shown):

WWW (optional):






Copyright © Michael Dale 2004. Page generated in 0.0064 seconds FreeBSD Powered
Background on style 5 is used from squidfingers How are we going? 3 queries