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;
|
padding:2px 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
font-family:MyriadProRegular, Helvetica, sans-serif;
|
||||||
|
font-size:20px;
|
||||||
|
color: #c1c1c1;
|
||||||
|
font-style:italic;
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
margin:0;
|
margin:0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@ -317,6 +327,8 @@ li {
|
|||||||
width: 960px;
|
width: 960px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.follow a {
|
.follow a {
|
||||||
font-family:MyriadProRegular, Helvetica, sans-serif;
|
font-family:MyriadProRegular, Helvetica, sans-serif;
|
||||||
font-size:11px;
|
font-size:11px;
|
||||||
|
@ -386,25 +386,32 @@ $(document).ready(function(){
|
|||||||
</div><!-- end of content section -->
|
</div><!-- end of content section -->
|
||||||
|
|
||||||
<div class="hr"></div>
|
<div class="hr"></div>
|
||||||
|
|
||||||
<a id="smallprint">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- start of content section -->
|
<!-- start of content section -->
|
||||||
<div class="content_section">
|
<div class="content_section">
|
||||||
|
|
||||||
<div class="section_title">Everyone needs Robots!</div>
|
<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>
|
<p>
|
||||||
You should email me - <a href="mailto:colin@robohash.org"> colin@robohash.org</a>
|
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>
|
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><!-- end of content section -->
|
||||||
|
|
||||||
<div class="hr"></div>
|
<div class="hr"></div>
|
||||||
|
|
||||||
|
|
||||||
</a>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div><!-- end of wrapper -->
|
||||||
<!-- *************************************************************************
|
<!-- *************************************************************************
|
||||||
****************************** FOOTER SECTION ******************************
|
****************************** FOOTER SECTION ******************************
|
||||||
************************************************************************** -->
|
************************************************************************** -->
|
||||||
@ -423,7 +430,7 @@ $(document).ready(function(){
|
|||||||
<!-- start of footer right -->
|
<!-- start of footer right -->
|
||||||
<div id="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>
|
<div class="tweet"></div>
|
||||||
|
|
||||||
|
22
webfront.py
22
webfront.py
@ -29,7 +29,8 @@ class Robohash(object):
|
|||||||
hash.update(string)
|
hash.update(string)
|
||||||
self.hexdigest = hash.hexdigest()
|
self.hexdigest = hash.hexdigest()
|
||||||
self.hasharray = []
|
self.hasharray = []
|
||||||
|
self.iter = 0
|
||||||
|
|
||||||
def createHashes(self,count):
|
def createHashes(self,count):
|
||||||
#Create and store a series of hash-values
|
#Create and store a series of hash-values
|
||||||
#Basically, split up a hash (SHA/md5/etc) into X parts
|
#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 the count of just the directories beneath me.
|
||||||
return sum([len(dirs) for (root, dirs, files) in os.walk(path)])
|
return sum([len(dirs) for (root, dirs, files) in os.walk(path)])
|
||||||
|
|
||||||
def getHashList(self,map):
|
def getHashList(self,path):
|
||||||
#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.
|
|
||||||
#Each iteration, if we hit a directory, recurse
|
#Each iteration, if we hit a directory, recurse
|
||||||
#If not, choose the appropriate file, given the hashes, stored above
|
#If not, choose the appropriate file, given the hashes, stored above
|
||||||
path = map['path']
|
|
||||||
depth = map['depth']
|
|
||||||
completelist = []
|
completelist = []
|
||||||
locallist = []
|
locallist = []
|
||||||
for ls in os.listdir(path):
|
for ls in os.listdir(path):
|
||||||
if not ls.startswith("."):
|
if not ls.startswith("."):
|
||||||
if os.path.isdir(path + "/" + ls):
|
if os.path.isdir(path + "/" + ls):
|
||||||
returnval = self.getHashList({'path': path + "/" + ls ,'depth': depth + 1})
|
subfiles = self.getHashList(path + "/" + ls)
|
||||||
subfiles = returnval['completelist']
|
|
||||||
if subfiles is not None:
|
if subfiles is not None:
|
||||||
completelist = completelist + subfiles
|
completelist = completelist + subfiles
|
||||||
else:
|
else:
|
||||||
locallist.append( path + "/" + ls)
|
locallist.append( path + "/" + ls)
|
||||||
|
|
||||||
if len(locallist) > 0:
|
if len(locallist) > 0:
|
||||||
elementchoice = self.hasharray[map['depth']] % len (locallist)
|
elementchoice = self.hasharray[self.iter] % len(locallist)
|
||||||
luckyelement = locallist[elementchoice]
|
luckyelement = locallist[elementchoice]
|
||||||
locallist = []
|
locallist = []
|
||||||
locallist.append(luckyelement)
|
locallist.append(luckyelement)
|
||||||
|
self.iter += 1
|
||||||
|
|
||||||
|
|
||||||
completelist = completelist + locallist
|
completelist = completelist + locallist
|
||||||
return {'completelist':completelist,'depth':depth}
|
return completelist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -98,9 +95,8 @@ class ImgHandler(tornado.web.RequestHandler):
|
|||||||
else:
|
else:
|
||||||
ext = "png"
|
ext = "png"
|
||||||
self.set_header("Content-Type", "image/" + ext)
|
self.set_header("Content-Type", "image/" + ext)
|
||||||
hashlist = r.getHashList({'path':"blue",'depth':0})['completelist']
|
hashlist = r.getHashList("blue")
|
||||||
hashlist.sort()
|
hashlist.sort()
|
||||||
pprint.pprint(hashlist)
|
|
||||||
robohash = Image.open(hashlist[0])
|
robohash = Image.open(hashlist[0])
|
||||||
for png in hashlist:
|
for png in hashlist:
|
||||||
img = Image.open(png)
|
img = Image.open(png)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user