Blog personal de Héctor Pérez

Seekr Code

Publicado en English por Héctor en Diciembre 5, 2007

I leave the main (and very simple) method below. Go to the subversion repository git repository to find the complete code of Seekr (license: GNU Affero GPL). You may want to go to the camping site sinatra site.

def get(key)
vars=key.split('/')
size=vars.size - 1
list=YAML.load(IO.read('list.yml'))
case size
when 0
url="http://www.google.com/search?q=" + key
when 1
#e.g. seekr.es/w/free_software -> http://en.wikipedia.org/wiki/Free_software
url=list[vars[0]]
url.gsub!("$1$",vars[1]) if url
else
#e.g. seekr.es/w/es/GNU -> http://es.wikipedia.org/wiki/GNU
url=list[vars[0] + size.to_s]
size.times{|n| url.gsub!("$#{n+1}$",vars[n+1])} if url
end
if url
redirect url
else
...
end
end
Etiquetado con:, , ,

2 comentarios

Suscríbete a los comentarios mediante RSS.

  1. hecpeare.net » Seekr.es - simple y útil said, on Diciembre 5, 2007 at 7:30 pm

    [...] No se si existirá algo similar, pero como no cuesta casi nada programarlo (ya publicaré… ver el código), no me he detenido a [...]

  2. [...] Update: Seekr code [...]


Deja un comentario