mirror of
https://github.com/e1ven/Robohash.git
synced 2025-06-23 21:35:02 +00:00
Fix bugs
This commit is contained in:
parent
d292f70879
commit
1e66a9c429
@ -259,6 +259,16 @@ img.right {
|
||||
padding:2px 0 0 0;
|
||||
}
|
||||
|
||||
a {
|
||||
font-family:MyriadProRegular, Helvetica, sans-serif;
|
||||
font-size:20px;
|
||||
color: #c1c1c1;
|
||||
font-style:italic;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ul {
|
||||
margin:0;
|
||||
padding: 0;
|
||||
@ -317,6 +327,8 @@ li {
|
||||
width: 960px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.follow a {
|
||||
font-family:MyriadProRegular, Helvetica, sans-serif;
|
||||
font-size:11px;
|
||||
|
@ -386,25 +386,32 @@ $(document).ready(function(){
|
||||
</div><!-- end of content section -->
|
||||
|
||||
<div class="hr"></div>
|
||||
|
||||
<a id="smallprint">
|
||||
|
||||
|
||||
<!-- start of content section -->
|
||||
<div class="content_section">
|
||||
|
||||
<div class="section_title">Everyone needs Robots!</div>
|
||||
RoboHash.org is here because Robots are funny, and because I needed the algorithm/art anyway for a Super-Awesome new forum I'm working on.<br>
|
||||
You should email me - <a href="mailto:colin@robohash.org"> colin@robohash.org</a>
|
||||
<p>
|
||||
RoboHash.org is here because Robots are funny, and because I needed the algorithm/art anyway for a Super-Awesome new forum I'm working on.</p><p>
|
||||
|
||||
You should email me -
|
||||
|
||||
<a href="mailto:colin@robohash.org" class="fade" title="I am probably not a robot."> colin@robohash.org</a>
|
||||
</p><p>
|
||||
|
||||
If the bandwidth gets crazy, I might add a [Robohash.org] banner to the bottom of the image. But it'd be super-tasteful.<br>
|
||||
|
||||
</p>
|
||||
</div><!-- end of content section -->
|
||||
|
||||
<div class="hr"></div>
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
</div><!-- end of wrapper -->
|
||||
<!-- *************************************************************************
|
||||
****************************** FOOTER SECTION ******************************
|
||||
************************************************************************** -->
|
||||
@ -423,7 +430,7 @@ $(document).ready(function(){
|
||||
<!-- start of footer right -->
|
||||
<div id="footer_right">
|
||||
|
||||
<span class="footer_heading">Twitter</span> <span class="follow"><a href="http://www.twitter.org/robohash" class="fade" title="Clicking on this will replace your cat with a robot.">Follow Us</a></span>
|
||||
<span class="footer_heading">Twitter</span> <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>
|
||||
|
||||
|
22
webfront.py
22
webfront.py
@ -29,7 +29,8 @@ class Robohash(object):
|
||||
hash.update(string)
|
||||
self.hexdigest = hash.hexdigest()
|
||||
self.hasharray = []
|
||||
|
||||
self.iter = 0
|
||||
|
||||
def createHashes(self,count):
|
||||
#Create and store a series of hash-values
|
||||
#Basically, split up a hash (SHA/md5/etc) into X parts
|
||||
@ -44,34 +45,30 @@ class Robohash(object):
|
||||
#return the count of just the directories beneath me.
|
||||
return sum([len(dirs) for (root, dirs, files) in os.walk(path)])
|
||||
|
||||
def getHashList(self,map):
|
||||
#Kinda a complicated function.
|
||||
#Basically, we're recursively calling ourselves, and keeping track of the depth
|
||||
#Since we use two return values, we're storing them in a map.
|
||||
def getHashList(self,path):
|
||||
#Each iteration, if we hit a directory, recurse
|
||||
#If not, choose the appropriate file, given the hashes, stored above
|
||||
path = map['path']
|
||||
depth = map['depth']
|
||||
completelist = []
|
||||
locallist = []
|
||||
for ls in os.listdir(path):
|
||||
if not ls.startswith("."):
|
||||
if os.path.isdir(path + "/" + ls):
|
||||
returnval = self.getHashList({'path': path + "/" + ls ,'depth': depth + 1})
|
||||
subfiles = returnval['completelist']
|
||||
subfiles = self.getHashList(path + "/" + ls)
|
||||
if subfiles is not None:
|
||||
completelist = completelist + subfiles
|
||||
else:
|
||||
locallist.append( path + "/" + ls)
|
||||
|
||||
if len(locallist) > 0:
|
||||
elementchoice = self.hasharray[map['depth']] % len (locallist)
|
||||
elementchoice = self.hasharray[self.iter] % len(locallist)
|
||||
luckyelement = locallist[elementchoice]
|
||||
locallist = []
|
||||
locallist.append(luckyelement)
|
||||
self.iter += 1
|
||||
|
||||
|
||||
completelist = completelist + locallist
|
||||
return {'completelist':completelist,'depth':depth}
|
||||
return completelist
|
||||
|
||||
|
||||
|
||||
@ -98,9 +95,8 @@ class ImgHandler(tornado.web.RequestHandler):
|
||||
else:
|
||||
ext = "png"
|
||||
self.set_header("Content-Type", "image/" + ext)
|
||||
hashlist = r.getHashList({'path':"blue",'depth':0})['completelist']
|
||||
hashlist = r.getHashList("blue")
|
||||
hashlist.sort()
|
||||
pprint.pprint(hashlist)
|
||||
robohash = Image.open(hashlist[0])
|
||||
for png in hashlist:
|
||||
img = Image.open(png)
|
||||
|
Loading…
x
Reference in New Issue
Block a user