blogger 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/History.txt +5 -0
  2. data/Rakefile +4 -50
  3. data/lib/blogger.rb +3 -3
  4. metadata +1 -1
@@ -1,3 +1,8 @@
1
+ === 0.5.1 / 2009-03-25
2
+
3
+ * Fixed a bug with Blogger::Account#post when userid is not provided
4
+ * Fixed typo in the 3-parameter constructor of Blogger::Account
5
+
1
6
  === 0.5.0 / 2009-03-24
2
7
 
3
8
  * First release
data/Rakefile CHANGED
@@ -11,63 +11,17 @@ Hoe.new('blogger', Blogger::VERSION) do |p|
11
11
  p.remote_rdoc_dir = ''
12
12
  desc 'Post your blog announcement to blogger.'
13
13
  task :post_blogger do
14
- require 'net/http'
15
- require 'net/https'
14
+ require 'blogger'
16
15
  p.with_config do |config, path|
17
16
  break unless config['blogs']
18
17
  subject, title, body, urls = p.announcement
19
- #body += "\n\n#{urls}"
20
18
 
21
19
  config['blogs'].each do |site|
22
20
  next unless site['url'] =~ /www\.blogger\.com/
23
- google_email = site['user']
24
- google_passwd = site['password']
25
- source = 'beforefilter.blogspot.com-rubypost'
21
+ acc = Blogger::Account.new(site['user'],site['password'])
22
+ post = Blogger::Post.new(:title => title, :content => body, :categories => p.blog_categories, :formatter => :rdiscount)
23
+ acc.post(site['blog_id'], post)
26
24
 
27
- http = Net::HTTP.new('www.google.com', 443)
28
- http.use_ssl = true
29
- login_url = '/accounts/ClientLogin'
30
-
31
- # Setup HTTPS request post data to obtain authentication token.
32
- data = 'Email=' + google_email +'&Passwd=' + google_passwd + '&source=' + source + '&service=blogger'
33
- headers = {
34
- 'Content-Type' => 'application/x-www-form-urlencoded'
35
- }
36
-
37
- # Submit HTTPS post request
38
- resp, data = http.post(login_url, data, headers)
39
-
40
- unless resp.code.eql? '200'
41
- puts "Error during authentication, blog at #{site['url']}, ##{site['blog_id']}: #{resp.message}\n"
42
- else
43
-
44
- # Parse for the authentication token.
45
- authToken = data.split("\n").map {|l| l.split("=")}.assoc("Auth")[1]
46
-
47
- headers = {
48
- 'Authorization' => 'GoogleLogin auth=' + authToken,
49
- 'Content-Type' => 'application/atom+xml'
50
- }
51
-
52
- data = <<-EOF
53
- <entry xmlns='http://www.w3.org/2005/Atom'>
54
- <title type='text'>#{title}</title>
55
- <content type='xhtml'>
56
- <div xmlns="http://www.w3.org/1999/xhtml">
57
- #{body}
58
- </div>
59
- </content>
60
- #{p.blog_categories.inject("") {|acc,cat| acc + "<category scheme=\"http://www.blogger.com/atom/ns#\" term=\"#{cat}\" />\n"}}
61
- </entry>
62
- EOF
63
-
64
- http = Net::HTTP.new('www.blogger.com')
65
- path = '/feeds/' + site['blog_id'] + '/posts/default'
66
-
67
- resp, data = http.post(path, data, headers)
68
- puts "Error while posting, blog at #{site['url']}, ##{site['blog_id']}: #{resp.message}" unless resp.code == 200
69
- # Expect resp.code == 200 and resp.message == 'OK' for a successful.
70
- end
71
25
  end
72
26
  end
73
27
  end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__)+'/google_auth.rb'
2
2
  require 'atom/feed'
3
3
  require File.dirname(__FILE__)+'/helpers.rb'
4
4
  module Blogger
5
- VERSION = '0.5.0'
5
+ VERSION = '0.5.1'
6
6
  class PostingError < StandardError # :nodoc:
7
7
  end
8
8
 
@@ -124,7 +124,7 @@ module Blogger
124
124
  def initialize(*args)
125
125
  @user_id, @username, @password = args[0], "", "" if args.size == 1 && args[0] =~ /^[0-9]+$/
126
126
  @username, @password = args[0], args[1] if args.size == 2
127
- @user_kid, @username, @password = args[0], args[1], args[2] if args.size == 3
127
+ @user_id, @username, @password = args[0], args[1], args[2] if args.size == 3
128
128
  authenticate unless @username.empty? || @password.empty?
129
129
  self
130
130
  end
@@ -178,7 +178,7 @@ module Blogger
178
178
 
179
179
  raise Blogger::PostingError.new("Error while posting to blog_id #{blog_id}: #{resp.message}") unless resp.code.eql? '201'
180
180
  # Expect resp.code == 200 and resp.message == 'OK' for a successful.
181
- Post.new(:atom => Atom::Entry.parse(resp.body), :blog => blog_for_id(blog_id))
181
+ Post.new(:atom => Atom::Entry.parse(resp.body), :blog => blog_for_id(blog_id)) if @user_id
182
182
  end
183
183
  end
184
184
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael J. Edgar