LGF Technical Update

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

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? Account Settings 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

► LGF Hits

► Resources

► Never Forget

► Statistics

► 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.

Hell hath no fury like an accountant scorned.

TwitterFacebook
LGF Pages
Recent Pages

researchok
California's Demographic Revolution
3 minutes ago
Views: 20 • Comments: 0
Tweets: 0 • Rating: 0

researchok
The Folly of Internet Freedom: The Mistake of Talking About the Internet as a Human Right
5 minutes ago
Views: 15 • Comments: 0
Tweets: 0 • Rating: 0

researchok
The Mobility Myth: Why Everyone Overestimates American Equality of Opportunity
7 minutes ago
Views: 16 • Comments: 0
Tweets: 0 • Rating: 0

researchok
Supreme Makeover
8 minutes ago
Views: 14 • Comments: 0
Tweets: 0 • Rating: 0

researchok
A Pattern Emerges
9 minutes ago
Views: 15 • Comments: 0
Tweets: 0 • Rating: 0

researchok
Thai Police Charge 2 Over Bangkok Blasts as Iran Denies Involvement
13 minutes ago
Views: 17 • Comments: 0
Tweets: 0 • Rating: 0

researchok
Putin Won't Go Quietly - if at All
15 minutes ago
Views: 27 • Comments: 0
Tweets: 0 • Rating: 0

researchok
12 Countries at Risk of New Economic Crises
15 minutes ago
Views: 17 • Comments: 0
Tweets: 0 • Rating: 0

researchok
Catholic Bishops Join Culture War on Obama: Margaret Carlson - Bloomberg
16 minutes ago
Views: 29 • Comments: 0
Tweets: 0 • Rating: 0

researchok
China Tells Clinton Syria Crisis Internal Matter
16 minutes ago
Views: 22 • Comments: 0
Tweets: 0 • Rating: 0

 Frank says:

I figure the odds are fifty-fifty I just might have some thing to say.