diff --git a/.gitignore b/.gitignore index 7bf85c5..9f87899 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ venv __pycache__/ direction.txt home.txt +emotions.js diff --git a/OodiUI/__init__.py b/OodiUI/__init__.py index eb236b1..5497d14 100644 --- a/OodiUI/__init__.py +++ b/OodiUI/__init__.py @@ -5,9 +5,14 @@ import time from pathlib import Path import sqlite3 +from flask_caching import Cache +import asyncio + def create_app(test_config=None): + cache = Cache(config={'CACHE_TYPE': 'simple'}) app = Flask(__name__, instance_relative_config=True) + cache.init_app(app) if test_config is None: app.config.from_pyfile('config.py', silent=True) @@ -24,21 +29,16 @@ def start_screen(): return render_template('start.html') + def start_emotions(): + ### korvaa sierran metodi halutulla metodilla alla ### + return sierra.search_shelved_books("kalastus") + @app.route('/main', methods=['POST', 'GET']) def search_screen(): - #config = Path("OodiUI/static/direction.txt") - #if config.is_file(): - # os.remove("OodiUI/static/direction.txt") - #config2 = Path("OodiUI/static/home.txt") - #if config2.is_file(): - # os.remove("OodiUI/static/home.txt") - #if request.method == 'POST': - #searchterm = request.form['searchfield'] - #error = None - #send searchterm forward to the sierra api? - #if result == "": - # error = 'Kirjoita hakukenttään avainsana.' - #flash(error) + first = request.args.get('first'); + if first == "True": + start_emotions() + return render_template('base.html') @app.route('/term_result', methods=['POST', 'GET']) @@ -54,7 +54,11 @@ def start(): @app.route('/term_result/guidance_term', methods=['POST', 'GET']) def guidance_term(): - bookname = request.args.get('title')[:40]+"..." #get the booktitle + b_name = request.args.get('title') #get the booktitle + if len(b_name) > 40: + bookname = b_name[:40]+"..." + else: + bookname = b_name book_id = request.args.get('id') #get the id of the book print(bookname) print(book_id) diff --git a/OodiUI/static/images/.DS_Store b/OodiUI/static/images/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/OodiUI/static/images/.DS_Store differ diff --git a/OodiUI/static/images/ajax-loader.gif b/OodiUI/static/images/ajax-loader.gif new file mode 100644 index 0000000..cbe59fb Binary files /dev/null and b/OodiUI/static/images/ajax-loader.gif differ diff --git a/OodiUI/static/style.css b/OodiUI/static/style.css index 2aa0ccb..22b3fd1 100644 --- a/OodiUI/static/style.css +++ b/OodiUI/static/style.css @@ -1,3 +1,7 @@ +html { + overflow-y: scroll; +} + #start1 { position: fixed; width: 265pt; @@ -33,8 +37,8 @@ .w3-btn { position: relative; align-content: center; - width: 160pt; - height: 100pt; + width: 140pt; + height: 80pt; left: 15%; top: 10pt; } @@ -53,35 +57,36 @@ left: 27%; } -#arts { + +#travel { position: absolute; top: 30%; - left: 2.5%; + left: 12.5%; height: 30%; width: 50%; - font-size:25pt; + font-size:20pt; font-weight: bold; color: white; } -#travel { +#cooking { position: absolute; top: 30%; - left: 16%; + left: 17.5%; height: 30%; width: 50%; - font-size:25pt; + font-size:20pt; font-weight: bold; color: white; } -#cooking { +#arts { position: absolute; top: 30%; - left: 0%; + left: 22.5%; height: 30%; width: 50%; - font-size:25pt; + font-size:20pt; font-weight: bold; color: white; } @@ -89,10 +94,10 @@ #languages { position: absolute; top: 30%; - left: 25%; + left: 6%; height: 30%; width: 50%; - font-size:25pt; + font-size:20pt; font-weight: bold; color: white; } @@ -100,10 +105,10 @@ #autobiography { position: absolute; top: 12.5%; - left: 22.5%; + left: 3%; height: 30%; width: 50%; - font-size:25pt; + font-size:20pt; font-weight: bold; color: white; } @@ -111,10 +116,10 @@ #history { position: absolute; top: 30%; - left: 17.5%; + left: 20%; height: 30%; width: 50%; - font-size:25pt; + font-size:20pt; font-weight: bold; color: white; } @@ -132,43 +137,43 @@ #travel-btn { position: fixed; background-color: rgb(2, 147, 71); - left: 17%; - top: 35%; + left: 20%; + top: 42%; } #cooking-btn { position: fixed; background-color: rgb(2, 147, 71); left: 40%; - top: 35%; + top: 42%; } #arts-btn { position: fixed; background-color: rgb(2, 147, 71); - left: 63%; - top: 35%; + left: 60%; + top: 42%; } #language-btn { position: fixed; background-color: rgb(2, 147, 71); - left: 17%; - top: 57.5%; + left: 20%; + top: 60.5%; } #bio-btn { position: fixed; background-color: rgb(2, 147, 71); left: 40%; - top: 57.5%; + top: 60.5%; } #history-btn { position: fixed; background-color: rgb(2, 147, 71); - left: 63%; - top: 57.5%; + left: 60%; + top: 60.5%; } a { @@ -185,7 +190,8 @@ a:hover { position: fixed; text-align: center; font-weight: bold; - left: 40%; + left: 39%; + top: 3%; color: rgb(42, 52, 60); font-family: "Arial-BoldMT"; } @@ -197,27 +203,92 @@ a:hover { position: fixed; text-align:left; font-weight: bold; - left: 30%; - top: 22.5%; + left: 28.5%; + top: 32%; color: rgb(42, 52, 60); font-family: "Arial-BoldMT"; } #search-box { - width: 450pt; + width: 365pt; height: 50pt; position: fixed; - top: 55pt; + top: 13%; left: 20%; border: 1px solid; } #submit-box { position: fixed; - width: 70pt; + width: 63pt; height: 50pt; - left: 600pt; - top: 55pt; + left: 518pt; + top: 13%; + background-color: rgb(2, 146, 71); +} + +#scroll-box { + position: fixed; + top: 65pt; + left: 8%; + height: 200pt; + width: 615pt; + max-height: 200pt; + max-width: 615pt; + overflow-y: scroll; + border: 1px solid; +} + +::-webkit-scrollbar { + -webkit-appearance: none; + width: 10px; +} + +::-webkit-scrollbar-thumb { + border-radius: 5px; + background-color: rgba(0,0,0,0.5); + -webkit-box-shadow:: 0 0 1px rgba(255,255,255,.5); +} + +.term-results { + position: relative; + width: 600pt; +} + +/*#scroll2 { + position: fixed; + left: 87.5%; + top: 9.75%; + height: 285pt; + max-width: 70pt; + max-height: 285pt; + overflow-y: scroll; +}*/ + +#book-indicator { + position: relative; + width: 2pt; + height: 53.5pt; + left: 0%; + top: -3pt; +} + +#column-span { + position: relative; + width: 100pt; +} + +#span-author { + width: 475pt; +} + +#choose-book { + position: relative; + width: 65pt; + height: 53.5pt; + left: 0%; + top: 0%; + max-height: 285pt; background-color: rgb(2, 146, 71); } @@ -231,44 +302,54 @@ input[type="text"] { #search-for-category { position: fixed; - font-size: 30pt; + text-align: relative; font-family: "ArialMT"; color: rgb(42, 52, 60); - text-align: center; - top: 50pt; - left: 17.5%; + top: 10pt; + left: 4%; + font-size: 35pt; } #search-result { - font-size: 30pt; - position: relative; - text-align: center; + font-size: 27pt; + position: fixed; + top: 3%; + left: 15.5%; font-family: "ArialMT"; color: rgb(42, 52, 60); } #advice1 { + position: fixed; text-align: center; font-weight: bold; + font-size: 20pt; + top: 12.5%; + left: 27.5%; font-family: "ArialMT"; color: rgb(42, 52, 60); } #advice2 { + position: fixed; text-align: center; font-weight: bold; + font-size: 20pt; + top: 12.5%; + left: 40%; font-family: "ArialMT"; color: rgb(42, 52, 60); } +/* .result-boxes { - left: 50pt; + position: sticky; + width: 450pt; + top: 0%; + left: 0%; margin: 5pt; -} - -.term-results { - width: 600pt; -} + overflow-y: scroll; +}*/ #look-for-book { position: fixed; @@ -276,8 +357,8 @@ input[type="text"] { font-family: "ArialMT"; color: rgb(42, 52, 60); top: 10pt; - left: 15%; - font-size: 40pt; + left: 7.5%; + font-size: 35pt; } #no-guidance { @@ -309,10 +390,11 @@ input[type="text"] { } #back-to-main { + position: fixed; width: 160pt; height: 100pt; left: 60pt; - top: 10pt; + top: 284.5pt; font-family: "Arial-BoldMT"; font-weight: bold; font-size: 30pt; @@ -333,12 +415,12 @@ input[type="text"] { } #no-sign2 { - position: absolute; + position: fixed; align-items: center; width: 70pt; height: 25pt; - left: 27.5%; - top: 55%; + left: 105pt; + top: 340pt; } #no-sign3 { @@ -380,7 +462,7 @@ input[type="text"] { #yes-child { position: absolute; top: 25%; - left: 2.5%; + left: 7%; height: 30%; width: 50%; color: white; @@ -388,18 +470,18 @@ input[type="text"] { #child-to-main { position: absolute; - top: 25%; + top: 32%; left: 2.5%; height: 30%; width: 50%; - font-size: 30pt; + font-size: 23pt; color: white; } #child-to-book2 { position: absolute; top: 25%; - left: 2.5%; + left: 7%; height: 30%; width: 50%; font-size: 30pt; @@ -412,7 +494,7 @@ input[type="text"] { font-weight: bold; text-align: center; top: 40pt; - left: 25%; + left: 18.5%; color: rgb(42, 52, 60); } @@ -422,7 +504,7 @@ input[type="text"] { font-weight: bold; text-align: center; top: 40pt; - left: 25%; + left: 18.5%; color: rgb(42, 52, 60); } @@ -432,7 +514,7 @@ input[type="text"] { font-weight: bold; text-align: center; top: 40pt; - left: 15%; + left: 26.5%; color: rgb(42, 52, 60); } @@ -442,61 +524,63 @@ input[type="text"] { font-weight: bold; text-align: center; top: 40pt; - left: 20%; + left: 32.5%; color: rgb(42, 52, 60); } #leftarrow { position: fixed; - top: 280pt; - left: 225pt; + top: 250pt; + left: 255pt; } #rightarrow { position: fixed; - top: 240pt; - left: 225pt; + top: 250pt; + left: 262pt; } #uparrow { position: fixed; - top: 180pt; - left: 300pt; + top: 160pt; + left: 312pt; } #leftrightarrow { position: fixed; - top: 280pt; - left: 180pt; + top: 250pt; + left: 76pt; } #going-home1 { - font-size: 80pt; + position: fixed; + font-size: 70pt; font-family: "Arial-BoldMT"; position: fixed; text-align: center; font-weight: bold; - top: -10%; - left: 240pt; + top: -5%; + left: 31%; color: rgb(42, 52, 60); } #going-home2 { + position: fixed; font-size: 35pt; font-family: "ArialMT"; position: fixed; text-align: center; font-weight: lighter; color: rgb(42, 52, 60); - top: 100pt; - left: 180pt; + top: 70pt; + left: 13.5%; } #home-pic { position: fixed; - left: 30%; - top: 200pt; + left: 30.5%; + top: 155pt; } form { @@ -509,26 +593,91 @@ form { display: none; } + #spinner { position:fixed; width:100%; left:0;right:0;top:0;bottom:0; - background-color: rgba(255,255,255,0.7); + background-color: rgba(255,255,255,0.9); z-index:9999; display:none; + } #spinner::after { - content:'Haetaan tuloksia...'; + content:'Searching for results...'; + text-align: center; + display:block; + font-size: 50pt; + position:absolute; + left: 10%; + top: 25%; +} + + +#spinner2 { + position:fixed; + text-align: center; + width:100%; + left:0;right:0;top:0;bottom:0; + background-color: rgba(255,255,255,0.9); + z-index:9999; + display:none; + +} + +#spinner2::after { + content:'Please wait a moment...'; display:block; + display: -webkit-box; + display: -ms-flexbox; font-size: 50pt; position:absolute; - left:35%; - top:35%; + left:10%; + top:25%; } +/* +@keyframes blink { + 0% { + opacity: .2; + } + 20% { + opacity: 1; + } + + 100% { + opacity: .2; + } +} + +#spinner span{ + animation-name: blink; + animation-duration: 1.4s; + animation-iteration-count: infinite; + animation-fill-mode: both; +} + +#spinner span:nth-child(2) { + animation-delay: .2s; +} + +#spinner span:nth-child(3) { + animation-delay: .4s; +} +*/ + .pagebottom { position: fixed; top: 85%; width: 100%; + z-index: 3; +} + +#oodi-last { + position: fixed; + top: 85%; + left: 0%; + width: 100%; z-index: -99; +} diff --git a/OodiUI/templates/base.html b/OodiUI/templates/base.html index ab6054b..5c06f6e 100644 --- a/OodiUI/templates/base.html +++ b/OodiUI/templates/base.html @@ -5,36 +5,57 @@ oodi
{% block header %} -

