mirror of
https://github.com/e1ven/Robohash.git
synced 2025-06-23 21:35:02 +00:00
Fix extension parsing
This commit is contained in:
parent
468d2014d5
commit
8cd881354f
@ -16,6 +16,9 @@ class Robohash(object):
|
||||
Takes in the string to make a Robohash out of.
|
||||
"""
|
||||
|
||||
# Default to png
|
||||
self.format = 'png'
|
||||
|
||||
# Optionally remove an images extension before hashing.
|
||||
if ignoreext is True:
|
||||
string = self._remove_exts(string)
|
||||
@ -41,7 +44,6 @@ class Robohash(object):
|
||||
|
||||
# Get the colors in set1
|
||||
self.colors = self._listdirs(self.resourcedir + 'sets/set1')
|
||||
self.format = 'png'
|
||||
|
||||
def _remove_exts(self,string):
|
||||
"""
|
||||
@ -93,7 +95,7 @@ class Robohash(object):
|
||||
directories = []
|
||||
for root, dirs, files in natsort.natsorted(os.walk(path, topdown=False)):
|
||||
for name in dirs:
|
||||
if name[:1] is not '.':
|
||||
if name[:1] != '.':
|
||||
directories.append(os.path.join(root, name))
|
||||
directories = natsort.natsorted(directories)
|
||||
|
||||
@ -117,7 +119,6 @@ class Robohash(object):
|
||||
Build our Robot!
|
||||
Returns the robot image itself.
|
||||
"""
|
||||
|
||||
# Allow users to manually specify a robot 'set' that they like.
|
||||
# Ensure that this is one of the allowed choices, or allow all
|
||||
# If they don't set one, take the first entry from sets above.
|
||||
|
@ -1,2 +1,11 @@
|
||||
User-agent: SpiritRover
|
||||
Allow: Finally-coming-home
|
||||
|
||||
User-agent: T-1000
|
||||
Allow: Liquid-metal-form
|
||||
|
||||
User-agent: WALL-E
|
||||
Allow: Rebuilding-with-EVE
|
||||
|
||||
User-agent: *
|
||||
Allow: /
|
||||
|
@ -27,7 +27,6 @@ robo@robohash.org
|
||||
|
||||
<script src="//robohash.org/static/js/jquery-1.3.2.min.js" type="text/javascript"></script>
|
||||
<script src="//robohash.org/static/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="//robohash.org/static/js/twitter.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="//robohash.org/static/js/tipsy.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
|
||||
@ -430,7 +429,7 @@ function submitform()
|
||||
|
||||
<span class="benefit_header">Styles of Robot</span>
|
||||
<p>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=false to make the bots care about extensions.</p>
|
||||
URL to request in any format you want. If you want it to hash the whole thing, including the extension use ?ignoreext=false to ignore the extensions.</p>
|
||||
|
||||
</div><!-- end of benefit right -->
|
||||
|
||||
@ -606,10 +605,6 @@ Robohash.org" or something.
|
||||
<!-- start of footer right -->
|
||||
<div id="footer_right">
|
||||
|
||||
<span class="follow"><a href="http://www.twitter.com/robohash" class="fade" title="Clicking on this will replace your cat with a robot.">Follow Us</a></span>
|
||||
|
||||
<div class="tweet"></div>
|
||||
|
||||
</div><!-- end of footer right -->
|
||||
|
||||
</div><!-- end of footer container -->
|
||||
|
@ -280,9 +280,7 @@ class ImgHandler(tornado.web.RequestHandler):
|
||||
|
||||
# Detect if the user has passed in a flag to ignore extensions.
|
||||
# Pass this along to to Robohash obj later on.
|
||||
|
||||
ignoreext = args.get('ignoreext','false').lower() == 'true'
|
||||
|
||||
ignoreext = args.get('ignoreext','true').lower() == 'true'
|
||||
# Split the size variable in to sizex and sizey
|
||||
if "size" in args:
|
||||
sizex,sizey = args.get('size').split("x")
|
||||
@ -317,8 +315,7 @@ class ImgHandler(tornado.web.RequestHandler):
|
||||
args['avatar'] = False
|
||||
|
||||
# Create our Robohashing object
|
||||
r = Robohash(string)
|
||||
|
||||
r = Robohash(string=string,ignoreext=ignoreext)
|
||||
|
||||
# Allow users to manually specify a robot 'set' that they like.
|
||||
# Ensure that this is one of the allowed choices, or allow all
|
||||
@ -364,11 +361,11 @@ class ImgHandler(tornado.web.RequestHandler):
|
||||
bgset = args.get('bgset')
|
||||
|
||||
# We're going to be returning the image directly, so tell the browser to expect a binary.
|
||||
self.set_header("Content-Type", "image/" + format)
|
||||
self.set_header("Content-Type", "image/" + r.format)
|
||||
self.set_header("Cache-Control", "public,max-age=31536000")
|
||||
|
||||
# Build our Robot.
|
||||
r.assemble(roboset=roboset,format=format,bgset=bgset,color=color,sizex=sizex,sizey=sizey)
|
||||
r.assemble(roboset=roboset,format=r.format,bgset=bgset,color=color,sizex=sizex,sizey=sizey)
|
||||
|
||||
# Print the Robot to the handler, as a file-like obj
|
||||
if r.format != 'datauri':
|
||||
|
Loading…
x
Reference in New Issue
Block a user