diff --git a/dashboard.py b/dashboard.py index 5d7e0d0..7b8637f 100644 --- a/dashboard.py +++ b/dashboard.py @@ -12,7 +12,7 @@ root_content_path = 'dashboard_static' # the action will be called with the context and the event @event('init') def setup(ctx, e): - start_offline_tweets('sports1.txt', event_name="sample") + start_offline_tweets('sports1.txt', event_name="tweet", time_factor=0.1) ctx.count = 0 # fire('sample', {'previous': 0.0}) @@ -21,21 +21,14 @@ def setup(ctx, e): def clip(lower, value, upper): return max(lower, min(value, upper)) -@event('sample') -def generate_sample(ctx, e): - ctx.count += 1 - if ctx.count % 50 == 0: - emit('debug', {'text': 'Log message #'+str(ctx.count)+'!'}) +@event('tweet') +def generate_tweet(ctx, e): tweet = e.data - # print(tweet) # base sample on previous one # sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100) # emit to outside world - emit('sample',{ - 'action': 'add', - 'value': tweet - }) + emit('tweet', tweet) - # chain event - fire('sample', {'previous': tweet}, delay=0.05) + # # chain event + # fire('tweet', {'previous': tweet}, delay=0.05) diff --git a/dashboard_static/index.html b/dashboard_static/index.html index 660db72..b37911b 100644 --- a/dashboard_static/index.html +++ b/dashboard_static/index.html @@ -13,8 +13,10 @@ + +
+ + + + + + + - \ No newline at end of file diff --git a/dashboard_static/js/code.js b/dashboard_static/js/code.js index d71171d..2fea0fc 100644 --- a/dashboard_static/js/code.js +++ b/dashboard_static/js/code.js @@ -23,7 +23,85 @@ function getCSSVariable(name) { } function tweetCell(tweet, parent) { - var cell = document.createElement("div") + var cell = document.createElement("div"); cell.innerHTML = - "
" + `
+ +
+
+ ${tweet.user.name} + @${tweet.user.screen_name} +
+ ${tweet.text} +
+
+ favorite + ${tweet.favorite_count} +
+
+ repeat + ${tweet.retweet_count} +
+
+ chat_bubble + ${tweet.reply_count} +
+
+
+
` + parent.append(cell); +} + + +var atweet = { + "created_at": "Sat Nov 16 12:51:41 +0000 2019", + "text": "@BobGreenburg @ONeill_Coffee Congrats to the excellent football program at Wilmington. One classy organization!", + "source": "Twitter for iPhone<\/a>", + "user": { + "name": "Express Youngstown", + "screen_name": "ExpressProsYO", + "url": "http:\/\/apply.expresspros.com\/", + "profile_image_url": "http:\/\/pbs.twimg.com\/profile_images\/775167844921188353\/fWquHsOK_normal.jpg", + }, + "quote_count": 0, + "reply_count": 0, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [ + + ], + "urls": [ + + ], + "user_mentions": [ + { + "screen_name": "BobGreenburg", + "name": "Bob Greenburg", + "id": 483881032, + "id_str": "483881032", + "indices": [ + 0, + 13 + ] + }, + { + "screen_name": "ONeill_Coffee", + "name": "O'NeillCoffeeCompany", + "id": 2804543925, + "id_str": "2804543925", + "indices": [ + 14, + 28 + ] + } + ], + "symbols": [ + + ] + }, +} + +for (let i = 0; i < 2; i++) { + tweetCell(atweet, $(".leftcol")); } \ No newline at end of file