aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bh20simplewebuploader/main.py42
-rw-r--r--bh20simplewebuploader/static/main.css49
-rw-r--r--bh20simplewebuploader/templates/home.html57
3 files changed, 118 insertions, 30 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py
index d697918..de3ba3f 100644
--- a/bh20simplewebuploader/main.py
+++ b/bh20simplewebuploader/main.py
@@ -248,32 +248,36 @@ def load_schema_generate_form():
FORM_ITEMS = load_schema_generate_form()
-@app.route('/')
-def send_home():
- """
- Send the front page.
- """
+
+def get_feed_items(name, start=0, stop=9):
redis_client = redis.Redis(host=os.environ.get('HOST', 'localhost'),
port=os.environ.get('PORT', 6379),
- db=os.environ.get('REDIS_DB', 0))
- tweets = []
+ db=os.environ.get('REDIS_DB', 0))
+ feed_items = []
try:
- for tweet_id in redis_client.zrevrange('bh20-tweet-score:',
- 0, 9):
- # Ensure the dict always has a value; otherwise a key
- # error will be thrown by jinja
- tweet_dict = redis_client.hgetall(tweet_id)
- if tweet_dict:
- tweets.append(
+ for el in redis_client.zrevrange(name, start, stop):
+ feed_dict = redis_client.hgetall(el)
+ if feed_dict and int(feed_dict.get(b"score", "0")) > 0:
+ feed_items.append(
{k.decode("utf-8"): v.decode("utf-8") for k, v in
- tweet_dict.items()})
-
+ feed_dict.items()})
+ return feed_items
except redis.exceptions.ConnectionError as e:
logging.warning(f"redis connect failed {e}")
pass
- return render_template('home.html', menu='HOME',
- tweets=tweets,
- load_map=True)
+
+
+@app.route('/')
+def send_home():
+ """
+ Send the front page.
+ """
+ return render_template(
+ 'home.html', menu='HOME',
+ tweets=get_feed_items("bh20-tweet-score:"),
+ commits=get_feed_items("bh20-commit-score:"),
+ pubmed_articles=get_feed_items("bh20-pubmed-score:"),
+ load_map=True)
@app.route('/upload')
diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css
index 237b952..b6c900c 100644
--- a/bh20simplewebuploader/static/main.css
+++ b/bh20simplewebuploader/static/main.css
@@ -17,11 +17,6 @@ h1 {
text-align: center;
}
-.intro {
- color: #505050;
- // font-weight: 300;
-}
-
.header {
background-color: white;
margin: 0 auto;
@@ -202,6 +197,7 @@ span.dropt:hover {text-decoration: none; background: #ffffff; z-index: 6; }
}
.intro {
+ color: #505050;
grid-area: a;
}
@@ -514,7 +510,7 @@ div.status {
justify-content: space-evenly;
}
-#twitter-feed {
+#feed {
background-color: #f5f8fa;
max-height: 440px;
max-width: 500px;
@@ -525,11 +521,11 @@ div.status {
}
-#twitter-feed ul {
+#feed ul {
list-style-type: none;
}
-#twitter-feed ul li {
+#feed ul li {
border-bottom: 2px solid white;
padding-bottom: 20px;
}
@@ -556,3 +552,40 @@ padding-right:10px;
{
max-width: 80%;
}
+
+/** Tabbed feed **/
+input[name="feed-tabs"] {
+ display: none;
+}
+
+input[name="feed-tabs"] + label {
+ display: inline-block;
+}
+
+input[name="feed-tabs"] ~ .tab {
+ display: none;
+}
+
+#tab-pubmed-articles:checked ~ .tab.content-pubmed-articles,
+#tab-tweets:checked ~ .tab.content-tweets,
+#tab-commits:checked ~ .tab.content-commits {
+ display: block;
+}
+
+input[name="feed-tabs"] + label {
+ border: 1px solid #999;
+ background: #EEE;
+ padding: 4px 12px;
+ border-radius: 4px 4px 0 0;
+ position: relative;
+ top: 1px;
+}
+
+input[name="feed-tabs"]:checked + label {
+ background: #FFF;
+ border-bottom: 1px solid transparent;
+}
+input[name="feed-tabs"] ~ .tab { /* grey line between tab and contents */
+ border-top: 1px solid #999;
+ padding: 12px;
+}
diff --git a/bh20simplewebuploader/templates/home.html b/bh20simplewebuploader/templates/home.html
index be948f6..7d5d89f 100644
--- a/bh20simplewebuploader/templates/home.html
+++ b/bh20simplewebuploader/templates/home.html
@@ -27,9 +27,34 @@
<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")%}
+
+ <div id="feed">
+ <input name="feed-tabs" type="radio" id="tab-pubmed-articles" checked/>
+ <label for="tab-pubmed-articles">Pubmed Articles</label>
+ <input name="feed-tabs" type="radio" id="tab-tweets"/>
+ <label for="tab-tweets">Tweets</label>
+ <input name="feed-tabs" type="radio" id="tab-commits"/>
+ <label for="tab-commits">Commits</label>
+ <ul class="tab content-pubmed-articles">
+ {% if pubmed_articles %}
+ {% for article in pubmed_articles|sort(reverse=true, attribute="score")%}
+ <li>
+ <p><a href="https://pubmed.ncbi.nlm.nih.gov/{{article['docsum-pmid']}}"><b>Summary:</b> {{ article['summary'] }}</a></p>
+ <p><b>Full Authors:</b> {{ article['full-authors'] }}</p>
+ <p><b>Short Authors:</b> {{ article['short-authors'] }}</p>
+ <p><b>Citation:</b> {{ article['citation'] }}</p>
+ <p><b>Short Journal Citation:</b> {{ article['short-journal-citation'] }}</p>
+ </li>
+ {% endfor %}
+ {% else %}
+
+ There are no articles to display :(
+
+ {% endif %}
+ </ul>
+ <ul class="tab content-tweets">
+ {% if tweets %}
+ {% for tweet in tweets|sort(reverse=true, attribute="score")%}
<li>
<p class="tweet">
{{ tweet.tweet|urlize(40, target="_blank") }} <br/>
@@ -40,6 +65,32 @@
</small>
</li>
{% endfor %}
+
+ {% else %}
+
+ There are no tweets to display :(
+
+ {% endif %}
+ </ul>
+ <ul class="tab content-commits">
+ {% if commits %}
+ {% for commit in commits|sort(reverse=true, attribute="score")%}
+ <li>
+ <p class="commit">
+ <a href="{{commit.url}}" target="_blank">
+ {{ commit.hash.split(":")[-1][:7] }}:{{ commit.content}}
+ </a>
+
+ </p>
+ <small class="timeposted">
+ <a href="{{ commit['repository-url']}}" target="_blank">{{ commit.author }}/{{ commit.repository }}</a>
+ on {{ commit.timeposted}}
+ </small>
+ </li>
+ {% endfor %}
+ {% else %}
+ There are no commits to be displayed.
+ {% endif %}
</ul>
</div>
</section>