middleman-hatenastar 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e48d0a3b9b0f5d2db9c2116f455e2b949659204c
4
+ data.tar.gz: 4a52e29fa96820957a178ce547a481a78c1e2247
5
+ SHA512:
6
+ metadata.gz: faad8904ed69a17a1956ea04e475c15799da1cf9e5c308786bb9678770eb922b34af0fe5f66378f6e8221b6bee3cb92b6a2a3a48f9de7d54be33ae13469dacee
7
+ data.tar.gz: 64a0a083f7e3472049b944eb1839b97d8e0be2b5d673d41fc8932d44bf85323a61c0c2e6a04eef0047e06d87d0e43df3c458f5f54f7773a839be142d6e5f5d6e
@@ -0,0 +1,7 @@
1
+ # Ignore bundler lock file
2
+ /Gemfile.lock
3
+
4
+ # Ignore pkg folder
5
+ /pkg
6
+
7
+ /tmp
@@ -0,0 +1,11 @@
1
+ inherit_gem:
2
+ unasukecop:
3
+ - "config/rubocop.yml"
4
+
5
+ Style/Documentation:
6
+ Enabled: false
7
+
8
+ Metrics/BlockLength:
9
+ Exclude:
10
+ - 'spec/**/*_spec.rb'
11
+ - 'middleman-hatenastar.gemspec'
@@ -0,0 +1,11 @@
1
+ notifications:
2
+ email: false
3
+ sudo: false
4
+ language: ruby
5
+ rvm:
6
+ - 2.3.4
7
+ - 2.4.1
8
+ - ruby-head
9
+ before_install: gem install bundler -v 1.14.3
10
+ script:
11
+ - bundle exec test
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # If you do not have OpenSSL installed, update
2
+ # the following line to use "http://" instead
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in middleman-hatenastar.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Yusuke Nakamura
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.
@@ -0,0 +1,70 @@
1
+ # middleman-hatenastar
2
+
3
+ middleman-hatenastar is a hatenastar extension for Middleman.
4
+
5
+
6
+ ## Usage
7
+ ### 1. bundle install
8
+
9
+ ```ruby
10
+ # Gemfile
11
+ source 'https://rubygems.org'
12
+
13
+ gem 'middleman', '>= 4.0.0'
14
+ gem 'middleman-hatenastar'
15
+ ```
16
+
17
+ and run `bundle install`
18
+
19
+ ### 2. get your hatenastar token
20
+
21
+ See also → [はてなスターをブログに貼り付ける - はてなスター日記](http://d.hatena.ne.jp/hatenastar/20070707/1184453490)
22
+
23
+ ### 3. activate hatenastar extension and setting it
24
+
25
+ ```ruby
26
+ # your middleman config.rb
27
+ activate :hatenastar,
28
+ token: 'your token',
29
+ uri: 'h3 a',
30
+ title: 'h3',
31
+ container: 'h3',
32
+ entry_node: 'div.section'
33
+ ```
34
+
35
+ ### 4. invoke hatenastar_tag in your layout
36
+
37
+ ```slim
38
+ doctype html
39
+ html
40
+ head
41
+ = hatenastar_tag
42
+ ```
43
+
44
+ You can overwrite setting like this.
45
+
46
+ ```slim
47
+ doctype html
48
+ html
49
+ head
50
+ = hatenastar_tag(uri: 'h4 a', entry_node: 'div.another-section')
51
+ ```
52
+
53
+ ### 5. build middleman site!
54
+
55
+ ```shell
56
+ $ bundle exec middleman build
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/unasuke/middleman-hatenastar.
62
+
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
67
+
68
+ ## Reference
69
+
70
+ - [はてなスターをブログに設置するには - はてなスター日記](http://d.hatena.ne.jp/hatenastar/20070707)
@@ -0,0 +1,16 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber/rake/task'
5
+ require 'rubocop/rake_task'
6
+
7
+ RuboCop::RakeTask.new
8
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
9
+ t.cucumber_opts = '--color --tags ~@wip --strict'
10
+ end
11
+
12
+ require 'rake/clean'
13
+
14
+ task test: ['cucumber']
15
+
16
+ task default: %i[test rubocop]
@@ -0,0 +1,9 @@
1
+ Feature: hatenaster
2
+ Scenario: Should embed hatenastar tag
3
+ Given a fixture app "hatenastar"
4
+ And the Server is running at "hatenastar"
5
+ When I go to "/index.html"
6
+ Then I should see "//s.hatena.ne.jp/js/HatenaStar.js"
7
+ Then I should see "Hatena.Star.Token = 'token';"
8
+ Then I should see "uri string"
9
+ Then I should see "div.section"
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-hatenastar')
@@ -0,0 +1,3 @@
1
+ activate :hatenastar,
2
+ token: 'token',
3
+ uri: 'uri string'
@@ -0,0 +1 @@
1
+ <p>aaaaa</p>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <%= hatenastar_tag %>
5
+ <title>Test App</title>
6
+ </head>
7
+ <body>
8
+ <%= yield %>
9
+ </body>
10
+ </html>
@@ -0,0 +1,6 @@
1
+ require "middleman-core"
2
+
3
+ Middleman::Extensions.register :hatenastar do
4
+ require "middleman-hatenastar/extension"
5
+ ::Middleman::Hatenastar::Extension
6
+ end
@@ -0,0 +1,30 @@
1
+ require 'middleman-core'
2
+ require 'middleman-hatenastar/generator'
3
+
4
+ module Middleman
5
+ module Hatenastar
6
+ class Extension < ::Middleman::Extension
7
+ option :token, nil, 'Your hatenastar token.'
8
+ option :uri, 'h3 a', 'Permarink of the entry.'
9
+ option :title, 'h3', 'Entry title.'
10
+ option :container, 'h3', 'Set hatenastar to after of the this tag.'
11
+ option :entry_node, 'div.section', 'Unit of each entry,'
12
+
13
+ def initialize(app, options_hash={}, &block)
14
+ super
15
+
16
+ if options[:token] == nil
17
+ raise ArgumentError, 'Hatenastar token is required.'
18
+ end
19
+
20
+ @generator = ::Middleman::Hatenastar::Generator.new(options)
21
+ end
22
+
23
+ expose_to_template :hatenastar_tag
24
+
25
+ def hatenastar_tag(uri: nil, title: nil, container: nil, entry_node: nil)
26
+ @generator.generate(uri: uri, title: title, container: container, entry_node: entry_node)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ module Middleman
2
+ module Hatenastar
3
+ class Generator
4
+ def initialize(option)
5
+ @token = option[:token]
6
+ @uri = option[:uri]
7
+ @title = option[:title]
8
+ @container = option[:container]
9
+ @entry_node = option[:entry_node]
10
+ end
11
+
12
+ def generate(uri: nil, title: nil, container: nil, entry_node: nil)
13
+ _uri = uri || @uri
14
+ _title = title || @title
15
+ _container = container || @container
16
+ _entry_node = entry_node || @entry_node
17
+
18
+ <<~TAG
19
+ <script type="text/javascript" src="//s.hatena.ne.jp/js/HatenaStar.js"></script>
20
+ <script type="text/javascript">
21
+ Hatena.Star.Token = '#{@token}';
22
+ Hatena.Star.SiteConfig = {
23
+ entryNodes: {
24
+ "#{_entry_node}": {
25
+ uri: "#{_uri}",
26
+ title: "#{_title}",
27
+ container: "#{_container}"
28
+ }
29
+ }
30
+ };
31
+ </script>
32
+ TAG
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module Hatenastar
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'middleman-hatenastar/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "middleman-hatenastar"
7
+ s.version = ::Middleman::Hatenastar::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Yusuke Nakamura"]
10
+ s.email = ["yusuke1994525@gmail.com"]
11
+ s.homepage = "https://github.com/unasuke/middleman-hatenastar"
12
+ s.summary = %q{Embedding hatenastar into the your middleman website.}
13
+ s.description = %q{Embedding hatenastar into the your middleman website.}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ # The version of middleman-core your extension depends on
21
+ s.add_runtime_dependency "middleman-core", ">= 4"
22
+
23
+ s.add_development_dependency 'aruba'
24
+ s.add_development_dependency 'bundler', '~> 1.14'
25
+ s.add_development_dependency 'capybara'
26
+ s.add_development_dependency 'cucumber'
27
+ s.add_development_dependency 'rake', '~> 10.0'
28
+ s.add_development_dependency 'rdoc'
29
+ s.add_development_dependency 'rspec'
30
+ s.add_development_dependency 'unasukecop'
31
+ s.add_development_dependency 'yard'
32
+ end
metadata ADDED
@@ -0,0 +1,202 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-hatenastar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yusuke Nakamura
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-22 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: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aruba
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: capybara
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: cucumber
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rdoc
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: unasukecop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: yard
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Embedding hatenastar into the your middleman website.
154
+ email:
155
+ - yusuke1994525@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rubocop.yml"
162
+ - ".travis.yml"
163
+ - Gemfile
164
+ - LICENSE.txt
165
+ - README.md
166
+ - Rakefile
167
+ - features/hatenastar.feature
168
+ - features/support/env.rb
169
+ - fixtures/hatenastar/config.rb
170
+ - fixtures/hatenastar/source/index.html.erb
171
+ - fixtures/hatenastar/source/layout.erb
172
+ - lib/middleman-hatenastar.rb
173
+ - lib/middleman-hatenastar/extension.rb
174
+ - lib/middleman-hatenastar/generator.rb
175
+ - lib/middleman-hatenastar/version.rb
176
+ - middleman-hatenastar.gemspec
177
+ homepage: https://github.com/unasuke/middleman-hatenastar
178
+ licenses: []
179
+ metadata: {}
180
+ post_install_message:
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ requirements: []
195
+ rubyforge_project:
196
+ rubygems_version: 2.6.11
197
+ signing_key:
198
+ specification_version: 4
199
+ summary: Embedding hatenastar into the your middleman website.
200
+ test_files:
201
+ - features/hatenastar.feature
202
+ - features/support/env.rb