From e866dd28cee393b2dbf0dcb3fdd65198fa8c8e30 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Tue, 3 Dec 2019 11:55:52 +0100 Subject: [PATCH] Apply changes made on the server --- contextualise.py | 24 ++++++++++++++++++------ static/.gitignore | 2 ++ static/css/main.css | 14 +++++++++++--- templates/description.html | 1 + templates/home.html | 2 +- 5 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 static/.gitignore diff --git a/contextualise.py b/contextualise.py index 79cf5ed..e00cfd8 100644 --- a/contextualise.py +++ b/contextualise.py @@ -30,7 +30,7 @@ thefile = None #selected file for description positioninarray = 8 #counter listofdicts=[] #to be able to import and use json content datafromjson = [] -max_wordpath_items = 200 # limit the nr. of items, as to +max_wordpath_items = 500 # limit the nr. of items, as to prevent possible glitches with bots # #test getting json file from id # id = "17" @@ -144,6 +144,7 @@ def description(): #open json file, list filepaths in array and loop with thefile textfile="" textfiles=[] + namefile=[] with open("static/"+jsonfilefordescription, 'r') as f: data_dict = json.load(f) datafromjson = data_dict["files"] @@ -157,11 +158,12 @@ def description(): session["id"] = list(ids) # ... and therefore, we have to convert it back for file in datafromjson: if file.lower().endswith(('.html')): + namefile.append(file) with open("static/"+file,"r", encoding='utf-8') as f: textfile = f.read() textfile = Markup(textfile) textfiles.append(textfile) - return render_template('description.html', datafromjson=datafromjson, itemid=itemid, textfiles=textfiles, idno=idno, index_dict=index_dict) + return render_template('description.html', datafromjson=datafromjson, itemid=itemid, textfiles=textfiles, idno=idno, index_dict=index_dict, namefile=namefile) @app.route('/diverge', methods=['GET']) def diverge(): @@ -206,11 +208,16 @@ def get_file(): timelist = session["clicktime"] veryfirstnow = session['veryfirstnow'] clickongetfiletime = datetime.now() - - tadam = None initialtime = None +# USER IP ADDRESS OBTENTION + if request.environ.get('HTTP_X_FORWARDED_FOR') is None: + userip = request.environ['REMOTE_ADDR'] + else: + userip = request.environ['HTTP_X_FORWARDED_FOR'] # if behind a proxy + +# CALCULATION OF INITIAL TIME BEFORE FIRST CLICK if len(timelist) and not (timelist[0] is None): thetime = timelist[0] thetime = str(thetime) @@ -223,7 +230,12 @@ def get_file(): initialtime = "."*initialtime print(initialtime) +#CALCULATE FILE NUMBER + dirListing = os.listdir("scores/") + scorenumber = len(dirListing) + +# CONVERSION OF TIME INTO FORMATS THAT CAN BE USED FOR CALCULATIONS timelistforoperations = [] for t in timelist : t = str(t) @@ -239,7 +251,7 @@ def get_file(): print(timelistforoperations) print(idlist) - +# WEAVING DELAYS AND WORDS TOGETHER AS A HUGE STRING OF CHARACTERS for (word, time) in zip(wordpath,timelistforoperations): # for (word, time, uniqueid) in zip(wordpath,timelistforoperations, idlist): # print("word : "+word+"\n") @@ -303,7 +315,7 @@ def get_file(): # 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) + tadam = '\n'.join(out) +"\n\nScore number : "+str(scorenumber)+ "\nGenerated at : "+str(clickongetfiletime)+"\nBy author : "+ userip # have a message in file if no nav has been recorded so it's less dull than error page if tadam is None: diff --git a/static/.gitignore b/static/.gitignore new file mode 100644 index 0000000..c12b2d1 --- /dev/null +++ b/static/.gitignore @@ -0,0 +1,2 @@ +files + diff --git a/static/css/main.css b/static/css/main.css index 7a0a685..4ec3d64 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -66,6 +66,14 @@ h2,h3{ a{ color: black; } + +div.home > a{ + border-bottom: 1px dashed black; + padding: 0.1em; + margin: 0.5em; + line-height: 1.5em; +} + .text a:visited{ color: red; } @@ -111,12 +119,12 @@ div.homecontent{ div.home{ /* padding: 1em 5em 1em 7.5em; */ - padding-left: 9em; + padding-left: 15em; padding-top: 2em; padding-bottom: 3em; - padding-right: 0.5em; + padding-right: 5em; text-align: justify; - font-size: 1em; + font-size: 0.8em; } div.home a{ diff --git a/templates/description.html b/templates/description.html index 721e1da..b7c883e 100644 --- a/templates/description.html +++ b/templates/description.html @@ -27,6 +27,7 @@ {% set count=[0] %} {% for item in datafromjson %} {% if item.lower().endswith(('.html')) %} +

{{ namefile[count[0]][12:-5] }}

{{ textfiles[count[0]] }} {% if count.append(count.pop() + 1) %}{% endif %}


diff --git a/templates/home.html b/templates/home.html index 7bfb5f9..cd64a01 100644 --- a/templates/home.html +++ b/templates/home.html @@ -11,7 +11,7 @@ {% for word in wordlist_dict %} {% set address = "/diverge?search=" + word %} - {{ word }} • + {{ word }} {% endfor %}