Archive for the 'Web Development' Category

Multistage deployments with Capistrano

I have been trying to set up a Capistrano script for deploying to a staging and production server. I found this very well written tutorial showing how to set up the various cap scripts to work with mod_rails (Passenger).

One note, Capistrano does not copy over the database.yml file. You need to put this in yourself. This tripped me up for a while since I was assuming that it would somehow magically take the database.yml.template file I had and turn it into a database.yml file that I would then have to configure. The Ruby magic doesn’t extend that far ;-) .

Keep CSS layout in layouts not in view pages

When using layouts in Rails, I strongly suggest keeping as much of the container elements in the layout and using content_for to create sections in which content can be placed.

I am working on a site right now that has used the YUI Grids to layout the site (something I highly recommend for anyone designing a site from scratch). Most of the site uses a two column layout. The application.html.erb file looks like this:

<body>
  <div id="doc" class="yui-t6">
    <div id="hd" role="banner">
      <%= render_partial "shared/header" %>
    </div>

    <div id="bd" role="main">
      <%= yield :content %>
    </div>

    <div id="ft" role="contentinfo">
      <%= render_partial "shared/footer" %>
    </div>
  </div>
</body>

What is missing is the part that divides the page into your content area and your, in this case, right-hand side area. This part was placed in the rest of the view files. Not only does this mean that it is repeated everywhere and a huge pain to change, it also means that it is much harder for coders, who may not know YUI CSS Grids, to properly lay out pages. In the case of the app that I am modifying, it has also meant that parts of the CSS layout are strewn careless between regular pages and partials.

Instead, this is how the layout page should look:

<body>
  <div id="doc" class="yui-t6">
    <div id="hd" role="banner">
      <%= render_partial "shared/header" %>
    </div>

    <div id="bd" role="main">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g">
            <%= yield :content %>
          </div>
        </div>
      </div>
      <div class="yui-b">
        <%= yield :side_content %>
      </div>
    </div>

    <div id="ft" role="contentinfo">
      <%= render_partial "shared/footer" %>
    </div>
  </div>
</body>

This keeps everything clean and makes for view pages that look like the following.

<% content_for :content do %>
  put content here
<% end %>

<% content_for :side_content do %>
  put side content here
<% end %>

I think that makes it much easier to see what is happening within view pages. It also keeps all the layout code in one place.

Smashing Magazine – 45+ jQuery usability tips

Smashing Magazine has a nice list of 45 jQuery tips and techniques for improving your users experience. This includes things like login screens, navigable menus, text size slider, and more. It is definitely worth checking out if you are thinking of using jQuery on a project.

Playing with C# 3.0 and .NET 3.5

It has been quite a while since my last post. Mostly that is because I have been fairly busy with a new project and busy trying to get my sorry butt into shape (it is amazing how much time exercising can take up). Anyway, the new project uses C# 3.0 and .NET 3.5, ASP.NET MVC and jQuery. All three are new to me and I have to say that I really like all three.

C# 3.0 is a really nice language. It seems to have gotten generics correct making for some really nice code, especially were the database layer is concerned. We are using LINQ to SQL and we have been able to implement a single class for the repository which works with whatever model object type we give it. I also really like the inclusion of Lambdas and delegates, which make for some very clean code constructs and are much cleaner then anonymous methods in Java.

The second new technology to me is ASP.NET MVC. This allows us to do ASP.NET without actually using ASP.NET. Currently, it is still in preview releases, but it is definitely heading in the right direction. Everything (with the possible exception of views) is completely and easily testable. This means no more having to hide functionality behind presenters or controllers and hoping it works in the code behind. Controllers are completely testable right down to testing what views or redirects they return.

The last new thing I am using is jQuery. I fully understand why it is becoming the defacto Javascript library. To do most things only require a few lines of jQuery Javascript and its AJAX and JSON capabilities are incredible. One nice thing about ASP.NET MVC is that it is capable of returning JSON results with a single line of code. This makes working with jQuery seamless.

If you are starting a new .NET web project, definitely check out ASP.NET MVC, C# 3.0 and jQuery. If you are new to C# 3.0 then check out the book C# in Depth. It highlights all the changes since 1.1 in a nice concise format that will bring you up to speed quickly.

Insanity of registering .ca domain name with WebNames.ca

I just registered a domain name for my wife for her photography business. For any .com domain name, this is a fairly easy, almost trivial process. You find the name you want, click a button, usually labelled “Register” or “Proceed to Checkout”, and then pay some money. Viola, the domain name is yours.

For a .ca domain name, the process is a little more involved. Once you find the name you want, you have to prove why you want it. Apparently, .ca names must maintain a very direct connection to Canada. This means you have to be a Canadian company, part of the government, a Canadian non-profit organization or a Canadian citizen. The next step is to register with CIRA, the Canadian Internet Registration Authority. This involves going to a completely different website and agreeing to five (5) pages worth of agreement policies.

At the end of the five pages, they have a paragraph which basically says that even if you didn’t read the preceding five, very long pages, you are still agreeing to them, and therefore, legally bound to whatever the five pages said. As you can tell, I did not read any of what I as agreeing to.

Once you register with CIRA and complete that insanely long process, then you can complete your registration. Eventually you pay them some money and you are done. Well, almost. Nowhere during the registration process are you asked to enter DNS information (at least on the webnames.ca website). This you have to figure out for yourself after the fact.

This is the part that infuriated me the most. I think this is Webnames.ca’s attempt to trick you into hosting the website with them. If searched around and finally found the spot to enter my DNS info. This was less then obvious. This ensures that .ca names must be registered by knowledgeable web professionals.

Bottom line, find somewhere else to register .ca domain names with other then webnames.ca. Or better yet, just get a .com domain and keep life simpler (and cheaper).

Google App Engine Launched

Google has announced the preview release of the Google App Engine. It allows developers to build web applications and run them on Google’s infrastructure. Currently the only language that is supported is Python. The service is free, but limited to “500MB of persistent storage and enough bandwidth and CPU for 5 million monthly page views”. Google is also limiting registration to the first 10,000 developers who sign up.

The development environment includes the following features:

  • Dynamic webserving, with full support of common web technologies
  • Persistent storage (powered by Bigtable and GFS with queries, sorting, and transactions)
  • Automatic scaling and load balancing
  • Google APIs for authenticating users and sending email
  • Fully featured local development environment

It will be interesting to follow the development of this. Hopefully Google will support more languages when this goes live (Ruby and Java would be really nice). At a minimum, this might just give Python the boost that it needs.

Wicket Phone Book and Maven 2

This evening I tried to download and setup the wicket-phonebook example in Eclipse. The application uses Maven2, something I have not had a lot of experience working with. In the root directory of wicket-phonebook, there is a script called Eclipse.sh which configures everything as an Eclipse project. It also downloads into the Maven2 repository almost all the dependencies.

However, there are two steps that are not done:

  1. Set up the M2_REPO environment variable in Eclipse
  2. Download and install JTA

For the first, I found the following command:

mvn -Declipse.workspace=
 eclipse:add-maven-repo

And for the second problem, I found the answer on JUGPadova website. In short, the problem has to do with Sun’s licensing of some of their J2EE jar files. Once I downloaded the JTA.1.0.1B.jar file, the following command put it in place and took care of all remaining errors in my Eclipse project.

mvn install:install-file \
  -Dfile=./jta-1_0_1B-classes.zip \
  -DgroupId=javax.transaction \
  -DartifactId=jta -Dversion=1.0.1B \
  -Dpackaging=jar

Next Page »