-
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
16 changed files
with
209 additions
and
33 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 |
---|---|---|
|
@@ -17,3 +17,6 @@ | |
/yarn-error.log | ||
|
||
.byebug_history | ||
|
||
# Ignore application configuration | ||
/config/application.yml |
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
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Place all the styles related to the Commands controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ | ||
|
||
@import "bootstrap-sprockets"; | ||
@import "bootstrap"; |
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
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 |
---|---|---|
@@ -1,8 +1,23 @@ | ||
<h1>Effin Quotes</h1> | ||
<ul> | ||
|
||
<table class="table table-striped"> | ||
<tbody> | ||
|
||
<% @quotes.each do |quote| %> | ||
<li> | ||
<%= link_to quote.contents, quote %> | ||
</li> | ||
<tr> | ||
<td> | ||
<%= link_to quote.id, quote %> | ||
</td> | ||
<td> | ||
<%= quote.contents %> | ||
</td> | ||
<td> | ||
<%= quote.url %> | ||
</td> | ||
<td> | ||
<%= quote.twitter_url %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</ul> | ||
</tbody> | ||
</table> |
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 |
---|---|---|
@@ -1,7 +1,24 @@ | ||
<h1>Effin Quote</h1> | ||
|
||
<%= image_tag(@quote.url) %> | ||
<p><%= @count %> incomplete quotes</p> | ||
|
||
<p> | ||
URL: | ||
<%= @quote.twitter_url %> | ||
</p> | ||
|
||
<p> | ||
<%= @quote.contents %> | ||
</p> | ||
|
||
<%= form_for(@quote) do |f| %> | ||
<%= f.text_field :contents %> | ||
<%= f.submit %> | ||
<% end %> | ||
|
||
<%= link_to "Destroy", @quote, method: :delete, class: "btn btn-danger" %> | ||
|
||
<p> | ||
<%= image_tag(@quote.url) %> | ||
</p> | ||
|
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 |
---|---|---|
@@ -1 +1 @@ | ||
json.extract! @quote, :id, :contents, :url | ||
json.extract! @quote, :id, :contents, :url, :twitter_url |
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 |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
</head> | ||
|
||
<body> | ||
<%= yield %> | ||
<div class="container"> | ||
<%= yield %> | ||
</div> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
client = Twitter::REST::Client.new do |config| | ||
config.consumer_key = ENV("TWITTER_CONSUMER_KEY") | ||
config.consumer_secret = ENV("TWITTER_CONSUMER_SECRET") | ||
config.access_token = ENV("TWITTER_ACCESS_TOKEN") | ||
config.access_token_secret = ENV("TWITTER_ACCESS_TOKEN_SECRET") | ||
end | ||
|
||
tweets = client.get_all_tweets("effinbirds") | ||
|
||
raw = tweets.map do |t| | ||
next unless t.media && t.media.first && t.media.first.uri | ||
image_url = t.media.first.media_uri | ||
tweet_url = t.uri | ||
|
||
[image_url, tweet_url] | ||
end.compact | ||
|
||
raw.each do |r| | ||
next if EffinQuote.find_by(url: r.first.to_s) | ||
|
||
EffinQuote.create(url: r.first.to_s, twitter_url: r.second.to_s) | ||
end | ||
|
||
def collect_with_max_id(collection=[], max_id=nil, &block) | ||
response = yield(max_id) | ||
collection += response | ||
response.empty? ? collection.flatten : collect_with_max_id(collection, response.last.id - 1, &block) | ||
end | ||
|
||
def client.get_all_tweets(user) | ||
collect_with_max_id do |max_id| | ||
options = {count: 200, include_rts: true} | ||
options[:max_id] = max_id unless max_id.nil? | ||
user_timeline(user, options) | ||
end | ||
end |
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,5 @@ | ||
class AddTwitterUrlToEffinQuotes < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :effin_quotes, :twitter_url, :string | ||
end | ||
end |
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
Oops, something went wrong.