{% block title %}Etsi tietokirja{% endblock %}

+

{% block title %}Find a book{% endblock %}

{% endblock %}
{% block content %}
- +
+ -
-

Etsi tietokirjan kategoria

- -
Taidekirjat
+
+ +
+

Look for a book category

+ +
+
Arts
+
+ + +
Traveling
- + +
Cooking
-
Keittokirjat
-
+

- + +
Languages
+
+ + +
     Auto-
biographies
- + +
History
-
Historia
-
+ + {% endblock %} {% block head %} diff --git a/OodiUI/templates/search/going_home.html b/OodiUI/templates/search/going_home.html index 9a6da72..1b144a9 100644 --- a/OodiUI/templates/search/going_home.html +++ b/OodiUI/templates/search/going_home.html @@ -1,13 +1,14 @@ + -
-
-

Heihei!

-

Palaan lähtöpisteeseen.

-
- - home - - - oodi -
+
+

Bye bye!

+

I'm going back to the starting point.

+ +
+home + + +oodi + diff --git a/OodiUI/templates/search/guidance.html b/OodiUI/templates/search/guidance.html index 3a7ef0f..99ecbbc 100644 --- a/OodiUI/templates/search/guidance.html +++ b/OodiUI/templates/search/guidance.html @@ -1,20 +1,24 @@ {% extends 'base.html' %} {% block header %} -

