-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
96 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var apiURL = 'tweets/' | ||
|
||
var tweets = new Vue({ | ||
el: '#tweets', | ||
|
||
data: { | ||
page: 1, | ||
tweets: null | ||
}, | ||
|
||
created: function() { | ||
this.fetchData() | ||
}, | ||
|
||
watch: { | ||
page: 'fetchData' | ||
}, | ||
|
||
filters: { | ||
truncate: function(v) { | ||
var newline = v.indexOf('\n') | ||
return newline > 0 ? v.slice(0, newline) : v | ||
}, | ||
formatDate: function(v) { | ||
return v.replace(/T|Z/g, ' ') | ||
} | ||
}, | ||
|
||
methods: { | ||
fetchData: function() { | ||
let uri = window.location.search.substring(1) | ||
let params = new URLSearchParams(uri) | ||
|
||
var xhr = new XMLHttpRequest() | ||
var self = this | ||
|
||
xhr.open('GET', apiURL + '?' + params.toString()) | ||
xhr.onload = function() { | ||
self.tweets = JSON.parse(xhr.responseText) | ||
} | ||
|
||
xhr.send() | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,25 +34,16 @@ <h2 class="subtitle"> | |
<canvas id="{{ a.slug }}"></canvas> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
<div class="column is-one-quarter"> | ||
<p class="title">Tweets ({{ tweets.count }})</p> | ||
<ul class="tweets"> | ||
{% for tweet in tweets %} | ||
<li> | ||
{% include 'chirp/includes/tweet.html' %} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> | ||
<div class="columns is-multiline"> | ||
<div class="column"> | ||
<div class="chart"> | ||
<p class="title">Words</p> | ||
<div class="wordcloud" id="wordcloud"></div> | ||
</div> | ||
</div> | ||
<div class="column is-one-quarter"> | ||
<div id="tweets"> | ||
{% include 'chirp/includes/tweets.html' %} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
|
@@ -61,8 +52,10 @@ <h2 class="subtitle"> | |
{% block footer_scripts %} | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script> | ||
<script src="https://google.github.io/palette.js/palette.js"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script> | ||
<script src="{% static 'vendor/wordcloud2.js/src/wordcloud2.js' %}"></script> | ||
<script src="{% static 'js/charts.js' %}"></script> | ||
<script src="{% static 'js/tweets.js' %}"></script> | ||
<script> | ||
$(function() { | ||
{% for a in object.get_aggregations %} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{% verbatim %} | ||
<p class="title">Tweets ({{ tweets.total }})</p> | ||
<ul> | ||
<li v-for="tweet in tweets.tweets"> | ||
<div class="card"> | ||
<div v-if="tweet.entities.media && tweet.entities.media[0].type === 'photo'" class="card-image"> | ||
<figure class="image"> | ||
<img :src="tweet.entities.media[0].media_url_https"> | ||
</figure> | ||
</div> | ||
<div class="card-content"> | ||
<div class="media"> | ||
<div class="media-left"> | ||
<figure class="image is-48x48"> | ||
<img :src="tweet.user.profile_image_url_https"> | ||
</figure> | ||
</div> | ||
<div class="media-content"> | ||
<p class="title is-5">{{ tweet.user.name }}</p> | ||
<p class="subtitle is-6">@{{ tweet.user.screen_name }}</p> | ||
</div> | ||
</div> | ||
<div class="content"> | ||
<p v-if="tweet.extended_tweet && tweet.extended_tweet.full_text">{{ tweet.extended_tweet.full_text }}</p> | ||
<p v-else>{{ tweet.text }}</p> | ||
<a :href="'//twitter.com/statuses/' + tweet.id" :target="tweet.id">View</a> | ||
<br> | ||
<time>{{ tweet.created_at }}</time> | ||
</div> | ||
</div> | ||
</div> | ||
</li> | ||
</ul> | ||
{% endverbatim %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters