flakey 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 +20 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +119 -0
- data/Rakefile +2 -0
- data/flakey.gemspec +19 -0
- data/lib/flakey.rb +12 -0
- data/lib/flakey/configuration.rb +36 -0
- data/lib/flakey/engine.rb +4 -0
- data/lib/flakey/facebook.rb +28 -0
- data/lib/flakey/github.rb +12 -0
- data/lib/flakey/google_plus.rb +21 -0
- data/lib/flakey/stackoverflow.rb +12 -0
- data/lib/flakey/twitter.rb +49 -0
- data/lib/flakey/version.rb +3 -0
- data/spec/flakey/twitter_spec.rb +19 -0
- data/spec/spec_helper.rb +5 -0
- data/vendor/assets/javascripts/flakey/facebook.js.erb +7 -0
- data/vendor/assets/javascripts/flakey/google_plus.js.erb +9 -0
- data/vendor/assets/javascripts/flakey/twitter.js +1 -0
- metadata +79 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 David Tuite
|
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,119 @@
|
|
1
|
+
# Flakey
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'flakey'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install flakey
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
### Twitter
|
22
|
+
|
23
|
+
# config/initializers/flakey.rb
|
24
|
+
Flakey.configure do |config|
|
25
|
+
# Optionally include:
|
26
|
+
# config.default_twitter_handle = 'dtuite'
|
27
|
+
# config.default_tweet_hastags = ''
|
28
|
+
# config.default_tweet_via = ''
|
29
|
+
# config.default_tweet_related = ''
|
30
|
+
end
|
31
|
+
|
32
|
+
# app/assets/javascrippts/application.js
|
33
|
+
#= require flakey/twitter
|
34
|
+
|
35
|
+
# app/helpers/application_helper.rb
|
36
|
+
module ApplicationHelper
|
37
|
+
include Flakey::Twitter
|
38
|
+
end
|
39
|
+
|
40
|
+
# app/views/layouts/application.html.erb
|
41
|
+
<%= tweet_button(hashtags: 'awesome') %>
|
42
|
+
|
43
|
+
### Facebook
|
44
|
+
|
45
|
+
# config/initializers/flakey.rb
|
46
|
+
Flakey.configure do |config|
|
47
|
+
config.facebook_app_id = '<YOUR_APP_ID>'
|
48
|
+
config.default_facebook_nickname = '<A_FACEBOOK_NICKNAME>'
|
49
|
+
end
|
50
|
+
|
51
|
+
# app/assets/javascrippts/application.js
|
52
|
+
#= require flakey/facebook
|
53
|
+
|
54
|
+
# app/helpers/application_helper.rb
|
55
|
+
module ApplicationHelper
|
56
|
+
include Flakey::Facebook
|
57
|
+
end
|
58
|
+
|
59
|
+
# app/views/layouts/application.html.erb
|
60
|
+
<%= like_button(width: 150) %>
|
61
|
+
|
62
|
+
### Github
|
63
|
+
|
64
|
+
# config/initializers/flakey.rb
|
65
|
+
Flakey.configure do |config|
|
66
|
+
config.default_github_name = 'dtuite'
|
67
|
+
end
|
68
|
+
|
69
|
+
# app/helpers/application_helper.rb
|
70
|
+
module ApplicationHelper
|
71
|
+
include Flakey::Github
|
72
|
+
end
|
73
|
+
|
74
|
+
# app/views/layouts/application.html.erb
|
75
|
+
<%= link_to "Github", github_url %>
|
76
|
+
|
77
|
+
### Stackoverflow
|
78
|
+
|
79
|
+
# config/initializers/flakey.rb
|
80
|
+
Flakey.configure do |config|
|
81
|
+
config.default_stackoverflow_nickname = 'david-tuite'
|
82
|
+
config.default_stackoverflow_user_id = '7389247'
|
83
|
+
end
|
84
|
+
|
85
|
+
# app/helpers/application_helper.rb
|
86
|
+
module ApplicationHelper
|
87
|
+
include Flakey::Stackoverflow
|
88
|
+
end
|
89
|
+
|
90
|
+
# app/views/layouts/application.html.erb
|
91
|
+
<%= link_to "Stackoverflow Profile", stackoverflow_profile_url %>
|
92
|
+
|
93
|
+
### Google Plus
|
94
|
+
|
95
|
+
# config/initializers/flakey.rb
|
96
|
+
Flakey.configure do |config|
|
97
|
+
# Optionally:
|
98
|
+
# Should be of the form of, for example, 'en-GB' or 'de'.
|
99
|
+
# config.plus_one_button_language = 'en-GB'
|
100
|
+
end
|
101
|
+
|
102
|
+
# app/assets/javascrippts/application.js
|
103
|
+
#= require flakey/google_plus
|
104
|
+
|
105
|
+
# app/helpers/application_helper.rb
|
106
|
+
module ApplicationHelper
|
107
|
+
include Flakey::GooglePlus
|
108
|
+
end
|
109
|
+
|
110
|
+
# app/views/layouts/application.html.erb
|
111
|
+
<%= plus_one_button %>
|
112
|
+
|
113
|
+
## Contributing
|
114
|
+
|
115
|
+
1. Fork it
|
116
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
117
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
118
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
119
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/flakey.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/flakey/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["David Tuite"]
|
6
|
+
gem.email = ["dtuite@gmail.com"]
|
7
|
+
gem.description = %q{Social helpers for Rails apps.}
|
8
|
+
gem.summary = %q{Makes a bunch of helper methods available for including in your Rails views.}
|
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 = "flakey"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Flakey::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency 'rspec'
|
19
|
+
end
|
data/lib/flakey.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "flakey/configuration"
|
2
|
+
require "flakey/twitter"
|
3
|
+
require "flakey/facebook"
|
4
|
+
require "flakey/engine"
|
5
|
+
require "flakey/github"
|
6
|
+
require "flakey/google_plus"
|
7
|
+
require "flakey/stackoverflow"
|
8
|
+
require "flakey/version"
|
9
|
+
|
10
|
+
module Flakey
|
11
|
+
# Your code goes here...
|
12
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Enable setting and getting of configuration options.
|
2
|
+
#
|
3
|
+
# Example:
|
4
|
+
#
|
5
|
+
# This can now be used under config/initializers/flakey.rb
|
6
|
+
# Flakey.configure do |config|
|
7
|
+
|
8
|
+
# end
|
9
|
+
|
10
|
+
module Flakey
|
11
|
+
class Configuration
|
12
|
+
attr_accessor :default_twitter_handle, :default_tweet_hashtags,
|
13
|
+
:default_tweet_via, :default_tweet_related,
|
14
|
+
:default_facebook_nickname, :facebook_app_id,
|
15
|
+
:default_stackoverflow_nickname, :default_stackoverflow_user_id,
|
16
|
+
:default_github_name, :plus_one_button_language
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
self.default_twitter_handle = ''
|
20
|
+
self.default_tweet_hashtags = ''
|
21
|
+
self.default_tweet_via = ''
|
22
|
+
self.default_tweet_related = ''
|
23
|
+
|
24
|
+
self.default_facebook_nickname = ''
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.configuration
|
30
|
+
@configuration ||= Configuration.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.configure
|
34
|
+
yield configuration
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Flakey
|
2
|
+
module Facebook
|
3
|
+
def facebook_nickname(options = {})
|
4
|
+
options[:nickname] ||
|
5
|
+
Flakey.configuration.default_facebook_nickname
|
6
|
+
end
|
7
|
+
|
8
|
+
def facebook_url(options = {})
|
9
|
+
nickname = options[:nickname] || facebook_nickname
|
10
|
+
"https://www.facebook.com/" + nickname
|
11
|
+
end
|
12
|
+
|
13
|
+
def like_button(options = {})
|
14
|
+
url = options[:url] || request.url
|
15
|
+
layout = options[:layout] || 'button_count'
|
16
|
+
width = options[:width] || 250
|
17
|
+
send = options[:send] || false
|
18
|
+
font = options[:font] || 'tahoma'
|
19
|
+
class_list = options[:class] || 'fb-like'
|
20
|
+
show_faces = options[:show_faces] || false
|
21
|
+
|
22
|
+
content_tag :div, '', :class => class_list, data: {
|
23
|
+
href: url, send: send, layout: layout, width: width.to_s,
|
24
|
+
:'show-faces' => show_faces, font: font
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Flakey
|
2
|
+
module GooglePlus
|
3
|
+
# INFO: https://developers.google.com/+/plugins/+1button/
|
4
|
+
def plus_one_button(options = {})
|
5
|
+
size = options[:size] || nil
|
6
|
+
annotation = options[:annotation] || 'inline'
|
7
|
+
width = options[:width] || 300
|
8
|
+
class_list = options[:class] || 'g-plusone'
|
9
|
+
href = options[:href] || request.url
|
10
|
+
callback = options[:callback] || nil
|
11
|
+
|
12
|
+
data_attr = { annotation: annotation, href: href }
|
13
|
+
# Width only applies to the 'inline' annotation type.
|
14
|
+
data_attr.merge!(width: width) if annotation == 'inline'
|
15
|
+
data_attr.merge!(size: size) if size
|
16
|
+
data_attr.merge!(callback: callback) if callback
|
17
|
+
|
18
|
+
content_tag :div, '', class: class_list, data: data_attr
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Flakey
|
2
|
+
module Stackoverflow
|
3
|
+
def stackoverflow_nickname(options = {})
|
4
|
+
options[:nickname] || Flakey.configuration.default_stackoverflow_nickname
|
5
|
+
end
|
6
|
+
|
7
|
+
def stackoverflow_profile_url(options = {})
|
8
|
+
user_id = Flakey.configuration.default_stackoverflow_user_id
|
9
|
+
"http://stackoverflow.com/users/#{user_id}/#{stackoverflow_nickname}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Flakey
|
2
|
+
module Twitter
|
3
|
+
|
4
|
+
def twitter_handle(options = {})
|
5
|
+
options[:handle] || Flakey.configuration.default_twitter_handle
|
6
|
+
end
|
7
|
+
|
8
|
+
def twitter_url(options = {})
|
9
|
+
handle = options[:handle] || twitter_handle
|
10
|
+
"https://twitter.com/#{handle}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def tweet_button(options = {})
|
14
|
+
url = options[:url] || request.url
|
15
|
+
text = options[:text]
|
16
|
+
hashtags = options[:hashtags] ||
|
17
|
+
Flakey.configuration.default_tweet_hashtags
|
18
|
+
label = options[:label] || 'Tweet'
|
19
|
+
via = options[:via] ||
|
20
|
+
Flakey.configuration.default_tweet_via
|
21
|
+
related = options[:related] ||
|
22
|
+
Flakey.configuration.default_tweet_related
|
23
|
+
class_list = options[:class] || "twitter-share-button"
|
24
|
+
|
25
|
+
data_attr = {
|
26
|
+
:via => via,
|
27
|
+
:related => related,
|
28
|
+
:hashtags => hashtags,
|
29
|
+
:url => url
|
30
|
+
}
|
31
|
+
# Twitter will take the page title if we just leave it out.
|
32
|
+
data_attr.merge!(text: text) unless text.nil?
|
33
|
+
|
34
|
+
link_to label, "https://twitter.com/share",
|
35
|
+
:class => class_list, :data => data_attr
|
36
|
+
end
|
37
|
+
|
38
|
+
def follow_button(options = {})
|
39
|
+
handle = options[:handle] || twitter_handle
|
40
|
+
label = options[:label] || "Follow #{handle}"
|
41
|
+
size = options[:size] || 'large'
|
42
|
+
class_list = options[:class] || "twitter-follow-button"
|
43
|
+
show_count = options[:show_count] || "false"
|
44
|
+
|
45
|
+
link_to label, "https://twitter.com/#{handle}",
|
46
|
+
class: class_list, data: { :"show-count" => show_count, size: size }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
class DummyHelper
|
4
|
+
include Flakey::Twitter
|
5
|
+
end
|
6
|
+
|
7
|
+
describe Flakey::Twitter do
|
8
|
+
subject { DummyHelper.new }
|
9
|
+
|
10
|
+
describe "twitter_handle" do
|
11
|
+
it "should output the twitter handle" do
|
12
|
+
subject.twitter_handle.should == 'grinnick'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should take a handle as an argument" do
|
16
|
+
subject.twitter_handle('hello').should == 'hello'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
(function(d, s, id) {
|
2
|
+
var js, fjs = d.getElementsByTagName(s)[0];
|
3
|
+
if (d.getElementById(id)) return;
|
4
|
+
js = d.createElement(s); js.id = id;
|
5
|
+
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=<%= Flakey.configuration.facebook_app_id %>";
|
6
|
+
fjs.parentNode.insertBefore(js, fjs);
|
7
|
+
}(document, 'script', 'facebook-jssdk'));
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% if Flakey.configuration.plus_one_button_language %>
|
2
|
+
window.___gcfg = {lang: '<%= Flakey.configuration.plus_one_button_language %>'};
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
(function() {
|
6
|
+
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
|
7
|
+
po.src = 'https://apis.google.com/js/plusone.js';
|
8
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
|
9
|
+
})();
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flakey
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David Tuite
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70355785100020 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70355785100020
|
25
|
+
description: Social helpers for Rails apps.
|
26
|
+
email:
|
27
|
+
- dtuite@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- .rspec
|
34
|
+
- Gemfile
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- flakey.gemspec
|
39
|
+
- lib/flakey.rb
|
40
|
+
- lib/flakey/configuration.rb
|
41
|
+
- lib/flakey/engine.rb
|
42
|
+
- lib/flakey/facebook.rb
|
43
|
+
- lib/flakey/github.rb
|
44
|
+
- lib/flakey/google_plus.rb
|
45
|
+
- lib/flakey/stackoverflow.rb
|
46
|
+
- lib/flakey/twitter.rb
|
47
|
+
- lib/flakey/version.rb
|
48
|
+
- spec/flakey/twitter_spec.rb
|
49
|
+
- spec/spec_helper.rb
|
50
|
+
- vendor/assets/javascripts/flakey/facebook.js.erb
|
51
|
+
- vendor/assets/javascripts/flakey/google_plus.js.erb
|
52
|
+
- vendor/assets/javascripts/flakey/twitter.js
|
53
|
+
homepage: ''
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.8.16
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Makes a bunch of helper methods available for including in your Rails views.
|
77
|
+
test_files:
|
78
|
+
- spec/flakey/twitter_spec.rb
|
79
|
+
- spec/spec_helper.rb
|