diff --git a/handler.py b/handler.py old mode 100644 new mode 100755 index f2431d3..626bf4c --- a/handler.py +++ b/handler.py @@ -14,7 +14,7 @@ #------------------------------------------------------------ class BaseHandler(tornado.web.RequestHandler): - + def get_current_user(self): return [] @@ -38,7 +38,7 @@ def get_current_user(self): class MainHandler(BaseHandler): def initialize(self): return - + def get(self): self.render( 'templates/index.html', @@ -51,13 +51,13 @@ def get(self): class ViewAboutHandler(BaseHandler): def initialize(self): return - + def get(self): self.render( 'templates/about.html', ) - + #------------------------------------------------------------ # /parse/ajax #------------------------------------------------------------ @@ -76,7 +76,7 @@ def find_str(self, s, char): return index index += 1 return -1 - + def findEntireLine(self, contents, str): lineNum = 0 for item in contents.split("\n"): @@ -84,13 +84,13 @@ def findEntireLine(self, contents, str): linkPos = self.find_str(item, str) return item,lineNum,linkPos lineNum = lineNum+1 - + def parseForLinks(self, contents): discoveredLinks = [] outputLinks = [] # ugh lol regex = "(`|'|\")([\/]([_a-zA-Z0-9\-\_]+))+" - links = re.finditer(regex, contents) + links = re.finditer(regex, contents) for link in links: linkStr = link.group(0) # discoveredLinks list to avoid dupes and complex dupe checks @@ -114,7 +114,7 @@ def getFormattedTimestamp(self): def formatHTMLOutput(self, html): output = output + html return output - + def beautifyJS(self, content): return jsbeautifier.beautify(content) @@ -122,17 +122,17 @@ def isLongLine(self, line): if len(line)>1000: return True return False - + def fileRoutine(self, url, content): html = "" - + # beautify the JS for cleaner parsing # note: this can be slow against large JS files and can lead to failure prettyContent = self.beautifyJS(content) - + # parse all the links out parsedLinks = self.parseForLinks(prettyContent) - + # if we have results, start building HTML if parsedLinks: print "Discovered {} links in {}".format(len(parsedLinks), url) @@ -153,43 +153,44 @@ def fileRoutine(self, url, content): html = html+'