pagecord-cli 0.3.2 → 0.3.4
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 +12 -2
- data/lib/pagecord_cli/SKILL.md +5 -3
- data/lib/pagecord_cli/cli.rb +3 -0
- data/lib/pagecord_cli/image_uploads.rb +21 -6
- data/lib/pagecord_cli/post_file.rb +1 -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: 19a08d2465d20f5f6b630f2cddd3d1d24c708ce88c4c398b5f9b3bd280627bb0
|
|
4
|
+
data.tar.gz: f3a94234b517171e5ebbcbd8847f06800dc794f9eb65e1071a0572fc5a658ff1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12d357026fc0faeb4056843b460691683df68c87941436961e47fd26e7601befe3d897c741fb0cc9cabc1730c86c0e05ecddbffc67fe9117e7a94f79e1d7bf63
|
|
7
|
+
data.tar.gz: b9dea1b6cf8f01476551d49d5acfc781b579a20120a25751e2babc6047ad9b1b6d9731b3f47f75d41cacff890bb10c82e2b4ac15ce8123474231e45cdf027f3a
|
data/README.md
CHANGED
|
@@ -76,8 +76,9 @@ pagecord post delete TOKEN # add --permanent to skip the bin
|
|
|
76
76
|
`pagecord page` takes the same commands. Lists are paged 15 at a time; pass
|
|
77
77
|
`--page N` for more. `--content-file` sends Markdown when the file ends `.md`,
|
|
78
78
|
and HTML otherwise. Other flags: `--title`, `--status draft|published`,
|
|
79
|
-
`--slug`, `--published-at`, `--tags`, `--canonical-url`, `--
|
|
80
|
-
`--hidden`/`--no-hidden`. `--json` prints the full
|
|
79
|
+
`--slug`, `--published-at`, `--tags`, `--canonical-url`, `--link-url` (posts
|
|
80
|
+
only), `--locale` and `--hidden`/`--no-hidden`. `--json` prints the full
|
|
81
|
+
response.
|
|
81
82
|
|
|
82
83
|
## Agent skill
|
|
83
84
|
|
|
@@ -165,6 +166,7 @@ Accepted by every command, before or after the command name:
|
|
|
165
166
|
--published-at TIME
|
|
166
167
|
--tags TAGS
|
|
167
168
|
--canonical-url URL
|
|
169
|
+
--link-url URL
|
|
168
170
|
--hidden
|
|
169
171
|
--locale LOCALE
|
|
170
172
|
```
|
|
@@ -182,11 +184,15 @@ tags:
|
|
|
182
184
|
- cli
|
|
183
185
|
published_at: 2026-01-02T03:04:05Z
|
|
184
186
|
canonical_url: https://example.com/original
|
|
187
|
+
link_url: https://example.com/an-article
|
|
185
188
|
hidden: false
|
|
186
189
|
locale: en
|
|
187
190
|
---
|
|
188
191
|
```
|
|
189
192
|
|
|
193
|
+
`link_url` makes it a link post: the title links to that address. Use
|
|
194
|
+
`--link-url ""` to turn a link post back into a normal post.
|
|
195
|
+
|
|
190
196
|
If `title` is omitted, the CLI uses the filename. Use `title:` or
|
|
191
197
|
`title: ""` to publish without a title.
|
|
192
198
|
|
|
@@ -210,9 +216,13 @@ Action Text attachments:
|
|
|
210
216
|
|
|
211
217
|
```markdown
|
|
212
218
|

|
|
219
|
+

