wp2hatena 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86732bb5e4fec9ae7d13f8d33e448cc30f47cd08
4
- data.tar.gz: 69559f845856391727e91ddc1566d770bcffa734
3
+ metadata.gz: 2d08ca24e7d9d8bd4f3335290ded1984a485b119
4
+ data.tar.gz: 55e174d51045ec03af56cb49f30c32bc736da82e
5
5
  SHA512:
6
- metadata.gz: 4e8abae7b393d30899b01bd4ca0de7c59ba75e519ba5d8507cd6132c776972597a988cf06feeebea2e432a76f14dade108fb7197a85119a5a8d0b8ef51c16899
7
- data.tar.gz: 3ffbcd83a271433c689a902704bc1324cba936294c5ae5bad409a3402b5c32f446a60bff5e22eef291f1917eaffa512f267df4b82c8700c0786a823415891919
6
+ metadata.gz: 749f102c9b6428528a506dfde274f61337d40ce6a14f37a9f66991368062dc26d647b32435d28e84a433c1c366c21f1271d46c11fd707eab2922d317b41fd36a
7
+ data.tar.gz: f79abb26d9183abc834406b71a06ad26bd67de5a9b8a5531d6d0c3046230708c763c4d29bbbd23438578ad4e9879c2010fea6c6af1151441a97638b4f9060e55
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler/setup'
4
3
  require 'wp2hatena'
5
4
 
6
5
  print 'CONSUMER_KEY:'
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'wp2hatena/hatena/oauth/app'
4
+ require 'io/console'
5
+
6
+ print 'CONSUMER_KEY:'
7
+ CONSUMER_KEY = gets.chomp
8
+ print 'CONSUMER_SECRET:'
9
+ CONSUMER_SECRET = gets.chomp
10
+
11
+ Wp2hatena::Hatena::OAuth::App.run!
@@ -0,0 +1,72 @@
1
+ require 'sinatra/base'
2
+ require 'oauth'
3
+ require 'erb'
4
+ require 'json'
5
+
6
+ module Wp2hatena
7
+ module Hatena
8
+ module OAuth
9
+
10
+ class App < Sinatra::Base
11
+ set :sessions, true
12
+ enable :sessions
13
+
14
+ before do
15
+ @consumer = ::OAuth::Consumer.new(
16
+ CONSUMER_KEY,
17
+ CONSUMER_SECRET,
18
+ :site => '',
19
+ :request_token_path => 'https://www.hatena.com/oauth/initiate',
20
+ :access_token_path => 'https://www.hatena.com/oauth/token',
21
+ :authorize_path => 'https://www.hatena.ne.jp/oauth/authorize'
22
+ )
23
+ end
24
+
25
+ get '/' do
26
+ erb :index
27
+ end
28
+
29
+ # リクエストトークン取得から認証用URLにリダイレクトするためのアクション
30
+ get '/oauth' do
31
+ # リクエストトークンの取得
32
+ request_token = @consumer.get_request_token(
33
+ {:oauth_callback => 'http://localhost:4567/oauth_callback'},
34
+ :scope => 'read_public,write_public,read_private,write_private'
35
+ )
36
+
37
+ # セッションへリクエストトークンを保存しておく
38
+ session[:request_token] = request_token.token
39
+ session[:request_token_secret] = request_token.secret
40
+
41
+ # 認証用URLにリダイレクトする
42
+ redirect request_token.authorize_url
43
+ end
44
+
45
+ # 認証からコールバックされ、アクセストークンを取得するためのアクション
46
+ get '/oauth_callback' do
47
+ request_token = ::OAuth::RequestToken.new(
48
+ @consumer,
49
+ session[:request_token],
50
+ session[:request_token_secret]
51
+ )
52
+
53
+ # リクエストトークンとverifierを用いてアクセストークンを取得
54
+ access_token = request_token.get_access_token(
55
+ {},
56
+ :oauth_verifier => params[:oauth_verifier]
57
+ )
58
+
59
+ session[:request_token] = nil
60
+ session[:request_token_secret] = nil
61
+
62
+ # アクセストークンをセッションに記録しておく
63
+ session[:access_token] = access_token.token
64
+ session[:access_token_secret] = access_token.secret
65
+
66
+ erb :oauth_callback, :locals => {:access_token => access_token}
67
+ end
68
+ end
69
+
70
+ end
71
+ end
72
+ end
@@ -0,0 +1 @@
1
+ <p><a href="/oauth">Hatena</a></p>
@@ -0,0 +1,12 @@
1
+ <p>success getting access_token.</p>
2
+
3
+ <p>your access token is below.</p>
4
+
5
+ <dl>
6
+ <dt>access_token</dt>
7
+ <dd><%= access_token.params[:oauth_token] %></dd>
8
+ <dt>access_token_secret</dt>
9
+ <dd><%= access_token.params[:oauth_token_secret] %></dd>
10
+ </dl>
11
+
12
+ <a href="/">back to top</a>
@@ -1,3 +1,3 @@
1
1
  module Wp2hatena
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/wp2hatena.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.description = %q{convert images of wordpress to hatena blog}
14
14
  spec.homepage = "https://github.com/utahta/wp2hatena.git"
