Posted on February 18, 2008
For a long time we've wanted to get better looking property adverts onto Rentability. We thought about offering several layout templates that the owner could choose from. Then we thought about totally "floating" layouts where the user creates several "blocks" of content (text or photos) that are designed to flow down the page and be happy with different page widths and font sizes. The user doesn't have precise control over the placement of blocks. Instead, they have a bunch of blocks, of different dimensions that slot together down the page (from right to left and top to bottom) filling all available space. With fixed element widths (say a third or two thirds of the page) you can get a nice magazine/newspaper style look. Of course, a simple CSS float:left won't work all that well - you get a lot of holes where elements sort of clear:right as they wrap around down the page. So I tried to create this 'flowy' layout with javascript. The javascript measures each block, figures out how it slots into the layout, then positions it absolutely.
In the editing UI I've used scriptaculous to animate the reflowing of reordered blocks. This isn't always entirely intuitive - try the demo below - but then the whole approach is a compromise of sorts.
It's not beyond the realms of possibility that a layout will flow slightly differently on two different browsers. Actually, Sim's advert for the Pigeonnier lays out differently on IE than it does on Safari. Both looks great though! It's interesting how robust this technique can be.
Unless I've shown you a preview, you're probably wondering what the hell I'm going on about. Here's a demo page that you can play with (the changes you make are only visible by you).

Filed under: Projects |
Tagged with: rentability |
0 comments
Posted on February 15, 2008
Anyone pointing trac at a subversion repository built with svnsync might run into the same problem as me - trac shows commits but they show with author set to the username passed to the svnsync command and not the real author from the source repository. My best guess is that this happens because trac detects the checkin before synsync has copied over the revision properties (that includes changing the author). So to fix it, just add a post-revprop-change hook script (to the target repository) that tells trac to resync the revision concerned:
#!/bin/sh
REV="$2"
TRAC_ENV="/path/to/trac/environment"
/usr/bin/trac-admin "$TRAC_ENV" resync "$REV"
I also add the call to the contributed trac-post-commit-hook in there too (rather than putting it in post-commit):
/usr/bin/python /path/to/trac-post-commit-hook -p "$TRAC_ENV" -r "$REV"
Update: 19/02/08:
After receiving a lot of duplicate emails from trac I realised that the above approach isn't quite good enough. svnsync updates revision properties more than once per commit (once for each property I guess) so you end up resyncing redundantly and, in my case, calling trac-post-commit-hook several times (resulting in duplicate ticket updates). So I decided not to use the subversion hook scripts and to do what I needed to do to trac directly after running svnsync. Here's the script I run with cron:
SVN_USER = "rails"
FROM = "svn://www.example.org/project"
TO = "file:///path/to/repos-mirror/"
TRAC_ENV = "/path/to/trac/environment"
POST_COMMIT_HOOK_SCRIPT = "/path/to/trac-post-commit-hook"
sync_output = `svnsync sync --non-interactive --username "#{SVN_USER}" "#{TO}" "#{FROM}"`
unless sync_output.empty?
revisions = sync_output.scan(/Committed revision (\d+)/).flatten
puts sync_output
for rev in revisions
puts "Telling trac about revision #{rev}..."
puts `/usr/bin/trac-admin "#{TRAC_ENV}" resync "#{rev}"`
puts `/usr/bin/python "#{POST_COMMIT_HOOK_SCRIPT}" -p "#{TRAC_ENV}" -r "#{rev}"`
end
end
Filed under: Projects |
Tagged with: svn trac |
1 comment
Posted on February 14, 2008
How come every time I install trac I do it a different way? Mostly, I'm installing on Centos or Fedora these days. The RPMs available rpmforge only go up to trac 0.10. It seems sensible to go with the 0.11 beta for a new installation - the trac admin web UI is included by default, there are fewer dependencies and the default ticket workflow has changed a bit. After some fiddling about with the manual download, realising that trac.cgi is missing (maybe it's deprecated) I realised that installation is fairly straightforward if you get setuptools (some strange python "egg" installer) and use modpython rather than cgi/fcgi (it's more efficient and easier anyway).
So here are my steps so I don't forget them:
# As root
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
easy_install Pygments
easy_install Genshi
easy_install Trac
trac-admin /srv/trac/myproject initenv
chown -R apache:apache /srv/trac/myproject
nano /etc/httpd.d/trac.conf
# And add something like:
<Location "/trac">
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /srv/trac
PythonOption TracUriRoot /trac
# The following gives basic HTTP authentication
AuthType Basic
AuthName "Trac"
AuthUserFile /srv/users.htpasswd
Require valid-user
# ... which should be used with SSL:
SSLRequireSSL
</Location>
service httpd restart
Filed under: Projects |
3 comments