LGF Technical Update

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

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.

Leave blank if devoid of snark.

TwitterFacebook
LGF Pages
Recent Pages

MikeySDCA
In 'Game of Thrones,' War Changes Everyone - the Atlantic
1 hour, 36 minutes ago
Views: 45 • Comments: 0
Tweets: 0 • Rating: 1

Randall Gross
Rush to Judgment: Missouri's Deceptive 'Right to Pray' Amendment Heads for August Ballot
2 hours ago
Views: 67 • Comments: 0
Tweets: 0 • Rating: 2

researchok
Lost Classics: An Address Delivered in 2009 to Graduates in Classics at UC Berkeley
12 hours, 59 minutes ago
Views: 149 • Comments: 0
Tweets: 0 • Rating: 0

Haywood Jabloeme
SWATting the Ericksons
16 hours, 2 minutes ago
Views: 175 • Comments: 2
Tweets: 0 • Rating: -2

Mostly sane, most of the time.
So wake up and notice already
16 hours, 11 minutes ago
Views: 110 • Comments: 0
Tweets: 0 • Rating: 1

Daniel Ballard
Late Afternoon Light-Kalanchoe
1 day, 20 hours ago
Views: 208 • Comments: 0
Tweets: 0 • Rating: 5

Eclectic Infidel
City College of San Francisco Budget Update
1 day, 21 hours ago
Views: 245 • Comments: 0
Tweets: 0 • Rating: 1

Aigle
National Geographic Traveler Veers Off Track
3 days, 2 hours ago
Views: 833 • Comments: 17
Tweets: 26 • Rating: -6

MichaelJ
Apple TV Slated to Debut in December?
3 days, 3 hours ago
Views: 310 • Comments: 0
Tweets: 0 • Rating: 1

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

 Frank says:

No one has forced Mrs. Baker or Mrs. Gore to bring Prince into their homes. -- PMRC Hearing 1985