diff --git a/__pycache__/contextualise.cpython-35.pyc b/__pycache__/contextualise.cpython-35.pyc index cea4e45..4f4d913 100644 Binary files a/__pycache__/contextualise.cpython-35.pyc and b/__pycache__/contextualise.cpython-35.pyc differ diff --git a/contextualise.py b/contextualise.py index f08c96b..ba8e57d 100644 --- a/contextualise.py +++ b/contextualise.py @@ -112,9 +112,10 @@ def functionsession(): return(session) # THIS IS NOT WORKING YET DUNNO WHY -# @app.context_processor -# def context_processor(): -# return dict(functionsession=functionsession) +@app.context_processor +def context_processor(): + functionsession = session['wordpath'] + return dict(functionsession=functionsession) @app.route('/about/') def about(): @@ -182,7 +183,21 @@ def get_file(): idlist = session["id"] timelist = session["clicktime"] veryfirstnow = session['veryfirstnow'] + clickongetfiletime = datetime.now() + tadam = None + initialtime = None + + if not (timelist[0] is None): + thetime = timelist[0] + thetime = str(thetime) + thetime = dt.datetime.strptime(thetime, '%Y-%m-%d %H:%M:%S.%f') + initialtime = thetime - veryfirstnow + initialtime = initialtime.total_seconds() + initialtime = int(initialtime) + initialtime = "."*initialtime + + print(initialtime) for t in timelist : t = str(t) @@ -192,7 +207,16 @@ def get_file(): prev = None wholestringy = None + print("veryfirstnow : "+str(veryfirstnow)+"\n") + + + for (word, time, uniqueid) in zip(wordpath,timelistforoperations, idlist): + print("word : "+word+"\n") + print("timeofclick : "+str(time)+"\n") + print("============") + print(wordpath) + print("============") filler = int(uniqueid) upperword = word.upper() @@ -225,18 +249,41 @@ def get_file(): fullscore = wholestringy - #If fullscore length superior 60 characters, insert linebreak + # #If fullscore length superior 60 characters, insert linebreak + + # # Defining splitting point + # n = 60 + # # Using list comprehension + # out = [(fullscore[i:i+n]) for i in range(0, len(fullscore), n)] + # #joining the strings with linebreaks + # tadam = '\n'.join(out) + + if not (fullscore is None): + # outside of the loop calculate seconds from "clickongetfiletime" minus the last "time" from the loop + lastdifftime = clickongetfiletime - prev + lastdifftime = lastdifftime.total_seconds() + lastdifftime = int(lastdifftime) + lastdifftime = lastdifftime * '.' + #the 60 seconds thing + # print(lastdifftime+"\n") + fullscore = initialtime+fullscore+lastdifftime # Defining splitting point n = 60 # Using list comprehension out = [(fullscore[i:i+n]) for i in range(0, len(fullscore), n)] #joining the strings with linebreaks tadam = '\n'.join(out) + + + # have a message in file if no nav has been recorded so it's less dull than error page if tadam is None: tadam = "This score is Null" + # print("verylastnow : "+str(clickongetfilefime)+"\n") + + print(tadam) return Response(tadam, diff --git a/generate_links.py b/generate_links.py index ee86ca7..c39fd89 100644 --- a/generate_links.py +++ b/generate_links.py @@ -4,16 +4,17 @@ import re with open('wordlist.json', 'r') as f: wordlist_dict = json.load(f) - +#goes through every single file ending in html +# path = "static/files/" for path, subdirs, files in os.walk(path): for name in files: if name.endswith('html'): file = os.path.join(path, name) - with open(file, 'r+') as f: + with open(file, 'r+', encoding="utf-8") as f: textfile = f.read() for word in wordlist_dict: - # word = re.escape(word) + word = re.escape(word) textfile = re.sub(r"(?\1", textfile) f.truncate(0) f.write(textfile) diff --git a/templates/layout.html b/templates/layout.html index fb9e22d..7565c41 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -26,6 +26,9 @@ +
+ {{ functionsession }} +
{% block content %} {% endblock content %}