Posts

Showing posts with the label Web

Just for a bit of fun... whohasmorefollowers.com

Recently I jumped on the Twitter bandwagon and created whohasmorefollowers.com - a simple service that lets you compare the number of followers for 2 Twitter users. This weekend I added a game feature to it - the player is presented with 2 random twitter users (from the top 50) and is challenged to guess which user has the most followers. It makes you think, and the results can surprise you! Why build such a thing? Well, just for a bit of fun really. But it was also a good excuse to familiarise myself with: jquery jquery plugins ( jquery.template ) blueprint css framework Another added benefit was with having such a simple application was that the whole exercise fitted into a very short timebox . The exposure to these frameworks made it worthwhile doing, and it reminded me how painful IE can be. If you're interested, play the game and tweet your score!

grails-selenium-0.4

This information is out of date - please see http://www.grails.org/Selenium+plugin Version 0.4 of the grails selenium plugin is now available. This version adds: scripts to create and run tests a postResults url for displaying the final test results Details are as follows: run-selenium Runs Selenium in the specified browser. Specify the path to your browser as a command line parameter i.e. grails run-selenium /usr/bin/firefox or, if the executable is on the path you would just need grails run-selenium firefox In your application.properties, you can specify: selenium.auto=true selenium.close=true selenium.multiWindow=true selenium.highlight=true selenium.resultsUrl=/your/url/here (defaults to ${appContext}/selenium/postResults) selenium.runInterval=1000 selenium.baseUrl= See http://selenium.openqa.org/installing.html (section titled Continuous Integration) for more information on selenium and continuous integration. create-selenium-test Generates a new empty selenium test. Supply th...

Regression testing grails plugins

For regression testing the grails plugins I've released, I have a shell script that: cleans up any previous runs packages the current code for the plugin OR downloads a release from my web site creates a new grails app copies preprepared resources into this new grails app installs the plugin Now all I have to do is run the application and test it through the browser (potential for selenium to help here?). This is great for testing the plugin against a new grails version, or just for testing code changes to the plugin itself. I put the script in <project_home>/test/regression/run.sh and the resources in <project_home>/test/regression/resources. The resources directory contains files like domain objects etc in the same directory layout as a normal grails project. This way I just need to copy the contents of the resources directory over the top of my newly created project. I should have written it as an ANT script though (what was I thinking?) - then it would be ...

Allowing or denying self registration with grails-acegi plugin

The grails-acegi-0.2 plugin is great - it adds login, user management, and user registration capabilities to your application in seconds. However, I'm building a web application where I want to be able to let the deployment team decide whether users can register themselves or alternatively, have an administrator create users. I want provide these settings without the deployment unit (the WAR file) having to be modified. I currently have a properties file for each server (DEV, STAGE, PROD) which defines properties specific to the environment - such as the email server and username/password etc. In this properties file, I also have application settings which are relevant to that environment. So, this is a good place to define a property: myapp.registration.enabled=false Grails has an excellent configuration strategy, and in my applications Config.groovy all I have to do is specify the external config locations: grails.config.locations = ["file:${System.getProperty('myapp.pro...

Maxlength HTML attribute for domain objects

With Grails domain classes, constraints can be specified - including the maximum size of a String. For example: class Book { String title static def constraints = { title(maxSize:20) } } When using 'grails generate-all' to create scaffolding, you'll notice that create.gsp and add.gsp hardcode the maxlength attribute: <input type="text" maxlength="20" id="title" name="title" value="${fieldValue(bean:book,field:'title')}"/> It is possible to directly reference the constraint, meaning that the maxlength attribute is not hardcoded - and thus only defined once (in the domain object): <input type="text" maxlength="${Book.constraints.title.getMaxSize()}" id="title" name="title" value="${fieldValue(bean:book,field:'title')}"/> In fact, we can go even further and create a tag where we pass in the object itself, and...

Limiting the content of a TextArea

Being able to limit the length of the content entered into a TextArea can be useful for various reasons. Although not supported natively by HTML, you can achieve the same effect using Javascript - on KeyUp and KeyDown events, check the length of the textarea value and truncate if necessary. We can also display how many characters are remaining if we want to provide user feedback. Because I've used this technique in several Grails applications, I've created a simple TagLib - you may want to customize it to your requirements. To use it: include the prototype library with <g:javascript library="prototype"/> use <jttext:changeScript /> once on your page for the utility script define your textarea including the maxlength attribute with <jttext:textArea id="messageField" maxlength="20" /> use <jttext:statusDiv for="messageField" /> to display the status message showing how many characters are left So, a simple GS...

Installing Grails on Linux

I run Linux ( Ubuntu 7.10) as my desktop operating system, and it's working out well. However, every time I upgrade Grails I forget to make the script in $GRAILS_HOME/bin executable and get this error: prule@dev2:~/workspace/film-suggestions-grails$ grails clean Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groovy/grails/cli/support/GrailsStarter So, if you find yourself with this cryptic message, it is time to RTFM - the installation instructions actually point out: If you get an error message, try to chmod +x the grails script inside the bin directory. When I googled this exception I got unrelated stuff. Hopefully now if you search for this you'll find this post and be up and running fast. Note:ร‚  I experience this problem because I always download the zip distribution. If you get the tar.gz binary, extracting this will preserve the correct file permissions.

BrowserShots - browser testing

Testing websites in all of the different browsers across all of the different platforms is no easy feat, and not always possible. I stumbled across BrowserShots which, given a web address, will produce screen shots of your website as they appear in different browsers on different platforms. This easily lets you see how your site is rendered. Although there are still other aspects you might want to test, having access to these screen shots is fantastic.

Wordpress themes

Looking for Wordpress themes? Try WPThemesFree.com . This site catalogues tons of themes, and has them categorised appropriately (number of columns, colour scheme, topic). You can view the themes against the test database, and there are statistics available for downloads, views, and tests.

Basic Apache2 setup

I just installed Apache 2.2.4 on Windows XP. I needed to set up virtual hosts , so I added the following to C:\WINDOWS\system32\drivers\etc\hosts: 127.0.0.1 server1.localhost server2.localhost 127.0.0.1 www.server1.localhost www.server2.localhost Now to configure Apache, the virtual host configuration needs to be included in C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf by uncommenting the line containing: Include conf/extra/httpd-vhosts.conf Edit C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf to set up your virtual hosts รข€“ In my case I used the following: NameVirtualHost *:80 <Directory /> Order deny,allow Allow from all </Directory> <VirtualHost 192.168.0.102:80> ServerAdmin webmaster@server1.localhost DocumentRoot /www/docs/server1.localhost ServerName server1.localhost ServerAlias www.server1.localhost ErrorLog logs/server1.localhost-error_log CustomLog logs/server1.localhost-access_log common </Virt...