Browse Source

Apply changes made on the server

master
Ruben van de Ven 5 years ago
parent
commit
e866dd28ce
  1. 24
      contextualise.py
  2. 2
      static/.gitignore
  3. 14
      static/css/main.css
  4. 1
      templates/description.html
  5. 2
      templates/home.html

24
contextualise.py

@ -30,7 +30,7 @@ thefile = None #selected file for description
positioninarray = 8 #counter positioninarray = 8 #counter
listofdicts=[] #to be able to import and use json content listofdicts=[] #to be able to import and use json content
datafromjson = [] 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 # #test getting json file from id
# id = "17" # id = "17"
@ -144,6 +144,7 @@ def description():
#open json file, list filepaths in array and loop with thefile #open json file, list filepaths in array and loop with thefile
textfile="" textfile=""
textfiles=[] textfiles=[]
namefile=[]
with open("static/"+jsonfilefordescription, 'r') as f: with open("static/"+jsonfilefordescription, 'r') as f:
data_dict = json.load(f) data_dict = json.load(f)
datafromjson = data_dict["files"] datafromjson = data_dict["files"]
@ -157,11 +158,12 @@ def description():
session["id"] = list(ids) # ... and therefore, we have to convert it back session["id"] = list(ids) # ... and therefore, we have to convert it back
for file in datafromjson: for file in datafromjson:
if file.lower().endswith(('.html')): if file.lower().endswith(('.html')):
namefile.append(file)
with open("static/"+file,"r", encoding='utf-8') as f: with open("static/"+file,"r", encoding='utf-8') as f:
textfile = f.read() textfile = f.read()
textfile = Markup(textfile) textfile = Markup(textfile)
textfiles.append(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']) @app.route('/diverge', methods=['GET'])
def diverge(): def diverge():
@ -206,11 +208,16 @@ def get_file():
timelist = session["clicktime"] timelist = session["clicktime"]
veryfirstnow = session['veryfirstnow'] veryfirstnow = session['veryfirstnow']
clickongetfiletime = datetime.now() clickongetfiletime = datetime.now()
tadam = None tadam = None
initialtime = 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): if len(timelist) and not (timelist[0] is None):
thetime = timelist[0] thetime = timelist[0]
thetime = str(thetime) thetime = str(thetime)
@ -223,7 +230,12 @@ def get_file():
initialtime = "."*initialtime initialtime = "."*initialtime
print(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 = [] timelistforoperations = []
for t in timelist : for t in timelist :
t = str(t) t = str(t)
@ -239,7 +251,7 @@ def get_file():
print(timelistforoperations) print(timelistforoperations)
print(idlist) print(idlist)
# WEAVING DELAYS AND WORDS TOGETHER AS A HUGE STRING OF CHARACTERS
for (word, time) in zip(wordpath,timelistforoperations): for (word, time) in zip(wordpath,timelistforoperations):
# for (word, time, uniqueid) in zip(wordpath,timelistforoperations, idlist): # for (word, time, uniqueid) in zip(wordpath,timelistforoperations, idlist):
# print("word : "+word+"\n") # print("word : "+word+"\n")
@ -303,7 +315,7 @@ def get_file():
# Using list comprehension # Using list comprehension
out = [(fullscore[i:i+n]) for i in range(0, len(fullscore), n)] out = [(fullscore[i:i+n]) for i in range(0, len(fullscore), n)]
#joining the strings with linebreaks #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 # have a message in file if no nav has been recorded so it's less dull than error page
if tadam is None: if tadam is None:

2
static/.gitignore

@ -0,0 +1,2 @@
files

14
static/css/main.css

@ -66,6 +66,14 @@ h2,h3{
a{ a{
color: black; color: black;
} }
div.home > a{
border-bottom: 1px dashed black;
padding: 0.1em;
margin: 0.5em;
line-height: 1.5em;
}
.text a:visited{ .text a:visited{
color: red; color: red;
} }
@ -111,12 +119,12 @@ div.homecontent{
div.home{ div.home{
/* padding: 1em 5em 1em 7.5em; */ /* padding: 1em 5em 1em 7.5em; */
padding-left: 9em; padding-left: 15em;
padding-top: 2em; padding-top: 2em;
padding-bottom: 3em; padding-bottom: 3em;
padding-right: 0.5em; padding-right: 5em;
text-align: justify; text-align: justify;
font-size: 1em; font-size: 0.8em;
} }
div.home a{ div.home a{

1
templates/description.html

@ -27,6 +27,7 @@
{% set count=[0] %} {% set count=[0] %}
{% for item in datafromjson %} {% for item in datafromjson %}
{% if item.lower().endswith(('.html')) %} {% if item.lower().endswith(('.html')) %}
<h3> {{ namefile[count[0]][12:-5] }}</h3>
{{ textfiles[count[0]] }} {{ textfiles[count[0]] }}
{% if count.append(count.pop() + 1) %}{% endif %} {% if count.append(count.pop() + 1) %}{% endif %}
<br/><br/><br/> <br/><br/><br/>

2
templates/home.html

@ -11,7 +11,7 @@
{% for word in wordlist_dict %} {% for word in wordlist_dict %}
{% set address = "/diverge?search=" + word %} {% set address = "/diverge?search=" + word %}
<a href={{address}}>{{ word }}</a> <a href={{address}}>{{ word }}</a>
{% endfor %} {% endfor %}
</div> </div>

Loading…
Cancel
Save