quickpress 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -24
- data/bin/qp +433 -83
- data/lib/quickpress.rb +222 -13
- data/lib/quickpress/cli.rb +11 -2
- data/lib/quickpress/options.rb +20 -5
- data/lib/quickpress/version.rb +1 -1
- data/lib/quickpress/wordpress.rb +144 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2139e020b8fc58f48b80aea389632cd9a4b6d3d8
|
4
|
+
data.tar.gz: b3873903acdfa799db6f20197190d67a55b94229
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f08d350ace33cf345c14c3dd7d8be16fcb984230183cf0d0dc94538df7ab0156f1c1186dc730805c636624bb5f326de65b0591b25ed1da3df2e5c1eca95b2e50
|
7
|
+
data.tar.gz: 57d30a935ed53a9f8b75297a1cc69f890038b044a11528a4214149faa6e8e00061247ae9dc9d6d6a59401a960c8498ce02c781d97207897a5de496a69c03a7fb
|
data/README.md
CHANGED
@@ -4,12 +4,13 @@
|
|
4
4
|
[![emacs banner](http://badges.alexdantas.net/emacs.png)](http://badges.alexdantas.net/)
|
5
5
|
[![free-software banner](http://badges.alexdantas.net/free-software.png)](http://badges.alexdantas.net/)
|
6
6
|
|
7
|
-
Manage your Wordpress site
|
7
|
+
Manage your Wordpress site from the command line.
|
8
8
|
|
9
9
|
## Features
|
10
10
|
|
11
|
-
Quickpress allows you to
|
12
|
-
|
11
|
+
Quickpress allows you to create, delete, edit and list both posts and pages on your Wordpress site. You can also retrieve settings of the site and get status on comments, categories and users.
|
12
|
+
|
13
|
+
It is:
|
13
14
|
|
14
15
|
* **Powerful**: With quickpress you can create, delete and list
|
15
16
|
your posts and pages. More actions are expected on next releases.
|
@@ -20,9 +21,11 @@ It is also:
|
|
20
21
|
* **Documented**: [The wiki][wiki]
|
21
22
|
has all the guides you'll ever need. Also, reference is only
|
22
23
|
a `qp help` away.
|
23
|
-
* **Unified**: Works on both Wordpress.com and self-hosted
|
24
|
-
websites.
|
25
|
-
* **Safe**: Quickpress doesn't store your username/password
|
24
|
+
* **Unified**: Works on both Wordpress.com and self-hosted
|
25
|
+
Wordpress.org websites.
|
26
|
+
* **Safe**: Quickpress doesn't store your username/password
|
27
|
+
anywhere. It has three authentication methods, letting you
|
28
|
+
decide how to deal with username/passwords.
|
26
29
|
* **Free**: It is licensed under the GPLv3. It means that quickpress
|
27
30
|
will always be free
|
28
31
|
([both as in "free beer" and as in "freedom"](http://en.wikipedia.org/wiki/Gratis_versus_libre#.22Free_beer.22_vs_.22free_speech.22_distinction)).
|
@@ -38,11 +41,12 @@ and there you go!
|
|
38
41
|
|
39
42
|
## Getting started
|
40
43
|
|
41
|
-
To use quickpress we call `qp` with some commands,
|
44
|
+
To use quickpress we call `qp` with some commands,
|
45
|
+
just like `git` or `bundle`.
|
42
46
|
|
43
|
-
To start
|
47
|
+
To start managing a site, do:
|
44
48
|
|
45
|
-
$ qp new-site
|
49
|
+
$ qp new-site your-site.com/path/to/blog
|
46
50
|
|
47
51
|
Now you can do a lot with it. For example, let's list all
|
48
52
|
existing posts there:
|
@@ -53,20 +57,27 @@ Want to post? Write it anywhere and point `qp` to it!
|
|
53
57
|
|
54
58
|
$ qp new-post my-post.md
|
55
59
|
|
56
|
-
If you're too lazy, calling `new-post` without
|
57
|
-
call your default text editor
|
58
|
-
|
60
|
+
If you're too lazy, calling `new-post` without filenames will
|
61
|
+
call your default text editor. When you're done, it is sent
|
62
|
+
automatically.
|
63
|
+
|
64
|
+
Oops, you made a mistake and want to edit a post.
|
65
|
+
First, list them and edit by id.
|
66
|
+
|
67
|
+
$ emacs file.md # edit your post
|
68
|
+
$ qp list-posts # shows all posts, with their ID
|
69
|
+
$ qp edit-post ID file.md # send changes to post with ID
|
59
70
|
|
60
|
-
|
61
|
-
First, list them and then delete by id:
|
71
|
+
Finally, you can delete a post by id too:
|
62
72
|
|
63
|
-
$ qp list-posts
|
73
|
+
$ qp list-posts
|
64
74
|
$ qp delete-post ID
|
65
75
|
|
66
76
|
All of the previous commands can be done with pages too.
|
77
|
+
Simply replace `-post` with `-page`.
|
67
78
|
|
68
79
|
Now say you want to post on another Worpress site.
|
69
|
-
By doing `qp new-site` it should become the default.
|
80
|
+
By doing `qp new-site` it should become the new default.
|
70
81
|
|
71
82
|
After doing this, you can switch between them by using:
|
72
83
|
|
@@ -77,20 +88,22 @@ If you want help with any command, just call:
|
|
77
88
|
|
78
89
|
$ qp help (command)
|
79
90
|
|
80
|
-
To see
|
91
|
+
To see all commands, go:
|
81
92
|
|
82
|
-
$ qp
|
93
|
+
$ qp
|
83
94
|
|
84
|
-
|
95
|
+
To see most commonly used commands and examples, do:
|
85
96
|
|
86
|
-
$ qp
|
97
|
+
$ qp help
|
87
98
|
|
88
99
|
For more help and nice guides, check out [the wiki][wiki].
|
89
100
|
|
90
101
|
## Supported template engines
|
91
102
|
|
92
|
-
Thanks to [Tilt][tilt], you can write on `quickpress` with
|
93
|
-
engines.
|
103
|
+
Thanks to [Tilt][tilt], you can write on `quickpress` with
|
104
|
+
several templating engines.
|
105
|
+
|
106
|
+
Just be sure to have at least one *required gem* of your favorite
|
94
107
|
*engine*.
|
95
108
|
|
96
109
|
| Engine | File extensions | Required gem |
|
@@ -127,8 +140,13 @@ lowercase:
|
|
127
140
|
|
128
141
|
## Development
|
129
142
|
|
130
|
-
Quickpress uses [Thor][thor] for it's CLI interface and
|
131
|
-
the Wordpress XMLRPC API.
|
143
|
+
Quickpress uses [Thor][thor] for it's CLI interface and
|
144
|
+
[rubypress] for the Wordpress XMLRPC API.
|
145
|
+
It was highly inspired by the [blogpost] tool - thanks
|
146
|
+
a lot, Stuart Rackam!
|
147
|
+
|
148
|
+
Quickpress follows the [Semantic Versioning standard][versioning],
|
149
|
+
meaning that it increments versions in a MAJOR.MINOR.PATCH way.
|
132
150
|
|
133
151
|
For now the source code is a mess.
|
134
152
|
Any comments are well-appreciated.
|
@@ -160,4 +178,7 @@ Please take the time to visit any of the links below.
|
|
160
178
|
[rubypress]:https://github.com/zachfeldman/rubypress
|
161
179
|
[wiki]:https://github.com/alexdantas/quickpress/wiki
|
162
180
|
[gem]:https://rubygems.org/gem/quickpress/
|
181
|
+
[blogpost]:http://srackham.wordpress.com/blogpost-readme/
|
182
|
+
[versioning]:http://semver.org/
|
163
183
|
|
184
|
+
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/72dc86b8e7c376b54dabd5d33b42c774 "githalytics.com")](http://githalytics.com/alexdantas/quickpress)
|
data/bin/qp
CHANGED
@@ -2,19 +2,43 @@
|
|
2
2
|
# ___ _ _ __ _ ___ ___ ____ __ __
|
3
3
|
# / / \ | | | | | / /` | |_/ | |_) | |_) | |_ ( (` ( (`
|
4
4
|
# \_\_\\ \_\_/ |_| \_\_, |_| \ |_| |_| \ |_|__ _)_) _)_)
|
5
|
+
#
|
6
|
+
# Command-line blog client for Wordpress.
|
5
7
|
|
6
8
|
require 'thor'
|
7
9
|
require 'quickpress'
|
8
10
|
|
9
|
-
# Command
|
11
|
+
# Command-line interface to quickpress' features.
|
12
|
+
#
|
13
|
+
# It uses `Thor` to implement commands on top of the
|
14
|
+
# `Quickpress` class. All the actual functionalities
|
15
|
+
# are there.
|
16
|
+
#
|
17
|
+
# Look out for `Thor`'s documentation to understand
|
18
|
+
# these domain-specific methods (like `desc`,
|
19
|
+
# `option` and such).
|
10
20
|
#
|
11
|
-
|
21
|
+
# @note Those `\x5` on the long descriptions are to force
|
22
|
+
# a line break - think of them as `<br />`s.
|
23
|
+
#
|
24
|
+
class QuickpressCLI < Thor
|
25
|
+
package_name "Quickpress"
|
12
26
|
|
13
27
|
# Global `--debug` flag
|
14
28
|
class_option(:debug,
|
15
29
|
:desc => "debugging mode",
|
16
30
|
:type => :boolean)
|
17
31
|
|
32
|
+
class_option(:user,
|
33
|
+
:desc => "Wordpress username",
|
34
|
+
:aliases => "-u",
|
35
|
+
:type => :string)
|
36
|
+
|
37
|
+
class_option(:pass,
|
38
|
+
:desc => "Wordpress password",
|
39
|
+
:aliases => "-p",
|
40
|
+
:type => :string)
|
41
|
+
|
18
42
|
# _ ____ _ ___ ___ __ _____
|
19
43
|
# | |\ | | |_ \ \ / | |_) / / \ ( (` | |
|
20
44
|
# |_| \| |_|__ \_\/\/ |_| \_\_/ _)_) |_|
|
@@ -23,9 +47,20 @@ class QP < Thor
|
|
23
47
|
'Creates a post on your Wordpress site')
|
24
48
|
|
25
49
|
option('markup',
|
26
|
-
:banner => "
|
50
|
+
:banner => "NAME",
|
27
51
|
:desc => "markup language",
|
28
|
-
:aliases => "-m"
|
52
|
+
:aliases => "-m",
|
53
|
+
:type => :string)
|
54
|
+
|
55
|
+
option('title',
|
56
|
+
:desc => "post title",
|
57
|
+
:aliases => "-t",
|
58
|
+
:type => :string)
|
59
|
+
|
60
|
+
option('category',
|
61
|
+
:desc => "categories",
|
62
|
+
:aliases => "-c",
|
63
|
+
:type => :string)
|
29
64
|
|
30
65
|
long_desc(<<-END).remove_starting!
|
31
66
|
If FILENAME is given, will post it to your Wordpress site.
|
@@ -34,14 +69,22 @@ class QP < Thor
|
|
34
69
|
\x5wait for you to write a post. After you save it, will post
|
35
70
|
\x5that.
|
36
71
|
|
37
|
-
|
38
|
-
\
|
39
|
-
|
72
|
+
The --categories option allows you to specify several of
|
73
|
+
\x5them, just make sure they're comma-separated. For example:
|
74
|
+
|
75
|
+
$ qp new-post file.md -t "My Title" -c "cat1, cat2, cat3"
|
76
|
+
|
77
|
+
Notes:
|
78
|
+
|
79
|
+
* Set default text editor with the `EDITOR` environment variable.
|
80
|
+
|
81
|
+
* For a list of languages to use with --markup, do `qp markup-list`.
|
82
|
+
|
83
|
+
* Unexisting categories will be created automatically.
|
40
84
|
END
|
41
85
|
|
42
86
|
def new_post(filename=nil)
|
43
|
-
$options
|
44
|
-
$options[:markup] = options[:markup]
|
87
|
+
$options.merge! options
|
45
88
|
|
46
89
|
Quickpress::new(:post, filename)
|
47
90
|
end
|
@@ -54,14 +97,18 @@ class QP < Thor
|
|
54
97
|
'Shows last posts from Wordpress site')
|
55
98
|
|
56
99
|
long_desc <<-END.remove_starting!
|
57
|
-
If COUNT is given, will show last COUNT posts
|
58
|
-
\x5most recent first.
|
100
|
+
If COUNT is given, will show last COUNT posts.
|
59
101
|
|
60
102
|
If no COUNT is given, will show all posts.
|
103
|
+
|
104
|
+
Notes:
|
105
|
+
|
106
|
+
* Posts are shown in order of old first, recent last.
|
61
107
|
END
|
62
108
|
|
63
109
|
def list_posts(ammount=0)
|
64
|
-
$options
|
110
|
+
$options.merge! options
|
111
|
+
|
65
112
|
Quickpress::list(:post, ammount.to_i)
|
66
113
|
end
|
67
114
|
|
@@ -80,25 +127,78 @@ class QP < Thor
|
|
80
127
|
long_desc(<<-END).remove_starting!
|
81
128
|
Deletes the post with numerical id equal to ID.
|
82
129
|
|
83
|
-
To see IDs, use `qp list-posts`.
|
84
|
-
|
85
130
|
You can specify multiple IDs, just make sure to
|
86
|
-
\x5keep them apart with commas.
|
131
|
+
\x5keep them apart with commas. For example:
|
87
132
|
|
88
|
-
|
133
|
+
$ qp delete-post "4,8,15,16,23,42"
|
89
134
|
|
90
|
-
|
135
|
+
Notes:
|
91
136
|
|
92
|
-
|
137
|
+
* To see IDs, use `qp list-posts`.
|
93
138
|
END
|
94
139
|
|
95
140
|
def delete_post(ids)
|
96
|
-
$options
|
97
|
-
$options[:force] = options[:force]
|
141
|
+
$options.merge! options
|
98
142
|
|
99
143
|
Quickpress::delete(:post, ids)
|
100
144
|
end
|
101
145
|
|
146
|
+
# ____ ___ _ _____ ___ ___ __ _____
|
147
|
+
# | |_ | | \ | | | | | |_) / / \ ( (` | |
|
148
|
+
# |_|__ |_|_/ |_| |_| |_| \_\_/ _)_) |_|
|
149
|
+
#
|
150
|
+
desc('edit-post ID [FILENAME]',
|
151
|
+
'Edits post already on Wordpress site')
|
152
|
+
|
153
|
+
option('markup',
|
154
|
+
:banner => "NAME",
|
155
|
+
:desc => "markup language",
|
156
|
+
:aliases => "-m",
|
157
|
+
:type => :string)
|
158
|
+
|
159
|
+
option('title',
|
160
|
+
:desc => "post title",
|
161
|
+
:aliases => "-t",
|
162
|
+
:type => :string)
|
163
|
+
|
164
|
+
option('category',
|
165
|
+
:desc => "categories",
|
166
|
+
:aliases => "-c",
|
167
|
+
:type => :string)
|
168
|
+
|
169
|
+
option('force',
|
170
|
+
:type => :boolean,
|
171
|
+
:desc => "upload even if no changes were made",
|
172
|
+
:aliases => "-f")
|
173
|
+
|
174
|
+
long_desc(<<-END).remove_starting!
|
175
|
+
If FILENAME is given, will make the post with ID to
|
176
|
+
\x5have the contents of that file.
|
177
|
+
|
178
|
+
If no FILENAME is set, will launch your default text editor.
|
179
|
+
\x5with current contents of the post. After saving it,
|
180
|
+
\x5will post that.
|
181
|
+
|
182
|
+
Quickpress compares the old content with the new.
|
183
|
+
\x5If no changes were made, skips uploading.
|
184
|
+
\x5If you want to do it anyway, use the --force (pun intended).
|
185
|
+
|
186
|
+
You can specify title and categories just like in `new-post`.
|
187
|
+
\x5Leave them blank to keep current values. For example:
|
188
|
+
|
189
|
+
$ qp edit-post 666 file.md -t "" -c ""
|
190
|
+
|
191
|
+
That would mantain the current title and categories.
|
192
|
+
|
193
|
+
See `qp new-post`, same notes apply here.
|
194
|
+
END
|
195
|
+
|
196
|
+
def edit_post(id, filename=nil)
|
197
|
+
$options.merge! options
|
198
|
+
|
199
|
+
Quickpress::edit(:post, id.to_i, filename)
|
200
|
+
end
|
201
|
+
|
102
202
|
# _ ____ _ ___ __ __ ____
|
103
203
|
# | |\ | | |_ \ \ / | |_) / /\ / /`_ | |_
|
104
204
|
# |_| \| |_|__ \_\/\/ |_| /_/--\ \_\_/ |_|__
|
@@ -107,9 +207,15 @@ class QP < Thor
|
|
107
207
|
'Creates a page on your Wordpress site')
|
108
208
|
|
109
209
|
option('markup',
|
110
|
-
:banner => "
|
210
|
+
:banner => "NAME",
|
111
211
|
:desc => "markup language",
|
112
|
-
:aliases => "-m"
|
212
|
+
:aliases => "-m",
|
213
|
+
:type => :string)
|
214
|
+
|
215
|
+
option('title',
|
216
|
+
:desc => "page title",
|
217
|
+
:aliases => "-t",
|
218
|
+
:type => :string)
|
113
219
|
|
114
220
|
long_desc <<-END.remove_starting!
|
115
221
|
If FILENAME is given, will send it as a page to your
|
@@ -119,14 +225,15 @@ class QP < Thor
|
|
119
225
|
\x5wait for you to write a page. After you save it, will send
|
120
226
|
\x5that.
|
121
227
|
|
122
|
-
|
123
|
-
|
124
|
-
|
228
|
+
Notes:
|
229
|
+
|
230
|
+
* Set default text editor with the `EDITOR` environment variable.
|
231
|
+
|
232
|
+
* For a list of languages to use with --markup, do `qp markup-list`.
|
125
233
|
END
|
126
234
|
|
127
235
|
def new_page(filename=nil)
|
128
|
-
$options
|
129
|
-
$options[:markup] = options[:markup]
|
236
|
+
$options.merge! options
|
130
237
|
|
131
238
|
Quickpress::new(:page, filename)
|
132
239
|
end
|
@@ -139,14 +246,18 @@ class QP < Thor
|
|
139
246
|
'Shows last pages from Wordpress site')
|
140
247
|
|
141
248
|
long_desc <<-END.remove_starting!
|
142
|
-
If COUNT is given, will show last COUNT pages
|
143
|
-
\x5most recent first.
|
249
|
+
If COUNT is given, will show last COUNT pages.
|
144
250
|
|
145
251
|
If no COUNT is given, will show all pages.
|
252
|
+
|
253
|
+
Notes:
|
254
|
+
|
255
|
+
* Pages are shown in order of old first, recent last.
|
146
256
|
END
|
147
257
|
|
148
258
|
def list_pages(ammount=0)
|
149
|
-
$options
|
259
|
+
$options.merge! options
|
260
|
+
|
150
261
|
Quickpress::list(:page, ammount.to_i)
|
151
262
|
end
|
152
263
|
|
@@ -165,24 +276,73 @@ class QP < Thor
|
|
165
276
|
long_desc(<<-END).remove_starting!
|
166
277
|
Deletes the page with numerical id equal to ID.
|
167
278
|
|
168
|
-
To see IDs, use `qp list-pages`.
|
169
|
-
|
170
279
|
You can specify multiple IDs, just make sure to
|
171
|
-
\x5keep them apart with commas.
|
172
|
-
|
280
|
+
\x5keep them apart with commas. For example:
|
281
|
+
|
282
|
+
$ qp delete-page "42,666,1337"
|
173
283
|
|
174
|
-
|
284
|
+
Notes:
|
175
285
|
|
176
|
-
|
286
|
+
* To see IDs, use `qp list-pages`.
|
177
287
|
END
|
178
288
|
|
179
289
|
def delete_page(ids)
|
180
|
-
$options
|
181
|
-
$options[:force] = options[:force]
|
290
|
+
$options.merge! options
|
182
291
|
|
183
292
|
Quickpress::delete(:page, ids)
|
184
293
|
end
|
185
294
|
|
295
|
+
# ____ ___ _ _____ ___ __ __ ____
|
296
|
+
# | |_ | | \ | | | | | |_) / /\ / /`_ | |_
|
297
|
+
# |_|__ |_|_/ |_| |_| |_| /_/--\ \_\_/ |_|__
|
298
|
+
#
|
299
|
+
desc('edit-page ID [FILENAME]',
|
300
|
+
'Edits page already on Wordpress site')
|
301
|
+
|
302
|
+
option('markup',
|
303
|
+
:banner => "NAME",
|
304
|
+
:desc => "markup language",
|
305
|
+
:aliases => "-m",
|
306
|
+
:type => :string)
|
307
|
+
|
308
|
+
option('title',
|
309
|
+
:desc => "page title",
|
310
|
+
:aliases => "-t",
|
311
|
+
:type => :string)
|
312
|
+
|
313
|
+
option('force',
|
314
|
+
:type => :boolean,
|
315
|
+
:desc => "upload even if no changes were made",
|
316
|
+
:aliases => "-f")
|
317
|
+
|
318
|
+
long_desc(<<-END).remove_starting!
|
319
|
+
If FILENAME is given, will make the page with ID to
|
320
|
+
\x5have the contents of that file.
|
321
|
+
|
322
|
+
If no FILENAME is set, will launch your default text editor.
|
323
|
+
\x5with current contents of the page. After saving it,
|
324
|
+
\x5will send that.
|
325
|
+
|
326
|
+
Quickpress compares the old content with the new.
|
327
|
+
\x5If no changes were made, skips uploading.
|
328
|
+
\x5If you want to do it anyway, use the --force (pun intended).
|
329
|
+
|
330
|
+
You can specify the title just like in `new-page`.
|
331
|
+
\x5Leave it blank to keep current value. For example:
|
332
|
+
|
333
|
+
$ qp edit-page 666 file.md -t ""
|
334
|
+
|
335
|
+
That would mantain the current title.
|
336
|
+
|
337
|
+
See `new-page`, same notes there apply here.
|
338
|
+
END
|
339
|
+
|
340
|
+
def edit_page(id, filename=nil)
|
341
|
+
$options.merge! options
|
342
|
+
|
343
|
+
Quickpress::edit(:page, id.to_i, filename)
|
344
|
+
end
|
345
|
+
|
186
346
|
# _ ____ _ __ _ _____ ____
|
187
347
|
# | |\ | | |_ \ \ / ( (` | | | | | |_
|
188
348
|
# |_| \| |_|__ \_\/\/ _)_) |_| |_| |_|__
|
@@ -193,16 +353,21 @@ class QP < Thor
|
|
193
353
|
long_desc <<-END.remove_starting!
|
194
354
|
If ADDRESS is provided, add it to quickpress.
|
195
355
|
|
196
|
-
If not,
|
197
|
-
\
|
356
|
+
If not, asks you for it. If everything's correct,
|
357
|
+
\x5will add that site to quickpress.
|
198
358
|
|
199
|
-
By adding we mean you'll be able to do all commands on it.
|
359
|
+
By "adding" we mean you'll be able to do all commands on it.
|
200
360
|
|
201
|
-
|
361
|
+
Notes:
|
362
|
+
|
363
|
+
* To see all sites added to quickpress, see `qp list-sites`.
|
364
|
+
|
365
|
+
* To see all possible commands, simply use `qp`.
|
202
366
|
END
|
203
367
|
|
204
368
|
def new_site(address=nil)
|
205
|
-
$options
|
369
|
+
$options.merge! options
|
370
|
+
|
206
371
|
Quickpress::new_site address
|
207
372
|
end
|
208
373
|
|
@@ -215,11 +380,14 @@ class QP < Thor
|
|
215
380
|
|
216
381
|
long_desc <<-END.remove_starting!
|
217
382
|
Will list all sites you've added with `qp new-site`.
|
218
|
-
|
383
|
+
|
384
|
+
They'll each have an id next to them. It is used by both
|
385
|
+
\x5`use-site` and `forget-site`.
|
219
386
|
END
|
220
387
|
|
221
388
|
def list_sites
|
222
|
-
$options
|
389
|
+
$options.merge! options
|
390
|
+
|
223
391
|
Quickpress::list_sites
|
224
392
|
end
|
225
393
|
|
@@ -239,18 +407,20 @@ class QP < Thor
|
|
239
407
|
Makes quickpress stop managing the site with numerical
|
240
408
|
\x5id equal to ID.
|
241
409
|
|
242
|
-
To see IDs, use `qp list-sites`.
|
243
|
-
|
244
410
|
You can specify multiple IDs, just make sure to
|
245
|
-
\x5keep them apart with commas.
|
246
|
-
|
411
|
+
\x5keep them apart with commas. For example:
|
412
|
+
|
413
|
+
$ qp forget-site "11,24,69"
|
414
|
+
|
415
|
+
Notes:
|
416
|
+
|
417
|
+
* To see IDs, use `qp list-sites`.
|
247
418
|
|
248
|
-
|
419
|
+
* It doesn't do anything to the blog, don't worry
|
249
420
|
END
|
250
421
|
|
251
|
-
def forget_site
|
252
|
-
$options
|
253
|
-
$options[:force] = options[:force]
|
422
|
+
def forget_site ids
|
423
|
+
$options.merge! options
|
254
424
|
|
255
425
|
Quickpress::forget_site(ids)
|
256
426
|
end
|
@@ -263,14 +433,16 @@ class QP < Thor
|
|
263
433
|
'Sets site with ID as default')
|
264
434
|
|
265
435
|
long_desc(<<-END).remove_starting!
|
266
|
-
From now on
|
267
|
-
|
436
|
+
From now on, all commands will affect the site with numerical ID.
|
437
|
+
|
438
|
+
Notes:
|
268
439
|
|
269
|
-
To see IDs, use `qp list-sites`.
|
440
|
+
* To see IDs, use `qp list-sites`.
|
270
441
|
END
|
271
442
|
|
272
443
|
def use_site id
|
273
|
-
$options
|
444
|
+
$options.merge! options
|
445
|
+
|
274
446
|
Quickpress::use_site(id.to_i)
|
275
447
|
end
|
276
448
|
|
@@ -282,56 +454,231 @@ class QP < Thor
|
|
282
454
|
'Show all supported templating languages')
|
283
455
|
|
284
456
|
long_desc(<<-END).remove_starting!
|
285
|
-
Lists all templating languages supported by quickpress
|
457
|
+
Lists all templating languages supported by quickpress,
|
458
|
+
\x5together with their file extensions.
|
286
459
|
|
287
|
-
You can use them with the
|
460
|
+
You can use them with the --markup option when creating
|
288
461
|
\x5new posts or pages.
|
289
462
|
|
290
|
-
|
463
|
+
$ qp new-post --markup asciidoc
|
291
464
|
|
292
|
-
If you create a post/page with a file, they're implied
|
293
|
-
\x5based on it's filename extension.
|
294
465
|
|
295
|
-
|
466
|
+
Notes:
|
467
|
+
|
468
|
+
* When you create a post/page using a file, the markup is implied by the filename extension.
|
296
469
|
END
|
297
470
|
|
298
471
|
def list_markup
|
472
|
+
$options.merge! options
|
473
|
+
|
299
474
|
Quickpress::list_markup
|
300
475
|
end
|
301
|
-
end
|
302
476
|
|
303
|
-
#
|
304
|
-
# | |
|
305
|
-
# |_|_)
|
306
|
-
#
|
307
|
-
|
308
|
-
|
477
|
+
# _ _ __ _____ __ __ _____ ____ __
|
478
|
+
# | | | | ( (` | | / /` / /\ | | | |_ / /`_ __
|
479
|
+
# |_|__ |_| _)_) |_| \_\_, /_/--\ |_| |_|__ \_\_/ (_()
|
480
|
+
#
|
481
|
+
desc('list-categories',
|
482
|
+
'Shows all posts\' categories on the Wordpress site')
|
483
|
+
|
484
|
+
long_desc <<-END.remove_starting!
|
485
|
+
Simply lists all existing categories withing the site.
|
486
|
+
END
|
487
|
+
|
488
|
+
def list_categories
|
489
|
+
$options.merge! options
|
490
|
+
|
491
|
+
Quickpress::list_categories
|
492
|
+
end
|
493
|
+
|
494
|
+
# _ _ __ _____ ___ ___ _____ _ ___ _ __
|
495
|
+
# | | | | ( (` | | / / \ | |_) | | | | / / \ | |\ | ( (`
|
496
|
+
# |_|__ |_| _)_) |_| \_\_/ |_| |_| |_| \_\_/ |_| \| _)_)
|
497
|
+
#
|
498
|
+
desc('list-options',
|
499
|
+
'Dumps all Wordpress options of the site')
|
500
|
+
|
501
|
+
long_desc <<-END.remove_starting!
|
502
|
+
Lists settings of the Wordpress site, along with their current
|
503
|
+
\x5values.
|
504
|
+
|
505
|
+
There's a lot of them, all explained here:
|
506
|
+
\x5http://codex.wordpress.org/Option_Reference
|
507
|
+
END
|
508
|
+
|
509
|
+
def list_options
|
510
|
+
$options.merge! options
|
511
|
+
|
512
|
+
Quickpress::list_options
|
513
|
+
end
|
514
|
+
|
515
|
+
# _ _ __ _____ _ __ ____ ___ __
|
516
|
+
# | | | | ( (` | | | | | ( (` | |_ | |_) ( (`
|
517
|
+
# |_|__ |_| _)_) |_| \_\_/ _)_) |_|__ |_| \ _)_)
|
518
|
+
#
|
519
|
+
desc('list-users',
|
520
|
+
'Shows all users on the site')
|
521
|
+
|
522
|
+
long_desc <<-END.remove_starting!
|
523
|
+
Lists all users currently registered on the site, along with
|
524
|
+
\x5their personal info :)
|
525
|
+
END
|
526
|
+
|
527
|
+
def list_users
|
528
|
+
$options.merge! options
|
529
|
+
|
530
|
+
Quickpress::list_users
|
531
|
+
end
|
532
|
+
|
533
|
+
# __ _____ __ _____ _ __ __ ___ _
|
534
|
+
# ( (` | | / /\ | | | | | ( (` / /` / / \ | |\/| __
|
535
|
+
# _)_) |_| /_/--\ |_| \_\_/ _)_) \_\_, \_\_/ |_| | (_()
|
536
|
+
#
|
537
|
+
desc('status-comments',
|
538
|
+
'Shows comment count according to their status')
|
539
|
+
|
540
|
+
long_desc <<-END.remove_starting!
|
541
|
+
Shows how many comments were:
|
542
|
+
|
543
|
+
- Approved
|
544
|
+
\x5- Awaiting Moderation
|
545
|
+
\x5- Marked as Spam
|
546
|
+
\x5- Created on Total
|
547
|
+
END
|
548
|
+
|
549
|
+
def status_comments
|
550
|
+
$options.merge! options
|
551
|
+
|
552
|
+
Quickpress::status_comments
|
553
|
+
end
|
554
|
+
|
555
|
+
# __ _____ __ _____ _ __ __ __ _____
|
556
|
+
# ( (` | | / /\ | | | | | ( (` / /` / /\ | | __
|
557
|
+
# _)_) |_| /_/--\ |_| \_\_/ _)_) \_\_, /_/--\ |_| (_()
|
558
|
+
#
|
559
|
+
desc('status-categories',
|
560
|
+
'Shows post count according to each category')
|
561
|
+
|
562
|
+
option('non-empty',
|
563
|
+
:desc => "don't show categories without posts",
|
564
|
+
:aliases => "-n",
|
565
|
+
:type => :boolean)
|
566
|
+
|
567
|
+
long_desc <<-END.remove_starting!
|
568
|
+
Shows every existing category along with how many
|
569
|
+
\x5posts were made on them.
|
570
|
+
END
|
571
|
+
|
572
|
+
def status_categories
|
573
|
+
$options.merge! options
|
574
|
+
|
575
|
+
Quickpress::status_categories
|
576
|
+
end
|
577
|
+
|
578
|
+
# ___ ___
|
579
|
+
# / / \ | |_)
|
580
|
+
# \_\_\\ |_|
|
581
|
+
#
|
582
|
+
# Overriding default message when user specify no arguments.
|
583
|
+
no_commands {
|
584
|
+
def self.qp
|
309
585
|
puts <<-END.remove_starting!
|
310
586
|
quickpress v#{Quickpress::VERSION}
|
311
|
-
|
587
|
+
Usage:
|
588
|
+
qp COMMAND [OPTIONS]
|
589
|
+
|
590
|
+
Quickpress works with commands, just like `git(1)` or `bundle(1)`.
|
591
|
+
Here's a list with all of them:
|
592
|
+
|
593
|
+
END
|
594
|
+
|
595
|
+
# Will get all commands and pretty-print them into
|
596
|
+
# columns.
|
597
|
+
all = QuickpressCLI
|
598
|
+
.all_tasks # internal Thor method
|
599
|
+
.to_a.sort
|
600
|
+
.map { |c| c[0] } # only need their names
|
312
601
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
$ qp list-markup
|
602
|
+
all = all
|
603
|
+
.map { |c| c.gsub(/_/, '-') } # replacing '_' with '-'
|
604
|
+
.each_slice(4) # splitting into columns
|
605
|
+
.to_a
|
318
606
|
|
319
|
-
|
320
|
-
|
607
|
+
Thor::Shell::Basic.new.print_table all
|
608
|
+
|
609
|
+
puts <<-END.remove_starting!
|
610
|
+
|
611
|
+
Use `qp help` to show most used commands and their basic description.
|
612
|
+
Use `qp help <command>` to get more info on a specific command.
|
321
613
|
|
322
614
|
Config directory: `~/.config/quickpress/`
|
323
615
|
|
324
|
-
|
325
|
-
|
616
|
+
Homepage: http://quickpress.alexdantas.net
|
617
|
+
Contact: Alexandre Dantas <eu@alexdantas.net>
|
326
618
|
|
327
|
-
This software is licensed under the
|
328
|
-
|
619
|
+
This software is licensed under the GNU General Public License
|
620
|
+
version 3 or later.
|
621
|
+
END
|
622
|
+
end
|
623
|
+
# _ ____ _ ___
|
624
|
+
# | |_| | |_ | | | |_)
|
625
|
+
# |_| | |_|__ |_|__ |_|
|
626
|
+
#
|
627
|
+
# Overriding default help message - shell and subcommands
|
628
|
+
# are Thor's internals.
|
629
|
+
def self.show_help
|
630
|
+
|
631
|
+
puts <<-END
|
632
|
+
quickpress v#{Quickpress::VERSION}
|
633
|
+
The most commonly used commands are:
|
634
|
+
|
635
|
+
qp new-site # Starts managing a new Wordpress site
|
636
|
+
qp use-site # Sets site to manage from now on
|
637
|
+
qp new-post # Creates a post on your Wordpress site
|
638
|
+
qp list-posts # Shows last posts from Wordpress site
|
639
|
+
qp delete-post # Deletes post by numerical ID
|
640
|
+
qp edit-post # Edits post already on Wordpress site
|
641
|
+
qp list-markup # Show formats on which you can write posts
|
642
|
+
qp status-comments # Display comment count according to status
|
643
|
+
|
644
|
+
Here's some examples:
|
645
|
+
|
646
|
+
# Uploads post within `file.md` (Markdown) with
|
647
|
+
# title and categories
|
648
|
+
qp new-post file.md -t "Title" -c "Cat1, Cat2"
|
649
|
+
|
650
|
+
# Uploads page within `file.adoc` (Asciidoc) with
|
651
|
+
# username and password
|
652
|
+
qp new-page file.adoc -u username -p password
|
653
|
+
|
654
|
+
# Calls your default text editor with the contents of
|
655
|
+
# the post of id 12. After you save, uploads the changes.
|
656
|
+
qp edit-post 12
|
657
|
+
|
658
|
+
Use `qp` to show all commands and program info.
|
659
|
+
Use `qp help <command>` for info on a specific command.
|
329
660
|
END
|
661
|
+
end}
|
662
|
+
|
663
|
+
end
|
664
|
+
|
665
|
+
# ___ ____ __ _ _
|
666
|
+
# | |_) | |_ / /`_ | | | |\ |
|
667
|
+
# |_|_) |_|__ \_\_/ |_| |_| \|
|
668
|
+
#
|
669
|
+
begin
|
670
|
+
if ARGV.empty?
|
671
|
+
QuickpressCLI.qp
|
672
|
+
exit
|
673
|
+
|
674
|
+
elsif (ARGV.size == 1) and (ARGV.last == "help")
|
675
|
+
QuickpressCLI.show_help
|
330
676
|
exit
|
331
677
|
end
|
332
678
|
|
333
679
|
Quickpress::config_init
|
334
|
-
|
680
|
+
|
681
|
+
QuickpressCLI.start ARGV
|
335
682
|
|
336
683
|
# Real mess of error-handling.
|
337
684
|
# I wonder if there's a better way to do it.
|
@@ -358,6 +705,7 @@ rescue XMLRPC::FaultException => e
|
|
358
705
|
else
|
359
706
|
$stderr.puts
|
360
707
|
$stderr.puts e.message
|
708
|
+
$stderr.puts e.backtrace if $options[:debug]
|
361
709
|
end
|
362
710
|
exit 666
|
363
711
|
|
@@ -368,6 +716,8 @@ rescue ArgumentError => arg
|
|
368
716
|
Please use `http` or `https`.
|
369
717
|
END
|
370
718
|
exit 666
|
719
|
+
else
|
720
|
+
$stderr.puts arg.backtrace if $options[:debug]
|
371
721
|
end
|
372
722
|
|
373
723
|
rescue Interrupt => i
|