middleman-social_tag_view_helper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +59 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/middleman/social_tag_view_helper.rb +5 -0
- data/lib/middleman/social_tag_view_helper/extension.rb +13 -0
- data/lib/middleman/social_tag_view_helper/helper.rb +59 -0
- data/lib/middleman/social_tag_view_helper/version.rb +5 -0
- data/middleman-social_tag_view_helper.gemspec +33 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 04eb1bb58a930d5e827b94ec42601baf071755a6
|
4
|
+
data.tar.gz: 89f1f81cd30724bb70137bf90f11f5c839016d36
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3f6555f093ce4e190dd40bf0270796e0243c81fcc89a4f8d72c915fc48baa3cb31b770975c745a33fdaf45de10a5cb847fcd044dec0bbed4c3009ab80be93303
|
7
|
+
data.tar.gz: b1a3a9b5b77d785fdf06d951ceaafed0ae120afc54663823ea930d91e562d4305b45f319ef1107be97505b0587fa9eb02a7f767e660c9b7725f51c3642818aaf
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 onodera_takumi
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Middleman::SocialTagViewHelper
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/middleman/social_tag_view_helper`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'middleman-social_tag_view_helper'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install middleman-social_tag_view_helper
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Configration
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
activate :social_tag_view_helper
|
27
|
+
set :facebook_app_id, 'facebook app id'
|
28
|
+
```
|
29
|
+
|
30
|
+
### View file
|
31
|
+
|
32
|
+
into head tag
|
33
|
+
```ruby
|
34
|
+
= facebook_app_id_meta_tag
|
35
|
+
= open_graph_meta_tag(page_title: "Title", page_image: "http://example.com/image.png")
|
36
|
+
```
|
37
|
+
|
38
|
+
into layout file
|
39
|
+
```ruby
|
40
|
+
= facebook_like_button # require facebook_app_id
|
41
|
+
= hatena_bookmark_button
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
48
|
+
|
49
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/takkjoga/middleman-social_tag_view_helper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
54
|
+
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
59
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "middleman/social_tag_view_helper"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'middleman/social_tag_view_helper/helper'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
module SocialTagViewHelper
|
5
|
+
class Extension < Middleman::Extension
|
6
|
+
def initialize(app, options_hash = {}, &block)
|
7
|
+
super
|
8
|
+
|
9
|
+
app.helpers Middleman::SocialTagViewHelper::Helper
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Middleman
|
2
|
+
module SocialTagViewHelper
|
3
|
+
module Helper
|
4
|
+
def open_graph_meta_tag(page_type: "website", page_title: nil, page_image: nil, _site_url: nil, _site_title: nil, _site_description: nil)
|
5
|
+
_site_url ||= site_url
|
6
|
+
_site_title ||= site_title
|
7
|
+
_site_description ||= site_description
|
8
|
+
%Q|<meta property="og:type" content="#{page_type}">
|
9
|
+
<meta property="og:url" content="#{_site_url}">
|
10
|
+
<meta property="og:title" content="#{page_title}">
|
11
|
+
<meta property="og:image" content="#{page_image}">
|
12
|
+
<meta property="og:site_name" content="#{_site_title}">
|
13
|
+
<meta property="og:description" content="#{_site_description}">|
|
14
|
+
end
|
15
|
+
|
16
|
+
def hatena_bookmark_button(_site_url = nil, _site_title = nil)
|
17
|
+
_site_url ||= site_url
|
18
|
+
_site_title ||= site_title
|
19
|
+
%Q|<a href="http://b.hatena.ne.jp/entry/#{_site_url.sub(/^http[s]?:\/\//, '')}" class="hatena-bookmark-button" data-hatena-bookmark-title="#{_site_title}" data-hatena-bookmark-layout="standard-balloon" data-hatena-bookmark-lang="ja" title="このエントリーをはてなブックマークに追加">
|
20
|
+
<img src="https://b.st-hatena.com/images/entry-button/button-only@2x.png" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" />
|
21
|
+
</a>
|
22
|
+
<script type="text/javascript" src="https://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script>|
|
23
|
+
end
|
24
|
+
|
25
|
+
def facebook_app_id_meta_tag(_facebook_app_id = nil)
|
26
|
+
_facebook_app_id ||= facebook_app_id
|
27
|
+
%Q|<meta property="fb:app_id" content="#{_facebook_app_id}" />|
|
28
|
+
end
|
29
|
+
|
30
|
+
def facebook_share_button(_facebook_app_id = nil)
|
31
|
+
_facebook_app_id ||= facebook_app_id
|
32
|
+
%Q|<script>
|
33
|
+
window.fbAsyncInit = function() {
|
34
|
+
FB.init({
|
35
|
+
appId : #{_facebook_app_id},
|
36
|
+
xfbml : true,
|
37
|
+
version : 'v2.5'
|
38
|
+
});
|
39
|
+
};
|
40
|
+
|
41
|
+
(function(d, s, id){
|
42
|
+
var js, fjs = d.getElementsByTagName(s)[0];
|
43
|
+
if (d.getElementById(id)) {return;}
|
44
|
+
js = d.createElement(s); js.id = id;
|
45
|
+
js.src = "//connect.facebook.net/en_US/sdk.js";
|
46
|
+
fjs.parentNode.insertBefore(js, fjs);
|
47
|
+
}(document, 'script', 'facebook-jssdk'));
|
48
|
+
</script>
|
49
|
+
|
50
|
+
<div
|
51
|
+
class="fb-share-button"
|
52
|
+
data-href="#{site_url}/#{current_article.url}"
|
53
|
+
data-layout="button_count">
|
54
|
+
</div>|
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'middleman/social_tag_view_helper/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "middleman-social_tag_view_helper"
|
8
|
+
spec.version = Middleman::SocialTagViewHelper::VERSION
|
9
|
+
spec.authors = ["Takumi Onodera"]
|
10
|
+
spec.email = ["takkjoga@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Social tag helper for Middleman"
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.homepage = "https://github.com/takkjoga/middleman-social_tag_view_helper"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_runtime_dependency 'middleman-core', ['>= 3.0.0']
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-social_tag_view_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takumi Onodera
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: middleman-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Social tag helper for Middleman
|
56
|
+
email:
|
57
|
+
- takkjoga@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- lib/middleman/social_tag_view_helper.rb
|
70
|
+
- lib/middleman/social_tag_view_helper/extension.rb
|
71
|
+
- lib/middleman/social_tag_view_helper/helper.rb
|
72
|
+
- lib/middleman/social_tag_view_helper/version.rb
|
73
|
+
- middleman-social_tag_view_helper.gemspec
|
74
|
+
homepage: https://github.com/takkjoga/middleman-social_tag_view_helper
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata:
|
78
|
+
allowed_push_host: https://rubygems.org
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.5.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Social tag helper for Middleman
|
99
|
+
test_files: []
|