juju's stuff

This commit is contained in:
zeroth 2019-11-27 18:02:41 +00:00
parent 86c603a7c4
commit eace763456
4 changed files with 1504 additions and 10 deletions

View File

@ -1,5 +1,7 @@
from flask import Flask, render_template, Markup, jsonify from flask import Flask, render_template, Markup, jsonify
import json import json
import os
from json import dumps
app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates") app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates")
app.jinja_env.add_extension('jinja2.ext.loopcontrols') app.jinja_env.add_extension('jinja2.ext.loopcontrols')
@ -8,17 +10,23 @@ app.jinja_env.add_extension('jinja2.ext.loopcontrols')
# SETTING THE VARIABLES # SETTING THE VARIABLES
path = "/static/files/" path = "/static/files/"
#move this list to Jinja so it can be placed in layout #move this list to Jinja so it can be placed in layout
#give back clicked value #give back clicked value
librarians = ["Alana", "Gentian", "Laurie", "Matias", "Scott", "Stacy", "Max", "Clara_B", "Michelle", "Clara_J_B", "Karen", "Lumsden_Primary_School", "Aaron", "Leo", "Maria", "Laura", "Honey", "Tender_Center", "wdka", "Naomi", "Cristina", "Julie", "ssw", "cyberspace", "Hannah", "Katarina", "Anastasia", "Kimmy", "Marie","Katherine", "Allison", "Mariana", "Viki", "Alice", "Eric", "hks", "cbk", "Sophie", "Antonio", "Jeremiah", "Angela", "Renee", "Marta", "Katherine", "Anna", "Auryn", "Ashley", "Anne", "Denise", "Eva", "Jonnah", "Kitty", "Masha", "Mia", "Cian", "Senke", "Maud", "Jinnie", "Rubin", "Julia", "Alana", "Gentian", "Laurie", "Matias","Scott", "Stacy"] # librarians = ["Alana", "Gentian", "Laurie", "Matias", "Scott", "Stacy", "Max", "Clara_B", "Michelle", "Clara_J_B", "Karen", "Lumsden_Primary_School", "Aaron", "Leo", "Maria", "Laura", "Honey", "Tender_Center", "wdka", "Naomi", "Cristina", "Julie", "ssw", "cyberspace", "Hannah", "Katarina", "Anastasia", "Kimmy", "Marie","Katherine", "Allison", "Mariana", "Viki", "Alice", "Eric", "hks", "cbk", "Sophie", "Antonio", "Jeremiah", "Angela", "Renee", "Marta", "Katherine", "Anna", "Auryn", "Ashley", "Anne", "Denise", "Eva", "Jonnah", "Kitty", "Masha", "Mia", "Cian", "Senke", "Maud", "Jinnie", "Rubin", "Julia", "Alana", "Gentian", "Laurie", "Matias","Scott", "Stacy"]
librarians = []
with open('fakejson.json', 'r', encoding='utf8') as filesandnames: with open('realjson.json', 'r', encoding='utf8') as filesandnames:
filetoname_dict = json.load(filesandnames) filetoname_dict = json.load(filesandnames)
#get full list librarians from json (printed later through global variable)
for file in filetoname_dict:
for name in file["librarian"]:
librarians.append(str(name))
librarians = list(dict.fromkeys(librarians))
#this value we should get from template #this value we should get from template
librarianselected = filetoname_dict[2]["librarian"] librarianselected = "Ruben"
#go from librarian name to file #go from librarian name to file
for file in filetoname_dict: for file in filetoname_dict:
@ -31,13 +39,13 @@ with open('fakejson.json', 'r', encoding='utf8') as filesandnames:
fileselected = filetoname_dict[1]["debris"] fileselected = filetoname_dict[1]["debris"]
#go from file name to librarian name #go from file name to librarian name
print(fileselected)
for file in filetoname_dict: for file in filetoname_dict:
if fileselected in file["debris"]: if fileselected in file["debris"]:
thelibrarian = file["librarian"] thelibrarian = file["librarian"]
print("librarians for "+ str(fileselected)+" are: " + str(thelibrarian)) print("librarians for "+ str(fileselected)+" are: " + str(thelibrarian))
print("---------------------------------------------------")
print(librarians)
@app.route("/") @app.route("/")
def home(): def home():

View File

@ -64,14 +64,15 @@ li a.nav-button {
z-index: 10000; z-index: 10000;
} }
a.librarian-names, a.file-names { span.librarian-names, a.file-names {
text-decoration: none; text-decoration: none;
padding: 0.3em; padding: 0.3em;
color: black; color: black;
} }
a.librarian-names:hover, a.file-names:hover { span.librarian-names:hover, a.file-names:hover {
color: white; color: white;
cursor: pointer;
} }
#listofpeople{ #listofpeople{

1460
static/js/realjson.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,29 @@
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
<!--TEST--> <!--TEST-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".librarian-names").click(function(event){
var thename = $(this).text();
$.getJSON('{{ url_for('static', filename='js/realjson.json') }}', function(test) {
alert(thename);
// iterate in test[i].librarian to find where the name is present
//to get the test[i].debris that goes with it
var alldocs = [];
for (var i = 0; i < test.length; ++i) {
var item = test[i];
if(item.librarian.includes(thename)){
ledocument = item.debris;
// alert(ledocument);
alldocs.push(ledocument);
};
};
alert(alldocs);
});
});
});
</script>
</head> </head>
<body> <body>
@ -24,7 +46,8 @@
<div id="listofpeople"> <div id="listofpeople">
{% for librarian in librarians %} {% for librarian in librarians %}
<a href="#" onclick="return test();" class="librarian-names">{{ librarian }}</a> <!-- <a href="#" class="librarian-names">{{ librarian }}</a> -->
<span class="librarian-names">{{ librarian }}</span>
{% endfor %} {% endfor %}
</div> </div>
<br> <br>
@ -37,6 +60,8 @@
</div> </div>
<div class="main-column-right"> <div class="main-column-right">
<a href="{{ url_for('static', filename='realjson.json') }}">test link</a>
{% block content %} {% block content %}
{% endblock content %} {% endblock content %}