pagecord-cli 0.2.0 → 0.2.2
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 +4 -4
- data/README.md +23 -18
- data/lib/pagecord_cli/cli.rb +10 -16
- data/lib/pagecord_cli/client.rb +9 -1
- data/lib/pagecord_cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 99eebd4d84788c1c5176bca0d7b1f036bb54ec2acb9e5f6a9f9fef7b63fc5d1d
|
|
4
|
+
data.tar.gz: 78d6e0b1623c066f1b9f992cf87e7e80c997ef7abfa2d2f4e6893ba6e34c0f8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 27842bcc27c07553c69ee4664aad327ab1d1f6155b3eaccc64d66fbcc699d73d543ae09bf2b406f568e6fca1eab83e0976d8f0ed08f62bd30ec63f57e5836796
|
|
7
|
+
data.tar.gz: 245f7e50410b5b93daca45d14ead9268f447cd9bada1bf580db1c73d3c5ec5d39207f7dacbf09fb21c98cc2debfba5d0b97f39b8e3b931b2d183dee9ead935cd
|
data/README.md
CHANGED
|
@@ -22,7 +22,7 @@ The name should be your Pagecord subdomain. The API key is stored in
|
|
|
22
22
|
For local testing there is an undocumented `--base-url` option:
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
pagecord login myblog --base-url http://localhost:3000
|
|
25
|
+
pagecord login myblog --base-url http://api.localhost:3000
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## Publishing
|
|
@@ -42,13 +42,6 @@ pagecord draft notes/idea.md
|
|
|
42
42
|
The first publish creates a post and writes Pagecord metadata back into the
|
|
43
43
|
file. Later publishes update the same post.
|
|
44
44
|
|
|
45
|
-
If you have one blog configured, `publish`, `draft`, and `logout` can omit the
|
|
46
|
-
subdomain. If you have more than one, pass the subdomain as the final argument:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
pagecord publish hello.md myblog
|
|
50
|
-
```
|
|
51
|
-
|
|
52
45
|
See configured blogs:
|
|
53
46
|
|
|
54
47
|
```bash
|
|
@@ -63,16 +56,26 @@ pagecord logout myblog
|
|
|
63
56
|
|
|
64
57
|
## Choosing a blog
|
|
65
58
|
|
|
66
|
-
With
|
|
59
|
+
With one blog configured, every command uses it. With several, set a default
|
|
60
|
+
once:
|
|
67
61
|
|
|
68
62
|
```bash
|
|
69
63
|
pagecord blog use myblog
|
|
70
64
|
```
|
|
71
65
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
or name the blog on the command line:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pagecord appearance show --blog myblog
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`--blog` wins over the `PAGECORD_BLOG` environment variable, which wins over
|
|
73
|
+
the default. `publish`, `draft` and `logout` also take the subdomain as a
|
|
74
|
+
trailing argument, which wins over all three:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pagecord publish hello.md myblog
|
|
78
|
+
```
|
|
76
79
|
|
|
77
80
|
## Appearance
|
|
78
81
|
|
|
@@ -88,17 +91,19 @@ Fields: `--theme`, `--font`, `--width`, `--layout`, the six
|
|
|
88
91
|
|
|
89
92
|
```bash
|
|
90
93
|
pagecord custom-code show --css > blog.css
|
|
91
|
-
pagecord custom-code update --css
|
|
94
|
+
pagecord custom-code update --css blog.css
|
|
92
95
|
```
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
file, or as `@-` to read standard input:
|
|
97
|
+
`--css`, `--footer-html`, `--head-html` and `--body-html` each take the path to
|
|
98
|
+
a file holding that content, so you can keep all of it under version control:
|
|
97
99
|
|
|
98
100
|
```bash
|
|
99
|
-
|
|
101
|
+
pagecord custom-code update --css blog.css --footer-html footer.html
|
|
100
102
|
```
|
|
101
103
|
|
|
104
|
+
There is also `--enabled true|false` to switch your head and body code off
|
|
105
|
+
without deleting it.
|
|
106
|
+
|
|
102
107
|
`custom-code show` prints JSON, or the raw field when you name one, so
|
|
103
108
|
redirecting it to a file round-trips.
|
|
104
109
|
|
data/lib/pagecord_cli/cli.rb
CHANGED
|
@@ -184,7 +184,7 @@ module PagecordCLI
|
|
|
184
184
|
params = {}
|
|
185
185
|
parser do |opts|
|
|
186
186
|
CUSTOM_CODE_FIELDS.each do |flag, name|
|
|
187
|
-
opts.on("--#{flag}
|
|
187
|
+
opts.on("--#{flag} PATH") { |path| params[name] = read_file(flag, path) }
|
|
188
188
|
end
|
|
189
189
|
opts.on("--enabled BOOL", TrueClass) { |value| params["custom_code_enabled"] = value }
|
|
190
190
|
end.parse!(argv)
|
|
@@ -247,12 +247,12 @@ module PagecordCLI
|
|
|
247
247
|
end
|
|
248
248
|
|
|
249
249
|
def resolve_blog(name = nil)
|
|
250
|
-
raise Error, "No blogs are configured. Run pagecord login SUBDOMAIN first." if config.blogs.empty?
|
|
250
|
+
raise Error, "No blogs are configured. Run `pagecord login SUBDOMAIN` first." if config.blogs.empty?
|
|
251
251
|
|
|
252
252
|
subdomain = name || options[:blog] || ENV["PAGECORD_BLOG"] || config.default_blog ||
|
|
253
253
|
(config.blogs.keys.first if config.blogs.size == 1)
|
|
254
254
|
|
|
255
|
-
raise Error, "
|
|
255
|
+
raise Error, "Several blogs are configured. Pass `--blog SUBDOMAIN`, or run `pagecord blog use SUBDOMAIN` to set a default." unless subdomain
|
|
256
256
|
raise Error, "Unknown blog: #{subdomain}" unless config.blog(subdomain)
|
|
257
257
|
|
|
258
258
|
subdomain
|
|
@@ -266,14 +266,10 @@ module PagecordCLI
|
|
|
266
266
|
)
|
|
267
267
|
end
|
|
268
268
|
|
|
269
|
-
def
|
|
270
|
-
|
|
271
|
-
when "@-" then input.read
|
|
272
|
-
when /\A@/ then File.read(value[1..])
|
|
273
|
-
else value
|
|
274
|
-
end
|
|
269
|
+
def read_file(flag, path)
|
|
270
|
+
File.read(path)
|
|
275
271
|
rescue SystemCallError
|
|
276
|
-
raise Error, "Could not read #{
|
|
272
|
+
raise Error, path.match?(/[{<]/) ? "--#{flag} takes a file path, not the content itself" : "Could not read #{path}"
|
|
277
273
|
end
|
|
278
274
|
|
|
279
275
|
def say(message)
|
|
@@ -319,9 +315,9 @@ module PagecordCLI
|
|
|
319
315
|
pagecord draft FILE [SUBDOMAIN] [options]
|
|
320
316
|
|
|
321
317
|
Global options:
|
|
322
|
-
--blog SUBDOMAIN
|
|
323
|
-
--json
|
|
324
|
-
--quiet
|
|
318
|
+
--blog SUBDOMAIN which blog to act on
|
|
319
|
+
--json machine-readable output
|
|
320
|
+
--quiet suppress confirmation messages
|
|
325
321
|
|
|
326
322
|
Publish options:
|
|
327
323
|
--title TITLE
|
|
@@ -339,10 +335,8 @@ module PagecordCLI
|
|
|
339
335
|
--show-branding true|false
|
|
340
336
|
|
|
341
337
|
Custom code options:
|
|
342
|
-
--css, --footer-html, --head-html, --body-html
|
|
338
|
+
--css, --footer-html, --head-html, --body-html (each takes a file path)
|
|
343
339
|
--enabled true|false
|
|
344
|
-
|
|
345
|
-
Custom code values can be a literal, @path to read a file, or @- to read stdin.
|
|
346
340
|
HELP
|
|
347
341
|
0
|
|
348
342
|
end
|
data/lib/pagecord_cli/client.rb
CHANGED
|
@@ -80,7 +80,15 @@ module PagecordCLI
|
|
|
80
80
|
|
|
81
81
|
def request(http_request)
|
|
82
82
|
http_request["Authorization"] ||= "Bearer #{api_key}"
|
|
83
|
-
|
|
83
|
+
uri = http_request.uri
|
|
84
|
+
address = uri.hostname
|
|
85
|
+
if address.end_with?(".localhost")
|
|
86
|
+
# *.localhost is loopback by definition (RFC 6761); macOS does not resolve it
|
|
87
|
+
http_request["Host"] = "#{uri.host}:#{uri.port}"
|
|
88
|
+
address = "127.0.0.1"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
response = Net::HTTP.start(address, uri.port, use_ssl: uri.scheme == "https") do |http|
|
|
84
92
|
http.open_timeout = OPEN_TIMEOUT
|
|
85
93
|
http.read_timeout = READ_TIMEOUT
|
|
86
94
|
http.write_timeout = WRITE_TIMEOUT if http.respond_to?(:write_timeout=)
|
data/lib/pagecord_cli/version.rb
CHANGED