nanoc-neocities 0.1.1 → 0.1.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 +8 -7
- data/lib/nanoc-neocities.rb +19 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37e9b3973ef2acc2feaac5cfb954b189c01604427d01564af88bae1cbaad81c2
|
4
|
+
data.tar.gz: b6409f078acc51c2e6015ae1077e8cc8845fbeed3de2cb5679dcef6b0b515a43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f475e040548c27436b09fd659de3c036c243c66bf663bcc38a8b078fd11fa5527a1d54d4e0efd25ab9ac881c754b897dcefdbb2635e2f61538ce7ce3d34b3986
|
7
|
+
data.tar.gz: f279969041f12a7a408fe697239700df7d3bc9d4dfc2c05e76b7fb07b23574e147dd6f2e67523e38a9e85653f86b7c01497b51064a2a601b126d6d7447f696ca
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ from your Nanoc site’s `lib/`.
|
|
12
12
|
|
13
13
|
Or add `nanoc-neocities` to the `nanoc` group of your Gemfile:
|
14
14
|
|
15
|
-
```
|
15
|
+
```
|
16
16
|
group :nanoc do
|
17
17
|
gem 'nanoc-neocities'
|
18
18
|
end
|
@@ -25,16 +25,17 @@ Available on [RubyGem](https://rubygems.org/gems/nanoc-neocities/).
|
|
25
25
|
Add a deployment target to your `nanoc.yaml` file and provide the
|
26
26
|
sitename (without the `.neocities.org` TLD) and your site API key:
|
27
27
|
|
28
|
-
```
|
29
|
-
|
28
|
+
```
|
29
|
+
deploy:
|
30
|
+
my_neocities:
|
30
31
|
kind: neocities
|
31
32
|
sitename: example-site
|
32
33
|
api_key: example-api-key
|
33
|
-
|
34
|
+
prune_remote: true
|
34
35
|
```
|
35
36
|
|
36
|
-
You can then run `nanoc deploy
|
37
|
-
|
37
|
+
You can then run `nanoc deploy my_neocities` from inside your Nanoc
|
38
|
+
site directory to deploy it to your configured Neocities™ site.
|
38
39
|
|
39
40
|
You can find the API key for your Neocities™ site on the Site
|
40
41
|
settings page on the main Neocities™ website.
|
@@ -42,4 +43,4 @@ settings page on the main Neocities™ website.
|
|
42
43
|
---
|
43
44
|
|
44
45
|
The project is licensed under the MIT License (see LICENSE).
|
45
|
-
“Neocities” is a trademark of Neocities Ltd.
|
46
|
+
“Neocities” is a trademark of Neocities Ltd.
|
data/lib/nanoc-neocities.rb
CHANGED
@@ -12,9 +12,10 @@ module Nanoc::Deploying::Deployers
|
|
12
12
|
#
|
13
13
|
# deploy:
|
14
14
|
# default:
|
15
|
-
# kind:
|
16
|
-
# api_key:
|
17
|
-
# sitename:
|
15
|
+
# kind: neocities
|
16
|
+
# api_key: 1234abcd
|
17
|
+
# sitename: mysite
|
18
|
+
# prune_remote: true
|
18
19
|
#
|
19
20
|
class NeocitiesDeployer < ::Nanoc::Deploying::Deployer
|
20
21
|
identifier :neocities
|
@@ -42,8 +43,8 @@ module Nanoc::Deploying::Deployers
|
|
42
43
|
end
|
43
44
|
|
44
45
|
class UploadFailed < Generic
|
45
|
-
def initialize(path)
|
46
|
-
super("Failed to upload file #{path} to Neocities
|
46
|
+
def initialize(path, message)
|
47
|
+
super("Failed to upload file #{path} to Neocities: #{message}")
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
@@ -61,6 +62,7 @@ module Nanoc::Deploying::Deployers
|
|
61
62
|
|
62
63
|
api_key = config.fetch(:api_key, '')
|
63
64
|
sitename = config.fetch(:sitename, '')
|
65
|
+
prune = config.fetch(:prune_remote, true)
|
64
66
|
|
65
67
|
client = Neocities::Client.new({api_key: api_key, sitename: sitename})
|
66
68
|
|
@@ -84,26 +86,29 @@ puts remote_files
|
|
84
86
|
if upload[:result] == 'success'
|
85
87
|
puts "Uploaded file “#{path}”."
|
86
88
|
elsif upload[:error_type] == 'file_exists'
|
87
|
-
puts "Existing file “#{path}”
|
89
|
+
puts "Existing file “#{path}” is identical. Skipping upload."
|
88
90
|
else
|
89
|
-
raise Errors::UploadFailed.new(path)
|
91
|
+
raise Errors::UploadFailed.new(path, upload[:message] || 'unknown problem')
|
90
92
|
end
|
91
93
|
end
|
92
94
|
}
|
93
95
|
|
94
96
|
puts "Neocities site “#{sitename}” deployed."
|
95
97
|
|
96
|
-
|
97
|
-
|
98
|
+
if prune
|
99
|
+
remote_files = client.list
|
100
|
+
puts "Deleting orphaned files from Neocities site “#{sitename}”…"
|
98
101
|
|
99
|
-
|
102
|
+
orphans = client.list[:files].map{|file| file[:path]} - Dir.glob("**/*")
|
100
103
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
104
|
+
for path in orphans
|
105
|
+
puts "Deleting “#{path}”."
|
106
|
+
unless client.delete(orphan)[:result] == 'success'
|
107
|
+
raise Errors::DeleteOrphanFailed.new(path)
|
108
|
+
end
|
105
109
|
end
|
106
110
|
end
|
111
|
+
|
107
112
|
end
|
108
113
|
end
|
109
114
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-neocities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Aleksandersen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nanoc
|