From 540b18a2ac9ab62e10204bdf6692d5e564b49562 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 4 Nov 2020 22:27:13 +0300 Subject: Fix typo --- test/rest-api.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rest-api.org b/test/rest-api.org index 4b66147..559c272 100644 --- a/test/rest-api.org +++ b/test/rest-api.org @@ -166,4 +166,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. -- cgit v1.2.3 From 712a193bec44c80070d16b7908c39f5ad294207e Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 4 Nov 2020 22:32:11 +0300 Subject: Update pip3 install command in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 03e4297..3815bf4 100644 --- a/README.md +++ b/README.md @@ -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: -- cgit v1.2.3 From 59b4c0ff845686ce2e58e0c2df126f1bae514ab1 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Thu, 5 Nov 2020 00:12:01 +0300 Subject: Add Redis to web deps --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1a2a8f6..ec15b59 100644 --- a/setup.py +++ b/setup.py @@ -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 [] -- cgit v1.2.3 From 2e2e2280f59b783759b7b70d410fb7a5c59206d5 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 10 Nov 2020 03:42:12 +0300 Subject: Add tweet feed * bh20simplewebuploader/main.py (send_home): Fetch tweets from Redis. * bh20simplewebuploader/static/main.css: Add styles for tweets * bh20simplewebuploader/templates/home.html: Add tweet section in frontpage. --- bh20simplewebuploader/main.py | 27 +++++++++++++++++++++++++-- bh20simplewebuploader/static/main.css | 27 +++++++++++++++++++++++++++ bh20simplewebuploader/templates/home.html | 27 +++++++++++++++++++++++---- 3 files changed, 75 insertions(+), 6 deletions(-) diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 73503b4..d3b9591 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('gn2-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') @@ -652,6 +664,17 @@ def blog_page(): buf = get_html_body('doc/blog/'+blog_content+'.html',"https://github.com/arvados/bh20-seq-resource/blob/master/doc/blog/"+blog_content+".org") return render_template('blog.html',menu='BLOG',embed=buf,blog=blog_content) +@app.route('/feed', methods=['GET']) +def feed(): + redis_client = redis.Redis(host=os.environ.get('HOST', 'localhost'), + port=os.environ.get('PORT', 6379), + db=os.environ.get('REDIS_DB', 0)) + tweets = [redis_client.hgetall(tweet_id) + for tweet_id in redis_client.zrevrange('bh20-tweet-score:', + 0, -1)] + return render_template('feed.html', + menu='FEED', + tweets=tweets) @app.route('/about') def about_page(): 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 77d2fb6..516fb33 100644 --- a/bh20simplewebuploader/templates/home.html +++ b/bh20simplewebuploader/templates/home.html @@ -22,9 +22,27 @@ or REST API. For more information see the FAQ!.

-
-
-
+ +
+
+
+
+
+ +
+

@@ -76,7 +94,8 @@ use, see the BLOG.

- + + {% include 'footer.html' %} -- cgit v1.2.3 From d42e6bc3fb58a087ba64427709034e0adf090524 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 10 Nov 2020 15:40:36 +0300 Subject: Fetch tweets from the correct redis queue * bh20simplewebuploader/main.py (send_home): Replace "gn2-tweet-score" with "bh20-tweet-score". --- bh20simplewebuploader/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index d3b9591..9d27879 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -257,7 +257,7 @@ def send_home(): port=os.environ.get('PORT', 6379), db=os.environ.get('REDIS_DB', 0)) tweets = [] - for tweet_id in redis_client.zrevrange('gn2-tweet-score:', + 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 -- cgit v1.2.3 From 203293363640e7f45ceaff09fb1a83f8c0f1496a Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 10 Nov 2020 15:42:00 +0300 Subject: Delete unused endpoint * bh20simplewebuploader/main.py (feed): Remove it. --- bh20simplewebuploader/main.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 9d27879..510df1c 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -664,17 +664,6 @@ def blog_page(): buf = get_html_body('doc/blog/'+blog_content+'.html',"https://github.com/arvados/bh20-seq-resource/blob/master/doc/blog/"+blog_content+".org") return render_template('blog.html',menu='BLOG',embed=buf,blog=blog_content) -@app.route('/feed', methods=['GET']) -def feed(): - redis_client = redis.Redis(host=os.environ.get('HOST', 'localhost'), - port=os.environ.get('PORT', 6379), - db=os.environ.get('REDIS_DB', 0)) - tweets = [redis_client.hgetall(tweet_id) - for tweet_id in redis_client.zrevrange('bh20-tweet-score:', - 0, -1)] - return render_template('feed.html', - menu='FEED', - tweets=tweets) @app.route('/about') def about_page(): -- cgit v1.2.3