#!/usr/bin/python # # CGI script to display contents of an RGTP server as bubbles # Thomas Thurman, autumn 2002 import Yarrow.cache import Yarrow.rgtp import time import md5 import math placement = [] def overlap1d(a,b,ap,bp): return ap%s' % ( link,title,size,size,title,x,y,size,size,colour) print "Content-Type: text/html" print print '' print 'GROGGS bubbles' connection = Yarrow.rgtp.fancy('rgtp-serv.groggs.group.cam.ac.uk', 1431, 0) connection.raise_access_level(None, None, None, 1) items = Yarrow.cache.index('groggs', connection).items() now = int(time.time()) for key in items.keys(): age = now-items[key]['date'] width = math.sqrt(items[key]['count']/math.pi)*10 y = int(age / 200000) y = y-width/2 x = 0 clear = 0 while not clear: clear = 1 for bubble in placement: if overlap(bubble['x'], bubble['y'], bubble['diameter'], x, y, width): # then we have a clash clear = 0 x = bubble['x'] + bubble['diameter'] draw_bubble(x, y, width, md5.new(items[key]['subject']).hexdigest()[0:6], 'http://rgtp.thurman.org.uk/gossip/groggs/'+key, items[key]['subject'].replace('"',""")) placement.append({'x':x, 'y':y, 'diameter':width}) print ""