Merge branch 'main' into filterFee
This commit is contained in:
55
dashboard.py
55
dashboard.py
@@ -13,7 +13,7 @@ root_content_path = 'dashboard_static'
|
|||||||
# the action will be called with the context and the event
|
# the action will be called with the context and the event
|
||||||
@event('init')
|
@event('init')
|
||||||
def setup(ctx, e):
|
def setup(ctx, e):
|
||||||
start_offline_tweets('sports1.txt', event_name="tweet", time_factor=0.1)
|
start_offline_tweets('sports1.txt', event_name="tweet", time_factor=0.01)
|
||||||
ctx.count = 0
|
ctx.count = 0
|
||||||
# fire('sample', {'previous': 0.0})
|
# fire('sample', {'previous': 0.0})
|
||||||
|
|
||||||
@@ -40,7 +40,58 @@ def words(message):
|
|||||||
|
|
||||||
@event('tweet')
|
@event('tweet')
|
||||||
def generate_tweet(ctx, e):
|
def generate_tweet(ctx, e):
|
||||||
tweet = e.data
|
tweet = dict(e.data)
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
tweet.pop("id_str")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("display_text_range")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("in_reply_to_status_id")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("in_reply_to_status_id_str")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("in_reply_to_user_id")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("in_reply_to_user_id_str")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("in_reply_to_screen_name")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("geo")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("coordinates")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("place")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("contributors")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
tweet.pop("is_quote_status")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
except:
|
||||||
|
pass
|
||||||
# base sample on previous one
|
# base sample on previous one
|
||||||
# sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100)
|
# sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100)
|
||||||
# emit to outside world
|
# emit to outside world
|
||||||
|
|||||||
@@ -24,18 +24,20 @@ function showFeeds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tweetCell(tweet) {
|
function tweetCell(tweet) {
|
||||||
|
const date = new Date(tweet.created_at);
|
||||||
var cell = document.createElement("div");
|
var cell = document.createElement("div");
|
||||||
cell.innerHTML =
|
cell.innerHTML =
|
||||||
`<div class="tweet">
|
`<div class="tweet">
|
||||||
<a href ="https://www.twitter.com/${tweet.user.screen_name}"><img src="${tweet.user.profile_image_url}" onerror="this.src='media/logo.png';" class="tweet-profilepicture"></a>
|
<a href ="https://www.twitter.com/${tweet.user.screen_name}"><img src="${tweet.user.profile_image_url}" onerror="this.src='media/logo.png';" class="tweet-profilepicture"></a>
|
||||||
<div class="tweet-content">
|
<div class="tweet-content">
|
||||||
<div class="tweet-name">
|
<div class="tweet-name">
|
||||||
<a class="tweet-nickname" href = "https://www.twitter.com/${tweet.user.screen_name}" target = "_blank">${tweet.user.name}</a>
|
<div>
|
||||||
<a class="tweet-username" href = "https://www.twitter.com/${tweet.user.screen_name}" target = "_blank">@${tweet.user.screen_name}</a>
|
<a class="tweet-nickname" href = "https://www.twitter.com/${tweet.user.screen_name}" target = "_blank">${tweet.user.name}</a>
|
||||||
<!-- add tweet date called created_at-->
|
<a class="tweet-username" href = "https://www.twitter.com/${tweet.user.screen_name}" target = "_blank">@${tweet.user.screen_name}</a>
|
||||||
<p class="tweet-date">${tweet.created_at}</p>
|
</div>
|
||||||
|
<span class="tweet-date"><em>${date.getHours()}:${date.getMinutes()}</em></span>
|
||||||
</div>
|
</div>
|
||||||
<span class="tweet-text">${tweet.text}</span>
|
<a class="tweet-text" href = "https://www.twitter.com/${tweet.user.screen_name}/status/${tweet.id_str}" target = "_blank">${tweet.text}</a>
|
||||||
<div class="tweet-interactions">
|
<div class="tweet-interactions">
|
||||||
<div class="tweet-interaction tweet-likes">
|
<div class="tweet-interaction tweet-likes">
|
||||||
<span class="material-symbols-outlined">favorite</span>
|
<span class="material-symbols-outlined">favorite</span>
|
||||||
@@ -123,7 +125,7 @@ function sortTweets(tweets, sort){
|
|||||||
tweets.sort(function(a,b){return a.reply_count-b.reply_count})
|
tweets.sort(function(a,b){return a.reply_count-b.reply_count})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sort.sortby == "date"){
|
if (sort.sortby == "time"){
|
||||||
if(sort.order == 'asc'){
|
if(sort.order == 'asc'){
|
||||||
tweets.sort(function(a,b){return Date(b.created_at)-Date(a.reply_count)})
|
tweets.sort(function(a,b){return Date(b.created_at)-Date(a.reply_count)})
|
||||||
} else{
|
} else{
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ let root = document.querySelector(":root")
|
|||||||
|
|
||||||
$(".logo").on("click", function() {
|
$(".logo").on("click", function() {
|
||||||
if (root.style.getPropertyValue("--main-bg") === 'snow') {
|
if (root.style.getPropertyValue("--main-bg") === 'snow') {
|
||||||
console.log("IM here")
|
|
||||||
var audio = new Audio("../media/Chicken.mp3");
|
var audio = new Audio("../media/Chicken.mp3");
|
||||||
audio.play();
|
audio.play();
|
||||||
root.style.setProperty('--main-medium-dark', '#1E1E1E');
|
root.style.setProperty('--main-medium-dark', '#1E1E1E');
|
||||||
@@ -66,16 +65,19 @@ $(".logo").on("click", function() {
|
|||||||
|
|
||||||
$(window).on("filter", function() {
|
$(window).on("filter", function() {
|
||||||
var parent = document.querySelector("#filtered")
|
var parent = document.querySelector("#filtered")
|
||||||
parent.replaceChildren();
|
var lastTweet = parent.firstChild
|
||||||
|
|
||||||
tweets = window.sessionStorage.getItem('tweets');
|
tweets = window.sessionStorage.getItem('tweets');
|
||||||
tweets = JSON.parse(tweets);
|
tweets = JSON.parse(tweets);
|
||||||
tweets = filterTweets(tweets, filters.blockedWords, filters.searchedWords.concat(filters.sports), filters.sorted, filters.order);
|
tweets = filterTweets(tweets, filters.blockedWords, filters.searchedWords.concat(filters.sports), filters.sorted, filters.order);
|
||||||
tweets = sortTweets(tweets, [filters.sorted, filters.order]);
|
tweets = sortTweets(tweets, {"sortby":filters.sorted, "order":filters.order});
|
||||||
var displayTweets = tweets.reverse().slice(0, 20).reverse();
|
var displayTweets = tweets.reverse().slice(0, 20).reverse();
|
||||||
for (i = 0; i < Math.min(19, displayTweets.length); i++){
|
if(tweetCell(displayTweets[0]) != lastTweet){
|
||||||
tweet = displayTweets[i];
|
parent.replaceChildren();
|
||||||
parent.prepend(tweetCell(tweet));
|
for (i = 0; i < Math.min(19, displayTweets.length); i++){
|
||||||
|
tweet = displayTweets[i];
|
||||||
|
parent.prepend(tweetCell(tweet));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ body {
|
|||||||
|
|
||||||
.tweet {
|
.tweet {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
background-color: var(--tweet-color);
|
background-color: var(--tweet-color);
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
@@ -108,6 +109,17 @@ body {
|
|||||||
|
|
||||||
.tweet-content {
|
.tweet-content {
|
||||||
padding-left: 16px;
|
padding-left: 16px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tweet-name {
|
||||||
|
display: flex;
|
||||||
|
gap: 1.5%;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tweet-date {
|
||||||
|
align-self: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tweet-interactions {
|
.tweet-interactions {
|
||||||
@@ -143,6 +155,10 @@ body {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tweet-text {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
.tweet-username {
|
.tweet-username {
|
||||||
color: var(--main-light);
|
color: var(--main-light);
|
||||||
@@ -150,6 +166,13 @@ body {
|
|||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tweet-date {
|
||||||
|
color: var(--main-light);
|
||||||
|
text-decoration: none;
|
||||||
|
justify-self: flex-end;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
.filters-search input {
|
.filters-search input {
|
||||||
height: 28px;
|
height: 28px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -301,4 +324,4 @@ body {
|
|||||||
|
|
||||||
.current-sort {
|
.current-sort {
|
||||||
line-height: 36px;
|
line-height: 36px;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
15
sports.json
15
sports.json
@@ -1,19 +1,9 @@
|
|||||||
{
|
{
|
||||||
"created_at":"Sat Nov 16 12:51:41 +0000 2019",
|
"created_at":"Sat Nov 16 12:51:41 +0000 2019",
|
||||||
"id":1195685871556710402,
|
"id":1195685871556710402,
|
||||||
"id_str":"1195685871556710402",
|
|
||||||
"text":"@BobGreenburg @ONeill_Coffee Congrats to the excellent football program at Wilmington. One classy organization!",
|
"text":"@BobGreenburg @ONeill_Coffee Congrats to the excellent football program at Wilmington. One classy organization!",
|
||||||
"display_text_range":[
|
|
||||||
29,
|
|
||||||
111
|
|
||||||
],
|
|
||||||
"source":"<a href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\">Twitter for iPhone<\/a>",
|
"source":"<a href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\">Twitter for iPhone<\/a>",
|
||||||
"truncated":false,
|
"truncated":false,
|
||||||
"in_reply_to_status_id":1195545633685475333,
|
|
||||||
"in_reply_to_status_id_str":"1195545633685475333",
|
|
||||||
"in_reply_to_user_id":483881032,
|
|
||||||
"in_reply_to_user_id_str":"483881032",
|
|
||||||
"in_reply_to_screen_name":"BobGreenburg",
|
|
||||||
"user":{
|
"user":{
|
||||||
"id":774718832212606976,
|
"id":774718832212606976,
|
||||||
"id_str":"774718832212606976",
|
"id_str":"774718832212606976",
|
||||||
@@ -55,11 +45,6 @@
|
|||||||
"follow_request_sent":null,
|
"follow_request_sent":null,
|
||||||
"notifications":null
|
"notifications":null
|
||||||
},
|
},
|
||||||
"geo":null,
|
|
||||||
"coordinates":null,
|
|
||||||
"place":null,
|
|
||||||
"contributors":null,
|
|
||||||
"is_quote_status":false,
|
|
||||||
"quote_count":0,
|
"quote_count":0,
|
||||||
"reply_count":0,
|
"reply_count":0,
|
||||||
"retweet_count":0,
|
"retweet_count":0,
|
||||||
|
|||||||
Reference in New Issue
Block a user