Instantly share code, notes, and snippets.

@kevinthompson /.env
Last active May 26, 2017

Embed
What would you like to do?
Litmus Example – Tweets in CSS
TWITTER_CONSUMER_KEY=""
TWITTER_CONSUMER_SECRET=""
TWITTER_SEARCH_STRING="#tedc15 -rt"
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
source 'https://rubygems.org'
gem 'sinatra'
gem 'twitter'
gem 'puma'
group 'development' do
gem 'foreman'
end
web: bundle exec ruby app.rb -p $PORT
@kevinthompson

This comment has been minimized.

Show comment
Hide comment
@kevinthompson

kevinthompson May 22, 2015

View the full example in the litmus/example-css-tweets repo,
or deploy a version to heroku to test your own search terms.

Deploy

Owner

kevinthompson commented May 22, 2015

View the full example in the litmus/example-css-tweets repo,
or deploy a version to heroku to test your own search terms.

Deploy

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 27, 2015

I truely love it. Great job! Seen your result in the Litmus example. Might use it someday. ;-)

Cheers.

ghost commented May 27, 2015

I truely love it. Great job! Seen your result in the Litmus example. Might use it someday. ;-)

Cheers.

@matthelbig

This comment has been minimized.

Show comment
Hide comment
@matthelbig

matthelbig Sep 2, 2015

Any way you can update this to include pulling down avatar photo, name, handle, and timestamp? 😄

matthelbig commented Sep 2, 2015

Any way you can update this to include pulling down avatar photo, name, handle, and timestamp? 😄

@nola

This comment has been minimized.

Show comment
Hide comment
@nola

nola Jan 14, 2016

Awesome stuff! Where do you add the Cache-Control? Is it a part of the repo?

nola commented Jan 14, 2016

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