*.bbl
*.blg
*.toc
+page*.pdf
+page*.svg
+ratings.db
--- /dev/null
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title> Hack My LitReview (Patent Pending) </title>
+ </head>
+<body>
+ <p> Someone once told me I needed to rest more, or maybe they meant something different, but basically you need to <code>POST</code> your answers.</p>
+ <p> Hopefully you can overcome this diabolical security measure I have so cunningly wrought upon my form. </p>
+ <p> <code>Happy HACKING</code></p>
+</body>
+
+</html>
--- /dev/null
+<!--<!DOCTYPE HTML>
+<html>
+ <head>
+ <title> Rate My LitReview (Patent Pending) </title>
+ </head>
+<body>-->
+ <div style="float: left; width: 50%">
+ <input type="image" src="sledgehammer.png" style="width:75px" alt="HAMMER OF JUDGEMENT">
+ <h2> Rate This Page </h2>
+ <p> Please answer the folowing questions first.</p>
+ <p> Or don't to give minimum rating. </p>
+
+
+ <h3> Formalness Of Language </h3>
+ <table>
+ <tr><td><input type="radio" name="formalness" value="Space Baboon" checked="yes"></td> <td> Space Baboon </td> </tr>
+ <tr><td><input type="radio" name="formalness" value="Pirate Ship"></td> <td> Pirate Ship</td> </tr>
+ <tr><td><input type="radio" name="formalness" value="Royal Dementia"></td> <td> Royal Dementia </td> </tr>
+ <tr><td><input type="radio" name="formalness" value="School Ball"></td> <td> School Ball </td> </tr>
+ <tr><td><input type="radio" name="formalness" value="Officer Of The Day"></td> <td> Officer Of The Day </td> </tr>
+ </table>
+
+ <h3> Citeyness </h3>
+ <table>
+ <tr><td><input type="radio" name="citeyness" value="Nary A Reference In Cite" checked="yes"></td> <td> Nary A Reference In Cite </td> </tr>
+ <tr><td><input type="radio" name="citeyness" value="[Citation Needed]"></td> <td> [Citation Needed]</td> </tr>
+ <tr><td><input type="radio" name="citeyness" value="[?] Does Not Count"></td> <td> [?] Does Not Count </td> </tr>
+ <tr><td><input type="radio" name="citeyness" value="Citation Ham Sandwich"></td> <td> Citation Ham Sandwich </td> </tr>
+ <tr><td><input type="radio" name="citeyness" value="More Citations Than Words"></td> <td> More Citations Than Words </td> </tr>
+ </table>
+
+ <h3> Reviewyness </h3>
+ <table>
+ <tr><td><input type="radio" name="reviewyness" value="A Plague of Iarism" checked="yes"></td> <td> A Plague of Iarism </td> </tr>
+ <tr><td><input type="radio" name="reviewyness" value="Wikipedia"></td> <td> Wikipedia</td></tr>
+ <tr><td><input type="radio" name="reviewyness" value="The Articles Linked From Wikipedia"></td> <td> The Articles Linked From Wikipedia </td> </tr>
+ <tr><td><input type="radio" name="reviewyness" value="Blog Posts"></td> <td> Blog Posts </td> </tr>
+ <tr><td><input type="radio" name="reviewyness" value="Papers that link to Blog Posts"></td> <td> Papers that link to Blog Posts</td> </tr>
+ <tr><td><input type="radio" name="reviewyness" value="What, you expected me to check your citations?"></td> <td>What, you expected me to check your citations?</td> </tr>
+
+ </table>
+
+ <h3>Overallness</h3>
+ <table>
+ <tr><td><input type="radio" name="overallness" value="Tear Inducingly Bad" checked="yes"></td> <td> Tear Inducingly Bad</td></tr>
+ <tr><td><input type="radio" name="overallness" value="Just Bad Enough To Read"></td> <td>Just Bad Enough To Read</td> </tr>
+ <tr><td><input type="radio" name="overallness" value="Interestingly Insignificant"></td> <td>Interestingly Insignificant</td> </tr>
+ <tr><td><input type="radio" name="overallness" value="Blog Post Worthy"></td> <td> Blog Post Worthy </td> </tr>
+ <tr><td><input type="radio" name="overallness" value="Would Read Another Page"></td> <td> Would Read Another Page</td> </tr>
+ </table>
+ </div>
+
+ <div style="float: right; width: 50%">
+ <!--<input type="reset">-->
+ <h3> Accurateness </h3>
+ <table>
+ <tr><td><input type="radio" name="accurateness" value="Dan Brown" checked="yes"></td> <td> Dan Brown</td></tr>
+ <tr><td><input type="radio" name="accurateness" value="A Body Of Lies"></td> <td>A Body Of Lies </td> </tr>
+ <tr><td><input type="radio" name="accurateness" value="As Right As Stalin"></td> <td>As Right As Stalin </td> </tr>
+ <tr><td><input type="radio" name="accurateness" value="Ministry Of Truth"></td> <td> Ministry Of Truth </td> </tr>
+ <tr><td><input type="radio" name="accurateness" value="Right Until Proven Left"></td> <td> Right Until Proven Left</td> </tr>
+ <tr><td><input type="radio" name="accurateness" value="No Shit Sherlock"></td> <td>No Shit Sherlock</td> </tr>
+
+ </table>
+
+ <h3>Boringness</h3>
+ <table>
+ <tr><td><input type="radio" name="boringness" value="A Joy To Read"></td> <td> A Joy To Read</td></tr>
+ <tr><td><input type="radio" name="boringness" value="Somebody call the Fun Police"></td> <td>Somebody call the Fun Police </td> </tr>
+ <tr><td><input type="radio" name="boringness" value="Too Punishing"></td> <td>Too Punishing </td> </tr>
+ <tr><td><input type="radio" name="boringness" value="Needs Salt"></td> <td> Needs Salt </td> </tr>
+ <tr><td><input type="radio" name="boringness" value="Deliciously Dry"></td> <td> Deliciously Dry</td> </tr>
+ <tr><td><input type="radio" name="boringness" value="Desert With One S"></td> <td>Desert With One S</td> </tr>
+ <tr><td><input type="radio" name="boringness" value="RFC2324" checked="yes"></td> <td>RFC2324</td> </tr>
+
+ </table>
+
+ <h3>Pointyness</h3>
+ <table>
+ <tr><td><input type="radio" name="pointyness" value="Blunt As A Pixel" checked="yes"></td> <td> Blunt As A Pixel</td></tr>
+ <tr><td><input type="radio" name="pointyness" value="Infinitely Flat"></td> <td>Infinitely Flat </td> </tr>
+ <tr><td><input type="radio" name="pointyness" value="Arbitrarily Smooth"></td> <td>Arbitrarily Smooth </td> </tr>
+ <tr><td><input type="radio" name="pointyness" value="Precisely Vague"></td> <td> Precisely Vague </td> </tr>
+ <tr><td><input type="radio" name="pointyness" value="Lead Pencil"></td> <td> Lead Pencil</td> </tr>
+ </table>
+
+
+ <h3> Words of Wisdom <h3>
+ <input type="text" name="message" value="">
+
+ <h3> Turing Test </h3>
+ <p> Are You A Robot? <input type="text" name="secret" value="No"></p>
+
+
+
+ </div>
+
+ </form>
+<!--</body>
+</html>-->
--- /dev/null
+#!/usr/bin/python
+
+import sys
+import os
+import sqlite3
+import cgi
+import smtplib
+from email.mime.text import MIMEText
+import datetime
+import subprocess
+import random
+
+# Setup a sqlite3 database before deploying:
+# sqlite3 ratings.db
+# sqlite> CREATE TABLE ratings(formalness, citeyness, reviewyness, accurateness, boringness, pointyness, overallness, version, time, message, page);
+# Get rid of database by DROP TABLE or deleting the file
+
+secret_answers = ["No", "no"]
+dbfile = "ratings.db"
+
+def print_form(name):
+ """ Print the form """
+ f = open(name,"r")
+ for line in f.readlines():
+ print(line)
+ f.close()
+
+def git_stamp():
+ # Python is nice but sometimes you just need to bash it over the head
+ p = subprocess.Popen("git show | head --lines=1 | awk '{print $NF}'", stdout=subprocess.PIPE, shell=True)
+ return p.stdout.readline().strip(" \r\n")
+
+def main(argv):
+ """ Do the shit """
+ con = sqlite3.connect(dbfile)
+ c = con.cursor()
+
+ # Values we expect
+ values = {
+ "formalness" : "",
+ "citeyness" : "",
+ "reviewyness" : "",
+ "accurateness" : "",
+ "boringness" : "",
+ "pointyness" : "",
+ "overallness" : "",
+ "page" : 0,
+ "secret" : "No"
+ }
+
+ sanity = True
+
+ # Max pages
+ p = subprocess.Popen("pdfinfo thesis.pdf | grep Pages | sed 's/[^0-9]*//'", stdout=subprocess.PIPE, shell=True)
+ max_pages = int(p.stdout.read().strip(" \r\bn"))
+
+
+
+ form = cgi.FieldStorage()
+
+ # Check we have all the values
+ for k in values.keys():
+ if k in form:
+ values[k] = form[k].value
+
+
+ # No values? Print the form
+ if len(form.keys()) <= 0 or "page" not in form:
+ values["page"] = random.randint(1, max_pages)
+
+ print("Content-type: text/html\n")
+ print("<!DOCTYPE html>")
+ print("<html>")
+ print("<head><title>Rate My LitReview(TM) (Patent Pending)</title>")
+ print("<style>body {font-size: 0;}")
+ print("body * {font-size: 16px;}")
+ print("</style>")
+ print("</head>")
+ print("<body style=\"font-size: 0;\">")
+
+ # Check page number
+ try:
+ values["page"] = int(values["page"])
+ except:
+ print("<p> Invalid Page %s!</p>" % values["page"])
+ values["page"] = random.randint(1, max_pages)
+ sanity = False
+
+ print("<form id=\"rating\" action=\"rate-my-litreview.py\" method=\"POST\">")
+
+
+ print("<h1>Rate My Lit Review</h1>")
+ print("<p>Read a page, then rate it with the hammer of judgement!</p>")
+ print("<p> Page: <input type=\"text\" name=\"page\" value=\"%d\" disabled> of %d" % (values["page"], max_pages))
+ if values["page"] > 1:
+ print("<a href=\"rate-my-litreview.py?page=%d\">Prev</a>" % (values["page"]-1))
+ if values["page"] < max_pages:
+ print("<a href=\"rate-my-litreview.py?page=%d\">Next</a>" % (values["page"]+1))
+ print("</p>")
+
+
+
+
+
+ # Check secret question
+ if values["secret"] not in secret_answers:
+ print("<p><b>You failed the turing test!</b> Hint: The answer is \"No\"</p>")
+ sanity = False
+ del values["secret"]
+
+
+ print("<div style=\"float: left; border:0px solid black;\">")
+ print("<img src=\"read-my-litreview.py?page=%d\" border=\"1\";>" % values["page"])
+ print("</div>")
+
+
+ print("<div style=\"float: right; border:0px solid black; width:43%;\">")
+ print_form("rate-my-litreview.html")
+ print("</div>")
+
+
+ if not sanity:
+ return 1
+
+ if len(form.keys()) <= 1:
+ print("</body></html>")
+ return 0
+
+ # Sanity checks complete; set other values
+ values.update({"time" : int(datetime.datetime.now().strftime("%s"))})
+ values.update({"version" : git_stamp()})
+
+ # Produce emails
+
+ # Send emails
+ userMsg = "Someone Rated Your LitReview!\n"
+ userMsg += "Your ratings\n-----------------\n"
+ for k in values:
+ userMsg += str(k) + ":\t" + str(values[k])
+
+ userMsg += "Happy LitReviewing!\n"
+ userMsg += "\n\nNOTE: This Message Automatically Sent By Rate My LitReview(TM) (Patent Pending)\n"
+ userMsg = MIMEText(userMsg)
+ for i,msg in enumerate([userMsg]):
+ msg["Subject"] = "Rate My LitReview"
+ msg["To"] = emails[i]
+ s = smtplib.SMTP("localhost")
+ s.sendmail(msg["From"], [msg["To"]], msg.as_string())
+ s.quit()
+
+ # Tell them what happened.
+ # Do the thing
+ c.execute("INSERT INTO ratings("+",".join(values.keys())+") VALUES("+",".join(["?" for _ in xrange(len(values.keys()))])+")", [values[k] for k in values.keys()])
+ con.commit()
+ con.close()
+
+ print("<script>alert(\"Thank you for rating Page %d.\");</script><noscript>Thanks for rating Page %d</noscript>" % (values["page"], values["page"]))
+ print("</body></html>")
+ return 0
+
+
+if __name__ == "__main__":
+ #try:
+ sys.exit(main(sys.argv))
+ #except:
+ # print "Content-type: text/plain\r\n\r\n"
+ # print "Something went wrong! You were unable to Rate Sam's LitReview(TM)!\nPlease send him an abusive email instead <matches at ucc.asn.au>\n"
+
--- /dev/null
+#!/usr/bin/python
+
+import sys
+import os
+import cgi
+import time
+
+def main(argv):
+ form = cgi.FieldStorage()
+ page = int(form["page"].value)
+
+
+ try:
+ f = open("page%d.svg" % page)
+ except IOError:
+ os.system("pdftk A=thesis.pdf cat A%d output page%d.pdf" % (page, page))
+ os.system("inkscape -l page%d.svg page%d.pdf" % (page, page))
+ os.unlink("page%d.pdf" % page)
+ f = open("page%d.svg" % page)
+
+ output = f.read()
+ print("Content-Length: %d" % len(output))
+ print("Content-Type: image/svg+xml\n")
+ sys.stdout.write(output)
+ f.close()
+
+ # TODO: Auto remove these on git pull, for now will just have to remember to do it
+ #os.unlink("page%d.svg" % page)
+
+
+
+
+if __name__ == "__main__":
+ #try:
+ main(sys.argv)
+ #except:
+ # print("Content-type: text/plain\n")
+ # print("Something went wrong!\n")
+ sys.exit(0)