Plugin: Title Case
Posted: 22 May 2008 12:03 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  58
Joined  02-02-2006

I’ve spent a little time porting John Gruber’s Title Case script to PHP, and then to ExpressionEngine as a plugin.

The PHP build went relatively quickly, and worked as I hoped (at least for an initial version), but the plugin has given me some fits.

Basically, once I use it as a plugin in ExpressionEngine, the script is suddenly dealing with html entities because EE converts straight quotes in titles to entities (normally I’d be very happy about this). My trouble is in getting the regular expression to function properly when looking for these entities. I can get the regular expression to work in isolation, just not in the plugin.

Anyway, I’ve now spent more time on this than I expected and will go ahead and post my plugin here - it works everywhere except where surrounded by html entities for quotes (these words simply aren’t cased properly by the script).

Hopefully someone out there can take a look and give me some clues… otherwise, I’ll pick up again on improving it tonight.

Thanks in advance.

Update: Version 1.2 now requires that the SmartyPants plugin be installed.

Update: Version 1.3 no longer requires that the SmartyPants plugin be installed, but if it is installed, SmartyPants will be applied automatically to fix the straight quotes this plugin creates.

File Attachments
pi.title_case1.3.zip  (File Size: 2KB - Downloads: 59)
Profile
 
 
Posted: 22 May 2008 09:48 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Avatar
Rank
Total Posts:  58
Joined  02-02-2006

I have now updated the plugin to allow for the html entities for quotes and apostrophes. I’m sure that this can be done in a much more elegant way, so I’m eager to hear from any PHP experts out there.

I can’t guarantee that this is a 100% accurate PHP port of Gruber’s script, but it is darn close from what I can tell.

Please kick the tires and let me know if you have any suggestions.

You can find the updated plugin posted above.

Profile
 
 
Posted: 23 May 2008 09:33 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  58
Joined  02-02-2006

Updated to version 1.2 - available above

I’ve gone back an updated this plugin again. It now requires that the SmartyPants plugin is also installed.

It solved a lot of problems I was having with converting quotes back and forth. It also adds the nice ability to a lot of punctuation to their proper html entities (something I do on a lot of sites anyway), so the combination made sense.

Let me know of any suggestions.

Profile
 
 
Posted: 11 July 2008 11:19 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  43
Joined  08-18-2005

Nice plugin. Thanks!

Was wondering whether you would consider updating it to check for/include either the SmartyPants plugin or the Typogrify plugin. The Typogrify plugin incorporates SmartyPants so your plugin will work with it.

Also, your plugin version number needs updating, and fashion is missing an ‘h’ in the description.

Thanks again smile

Profile
 
 
Posted: 11 July 2008 12:26 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  58
Joined  02-02-2006

@Will

Thanks for the suggestions. I’m having trouble downloading the Typogrify plugin (looks promising) for testing.

In the meantime, I’ve taken care of the problems you highlighted (thank you very much), and I’ve removed the dependency on SmartyPants (instead, applying it if it is installed, but not requiring it). I’m happy to add a round of checks for Typogrify if I can find a place to download it properly.

Profile
 
 
Posted: 11 July 2008 12:35 PM   [ Ignore ]   [ # 5 ]  
Grad Student
Avatar
Rank
Total Posts:  43
Joined  08-18-2005

Yeah, I get a load of mangled code when I click on the link to the plugin. However, I was able to download it on Firefox by right-clicking on the link and selecting Save Link As…

When uncompressed it is lacking the .php file extension - add that in and all is fine.

Profile
 
 
Posted: 11 July 2008 12:57 PM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  58
Joined  02-02-2006

I tried the right-click trick, too. I was also able to unzip the file, but when I opened it in my text-editor all I got was gibberish, so I was (understandably) a little hesitant to upload it to my site.

I’m out of town for the weekend, but I’ll give it a try again as soon as I’m back.

Update: Will got the Typogrify plugin to me, but I’m currently having some trouble implementing it. If we get it working properly, I’ll post an update to this thread.

Profile
 
 
Posted: 20 July 2008 12:55 AM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  1
Joined  10-06-2006

Sorry about the download problems with the typogrify plugin.  I’m sure I had that working properly at some point, but it should be solved now.  :)

It seems that EE has a problem with filenames ending in .php.zip—-it displays it as a page by default or if you try to download it, it appends a .html ending.  I’ve changed the ending of the downloadable file to just .zip, which will then expand to the .php file after you unzip it.  It should work with you just clicking on the link now without the need for using the right-click menu.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64908 Total Logged-in Users: 36
Total Topics: 81852 Total Anonymous Users: 21
Total Replies: 440059 Total Guests: 234
Total Posts: 521911    
Members ( View Memberlist )