├── .env.example ├── .gitignore ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── Procfile ├── README.md ├── app.json └── app.rb /.env.example: -------------------------------------------------------------------------------- 1 | TWITTER_CONSUMER_KEY="" 2 | TWITTER_CONSUMER_SECRET="" 3 | TWITTER_SEARCH_STRING="#tedc15 -rt" 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.sw[nop] 3 | .bundle 4 | .env 5 | db/*.sqlite3 6 | log/*.log 7 | rerun.txt 8 | tags 9 | !tags/ 10 | tmp/**/* 11 | !tmp/cache/.keep 12 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'sinatra' 4 | gem 'twitter' 5 | gem 'puma' 6 | 7 | group 'development' do 8 | gem 'foreman' 9 | end 10 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | addressable (2.3.8) 5 | buftok (0.2.0) 6 | equalizer (0.0.11) 7 | faraday (0.9.1) 8 | multipart-post (>= 1.2, < 3) 9 | foreman (0.78.0) 10 | thor (~> 0.19.1) 11 | http (0.6.4) 12 | http_parser.rb (~> 0.6.0) 13 | http_parser.rb (0.6.0) 14 | json (1.8.2) 15 | memoizable (0.4.2) 16 | thread_safe (~> 0.3, >= 0.3.1) 17 | multipart-post (2.0.0) 18 | naught (1.0.0) 19 | puma (2.11.2) 20 | rack (>= 1.1, < 2.0) 21 | rack (1.6.1) 22 | rack-protection (1.5.3) 23 | rack 24 | simple_oauth (0.3.1) 25 | sinatra (1.4.6) 26 | rack (~> 1.4) 27 | rack-protection (~> 1.4) 28 | tilt (>= 1.3, < 3) 29 | thor (0.19.1) 30 | thread_safe (0.3.5) 31 | tilt (2.0.1) 32 | twitter (5.14.0) 33 | addressable (~> 2.3) 34 | buftok (~> 0.2.0) 35 | equalizer (~> 0.0.9) 36 | faraday (~> 0.9.0) 37 | http (~> 0.6.0) 38 | http_parser.rb (~> 0.6.0) 39 | json (~> 1.8) 40 | memoizable (~> 0.4.0) 41 | naught (~> 1.0) 42 | simple_oauth (~> 0.3.0) 43 | 44 | PLATFORMS 45 | ruby 46 | 47 | DEPENDENCIES 48 | foreman 49 | puma 50 | sinatra 51 | twitter 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Litmus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec ruby app.rb -p $PORT 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Litmus Example – Tweets in CSS 2 | 3 | ## Deploy A Copy 4 | You can easily deploy this application to [Heroku](https://heroku.com) using 5 | the button below. After creating your [Twitter application](https://apps.twitter.com), 6 | click the "Deploy to Heroku" button and follow the steps on the next screen to create 7 | your own version of this application. 8 | 9 | [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) 10 | 11 | ## Local Development 12 | 13 | ### Requirements 14 | * Git 15 | * Ruby 16 | * Bundler 17 | 18 | ### Setup 19 | 1. Clone This Repo: `git clone https://github.com/litmus/example-css-tweets.git` 20 | 2. Install Dependencies: `cd example-css-tweets && bundle install` 21 | 3. Create Environment File: `cp .env.example .env` 22 | 4. Create Twitter Application: https://apps.twitter.com/ 23 | 5. Enter Your Application's API Credentials in `.env` 24 | 5. Run `bundle exec foreman start` 25 | 6. Visit [http://localhost:5000/tweets.css](http://localhost:5000/tweets.css) 26 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Litmus Example – Tweets in CSS", 3 | "description": "A simple Sinatra application that populates tweet content in CSS", 4 | "repository": "https://github.com/litmus/example-css-tweets.git", 5 | "success_url": "/tweets.css", 6 | "env": { 7 | "TWITTER_CONSUMER_KEY": { 8 | "description": "Your Twitter Application API Key from https://apps.twitter.com", 9 | "required": true 10 | }, 11 | "TWITTER_CONSUMER_SECRET": { 12 | "description": "Your Twitter Application API Secret from https://apps.twitter.com", 13 | "required": true 14 | }, 15 | "TWITTER_SEARCH_STRING": { 16 | "description": "Your Twitter Search Terms (`-rt` means without retweets)", 17 | "value": "#tedc15 -rt", 18 | "required": true 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app.rb: -------------------------------------------------------------------------------- 1 | require 'sinatra' 2 | require 'twitter' 3 | 4 | helpers do 5 | def twitter 6 | @twitter ||= Twitter::REST::Client.new do |config| 7 | config.consumer_key = ENV.fetch("TWITTER_CONSUMER_KEY") 8 | config.consumer_secret = ENV.fetch("TWITTER_CONSUMER_SECRET") 9 | end 10 | end 11 | end 12 | 13 | get "/tweets.css" do 14 | content_type "text/css" 15 | tweets = twitter.search(ENV.fetch("TWITTER_SEARCH_STRING")) 16 | tweets.take(15).map.with_index do |tweet, i| 17 | <<-CSS 18 | #tweet-#{i + 1} .copy { 19 | content: "#{tweet.text}"; 20 | } 21 | CSS 22 | end 23 | end 24 | --------------------------------------------------------------------------------