Color Coding in BlogCFC with ColdFish

Jason Delmore created ColdFish to color code any file content or string.  Its wickidly easy to implement.

To add it to your blog you simply need to modify a couple files.

1) Application.cfm - this is optional, but a good idea I think.  Just after the cfset for application.blog add:

<cfset application.coldfish = createObject("component","org.delmore.coldfish").init()/>

2) in Blog.cfc (typically org/camden/blog/blog.cfc) line 2085 ish:

<cfset result = "<div class=""#style#"">" & application.coldfish.formatString(codeportion) &  "</div>"/>

For item 2 I had to add a bit more as I use FCK editor and as such the html was changed a bit when saved to the DB.  I also dont't use <code></code> but rather directly applied a class to my html with <div class="code"></div> instead.  So I needed to reformat my content a bit for coldFish to format.

So I added:

<!--- line 2072 ish to replace the divs with code tags  --->

<cfset arguments.string =  replacenocase(arguments.string, '<div class="code">','<code>', 'ALL')>   
<cfset arguments.string =  replacenocase(arguments.string, '</div>','</code>', 'ALL')>   

<!--- line 2085ish just above my item 2 above to set the html as coldFish wants it and remove formating breaks --->

<cfset codeportion= replace(codeportion, '<br />', '', 'all')>
<cfset codeportion= replace(codeportion, '<p>', '', 'all')>
<cfset codeportion= replace(codeportion, '</p>', '', 'all')>

<cfset codeportion= replace(codeportion, '&lt;', '<', 'all')>
<cfset codeportion= replace(codeportion, '&gt;', '>', 'all')>
<cfset codeportion= replace(codeportion, '&amp;', '&', 'all')>
<cfset codeportion= replace(codeportion, '&quot;', '"', 'all')>

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
jax's Gravatar Note: Coldfish requires CF 8 ....
# Posted By jax | 3/6/08 5:32 AM

NAVIGATION

Home
About Me

RSS


Search

Subscribe

Enter your email address to subscribe to this blog.

Recent Entries

Google TV Review
Playbook - Developers It's Time To Get Started
cf.Objective 2011 - Speak Your Mind
Timesheets, Project Management, and Invoicing - FreshBooks Review
A New Phase of My Life

Recent Comments

OTA OK?
AnoraDD said: I get 18 of these exact sms's everyday! How do I get it to STOP?!? [More]

Coldfusion Hosting with Network Solutions
LIzm said: Ugh. I have a client who insists on hosting with them and two weeks after first contact, a very simp... [More]

IE nested list item whitespace solution: vertical-align:bottom
Lauren said: Thought I'd add to the thank yous... Thank you! [More]

OTA OK?
Rita said: Thank you, this was very helpful. [More]

OTA OK?
diggs said: Just got it today, T-Mobile. Thanks for the articale about it. [More]

Calendar

Sun Mon Tue Wed Thu Fri Sat
   1234
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29    

Archives By Subject

blogs (31) [RSS]
books (4) [RSS]
Consulting (2) [RSS]
Crazy (39) [RSS]
DIY (8) [RSS]
Flex (3) [RSS]
games (10) [RSS]
GRRR (13) [RSS]
Ideas (11) [RSS]
Local (15) [RSS]
LOLpics (2) [RSS]
money (9) [RSS]
music (3) [RSS]
Personal (28) [RSS]
Photos (8) [RSS]
Politics (8) [RSS]
Projects (22) [RSS]
Review (20) [RSS]
RPM (9) [RSS]
Spam (16) [RSS]
Technology (69) [RSS]
Testing (3) [RSS]
TV (15) [RSS]
video (32) [RSS]
Web Dev (230) [RSS]
World of Warcraft (16) [RSS]