distributed-press-api-client 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e07140dcbdfe76cdb6c2fd374d5a8505035b27a8be4298f31f6694f41a20a5d
4
- data.tar.gz: 49035a7a44b9445ef067ba92f1fa3efcb74943202570c5e7eccda33266175cf7
3
+ metadata.gz: c37544ed2afa25eb25880482b5882f197dd2eb7debf9db754cf7759e3d99fe26
4
+ data.tar.gz: f34ebb76bb1ce46164812ae1527202d888cb01a8bba51859f8100eebc71ba117
5
5
  SHA512:
6
- metadata.gz: 70fc5c1446cbd965afb21757c3abcc630067d41971d4b3c0ce9114d7bab322df4a8dba073a5394a204a6ad05269a599448e0d6c572b0acf3b5d4ed9ee30e016b
7
- data.tar.gz: 86a84f86f460b27dc75e384389892ea7ade9973b4aa302d688de89d9622eb5257f0466aaa063364926b2693fbe678728aaa928f1c7af53e096b82d0b00c36b00
6
+ metadata.gz: 4576d6dfb4095303612df97b3a7a737f973ea0fa8f8c2d33c881eb642ecaae6dd477661173fd52cc1467cf786c82a45fc0cb1ca0b4b349e2d4cf3f9b42a5fd4c
7
+ data.tar.gz: 21afc0dd53b4e48246e75bf53499638821aad983c2120f63f5919e5ce2be3e200d877999f0dbd02ea833d8eaaa66edf363c77f1c00dcb56fadbff7286c5e71cf
data/README.md CHANGED
@@ -62,6 +62,13 @@ Build and publish site:
62
62
  JEKYLL_ENV=production DISTRIBUTED_PRESS_API_KEY=the_api_key bundle exec jekyll build
63
63
  ```
64
64
 
65
+ Other env vars:
66
+
67
+ ```bash
68
+ DISTRIBUTED_PRESS_PROJECT_DOMAIN=your.domain.at.distributed.press
69
+ DISTRIBUTED_PRESS_API_URL=https://api.distributed.press
70
+ ```
71
+
65
72
  ## Contributing
66
73
 
67
74
  Bug reports and pull requests are welcome on 0xacab.org at
@@ -10,7 +10,7 @@ class DistributedPress
10
10
  NEWLINE = "\r\n"
11
11
  BOUNDARY = '--'
12
12
 
13
- attr_reader :api_key, :project_domain
13
+ attr_reader :api_key, :project_domain, :configure_result, :publish_result
14
14
 
15
15
  # @param options [Hash]
16
16
  # @option options [String] :url API URL
@@ -40,9 +40,9 @@ class DistributedPress
40
40
  config.close
41
41
  end
42
42
 
43
- result = upload_io('/v0/publication/configure', stream)
43
+ @configure_result = upload_io('/v0/publication/configure', stream)
44
44
 
45
- result['errorCode'].zero?
45
+ configure_result['errorCode'].zero?
46
46
  end
47
47
 
48
48
  # Publishes a directory by tarballing it on the fly.
@@ -66,11 +66,11 @@ class DistributedPress
66
66
  body.close
67
67
  end
68
68
 
69
- result = upload_io '/v0/publication/publish', stream
69
+ @publish_result = upload_io '/v0/publication/publish', stream
70
70
 
71
71
  # wait
72
72
  thread.value
73
- result['errorCode'].zero?
73
+ publish_result['errorCode'].zero?
74
74
  end
75
75
  end
76
76
 
@@ -3,7 +3,41 @@
3
3
  require 'distributed_press'
4
4
 
5
5
  Jekyll::Hooks.register :site, :post_write, priority: :low do |site|
6
- next unless ENV['JEKYLL_ENV'] == 'production'
6
+ def logger(message:, level: :info)
7
+ Jekyll.logger.public_send(level, 'Distributed Press:', message)
8
+ end
9
+
10
+ def warn(message)
11
+ logger level: :warn, message: message
12
+ end
13
+
14
+ def debug(message)
15
+ logger level: :debug, message: message
16
+ end
17
+
18
+ def info(message)
19
+ logger message: message
20
+ end
21
+
22
+ unless ENV['JEKYLL_ENV'] == 'production'
23
+ debug "Ignoring publication in #{ENV['JEKYLL_ENV']} mode"
24
+ next
25
+ end
26
+
27
+ # Compatibility with jekyll-locales, only publish on the last locale
28
+ dest = site.dest
29
+ locales_enabled = site.config['plugins'].include?('jekyll-locales')
30
+
31
+ if locales_enabled
32
+ if site.locales?
33
+ if site.locale != site.locales.last
34
+ info "Ignoring #{site.locale}"
35
+ next
36
+ else
37
+ dest = File.realpath(File.join(site.dest, '..'))
38
+ end
39
+ end
40
+ end
7
41
 
8
42
  hostname = ENV['DISTRIBUTED_PRESS_PROJECT_DOMAIN']
9
43
  hostname ||= site.config['hostname']
@@ -11,8 +45,19 @@ Jekyll::Hooks.register :site, :post_write, priority: :low do |site|
11
45
 
12
46
  raise URI::Error unless hostname
13
47
 
14
- distributed_press = DistributedPress.new project_domain: hostname
15
- distributed_press.configure && distributed_press.publish(site.dest)
48
+ info 'Publishing website'
49
+
50
+ distributed_press = DistributedPress.new(url: ENV['DISTRIBUTED_PRESS_API_URL'], project_domain: hostname)
51
+
52
+ if distributed_press.configure
53
+ if distributed_press.publish(dest)
54
+ info 'Published!'
55
+ else
56
+ warn distributed_press.publish_result['error']
57
+ end
58
+ else
59
+ warn distributed_press.configure_result['error']
60
+ end
16
61
  rescue URI::Error
17
- Jekyll::Logger.warn "`hostname` or `url` keys missing on _config.yml, skipping Distributed Press publication."
62
+ warn '`hostname` or `url` keys missing on _config.yml, skipping publication.'
18
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distributed-press-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-09 00:00:00.000000000 Z
11
+ date: 2022-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -59,14 +59,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 2.6.0
62
+ version: '2.7'
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubygems_version: 3.1.2
69
+ rubygems_version: 3.3.19
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: Distributed Press API Client