jekyll-paspagon 1.0.2 → 1.0.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 +6 -7
- data/lib/jekyll-paspagon/hooks.rb +13 -3
- data/lib/jekyll/commands/paspagon.rb +8 -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: eaafe762fcedbd097542c0fa0290e5beb71da952
|
4
|
+
data.tar.gz: f03219074db63e2337a6f62f7ad022a1bd33437b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 729648696853240d580a7345758c19f501b10f69c37394077c0f3e506cb1bae529a72b5952d507fb0e13be9d1a3dfecd22bae6f671f2077e5f9568fb3358bfd9
|
7
|
+
data.tar.gz: 183710d63a62d988f63d06db6f134ebf47a106b4fcc130b17ef9f3061a5ae21c314e34da2d54e293a2bf835a17f662a46f0dc03b2631bf0820fb5d1122eb2cef
|
data/README.md
CHANGED
@@ -18,10 +18,6 @@ group :jekyll_plugins do
|
|
18
18
|
end
|
19
19
|
```
|
20
20
|
|
21
|
-
### Configure S3 bucket
|
22
|
-
|
23
|
-
Create a S3 bucket in the `s3-us-west-2` region (Oregon) and [grant Paspagon read access to it](http://paspagon.com/terms-seller/#step-1-grant-us-read-access-to-your-bucket), as described in Paspagon’s terms of service.
|
24
|
-
|
25
21
|
### Configure Paspagon
|
26
22
|
|
27
23
|
To your `_config.yml`, add a section adhering to the following example:
|
@@ -68,6 +64,9 @@ defaults:
|
|
68
64
|
paid_after: 15 # HTML version will be paid 15 days after publication.
|
69
65
|
pdf:
|
70
66
|
content_disposition: attachment
|
67
|
+
# If you don’t provide content type, the plugin will try to set a
|
68
|
+
# reasonable default for some popular formats, falling back to
|
69
|
+
# application/octet-stream if necessary.
|
71
70
|
content_type: application/pdf
|
72
71
|
paid_before: 2 # PDF version will be paid for the first two days.
|
73
72
|
epub: {} # EPUB version will be paid from the beginning.
|
@@ -123,7 +122,7 @@ After doing the steps above, paid versions of your posts will be generated autom
|
|
123
122
|
|
124
123
|
If you specify thresholds like `paid_before`, you will need to run `jekyll build` again after reaching them.
|
125
124
|
|
126
|
-
You may override formats, buckets, prices
|
125
|
+
You may override formats, assigned buckets, prices, payment addresses and link expiration times for each post by putting the relevant data in the YAML front matter:
|
127
126
|
|
128
127
|
```yaml
|
129
128
|
layout: post
|
@@ -133,7 +132,7 @@ payment:
|
|
133
132
|
USD: false
|
134
133
|
XAU: 3
|
135
134
|
address:
|
136
|
-
|
135
|
+
BTC: 1Foo
|
137
136
|
bucket: foo
|
138
137
|
formats:
|
139
138
|
epub:
|
@@ -157,7 +156,7 @@ This command uploads missing or updated paid files to S3 and removes ones which
|
|
157
156
|
|
158
157
|
## Markdown compatibility
|
159
158
|
|
160
|
-
jekyll-paspagon uses Pandoc to generate formats other than HTML. The default input format is `markdown_github-hard_line_breaks`. It may be impacted by some site settings like Kramdown’s `hard_wrap`, but the most reliable it
|
159
|
+
jekyll-paspagon uses Pandoc to generate formats other than HTML. The default input format is `markdown_github-hard_line_breaks`. It may be impacted by some site settings like Kramdown’s `hard_wrap`, but the most reliable way of changing it is setting it explicitly in `_config.yml`:
|
161
160
|
|
162
161
|
```yaml
|
163
162
|
pandoc:
|
@@ -62,13 +62,13 @@ Jekyll::Hooks.register :posts, :post_write do |post|
|
|
62
62
|
unless post.data['excerpt_only']
|
63
63
|
post.data['formats'].each do |format, format_config|
|
64
64
|
puts("Generated #{format_config['path']}.") if maybe_generate_doc(post, format)
|
65
|
-
attrs = format_xattrs(format_config)
|
65
|
+
attrs = format_xattrs(format, format_config)
|
66
66
|
sync_payment_attributes(format_config['path'], attrs)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
def format_xattrs(format_config)
|
71
|
+
def format_xattrs(format, format_config)
|
72
72
|
attrs = {}
|
73
73
|
format_config['prices'].each do |currency, price|
|
74
74
|
attrs["user.x-amz-meta-price-#{currency}"] = price if price
|
@@ -78,10 +78,20 @@ def format_xattrs(format_config)
|
|
78
78
|
end
|
79
79
|
attrs['user.x-amz-meta-link-expiration-time'] = format_config['link_expiration_time'] if format_config['link_expiration_time']
|
80
80
|
attrs['user.content-disposition'] = format_config['content_disposition'] if format_config['content_disposition']
|
81
|
-
attrs['user.content-type'] = format_config['content_type']
|
81
|
+
attrs['user.content-type'] = format_config['content_type'] || default_content_type(format)
|
82
82
|
attrs
|
83
83
|
end
|
84
84
|
|
85
|
+
def default_content_type(format)
|
86
|
+
content_types =
|
87
|
+
{'epub' => 'application/epub+zip',
|
88
|
+
'html' => 'text/html',
|
89
|
+
'mobi' => 'application/x-mobipocket-ebook',
|
90
|
+
'pdf' => 'application/pdf'}
|
91
|
+
content_types.default = 'application/octet-stream'
|
92
|
+
content_types[format]
|
93
|
+
end
|
94
|
+
|
85
95
|
def sync_payment_attributes(path, attrs)
|
86
96
|
xattr = Xattr.new(path)
|
87
97
|
old = xattr.list.select { |a| a.start_with?('user.') }
|
@@ -103,10 +103,14 @@ module Jekyll
|
|
103
103
|
to_upload.each do |p|
|
104
104
|
puts("Uploading #{p} to bucket #{bucket_name}…")
|
105
105
|
xattr = Xattr.new(p)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
user_metadata = xattr.as_json.select { |k, _| k.start_with?('user.x-amz-meta-') }.map { |k, v| [k.sub(/^user./, ''), v] }.to_h
|
107
|
+
options =
|
108
|
+
{body: File.open(p),
|
109
|
+
metadata: user_metadata,
|
110
|
+
key: p}
|
111
|
+
options[:content_disposition] = xattr['user.content-disposition'] if xattr['user.content-disposition']
|
112
|
+
options[:content_type] = xattr['user.content-type'] if xattr['user.content-type']
|
113
|
+
bucket.put_object(options)
|
110
114
|
end
|
111
115
|
end
|
112
116
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-paspagon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Jurewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-xattr
|