pagecord-cli 0.2.1 → 0.2.3
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 +22 -13
- data/lib/pagecord_cli/cli.rb +12 -6
- 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: 691c38a950d1636ababf3611ca1d767046570a2558673fafe649c0c82712da57
|
|
4
|
+
data.tar.gz: d49abbd1d948cf7ed4e52b56a31e32aa091eaa3a826780ade9b57c663d74cac4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc466f620c67a38c614ce658d755f6c9f8e775f62a2d133bbc986246aaea38e4a039d2b55f02664bd0d7906b53eb57a82c15814283713e5147c8fb9382e48321
|
|
7
|
+
data.tar.gz: 45b006d11a1a4be80e3a8d8728032c8500f41422e9a33c44a59c0dc24cf726e554f1448cafd7c6a1e572fd916e6b06b73a122f58a9e489f2902e03580a9844ea
|
data/README.md
CHANGED
|
@@ -8,6 +8,12 @@ Publish local Markdown and HTML files to [Pagecord](https://pagecord.com).
|
|
|
8
8
|
gem install pagecord-cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
Needs Ruby 3.2 or newer. The Ruby that ships with macOS is too old, so:
|
|
12
|
+
|
|
13
|
+
- **macOS**: `brew install ruby`, or a version manager like [mise](https://mise.jdx.dev)
|
|
14
|
+
- **Windows**: [RubyInstaller](https://rubyinstaller.org)
|
|
15
|
+
- **Linux**: your package manager, if it offers 3.2 or newer; otherwise [mise](https://mise.jdx.dev)
|
|
16
|
+
|
|
11
17
|
## Login
|
|
12
18
|
|
|
13
19
|
Generate an API key from **Settings > API** in Pagecord, then save it locally:
|
|
@@ -22,7 +28,7 @@ The name should be your Pagecord subdomain. The API key is stored in
|
|
|
22
28
|
For local testing there is an undocumented `--base-url` option:
|
|
23
29
|
|
|
24
30
|
```bash
|
|
25
|
-
pagecord login myblog --base-url http://localhost:3000
|
|
31
|
+
pagecord login myblog --base-url http://api.localhost:3000
|
|
26
32
|
```
|
|
27
33
|
|
|
28
34
|
## Publishing
|
|
@@ -42,13 +48,6 @@ pagecord draft notes/idea.md
|
|
|
42
48
|
The first publish creates a post and writes Pagecord metadata back into the
|
|
43
49
|
file. Later publishes update the same post.
|
|
44
50
|
|
|
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
51
|
See configured blogs:
|
|
53
52
|
|
|
54
53
|
```bash
|
|
@@ -63,16 +62,26 @@ pagecord logout myblog
|
|
|
63
62
|
|
|
64
63
|
## Choosing a blog
|
|
65
64
|
|
|
66
|
-
With
|
|
65
|
+
With one blog configured, every command uses it. With several, set a default
|
|
66
|
+
once:
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
69
|
pagecord blog use myblog
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
or name the blog on the command line:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pagecord appearance show --blog myblog
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`--blog` wins over the `PAGECORD_BLOG` environment variable, which wins over
|
|
79
|
+
the default. `publish`, `draft` and `logout` also take the subdomain as a
|
|
80
|
+
trailing argument, which wins over all three:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pagecord publish hello.md myblog
|
|
84
|
+
```
|
|
76
85
|
|
|
77
86
|
## Appearance
|
|
78
87
|
|
data/lib/pagecord_cli/cli.rb
CHANGED
|
@@ -194,6 +194,10 @@ module PagecordCLI
|
|
|
194
194
|
settings = client_for(resolve_blog).update_custom_code(params)
|
|
195
195
|
options[:json] ? print_json(settings) : say("Updated custom code")
|
|
196
196
|
0
|
|
197
|
+
rescue Client::Error => e
|
|
198
|
+
raise unless e.status == 422 && params.key?("custom_css")
|
|
199
|
+
|
|
200
|
+
raise Error, "#{e.message}.\nCommon causes: nested CSS, or @import from a host other than Google Fonts or Bunny Fonts.\nSee https://help.pagecord.com/custom-css"
|
|
197
201
|
end
|
|
198
202
|
|
|
199
203
|
def publish(status)
|
|
@@ -247,12 +251,12 @@ module PagecordCLI
|
|
|
247
251
|
end
|
|
248
252
|
|
|
249
253
|
def resolve_blog(name = nil)
|
|
250
|
-
raise Error, "No blogs are configured. Run pagecord login SUBDOMAIN first." if config.blogs.empty?
|
|
254
|
+
raise Error, "No blogs are configured. Run `pagecord login SUBDOMAIN` first." if config.blogs.empty?
|
|
251
255
|
|
|
252
256
|
subdomain = name || options[:blog] || ENV["PAGECORD_BLOG"] || config.default_blog ||
|
|
253
257
|
(config.blogs.keys.first if config.blogs.size == 1)
|
|
254
258
|
|
|
255
|
-
raise Error, "
|
|
259
|
+
raise Error, "Several blogs are configured. Pass `--blog SUBDOMAIN`, or run `pagecord blog use SUBDOMAIN` to set a default." unless subdomain
|
|
256
260
|
raise Error, "Unknown blog: #{subdomain}" unless config.blog(subdomain)
|
|
257
261
|
|
|
258
262
|
subdomain
|
|
@@ -310,15 +314,14 @@ module PagecordCLI
|
|
|
310
314
|
pagecord appearance show
|
|
311
315
|
pagecord appearance update [options]
|
|
312
316
|
pagecord custom-code show [--css|--footer-html|--head-html|--body-html]
|
|
313
|
-
pagecord custom-code update --css blog.css
|
|
314
317
|
pagecord custom-code update [options]
|
|
315
318
|
pagecord publish FILE [SUBDOMAIN] [options]
|
|
316
319
|
pagecord draft FILE [SUBDOMAIN] [options]
|
|
317
320
|
|
|
318
321
|
Global options:
|
|
319
|
-
--blog SUBDOMAIN
|
|
320
|
-
--json
|
|
321
|
-
--quiet
|
|
322
|
+
--blog SUBDOMAIN which blog to act on
|
|
323
|
+
--json machine-readable output
|
|
324
|
+
--quiet suppress confirmation messages
|
|
322
325
|
|
|
323
326
|
Publish options:
|
|
324
327
|
--title TITLE
|
|
@@ -338,6 +341,9 @@ module PagecordCLI
|
|
|
338
341
|
Custom code options:
|
|
339
342
|
--css, --footer-html, --head-html, --body-html (each takes a file path)
|
|
340
343
|
--enabled true|false
|
|
344
|
+
|
|
345
|
+
Custom CSS reference:
|
|
346
|
+
https://help.pagecord.com/custom-css
|
|
341
347
|
HELP
|
|
342
348
|
0
|
|
343
349
|
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