twisplay 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in twisplay.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Joost Diepenmaat
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Twisplay
2
+
3
+ A little helper to display Tweets on your Rails website, taking Twitter's [Design Guidelines](https://dev.twitter.com/terms/display-guidelines) into account. Tweet's are stored in your local database.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'twisplay'
10
+
11
+ And then execute:
12
+
13
+ $ rails g twisplay
14
+ $ rake db:migrate
15
+
16
+ Add the Twisplay CSS file 'application.css.scss':
17
+
18
+ @import "twisplay";
19
+
20
+
21
+ ## Usage
22
+
23
+ Render a tweet in a view using the status id from the URL (E.g. "https://twitter.com/#!/rails/status/185856371667894273"):
24
+
25
+ tweet("185856371667894273")
26
+
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,83 @@
1
+ div.twisplay {
2
+ width: 638px;
3
+ height: 124px;
4
+ background: #f8f8f8;
5
+ border: 1px solid #ddd;
6
+ @include border-radius(5px, 5px);
7
+ @include box-shadow(#eee 0px 2px 2px);
8
+ margin-bottom: 1em;
9
+
10
+ div.avatar {
11
+ float: left;
12
+ width: 100px;
13
+ height: 100px;
14
+ padding: 12px 10px;
15
+
16
+ img {
17
+ width: 100px;
18
+ height: 100px;
19
+ @include border-radius(5px, 5px);
20
+ }
21
+ }
22
+
23
+ div.message {
24
+ float: left;
25
+ width: 503px;
26
+ height: 100px;
27
+ padding: 12px 10px 12px 5px;
28
+
29
+ p {
30
+ font-family: "HelveticaNeue","Helvetica Neue",Helvetica,Arial,sans-serif;
31
+ color: #666;
32
+
33
+ &.author {
34
+ font-size: 14px;
35
+ margin-bottom: 0;
36
+
37
+ a {
38
+ font-size: 18px;
39
+ text-decoration: none;
40
+ font-weight: bold;
41
+ }
42
+ }
43
+
44
+ &.tweet {
45
+ font-size: 16px;
46
+ margin-bottom: 0;
47
+ height: 53px;
48
+
49
+ a {
50
+ text-decoration: none;
51
+ }
52
+ }
53
+ }
54
+
55
+ div.twitter_links {
56
+ float: left;
57
+ width: 503px;
58
+ height: 10px;
59
+
60
+ div {
61
+ float: left;
62
+ height: 10px;
63
+ font-size: 13px;
64
+ margin-right: 15px;
65
+
66
+ a {
67
+ text-decoration: none;
68
+ color: #666;
69
+ line-height: 15px;
70
+ vertical-align: bottom;
71
+
72
+ img {
73
+ vertical-align: bottom;
74
+ }
75
+
76
+ &:hover {
77
+ color: #0066cc;
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,6 @@
1
+ module TwisplayHelper
2
+ def tweet(tweet)
3
+ @tweet = Tweet.find_by_tweet_id(tweet)
4
+ render :template => "twisplay/tweet"
5
+ end
6
+ end
@@ -0,0 +1,39 @@
1
+ require "twitter"
2
+
3
+ class Tweet < ActiveRecord::Base
4
+
5
+ validates_presence_of :text, :tweet_created_at, :tweet_id, :user_name, :user_screen_name
6
+
7
+ # attr_accessible :text, :tweet_created_at, :tweet_id, :user_name, :user_screen_name, :user_profile_image_url
8
+
9
+ def self.find_by_tweet_id(tweet_id)
10
+ if Tweet.exists?(:tweet_id => tweet_id.to_s)
11
+ Tweet.where(:tweet_id => tweet_id.to_s).first
12
+ else
13
+ status = Twitter.status(tweet_id)
14
+ tweet = Tweet.new
15
+ tweet.text = status.text
16
+ tweet.tweet_created_at = status.created_at
17
+ tweet.tweet_id = status.id
18
+ tweet.user_name = status.user.name
19
+ tweet.user_screen_name = status.user.screen_name
20
+ tweet.user_profile_image_url = status.user.profile_image_url.sub("_normal", "_reasonably_small")
21
+ tweet.save!
22
+ tweet
23
+ end
24
+ end
25
+
26
+ def client
27
+ self.class.client
28
+ end
29
+
30
+ def self.client
31
+ Twitter.configure do |config|
32
+ config.consumer_key = TWITTER_CONSUMER_KEY
33
+ config.consumer_secret = TWITTER_CONSUMER_SECRET
34
+ config.oauth_token = TWITTER_ACCESS_TOKEN
35
+ config.oauth_token_secret = TWITTER_ACCESS_TOKEN_SECRET
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,29 @@
1
+ <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
2
+ <div class="twisplay">
3
+ <div class="avatar">
4
+ <%= image_tag @tweet.user_profile_image_url %>
5
+ </div>
6
+ <div class="message">
7
+ <p class="author">
8
+ <%= link_to @tweet.user_name, "https://twitter.com/intent/user?screen_name=#{@tweet.user_screen_name}" %>
9
+ </p>
10
+ <p class="tweet">
11
+ <%= @tweet.text %>
12
+ </p>
13
+ <div class="twitter_links">
14
+ <div class="date">
15
+ <%= link_to image_tag("twisplay/bird_16_gray.png") + " #{@tweet.tweet_created_at.strftime("%d %b")}", "https://twitter.com/#!/#{@tweet.user_screen_name}/status/#{@tweet.tweet_id}" %>
16
+
17
+ </div>
18
+ <div class="reply">
19
+ <%= link_to image_tag("twisplay/reply.png") + " Reply", "https://twitter.com/intent/tweet?in_reply_to=#{@tweet.tweet_id}" %>
20
+ </div>
21
+ <div class="retweet">
22
+ <%= link_to image_tag("twisplay/retweet.png") + " Retweet", "https://twitter.com/intent/retweet?tweet_id=#{@tweet.tweet_id}" %>
23
+ </div>
24
+ <div class="favorite">
25
+ <%= link_to image_tag("twisplay/favorite.png") + " Favorite", "https://twitter.com/intent/favorite?tweet_id=#{@tweet.tweet_id}" %>
26
+ </div>
27
+ </div>
28
+ </div>
29
+ </div>
@@ -0,0 +1,20 @@
1
+ class CreateTweetsTable < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :tweets do |t|
4
+ t.text :text
5
+ t.datetime :tweet_created_at
6
+ t.string :tweet_id
7
+ t.string :user_name
8
+ t.string :user_screen_name
9
+ t.string :user_profile_image_url
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :tweets, :tweet_created_at
14
+ add_index :tweets, :tweet_id, :unique => true
15
+ end
16
+
17
+ def self.down
18
+ drop_table :tweets
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ class TwisplayGenerator < Rails::Generators::Base
5
+ include Rails::Generators::Migration
6
+ def self.source_root
7
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
8
+ end
9
+
10
+ def self.next_migration_number(dirname)
11
+ if ActiveRecord::Base.timestamped_migrations
12
+ Time.new.utc.strftime("%Y%m%d%H%M%S")
13
+ else
14
+ "%.3d" % (current_migration_number(dirname) + 1)
15
+ end
16
+ end
17
+
18
+ def create_migration_file
19
+ migration_template 'migration.rb', 'db/migrate/create_tweets_table.rb'
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Twisplay
2
+ VERSION = "0.0.1"
3
+ end
data/lib/twisplay.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "twisplay/version"
2
+
3
+ module Twisplay
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
data/twisplay.gemspec ADDED
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/twisplay/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Joost Diepenmaat"]
6
+ gem.email = ["j.diepenmaat@bluetools.nl"]
7
+ gem.description = "Display tweets on your website using Twitter's Design Guidelines."
8
+ gem.summary = "Display tweets on your website using Twitter's Design Guidelines."
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "twisplay"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Twisplay::VERSION
17
+ gem.add_dependency "twitter", "~> 2.2.5"
18
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twisplay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Joost Diepenmaat
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: twitter
16
+ requirement: &70219364829000 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.2.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70219364829000
25
+ description: Display tweets on your website using Twitter's Design Guidelines.
26
+ email:
27
+ - j.diepenmaat@bluetools.nl
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - app/assets/images/twisplay/bird_16_blue.png
38
+ - app/assets/images/twisplay/bird_16_gray.png
39
+ - app/assets/images/twisplay/favorite.png
40
+ - app/assets/images/twisplay/favorite_hover.png
41
+ - app/assets/images/twisplay/reply.png
42
+ - app/assets/images/twisplay/reply_hover.png
43
+ - app/assets/images/twisplay/retweet.png
44
+ - app/assets/images/twisplay/retweet_hover.png
45
+ - app/assets/stylesheets/twisplay.css.scss
46
+ - app/helpers/twisplay_helper.rb
47
+ - app/models/tweet.rb
48
+ - app/views/twisplay/tweet.html.erb
49
+ - lib/generators/twisplay/templates/migration.rb
50
+ - lib/generators/twisplay/twisplay_generator.rb
51
+ - lib/twisplay.rb
52
+ - lib/twisplay/version.rb
53
+ - twisplay.gemspec
54
+ homepage: ''
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.17
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Display tweets on your website using Twitter's Design Guidelines.
78
+ test_files: []