middleman-blog-selfbookmark 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +27 -0
- data/Rakefile +6 -0
- data/lib/middleman-blog-selfbookmark.rb +8 -0
- data/lib/middleman-blog-selfbookmark/commands.rb +35 -0
- data/lib/middleman-blog-selfbookmark/extension.rb +26 -0
- data/lib/middleman/blog/selfbookmark.rb +45 -0
- data/lib/middleman/blog/selfbookmark/version.rb +7 -0
- data/middleman-blog-selfbookmark.gemspec +37 -0
- metadata +113 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 37670d50dc06bc417e6ce5938f48d869516d32b9
|
|
4
|
+
data.tar.gz: bcc8f5004d2b5fd5e65b87362f3132bed5a0bd1d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 20ae96937c9b2946e1d6d19b9ac5817e19709d213b92566211896787fafefb69b52cc58ccff3620aeaff36480e265af04a500bb31fa5ca4aebd7b76c64224d7e
|
|
7
|
+
data.tar.gz: 7e4ebe035855e25fba37498c8edc31f00eea0c16708b68a86d9eab2717559240a3e52264c78809aae0df7eb3178deb302f1231887674288e45363a0e896b859c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Michiaki Mizoguchi
|
|
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,27 @@
|
|
|
1
|
+
# Middleman::Blog::Selfbookmark
|
|
2
|
+
Create hatena bookmark on new post created.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
|
|
6
|
+
Add this line to your application's Gemfile:
|
|
7
|
+
|
|
8
|
+
```ruby
|
|
9
|
+
gem 'middleman-blog-selfbookmark'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
And then execute:
|
|
13
|
+
|
|
14
|
+
$ bundle
|
|
15
|
+
|
|
16
|
+
Or install it yourself as:
|
|
17
|
+
|
|
18
|
+
$ gem install middleman-blog-selfbookmark
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
TODO: Write usage instructions here
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
27
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
require 'middleman-core'
|
|
2
|
+
require 'middleman-blog-selfbookmark/commands'
|
|
3
|
+
require 'middleman/blog/selfbookmark'
|
|
4
|
+
|
|
5
|
+
Middleman::Extensions.register :blog_selfbookmark do
|
|
6
|
+
require "middleman-blog-selfbookmark/extension"
|
|
7
|
+
::Middleman::Blog::SelfbookmarkExtension
|
|
8
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'middleman-cli'
|
|
2
|
+
require 'middleman-blog/uri_templates'
|
|
3
|
+
|
|
4
|
+
module Middleman
|
|
5
|
+
module Cli
|
|
6
|
+
class Selfbookmark < ::Thor::Group
|
|
7
|
+
include Thor::Actions
|
|
8
|
+
include Middleman::Blog::UriTemplates
|
|
9
|
+
|
|
10
|
+
check_unknown_options!
|
|
11
|
+
|
|
12
|
+
namespace :tweet
|
|
13
|
+
|
|
14
|
+
def self.exit_on_failure?
|
|
15
|
+
true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def selfbookmark
|
|
19
|
+
env = options[:environment].to_s.to_sym
|
|
20
|
+
verbose = options[:verbose] ? 0 : 1
|
|
21
|
+
instrument = options[:instrument]
|
|
22
|
+
|
|
23
|
+
::Middleman::Blog::Selfbookmark.app = ::Middleman::Application.new do
|
|
24
|
+
config[:mode] = :build
|
|
25
|
+
config[:environment] = env
|
|
26
|
+
::Middleman::Logger.singleton(verbose, instrument)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
::Middleman::Blog::Selfbookmark.selfbookmark
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Base.register(Middleman::Cli::Selfbookmark, 'selfbookmark', 'selfbookmark', 'Create bookmark of latest article')
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'middleman-core'
|
|
2
|
+
require 'middleman/blog/selfbookmark'
|
|
3
|
+
require 'active_support'
|
|
4
|
+
require 'active_support/core_ext'
|
|
5
|
+
|
|
6
|
+
module Middleman
|
|
7
|
+
module Blog
|
|
8
|
+
class SelfbookmarkExtension < ::Middleman::Extension
|
|
9
|
+
option :consumer_key, nil, 'Hatena Bookmark consumer key'
|
|
10
|
+
option :consumer_secret, nil, 'Hatena Bookmark consumer secret'
|
|
11
|
+
option :request_token, nil, 'Hatena Bookmark request token'
|
|
12
|
+
option :request_token_secret, nil, 'Hatena Bookmark request token secret'
|
|
13
|
+
option :hostname, nil, 'Your site hostname'
|
|
14
|
+
option :comment, '', 'Bookmark comment'
|
|
15
|
+
option :new_article_threshold, 1.hour, 'Threshold if latest article'
|
|
16
|
+
|
|
17
|
+
attr_reader :options
|
|
18
|
+
|
|
19
|
+
def initialize(app, options_hash={}, &block)
|
|
20
|
+
super
|
|
21
|
+
|
|
22
|
+
@options = options
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require "middleman/blog/selfbookmark/version"
|
|
2
|
+
require 'hatena-bookmark'
|
|
3
|
+
|
|
4
|
+
module Middleman
|
|
5
|
+
module Blog
|
|
6
|
+
module Selfbookmark
|
|
7
|
+
class << self
|
|
8
|
+
attr_reader :app
|
|
9
|
+
|
|
10
|
+
def selfbookmark
|
|
11
|
+
@app ||= ::Middleman::Application.new
|
|
12
|
+
|
|
13
|
+
blog_extension = @app.extensions[:blog].values.first
|
|
14
|
+
latest_article = blog_extension.data.articles.select{ |a| a.published? }.first
|
|
15
|
+
return unless should_bookmark(latest_article)
|
|
16
|
+
|
|
17
|
+
client.create(url: "#{settings.hostname}#{latest_article.url}", comment: settings.comment)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def app=(app)
|
|
21
|
+
@app = app
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def settings
|
|
27
|
+
@app.extensions[:blog_selfbookmark].options
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def client
|
|
31
|
+
Hatena::Bookmark.new(
|
|
32
|
+
consumer_key: settings.consumer_key,
|
|
33
|
+
consumer_secret: settings.consumer_secret,
|
|
34
|
+
request_token: settings.request_token,
|
|
35
|
+
request_secret: settings.request_token_secret
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def should_bookmark(latest_article)
|
|
40
|
+
(latest_article.date > DateTime.now.ago(settings.new_article_threshold)) && latest_article.published?
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'middleman/blog/selfbookmark/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "middleman-blog-selfbookmark"
|
|
8
|
+
spec.version = Middleman::Blog::Selfbookmark::VERSION
|
|
9
|
+
spec.authors = ["Michiaki Mizoguchi"]
|
|
10
|
+
spec.email = ["michiaki.mizoguchi@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Create hatena bookmark on new post created.}
|
|
13
|
+
spec.homepage = "https://github.com/mizoguche/middleman-blog-selfbookmark"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
if spec.respond_to?(:metadata)
|
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
20
|
+
else
|
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
22
|
+
"public gem pushes."
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
|
27
|
+
end
|
|
28
|
+
spec.bindir = "exe"
|
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
30
|
+
spec.require_paths = ["lib"]
|
|
31
|
+
|
|
32
|
+
spec.add_runtime_dependency "hatena-bookmark"
|
|
33
|
+
|
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
36
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: middleman-blog-selfbookmark
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Michiaki Mizoguchi
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-01-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: hatena-bookmark
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '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.13'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.13'
|
|
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
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
description:
|
|
70
|
+
email:
|
|
71
|
+
- michiaki.mizoguchi@gmail.com
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- ".gitignore"
|
|
77
|
+
- ".rspec"
|
|
78
|
+
- Gemfile
|
|
79
|
+
- LICENSE.txt
|
|
80
|
+
- README.md
|
|
81
|
+
- Rakefile
|
|
82
|
+
- lib/middleman-blog-selfbookmark.rb
|
|
83
|
+
- lib/middleman-blog-selfbookmark/commands.rb
|
|
84
|
+
- lib/middleman-blog-selfbookmark/extension.rb
|
|
85
|
+
- lib/middleman/blog/selfbookmark.rb
|
|
86
|
+
- lib/middleman/blog/selfbookmark/version.rb
|
|
87
|
+
- middleman-blog-selfbookmark.gemspec
|
|
88
|
+
homepage: https://github.com/mizoguche/middleman-blog-selfbookmark
|
|
89
|
+
licenses:
|
|
90
|
+
- MIT
|
|
91
|
+
metadata:
|
|
92
|
+
allowed_push_host: https://rubygems.org
|
|
93
|
+
post_install_message:
|
|
94
|
+
rdoc_options: []
|
|
95
|
+
require_paths:
|
|
96
|
+
- lib
|
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: '0'
|
|
107
|
+
requirements: []
|
|
108
|
+
rubyforge_project:
|
|
109
|
+
rubygems_version: 2.5.2
|
|
110
|
+
signing_key:
|
|
111
|
+
specification_version: 4
|
|
112
|
+
summary: Create hatena bookmark on new post created.
|
|
113
|
+
test_files: []
|