From 19c7b6fffbd2254a5c28c0e58566f684292a9f48 Mon Sep 17 00:00:00 2001
From: Robohash <401330+e1ven@users.noreply.github.com>
Date: Sat, 16 Jul 2011 00:23:55 -0400
Subject: [PATCH] Add popular feature
---
templates/root.html | 2 +-
webfront.py | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/templates/root.html b/templates/root.html
index 9bca480..e9291b9 100644
--- a/templates/root.html
+++ b/templates/root.html
@@ -414,7 +414,7 @@ src="http://static1.robohash.com/static/img/indented_star.png" width="27" height
-
Want a JPG instead? Fine. PNG? Fine. Want it as a bitmap? I think you're nutty. But fine. Just change the URL to request in any format you want.
+
Want a JPG instead? Fine. PNG? Fine. Want it as a bitmap? I think you're nutty. But fine. Just change the URL to request in any format you want. Use ?ignoreext=true to get the same robot across multiple format.
diff --git a/webfront.py b/webfront.py
index 79bce32..f77b95a 100755
--- a/webfront.py
+++ b/webfront.py
@@ -220,8 +220,19 @@ class ImgHandler(tornado.web.RequestHandler):
if string is None:
string = self.request.remote_ip
string = urllib.quote_plus(string)
+
+ if "ignoreext" in self.request.arguments:
+ client_ignoreext = tornado.escape.xhtml_escape(self.get_argument("ignoreext"))
+ else:
+ client_ignoreext = None
+
+ if client_ignoreext == "true":
+ if string.endswith(('.png','.gif','.jpg','.bmp','.im','.jpeg','.pcx','.ppm','.tiff','.xbm','tif')):
+ string = string[0:string.rfind('.')]
+ print string
r = Robohash(string)
-
+
+
#Create 10 hashes. This should be long enough for the current crop of variables.
#This is probably not insecure, sicne we'd be modding anyway. This just spreads it out more.
r.createHashes(11)
@@ -235,6 +246,9 @@ class ImgHandler(tornado.web.RequestHandler):
sizex = 300
sizey = 300
+
+
+
if "size" in self.request.arguments:
sizelist = self.get_argument("size").split(tornado.escape.xhtml_escape("x"),3)
if ((int(sizelist[0]) > 0) and (int(sizelist[0]) < 4096)):