diff options
Diffstat (limited to 'bh20simplewebuploader')
-rw-r--r-- | bh20simplewebuploader/main.py | 16 | ||||
-rw-r--r-- | bh20simplewebuploader/static/main.css | 27 | ||||
-rw-r--r-- | bh20simplewebuploader/static/main.js | 6 | ||||
-rw-r--r-- | bh20simplewebuploader/templates/home.html | 27 |
4 files changed, 70 insertions, 6 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index bcdf8d8..1d7154c 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -7,6 +7,7 @@ import logging import os import sys import re +import redis import string import ruamel.yaml as yaml import pkg_resources @@ -252,8 +253,19 @@ def send_home(): """ Send the front page. """ - - return render_template('home.html', menu='HOME', load_map=True) + redis_client = redis.Redis(host=os.environ.get('HOST', 'localhost'), + port=os.environ.get('PORT', 6379), + db=os.environ.get('REDIS_DB', 0)) + tweets = [] + for tweet_id in redis_client.zrevrange('bh20-tweet-score:', + 0, -1): + tweets.append( + {k.decode("utf-8"): v.decode("utf-8") for k, v in + redis_client.hgetall(tweet_id).items()} + ) + return render_template('home.html', menu='HOME', + tweets=tweets, + load_map=True) @app.route('/upload') diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css index bc4f705..76a1755 100644 --- a/bh20simplewebuploader/static/main.css +++ b/bh20simplewebuploader/static/main.css @@ -506,3 +506,30 @@ div.status { font-size: 16px; box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19); } + +.flex-container { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-evenly; +} + +#twitter-feed { + background-color: #f5f8fa; + max-height: 440px; + max-width: 500px; + overflow-y: auto; + padding: 20px; + margin-left: auto; + margin-right: auto; +} + + +#twitter-feed ul { + list-style-type: none; +} + +#twitter-feed ul li { + border-bottom: 2px solid white; + padding-bottom: 20px; +} diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js index 89bc603..6cc0d9f 100644 --- a/bh20simplewebuploader/static/main.js +++ b/bh20simplewebuploader/static/main.js @@ -68,6 +68,12 @@ function fetchHTMLTable(apiEndPoint) { htmlString="<table>" for (var i=0; i<data.length;i++) { let url = data[i]["key"]; + continents = ["Q538", "Q48", "Q49", "Q18", "Q15", "Q27611" ]; + node = url.split("/").pop(); + console.log(continents.includes(node)); + if (url.includes("wikidata") && !continents.includes(node)) { + url = "http://covid19.genenetwork.org/location?label="+url ; + } let label = data[i]["label"]; htmlString=htmlString+"<tr><td><a href=\""+url+"\">"+label+"</a></td><td>"+data[i]["count"]+"<td></tr>" } diff --git a/bh20simplewebuploader/templates/home.html b/bh20simplewebuploader/templates/home.html index 5986d72..be948f6 100644 --- a/bh20simplewebuploader/templates/home.html +++ b/bh20simplewebuploader/templates/home.html @@ -22,9 +22,27 @@ or <a href="/apidoc">REST API</a>. For more information see the <a href="/about">FAQ!</a>. </p> - <section id="map_view" class="map"> - <div id="mapid"></div> - </section> + + <section class="flex-container"> + <div id="map_view" class="map"> + <div id="mapid"></div> + </div> + <div id="twitter-feed"> + <ul> + {% for tweet in tweets|sort(reverse=true, attribute="timeposted")%} + <li> + <p class="tweet"> + {{ tweet.tweet|urlize(40, target="_blank") }} <br/> + by {{ tweet.author }} + </p> + <small class="timeposted"> + {{ tweet.timeposted }} + </small> + </li> + {% endfor %} + </ul> + </div> + </section> <a href="https://projectredcap.org/"><img class="img-right" src="static/image/REDCap.png" /></a> <p> @@ -76,7 +94,8 @@ use, see the <a href="/blog">docs</a>. </p> </div> - </section> + </section> + {% include 'footer.html' %} |