Blux 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/Blux.gemspec +4 -4
- data/Manifest +2 -1
- data/README.markdown +12 -0
- data/Rakefile +1 -1
- data/bin/blux +71 -35
- data/lib/blog_manager.rb +45 -28
- data/lib/blux_option_parser.rb +13 -0
- data/lib/draft_manager.rb +23 -9
- data/lib/indexer.rb +68 -27
- data/lib/publishing/wp_options.rb +76 -0
- data/lib/publishing/wp_publish.rb +136 -0
- data/spec/blog_manager_spec.rb +46 -35
- data/spec/draft_manager_spec.rb +102 -15
- metadata +7 -5
- metadata.gz.sig +0 -0
- data/lib/wp_publish.rb +0 -149
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Louis Salin
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
1GuoIVBODMvF3w==
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date: 2010-
|
38
|
+
date: 2010-11-06 00:00:00 -05:00
|
39
39
|
default_executable:
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -169,12 +169,13 @@ extra_rdoc_files:
|
|
169
169
|
- README.markdown
|
170
170
|
- bin/blux
|
171
171
|
- lib/textile_to_html.rb
|
172
|
-
- lib/wp_publish.rb
|
173
172
|
- lib/blog_manager.rb
|
174
173
|
- lib/blux_config_reader.rb
|
175
174
|
- lib/blux_option_parser.rb
|
176
175
|
- lib/draft_manager.rb
|
177
176
|
- lib/indexer.rb
|
177
|
+
- lib/publishing/wp_publish.rb
|
178
|
+
- lib/publishing/wp_options.rb
|
178
179
|
files:
|
179
180
|
- COPYING
|
180
181
|
- Manifest
|
@@ -182,12 +183,13 @@ files:
|
|
182
183
|
- Rakefile
|
183
184
|
- bin/blux
|
184
185
|
- lib/textile_to_html.rb
|
185
|
-
- lib/wp_publish.rb
|
186
186
|
- lib/blog_manager.rb
|
187
187
|
- lib/blux_config_reader.rb
|
188
188
|
- lib/blux_option_parser.rb
|
189
189
|
- lib/draft_manager.rb
|
190
190
|
- lib/indexer.rb
|
191
|
+
- lib/publishing/wp_publish.rb
|
192
|
+
- lib/publishing/wp_options.rb
|
191
193
|
- spec/blog_manager_spec.rb
|
192
194
|
- spec/blux_config_reader_spec.rb
|
193
195
|
- spec/draft_manager_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/wp_publish.rb
DELETED
@@ -1,149 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
## Copyright (c) 2007 John Mettraux
|
3
|
-
## Released under the MIT license
|
4
|
-
## http://www.opensource.org/licenses/mit-license.php
|
5
|
-
##
|
6
|
-
## Modifications by Louis Salin, October 2010
|
7
|
-
## => reading blog information from the configuration file
|
8
|
-
|
9
|
-
require 'optparse'
|
10
|
-
require 'net/http'
|
11
|
-
require 'atom/entry' # sudo gem install atom-tools
|
12
|
-
require 'atom/collection'
|
13
|
-
require "#{File.dirname(__FILE__)}/blux_config_reader"
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
# parse options
|
18
|
-
|
19
|
-
tags = []
|
20
|
-
title = nil
|
21
|
-
type = 'html'
|
22
|
-
bluxrc = nil
|
23
|
-
command = :post
|
24
|
-
entry_id = nil
|
25
|
-
|
26
|
-
opts = OptionParser.new
|
27
|
-
opts.banner = "Usage: post.rb [options]"
|
28
|
-
opts.separator ""
|
29
|
-
opts.separator "options :"
|
30
|
-
|
31
|
-
opts.on(
|
32
|
-
"-c",
|
33
|
-
"--categories {list}",
|
34
|
-
"comma separated list of tags/categories") do |v|
|
35
|
-
|
36
|
-
tags = v.split ","
|
37
|
-
end
|
38
|
-
|
39
|
-
opts.on(
|
40
|
-
"-t",
|
41
|
-
"--title {title}",
|
42
|
-
"title for the post") do |v|
|
43
|
-
|
44
|
-
title = v
|
45
|
-
end
|
46
|
-
|
47
|
-
opts.on(
|
48
|
-
"-T",
|
49
|
-
"--type {html|xhtml|text}",
|
50
|
-
"type of the content. ('html' is the default).") do |v|
|
51
|
-
|
52
|
-
type = v
|
53
|
-
end
|
54
|
-
|
55
|
-
opts.on(
|
56
|
-
"--config {config_file}",
|
57
|
-
"blux config file path") do |f|
|
58
|
-
bluxrc = f
|
59
|
-
end
|
60
|
-
|
61
|
-
opts.on(
|
62
|
-
"--update {entry_id}",
|
63
|
-
"update an existing post") do |id|
|
64
|
-
command = :put
|
65
|
-
entry_id = id
|
66
|
-
end
|
67
|
-
|
68
|
-
opts.on(
|
69
|
-
"-h",
|
70
|
-
"--help",
|
71
|
-
"displays this help") do
|
72
|
-
|
73
|
-
puts
|
74
|
-
puts opts.to_s
|
75
|
-
puts
|
76
|
-
exit 0
|
77
|
-
end
|
78
|
-
|
79
|
-
opts.parse ARGV
|
80
|
-
|
81
|
-
raise "please specify a title for the post with the -t option" unless title
|
82
|
-
|
83
|
-
# a great thanks to the devs of all the libs used here
|
84
|
-
#
|
85
|
-
# some info about you and your blog
|
86
|
-
|
87
|
-
config = BluxConfigurationReader.new
|
88
|
-
config.load_config bluxrc
|
89
|
-
|
90
|
-
blog = config.blog
|
91
|
-
authorname = config.author_name
|
92
|
-
username = config.user_name
|
93
|
-
password = config.password
|
94
|
-
|
95
|
-
bloguri = "http://#{blog}.wordpress.com"
|
96
|
-
base = "https://#{blog}.wordpress.com/wp-app.php"
|
97
|
-
|
98
|
-
#
|
99
|
-
# gather content
|
100
|
-
|
101
|
-
content = ""
|
102
|
-
loop do
|
103
|
-
line = STDIN.gets
|
104
|
-
break unless line
|
105
|
-
content += line
|
106
|
-
end
|
107
|
-
|
108
|
-
# create entry
|
109
|
-
|
110
|
-
entry = Atom::Entry.new
|
111
|
-
entry.title = title
|
112
|
-
entry.updated!
|
113
|
-
|
114
|
-
author = Atom::Author.new
|
115
|
-
author.name = authorname
|
116
|
-
author.uri = bloguri
|
117
|
-
entry.authors << author
|
118
|
-
|
119
|
-
tags.each do |t|
|
120
|
-
c = Atom::Category.new
|
121
|
-
c["scheme"] = bloguri
|
122
|
-
c["term"] = t.strip
|
123
|
-
entry.categories << c
|
124
|
-
end
|
125
|
-
|
126
|
-
entry.content = content
|
127
|
-
entry.content["type"] = type if type
|
128
|
-
|
129
|
-
h = Atom::HTTP.new
|
130
|
-
h.user = username
|
131
|
-
h.pass = password
|
132
|
-
h.always_auth = :basic
|
133
|
-
|
134
|
-
c = Atom::Collection.new(base + "/posts", h)
|
135
|
-
if command == :post
|
136
|
-
res = c.post! entry
|
137
|
-
puts "--entry--"
|
138
|
-
puts entry
|
139
|
-
|
140
|
-
puts "--response--"
|
141
|
-
puts res
|
142
|
-
|
143
|
-
puts "--url--"
|
144
|
-
puts Atom::Entry.parse(res.read_body).edit_url
|
145
|
-
elsif command == :put
|
146
|
-
entry.edit_url = entry_id
|
147
|
-
res = c.put! entry
|
148
|
-
end
|
149
|
-
|