Readme and junk. Open source yo
This commit is contained in:
commit
f3fab159ca
5 changed files with 163 additions and 0 deletions
76
index.html
Normal file
76
index.html
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Images in Comments on Reddit</title>
|
||||||
|
<style type="text/css">
|
||||||
|
html {
|
||||||
|
border-top: 5px solid #010101;
|
||||||
|
background-color: #c9c9c9;
|
||||||
|
font-family: helvetica, arial, sans-serif;
|
||||||
|
color: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
a, a:visited { color: #307ace; text-decoration: none; } a:hover { text-decoration: underline; }
|
||||||
|
|
||||||
|
body {
|
||||||
|
width: 600px;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 10px 40px;
|
||||||
|
margin: 3% auto 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 18px;
|
||||||
|
-webkit-border-radius: 1.7em;
|
||||||
|
-moz-border-radius: 1.7em;
|
||||||
|
border-radius: 1.7em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 { color: #f30; font-size: 28px; }
|
||||||
|
h2 { font-size: 18px; }
|
||||||
|
|
||||||
|
#theLulz { border: 1px solid #c9c9c9; margin: 15px 0 10px; width: 600px; height: 40px; }
|
||||||
|
#lulzInject { width: 590px; height: 150px; padding: 5px; line-height: 15px; font-size: 12px; font-family: inconsolata, monaco, monospace; }
|
||||||
|
#footer { text-align: center; }
|
||||||
|
#ohgoddontreadthis { display: block; margin: 10px 0 -5px 0; font-size: 9px; color: #c9c9c9; }
|
||||||
|
#userscript { display: block; padding: 10px; font-size: 18px; color: #fff; font-weight: bold; text-align: center;
|
||||||
|
-moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; background-color: #94b2d0; }
|
||||||
|
#userscript:hover { text-decoration: none; background-color: #82a8cf; }
|
||||||
|
</style>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function lulz(lol) {
|
||||||
|
document.getElementById("theLulz").style.display = "none";
|
||||||
|
document.getElementById("lulzInject").value = lol.replace(/blol/g, "\n");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Put Images in your Reddit Comments</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Once upon a time, there existed a <a href="http://www.reddit.com/r/commentimages/" title="Magical Subreddit">magical subreddit</a>
|
||||||
|
where a user by the name of <a href="http://reddit.com/user/jamt9000" title="jamt9000">jamt9000</a>
|
||||||
|
did some real mad scientist type work. He basically created a script (and corresponding stylesheet) to generate small-scale images in comments on Reddit. It
|
||||||
|
was a neat trick, but limited solely to that subreddit, as it required custom CSS to function. You see, madness, as you know, is like gravity - all
|
||||||
|
it takes is a little push!
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Then I got bored. I wrapped up his work into a service to generate the code necessary to show the images in the comments, and wrote a corresponding
|
||||||
|
user script (Firefox, Opera, Chrome, et al that support user scripts) to handle the necessary CSS injection. That's part of why this is cool - unless you
|
||||||
|
install said userscript, <strong>your Reddit experience will (mostly) not change at all - almost 100% opt-in</strong>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<a id="userscript" href="http://reddit.venodesigns.net/redditimages.user.js" title="Reddit: Images in Comments User Script">Download the Reddit: Images in Comments User Script</a>
|
||||||
|
|
||||||
|
<div id="bottom">
|
||||||
|
<iframe src="lulz.html" id="theLulz"></iframe>
|
||||||
|
<textarea id="lulzInject"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p id="footer">
|
||||||
|
This service was created by <a href="http://twitter.com/ryanmcgrath/" title="Ryan McGrath" target="_blank">Ryan McGrath</a>, because some men just like to watch the world burn.
|
||||||
|
In the spirit of the original effort by jamt9000, this work is all open sourced and up on Github.
|
||||||
|
<span id="ohgoddontreadthis">This may or may not cause Reddit pages to crash due to the amount of nodes appended. I claim social experiment.</span>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
21
lulz.html
Normal file
21
lulz.html
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Images in Comments on Reddit</title>
|
||||||
|
<style type="text/css">
|
||||||
|
html {
|
||||||
|
font-family: helvetica, arial, sans-serif;
|
||||||
|
color: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
a, a:visited { color: #307ace; text-decoration: none; } a:hover { text-decoration: underline; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form action="/upload_lulz.py" method="POST" enctype="multipart/form-data">
|
||||||
|
<input type="file" name="derimagen">
|
||||||
|
<input type="submit" value="And here... we... go!">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
11
readme.md
Normal file
11
readme.md
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
Reddit: Images in Comments
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
Based off the work done by Reddit user jamt9000 in http://www.reddit.com/r/commentimages/.
|
||||||
|
|
||||||
|
Requires
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
This stack runs on mod_wsgi/Python 2.5. Extremely barebones; fork, patch, port, whatever, just enjoy.
|
||||||
|
|
||||||
|
Contact?
|
||||||
|
------------------------------------------------------------------
|
||||||
|
ryan [/at\] venodesigns.net
|
||||||
13
redditimages.user.js
Normal file
13
redditimages.user.js
Normal file
File diff suppressed because one or more lines are too long
42
upload_lulz.py
Normal file
42
upload_lulz.py
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import numpy, sys, os, cgi
|
||||||
|
from PIL import Image
|
||||||
|
from cStringIO import StringIO
|
||||||
|
|
||||||
|
def application(environ, start_response):
|
||||||
|
if environ['REQUEST_METHOD'] == 'POST':
|
||||||
|
bert = environ.copy()
|
||||||
|
bert['QUERY_STRING'] = ''
|
||||||
|
post = cgi.FieldStorage(
|
||||||
|
fp = bert['wsgi.input'],
|
||||||
|
environ=bert,
|
||||||
|
keep_blank_values=True
|
||||||
|
)
|
||||||
|
map = {'000':'!','003':'#','006':'$','009':'%','00C':'&','00F':'*','030':'+','033':',','036':'-','039':'.','03C':'0','03F':'1','060':'2','063':'3','066':'4','069':'5','06C':'6','06F':'7','090':'8','093':'9','096':':','099':';','09C':'<','09F':'=','0C0':'>','0C3':'?','0C6':'@','0C9':'A','0CC':'B','0CF':'C','0F0':'D','0F3':'E','0F6':'F','0F9':'G','0FC':'H','0FF':'I','300':'J','303':'K','306':'L','309':'M','30C':'N','30F':'O','330':'P','333':'Q','336':'R','339':'S','33C':'T','33F':'U','360':'V','363':'W','366':'X','369':'Y','36C':'Z','36F':'^','390':'_','393':'`','396':'a','399':'b','39C':'c','39F':'d','3C0':'e','3C3':'f','3C6':'g','3C9':'h','3CC':'i','3CF':'j','3F0':'k','3F3':'l','3F6':'m','3F9':'n','3FC':'o','3FF':'p','600':'q','603':'r','606':'s','609':'t','60C':'u','60F':'v','630':'w','633':'x','636':'y','639':'z','63C':'{','63F':'|','660':'}','663':'~','666':'①','669':'②','66C':'③','66F':'④','690':'⑤','693':'⑥','696':'⑦','699':'⑧','69C':'⑨','69F':'⑩','6C0':'⑪','6C3':'⑫','6C6':'⑬','6C9':'⑭','6CC':'⑮','6CF':'⑯','6F0':'⑰','6F3':'⑱','6F6':'⑲','6F9':'⑳','6FC':'⑴','6FF':'⑵','900':'⑶','903':'⑷','906':'⑸','909':'⑹','90C':'⑺','90F':'⑻','930':'⑼','933':'⑽','936':'⑾','939':'⑿','93C':'⒀','93F':'⒁','960':'⒂','963':'⒃','966':'⒄','969':'⒅','96C':'⒆','96F':'⒇','990':'⒈','993':'⒉','996':'⒊','999':'⒋','99C':'⒌','99F':'⒍','9C0':'⒎','9C3':'⒏','9C6':'⒐','9C9':'⒑','9CC':'⒒','9CF':'⒓','9F0':'⒔','9F3':'⒕','9F6':'⒖','9F9':'⒗','9FC':'⒘','9FF':'⒙','C00':'⒚','C03':'⒛','C06':'⒜','C09':'⒝','C0C':'⒞','C0F':'⒟','C30':'⒠','C33':'⒡','C36':'⒢','C39':'⒣','C3C':'⒤','C3F':'⒥','C60':'⒦','C63':'⒧','C66':'⒨','C69':'⒩','C6C':'⒪','C6F':'⒫','C90':'⒬','C93':'⒭','C96':'⒮','C99':'⒯','C9C':'⒰','C9F':'⒱','CC0':'⒲','CC3':'⒳','CC6':'⒴','CC9':'⒵','CCC':'Ⓐ','CCF':'Ⓑ','CF0':'Ⓒ','CF3':'Ⓓ','CF6':'Ⓔ','CF9':'Ⓕ','CFC':'Ⓖ','CFF':'Ⓗ','F00':'Ⓘ','F03':'Ⓙ','F06':'Ⓚ','F09':'Ⓛ','F0C':'Ⓜ','F0F':'Ⓝ','F30':'Ⓞ','F33':'Ⓟ','F36':'Ⓠ','F39':'Ⓡ','F3C':'Ⓢ','F3F':'Ⓣ','F60':'Ⓤ','F63':'Ⓥ','F66':'Ⓦ','F69':'Ⓧ','F6C':'Ⓨ','F6F':'Ⓩ','F90':'ⓐ','F93':'ⓑ','F96':'ⓒ','F99':'ⓓ','F9C':'ⓔ','F9F':'ⓕ','FC0':'ⓖ','FC3':'ⓗ','FC6':'ⓘ','FC9':'ⓙ','FCC':'ⓚ','FCF':'ⓛ','FF0':'ⓜ','FF3':'ⓝ','FF6':'ⓞ','FF9':'ⓟ','FFC':'ⓠ','FFF':'ⓡ',}
|
||||||
|
#print post['derimagen'].value
|
||||||
|
im = Image.open( StringIO(post['derimagen'].value) )
|
||||||
|
im = im.convert('P', palette = Image.WEB)
|
||||||
|
im = im.convert('RGB')
|
||||||
|
pixels = numpy.asarray(im)
|
||||||
|
output= ""
|
||||||
|
for line in pixels:
|
||||||
|
for pixel in line:
|
||||||
|
color = ""
|
||||||
|
for value in pixel:
|
||||||
|
hex = "%X" % value
|
||||||
|
color += hex[0]
|
||||||
|
link = "[](/%s)" % map[color]
|
||||||
|
output += link
|
||||||
|
output += " blol"
|
||||||
|
else:
|
||||||
|
output = "N/A"
|
||||||
|
te = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>'
|
||||||
|
te += '<body>'
|
||||||
|
te += '<script type="text/javascript">if(parent && typeof parent.lulz === "function") parent.lulz("' + output + '");</script>'
|
||||||
|
te += '</body></html>'
|
||||||
|
response_headers = [
|
||||||
|
('Content-Length', str(len(te))),
|
||||||
|
('Content-Type', 'text/html'),
|
||||||
|
]
|
||||||
|
start_response('200 OK', response_headers)
|
||||||
|
return [te]
|
||||||
Reference in a new issue