LGF Technical Update

Charles Johnsonfollow me on twitter
Sun Nov 26, 2006 at 5:02 pm PST • Views: 208

The comment posting code has been greatly improved, with a new URL autolinking routine that works much more reliably than the dated, buggy one we’ve been using for at least three years. It also produces prettier links than the previous autolinker; the title for the link is set to the domain name portion of the linked site, so you can see at a glance where the link will take you. For example, if you paste a link to the New York Times into a comment, the link will be titled “www.nytimes.com”.

If you type in the full HTML code for your link instead of just pasting the URL, the autolinker leaves it alone. This new code also fixes a bug in the previous autolinker, which would mess up the HTML if there were two links in a comment to the same domain name.

I’ve also written some new routines to allow formatted blocks of sample code to be included in a post (not a comment, sorry… although I might allow it if there’s a public outcry). The only thing I’m not sure about is whether the CSS styles that wrap the <PRE> block at our column width will work in all browsers; so I’m going to test this now by posting the new LGF autolinking routines. If it makes the page blow up in your browser, I’m sure you’ll let me know. It looks beautiful in Safari, and OK in Firefox; if there’s a problem I’m sure it will come from Internet Explorer, as always.

This gnarly bunch of regular expressions may come in handy to another PHP programmer or two; they’re based on some code that was posted at the PHP web site under the documentation for the preg_replace() function, with lizardoid modifications to make things more sleek. To use the function, simply call MakeLinks($text), with the $text variable set to the chunk of text you want to scan for URLs. (The PrettyLink() function is called internally by MakeLinks().)

Here are the CSS styles that are supposed to make this PRE-formatted area wrap to a width of 520 pixels in a perfect world:

UPDATE at 11/27/06 9:33:54 am:

Since Microsoft Internet Explorer, the bane of my existence, refuses to play nice with my PRE-formatted blocks, I’ve now changed the post generation module to include a browser sniffer (PEAR’s Net_UserAgent_Detect) so that users of IE will see the code fragments enclosed safely in HTML <textarea> tags. I don’t like using sniffers, but it’s the only solution for the IE nightmare.

Firefox is still being a bit of a pest in the issue of PRE wrapping. The text is wrapping, but not where it’s supposed to wrap. It’s not as much of a problem as IE, because it doesn’t cause the middle column to expand; the text simply runs over the right column.

Advertisement

371 comments

^ back to top ^

Name:

Pass:

Register Forgot Your Password? Re-send Confirmation (To log in, cookies must be enabled in your browser!)

Turn off ads by subscribing!
For about 33 cents a day, our subscription option turns off all advertisements at LGF!
Read more...


► LGF Headlines

  • Loading...

► Tweeted Articles

  • Loading...

► Tweeted Pages

  • Loading...

► Top 10 Comments

  • Loading...

► Bottom Comments

  • Loading...

► Recent Comments

  • Loading...

► Tools/Info

► Tag Cloud

► Contact

You must have Javascript enabled to use the contact form.
Your email:

Subject:

Message:


Messages may be published in our weblog, unless you request otherwise.
Tech Note:
Using the Contact Form

More Partners

Compare Electricity Prices in your area. Texas Electricity is deregulated; you have the right to choose Texas Electric Rates from among many Texas Electric Companies.

Nobody's human.

TwitterFacebook
LGF Pages
Recent Pages

Daniel Ballard
Video and Photos: SpaceX's Rendezvous With the Space Station
2 hours, 36 minutes ago
Views: 44 • Comments: 2
Tweets: 0 • Rating: 0

Michael McBacon
Kansas governor signs 'Shariah bill' to ban Islamic law
2 hours, 54 minutes ago
Views: 95 • Comments: 5
Tweets: 0 • Rating: 3

MikeySDCA
Glenn Beck in Exile: Don't cry for the former Fox star—he's building a 24/7 media empire in his loopy image.- the Atlantic
2 hours, 57 minutes ago
Views: 61 • Comments: 0
Tweets: 0 • Rating: 0

researchok
How Did Wisconsin Become the Most Politically Divisive Place in America?
13 hours, 50 minutes ago
Views: 172 • Comments: 1
Tweets: 0 • Rating: 2

Aigle
National Geographic Traveler Veers Off Track
1 day, 3 hours ago
Views: 351 • Comments: 3
Tweets: 0 • Rating: -5

MichaelJ
Apple TV Slated to Debut in December?
1 day, 4 hours ago
Views: 181 • Comments: 0
Tweets: 0 • Rating: 1

Ascher
Israeli Who Saved Turk on Everest: You Never Abandon a Friend - Israel News, Ynetnews
1 day, 5 hours ago
Views: 240 • Comments: 1
Tweets: 0 • Rating: 3

Haywood Jabloeme
The Harrassment of Patterico & Its Roots in Left-Wing Activism
1 day, 5 hours ago
Views: 451 • Comments: 2
Tweets: 0 • Rating: 4

Curt
Brian Banks: (Video) Falsely accused of rape speaks out
1 day, 7 hours ago
Views: 217 • Comments: 1
Tweets: 0 • Rating: 3

Mickey_being_mickey
Obama Administration begins to form plan to arm Syrian rebels
1 day, 21 hours ago
Views: 213 • Comments: 2
Tweets: 0 • Rating: 1

 Frank says:

Seriousity is something to be laughed at. -- FZ responding to Dutch television after being told that Europeans take Frank's music very seriously.