15
15
  spec.license = "MIT"
16
-
16
+
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.bindir = "exe"
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wp2hatena
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - utahta
@@ -69,7 +69,9 @@ dependencies:
69
69
  description: convert images of wordpress to hatena blog
70
70
  email:
71
71
  - labs.ninxit@gmail.com
72
- executables: []
72
+ executables:
73
+ - wp2hatena
74
+ - wp2hatena_oauth
73
75
  extensions: []
74
76
  extra_rdoc_files: []
75
77
  files:
@@ -80,11 +82,14 @@ files:
80
82
  - Rakefile
81
83
  - bin/console
82
84
  - bin/setup
83
- - bin/wp2hatena
84
- - bin/wp2hatena_oauth
85
+ - exe/wp2hatena
86
+ - exe/wp2hatena_oauth
85
87
  - lib/wp2hatena.rb
86
88
  - lib/wp2hatena/hatena/converter.rb
87
89
  - lib/wp2hatena/hatena/fotolife.rb
90
+ - lib/wp2hatena/hatena/oauth/app.rb
91
+ - lib/wp2hatena/hatena/oauth/views/index.erb
92
+ - lib/wp2hatena/hatena/oauth/views/oauth_callback.erb
88
93
  - lib/wp2hatena/version.rb
89
94
  - lib/wp2hatena/wordpress/image.rb
90
95
  - wp2hatena.gemspec
data/bin/wp2hatena_oauth DELETED
@@ -1,90 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'sinatra'
5
- require 'oauth'
6
- require 'erb'
7
- require 'json'
8
- require 'io/console'
9
-
10
- print 'CONSUMER_KEY:'
11
- CONSUMER_KEY = gets.chomp
12
- print 'CONSUMER_SECRET:'
13
- CONSUMER_SECRET = gets.chomp
14
-
15
- set :sessions, true
16
- enable :sessions
17
-
18
- before do
19
- @consumer = OAuth::Consumer.new(
20
- CONSUMER_KEY,
21
- CONSUMER_SECRET,
22
- :site => '',
23
- :request_token_path => 'https://www.hatena.com/oauth/initiate',
24
- :access_token_path => 'https://www.hatena.com/oauth/token',
25
- :authorize_path => 'https://www.hatena.ne.jp/oauth/authorize'
26
- )
27
- end
28
-
29
- get '/' do
30
- erb :index
31
- end
32
-
33
- # リクエストトークン取得から認証用URLにリダイレクトするためのアクション
34
- get '/oauth' do
35
- # リクエストトークンの取得
36
- request_token = @consumer.get_request_token(
37
- {:oauth_callback => 'http://localhost:4567/oauth_callback'},
38
- :scope => 'read_public,write_public,read_private,write_private'
39
- )
40
-
41
- # セッションへリクエストトークンを保存しておく
42
- session[:request_token] = request_token.token
43
- session[:request_token_secret] = request_token.secret
44
-
45
- # 認証用URLにリダイレクトする
46
- redirect request_token.authorize_url
47
- end
48
-
49
- # 認証からコールバックされ、アクセストークンを取得するためのアクション
50
- get '/oauth_callback' do
51
- request_token = OAuth::RequestToken.new(
52
- @consumer,
53
- session[:request_token],
54
- session[:request_token_secret]
55
- )
56
-
57
- # リクエストトークンとverifierを用いてアクセストークンを取得
58
- access_token = request_token.get_access_token(
59
- {},
60
- :oauth_verifier => params[:oauth_verifier]
61
- )
62
-
63
- session[:request_token] = nil
64
- session[:request_token_secret] = nil
65
-
66
- # アクセストークンをセッションに記録しておく
67
- session[:access_token] = access_token.token
68
- session[:access_token_secret] = access_token.secret
69
-
70
- erb :oauth_callback, :locals => {:access_token => access_token}
71
- end
72
-
73
- __END__
74
-
75
- @@ index
76
- <p><a href="/oauth">Hatena</a></p>
77
-
78
- @@ oauth_callback
79
- <p>success getting access_token.</p>
80
-
81
- <p>your access token is below.</p>
82
-
83
- <dl>
84
- <dt>access_token</dt>
85
- <dd><%= access_token.params[:oauth_token] %></dd>
86
- <dt>access_token_secret</dt>
87
- <dd><%= access_token.params[:oauth_token_secret] %></dd>
88
- </dl>
89
-
90
- <a href="/">back to top</a>