Category: Railo

Jan 24 2012

Railo running JAVA version of less.js

At Work, we are giving one of our sites a make over which was done by an external company. They have delivered some working HTML, but very quickly that I discovered that I am going to have to tweak the CSS - lots of hard coded height and widths for mega menu; not so good for a CMS.

After a bit of a look around it seems to me that it was generated with less.js. So I have asked if they could provide me with the less files.

While waiting for that I did a bit of Googling and found that Railo can run a JAVA version of less.js. A bit of downloading some JARS and cut and paste coding I had it working - first time!

Next I tweaked it a bit forther to create something that would output CSS content with something like:

<link rel='stylesheet' href='/less/index.cfm?src=/css/global-styles.less' />

Code:

<cfsetting enablecfoutputonly="true">
<cfparam name="URL.src" type="string">
<cfset variables.javajs = createObject("java","org.mozilla.javascript.tools.shell.Main",
"/labs/less-js/cfelements/jars/js.jar")>
<cfset variables.javaless = createObject("java","com.asual.lesscss.LessEngine",
"/labs/less-js/cfelements/jars/lesscss-engine-1.1.4.jar")>
<cfcontent type="text/css" reset="true">
<cfoutput>#variables.javaless.compile(fileRead(URL.src))#</cfoutput>
<cfsetting enablecfoutputonly="false">

Thanks to Cfelement, Nathan Strutz and Asual - Oh, and those wonderful folks over at Railo ;-)

0 comments - Posted by AJ Mercer at 3:14 PM - Categories: CFML | Railo

Jan 5 2012

CFML Study Group - Perth AU

At the start of last year, Chris Bauer and I got together to take a look at the CFWheels framework in what we refered to as a 'study group'. We are going to kick this off again in the new year.

We have also been discussing running CFML classes. The recently released Railo 3 Beginners Guide book would make an excellent text book. I am sure I could get a good price for bulk order.

So if you would like to learn the ColdFusion Markup Language, or would like to extend your skills, please leave a comment.

 

1 comments - Posted by AJ Mercer at 2:16 PM - Categories: CFML | Railo

Dec 20 2011

Railo 3 Beginner’s Guide

0 comments - Posted by AJ Mercer at 8:52 AM - Categories: CFML | Railo

Sep 26 2011

CFML Image Place holder Custom Tag

0 comments - Posted by AJ Mercer at 3:09 PM - Categories: CFML | ColdFusion | Railo

Aug 30 2011

CFML has not hit critical mass

1 comments - Posted by AJ Mercer at 1:17 PM - Categories: CFML | ColdFusion | Railo

May 25 2011

Customised URLs for CFEclipse

1 comments - Posted by AJ Mercer at 4:27 PM - Categories: CFElipse | CFML | cfwheels | Railo

May 9 2011

Friendly URLs for Railo in Cloudbees

Railo was so easy to deploy to the 'cloud' using Cloudbees RUN@Cloud. Mark Drew has written up how to deploy Railo to Cloudbees.

I have been messing around with this just to see what 'cloud' computing is all about and just for fun uploaded CFWheels to http://cloudbees.webonix.org (http://cfwheels.webonix.cloudbees.net/ cloudbees lets you add your own domains). But for a wheels site to look sexy it needs friendly URLs.

This is achievable using Tuckey URL Rewrite Filter which I discovered on Aaron Greenlee's website. Extract to the WEB-INF in the root of your website. Edit the WEB-INF/web.xml and add this before the servet tag

    <filter>
        <filter-name>UrlRewriteFilter</filter-name>
        <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>UrlRewriteFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

While you are in this file, also add the following with the rest of the CFML mappings. Tomcat does not allow for multiple wildcards

<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>/rewrite.cfm/*</url-pattern>
</servlet-mapping>

Next Create urlrewrite.xml in WEB-INF. This is what I have based on comments in CFWheels doco

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN" "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
 <!--
  
    Configuration file for UrlRewriteFilter
    http://tuckey.org/urlrewrite/
  
-->
<urlrewrite>
    <rule>
        <note>
            Allow TomCat to have SES links.
        </note>
        <!--
            If our URI ends with one of these extentions we will not perform
            a URL rewrite.
        -->
        <condition type="request-uri" operator="notequal">\.(bmp|gif|jpe?g|png|css|js|txt|pdf|doc|xls|xml|cfc|ico|php|asp)$</condition>
        <!--
            If any URI begins with one of these directories, we will not
            perform a rewrite. Helpful for running your unit tests or
            "blocking" rewrite for some directories.
        --> 
<condition type="request-uri" operator="notequal">^/$</condition>
       <condition type="request-uri" operator="notequal">^$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/railo-context(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/flex2gateway(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/jrunscripts(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/cfide(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/cfformgateway(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/files(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/images(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/javascripts(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/miscellaneous(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/stylesheets(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/robots.txt(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/sitemap.xml(.*)$</condition>
       <condition type="request-uri" operator="notequal">^(.*)/rewrite.cfm(.*)$</condition>
        <from>^/(.*)$</from>
        <to>/rewrite.cfm/$1</to>
    </rule>
</urlrewrite>

Now you can start cloudbees for your site and you should be ready for creating freindly URLS. Which for CFWheels means editing config/settings.cfm and adding 

<cfset set(URLRewriting="On")>

And builing links using linkTo(). E.g.

<h1>Page One</h1>
<cfoutput>
#linkTo(text="Page Two", controller="ses", action="pageTwo")#
</cfoutput>

Now you are ready to deploy to the cloud and end up with something like this http://cloudbees.webonix.org/ses/page-one

10 comments - Posted by AJ Mercer at 4:18 PM - Categories: cfwheels | cloudbees | Railo