Seuraa minua!

+

Let's go!

+

Search the shelf
on the left

+

Search the shelf
on the right

+

Search both
shelves

+ {% endblock %} {#% block body %} diff --git a/OodiUI/templates/search/guidance_category.html b/OodiUI/templates/search/guidance_category.html index 3d8a127..e7cf971 100644 --- a/OodiUI/templates/search/guidance_category.html +++ b/OodiUI/templates/search/guidance_category.html @@ -1,15 +1,16 @@ {% extends 'base.html' %} {% block header %} -

Lähdetäänkö hakemaan kategoriaa
{{categoryname}}?

+

Would you like to be guided to the category
{{categoryname}}?

+

{% endblock %} {% block content %} -Takaisintakaisin +Go backtakaisin -
Etsi hylly
+
Proceed
{% endblock %} diff --git a/OodiUI/templates/search/guidance_term.html b/OodiUI/templates/search/guidance_term.html index 0bb6e45..e5fb23a 100644 --- a/OodiUI/templates/search/guidance_term.html +++ b/OodiUI/templates/search/guidance_term.html @@ -1,15 +1,19 @@ {% extends 'base.html' %} {% block header %} -

Lähdetäänkö etsimään kirjaa
{{bookname}}

+

Would you like to be guided to the book:
{{bookname}}

+

{% endblock %} {% block content %} -Takaisintakaisin +Go backtakaisin -
Etsi kirja
+
Proceed
+ +
+
{% endblock %} diff --git a/OodiUI/templates/search/term_result.html b/OodiUI/templates/search/term_result.html index 825c783..a63b46f 100644 --- a/OodiUI/templates/search/term_result.html +++ b/OodiUI/templates/search/term_result.html @@ -1,24 +1,29 @@ {% extends 'base.html' %} {% block header %} -
-
+ {% endblock %} {% block content %} -

Hyllyssä olevat tulokset haulle "{{searchterm}}"

-
- Takaisintakaisin -
+

Available books with the keyword: {{searchterm|truncate(8, True)}}

+

+ Go backtakaisin {% if books|length == 0 %} -

Ei tuloksia haulle: {{searchterm}}

- {% else %} -

Klikkaa laatikkoa!

+

No results for: {{searchterm|truncate(20, True)}}

+ {% endif %} - {% for b_id, b_info in books.items() %} -

{{b_info['title']}}
Tekijä: {{b_info['author']}}

- {% endfor %} +
+
+ {% for b_id, b_info in books.items() %} +

 {{ b_info['title']|truncate(50, True) }}
 Author: {{b_info['author']|truncate(42, True)}}
+ + Etsi +

+ {% endfor %} +
{% endblock %} + + diff --git a/OodiUI/templates/start.html b/OodiUI/templates/start.html index 68b5e2a..1058c27 100644 --- a/OodiUI/templates/start.html +++ b/OodiUI/templates/start.html @@ -3,19 +3,20 @@
-

Hei!

-

Olen tietokirjarobotti.
Opastan sinut kirjan luokse.

+

Hey!

+

I am a book robot.
I will guide you to a book's location.

+
- -
Etsi kirja
+ +
Find a book
+
oodi - +