diff options
author | Pjotr Prins | 2020-11-10 14:06:21 +0000 |
---|---|---|
committer | GitHub | 2020-11-10 14:06:21 +0000 |
commit | d213801678926e16135299a2e3ca0392a821507b (patch) | |
tree | 0c9919dec5153284f7c89d4054e36685aea0b493 | |
parent | d53120b6106e301c7f5b58bdb4dc89f85dbe2ad0 (diff) | |
parent | 203293363640e7f45ceaff09fb1a83f8c0f1496a (diff) | |
download | bh20-seq-resource-d213801678926e16135299a2e3ca0392a821507b.tar.gz bh20-seq-resource-d213801678926e16135299a2e3ca0392a821507b.tar.lz bh20-seq-resource-d213801678926e16135299a2e3ca0392a821507b.zip |
Merge pull request #114 from BonfaceKilz/feature/add-twitter-feed
Feature/add twitter feed
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | bh20simplewebuploader/main.py | 16 | ||||
-rw-r--r-- | bh20simplewebuploader/static/main.css | 27 | ||||
-rw-r--r-- | bh20simplewebuploader/templates/home.html | 27 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | test/rest-api.org | 2 |
6 files changed, 67 insertions, 9 deletions
@@ -40,7 +40,7 @@ Note that you will need to repeat the `. venv/bin/activate` step from this direc Install from PyPi: ```sh -pip3 bh20-seq-uploader +pip3 install bh20-seq-uploader ``` Install from git: diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 51048a4..fc145e6 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/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' %} @@ -17,7 +17,7 @@ except ImportError: install_requires = ["arvados-python-client", "schema-salad", "python-magic", "pyshex", "pyshexc==0.7.0", "py-dateutil"] -web_requires = ["flask", "pyyaml"] +web_requires = ["flask", "pyyaml", "redis"] needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv) pytest_runner = ["pytest < 6", "pytest-runner < 5"] if needs_pytest else [] diff --git a/test/rest-api.org b/test/rest-api.org index 945631a..66639c3 100644 --- a/test/rest-api.org +++ b/test/rest-api.org @@ -169,4 +169,4 @@ To skip confirmations you may also want to set : (setq org-confirm-babel-evaluate nil) -To see output of the inpreter open then *Python* buffer. +To see output of the interpreter open then *Python* buffer. |