-
-
Save kevinthompson/c3023df8e2c904ad00d9 to your computer and use it in GitHub Desktop.
Litmus Example – Tweets in CSS
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
TWITTER_CONSUMER_KEY="" | |
TWITTER_CONSUMER_SECRET="" | |
TWITTER_SEARCH_STRING="#tedc15 -rt" |
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
require 'sinatra' | |
require 'twitter' | |
helpers do | |
def twitter | |
@twitter ||= Twitter::REST::Client.new do |config| | |
config.consumer_key = ENV.fetch("TWITTER_CONSUMER_KEY") | |
config.consumer_secret = ENV.fetch("TWITTER_CONSUMER_SECRET") | |
end | |
end | |
end | |
get "/tweets.css" do | |
content_type "text/css" | |
tweets = twitter.search(ENV.fetch("TWITTER_SEARCH_STRING")) | |
tweets.take(15).map.with_index do |tweet, i| | |
<<-CSS | |
#tweet-#{i + 1} .copy { | |
content: "#{tweet.text}"; | |
} | |
CSS | |
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
source 'https://rubygems.org' | |
gem 'sinatra' | |
gem 'twitter' | |
gem 'puma' | |
group 'development' do | |
gem 'foreman' | |
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
web: bundle exec ruby app.rb -p $PORT |
I truely love it. Great job! Seen your result in the Litmus example. Might use it someday. ;-)
Cheers.
Any way you can update this to include pulling down avatar photo, name, handle, and timestamp? 😄
Awesome stuff! Where do you add the Cache-Control? Is it a part of the repo?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
View the full example in the litmus/example-css-tweets repo,
or deploy a version to heroku to test your own search terms.