|
|
213
220
|
![[photo.jpg]]
|
|
214
221
|
```
|
|
215
222
|
|
|
223
|
+
The alt text and an optional quoted caption go onto the image. Filenames can
|
|
224
|
+
contain spaces.
|
|
225
|
+
|
|
216
226
|
Supported local image types are JPEG, PNG, GIF, and WebP. External image URLs
|
|
217
227
|
and HTML `<img>` tags are left alone.
|
|
218
228
|
|
data/lib/pagecord_cli/SKILL.md
CHANGED
|
@@ -51,7 +51,8 @@ pagecord post update TOKEN --content-file post.html --status draft
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
`update` changes only the flags given. Other fields: `--slug`,
|
|
54
|
-
`--published-at`, `--tags "a, b"`, `--canonical-url`, `--
|
|
54
|
+
`--published-at`, `--tags "a, b"`, `--canonical-url`, `--link-url` (makes a
|
|
55
|
+
link post, whose title links to that address), `--locale`,
|
|
55
56
|
`--hidden`/`--no-hidden`. Delete moves a post to the bin unless you pass
|
|
56
57
|
`--permanent`, which can't be undone: confirm with the user first.
|
|
57
58
|
|
|
@@ -64,8 +65,9 @@ pagecord draft notes/idea.md # save as a draft
|
|
|
64
65
|
|
|
65
66
|
The first run writes a `pagecord_token` into the file's front matter, and later
|
|
66
67
|
runs update that same post. Front matter can set `title`, `slug`, `tags`,
|
|
67
|
-
`published_at`, `canonical_url`, `hidden` and `locale`. Local images written as
|
|
68
|
-
`` are uploaded
|
|
68
|
+
`published_at`, `canonical_url`, `link_url`, `hidden` and `locale`. Local images written as
|
|
69
|
+
`` are uploaded with their alt text and
|
|
70
|
+
optional caption.
|
|
69
71
|
|
|
70
72
|
## Restyling a blog
|
|
71
73
|
|
data/lib/pagecord_cli/cli.rb
CHANGED
|
@@ -307,6 +307,7 @@ module PagecordCLI
|
|
|
307
307
|
opts.on("--published-at TIME") { |value| params[:published_at] = value }
|
|
308
308
|
opts.on("--tags TAGS") { |value| params[:tags] = value }
|
|
309
309
|
opts.on("--canonical-url URL") { |value| params[:canonical_url] = value }
|
|
310
|
+
opts.on("--link-url URL") { |value| params[:link_url] = value }
|
|
310
311
|
opts.on("--[no-]hidden") { |value| params[:hidden] = value }
|
|
311
312
|
opts.on("--locale LOCALE") { |value| params[:locale] = value }
|
|
312
313
|
end.parse!(argv)
|
|
@@ -349,6 +350,7 @@ module PagecordCLI
|
|
|
349
350
|
opts.on("--published-at TIME") { |value| overrides[:published_at] = value }
|
|
350
351
|
opts.on("--tags TAGS") { |value| overrides[:tags] = value }
|
|
351
352
|
opts.on("--canonical-url URL") { |value| overrides[:canonical_url] = value }
|
|
353
|
+
opts.on("--link-url URL") { |value| overrides[:link_url] = value }
|
|
352
354
|
opts.on("--[no-]hidden") { |value| overrides[:hidden] = value }
|
|
353
355
|
opts.on("--locale LOCALE") { |value| overrides[:locale] = value }
|
|
354
356
|
end.parse!(argv)
|
|
@@ -484,6 +486,7 @@ module PagecordCLI
|
|
|
484
486
|
--published-at TIME
|
|
485
487
|
--tags TAGS
|
|
486
488
|
--canonical-url URL
|
|
489
|
+
--link-url URL makes a post a link post: the title links here
|
|
487
490
|
--locale LOCALE
|
|
488
491
|
--hidden, --no-hidden
|
|
489
492
|
--content-file PATH post/page create and update; Markdown if it ends .md
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "digest"
|
|
4
|
+
require "cgi/escape"
|
|
5
|
+
require "uri"
|
|
4
6
|
|
|
5
7
|
module PagecordCLI
|
|
6
8
|
class ImageUploads
|
|
7
|
-
MARKDOWN_IMAGE = /!\[([^\]]*)\]\(([^)]+)
|
|
9
|
+
MARKDOWN_IMAGE = /!\[([^\]]*)\]\(([^)"]+?)(?:\s+"([^"]*)")?\)/
|
|
8
10
|
OBSIDIAN_IMAGE = /!\[\[([^\]]+)\]\]/
|
|
9
11
|
IMAGE_EXTENSIONS = /\.(jpe?g|png|gif|webp)\z/i
|
|
10
12
|
|
|
@@ -20,8 +22,9 @@ module PagecordCLI
|
|
|
20
22
|
|
|
21
23
|
def process
|
|
22
24
|
with_markdown_images = content.gsub(MARKDOWN_IMAGE) do |match|
|
|
23
|
-
path = Regexp.last_match
|
|
24
|
-
|
|
25
|
+
alt, path, caption = Regexp.last_match.captures
|
|
26
|
+
path = decode_path(path)
|
|
27
|
+
local_path?(path) ? attachment_tag_for(path, alt: alt, caption: caption) : match
|
|
25
28
|
end
|
|
26
29
|
|
|
27
30
|
with_markdown_images.gsub(OBSIDIAN_IMAGE) do |match|
|
|
@@ -32,9 +35,20 @@ module PagecordCLI
|
|
|
32
35
|
|
|
33
36
|
private
|
|
34
37
|
|
|
35
|
-
def attachment_tag_for(path)
|
|
38
|
+
def attachment_tag_for(path, alt: nil, caption: nil)
|
|
36
39
|
sgid = cached_sgid(path) || upload(path)
|
|
37
|
-
%(<action-text-attachment sgid="#{sgid}"></action-text-attachment>)
|
|
40
|
+
%(<action-text-attachment sgid="#{sgid}"#{attribute("alt", alt)}#{attribute("caption", caption)}></action-text-attachment>)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def attribute(name, value)
|
|
44
|
+
%( #{name}="#{CGI.escapeHTML(value)}") unless value.to_s.empty?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# A filename can contain a literal "%", as in 100%.jpg.
|
|
48
|
+
def decode_path(path)
|
|
49
|
+
URI.decode_uri_component(path)
|
|
50
|
+
rescue ArgumentError
|
|
51
|
+
path
|
|
38
52
|
end
|
|
39
53
|
|
|
40
54
|
def cached_sgid(path)
|
|
@@ -74,7 +88,8 @@ module PagecordCLI
|
|
|
74
88
|
end
|
|
75
89
|
|
|
76
90
|
def checksum(path)
|
|
77
|
-
|
|
91
|
+
@checksums ||= {}
|
|
92
|
+
@checksums[path] ||= Digest::SHA256.file(path).hexdigest[0, 16]
|
|
78
93
|
end
|
|
79
94
|
|
|
80
95
|
def filename(path)
|
|
@@ -66,7 +66,7 @@ module PagecordCLI
|
|
|
66
66
|
def params
|
|
67
67
|
publish_params = { title: title_from_metadata }
|
|
68
68
|
|
|
69
|
-
%w[slug published_at canonical_url locale].each do |key|
|
|
69
|
+
%w[slug published_at canonical_url link_url locale].each do |key|
|
|
70
70
|
value = frontmatter_string(metadata[key])
|
|
71
71
|
publish_params[key.to_sym] = value if value
|
|
72
72
|
end
|
data/lib/pagecord_cli/version.rb
CHANGED