nanoc-neocities 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +10 -0
- data/README.md +45 -0
- data/lib/nanoc-neocities.rb +110 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '028bae6c19a810cfda8e7a04b3bb8f41ac780795bc76e5ab6efcef4cf08f8f35'
|
4
|
+
data.tar.gz: d5f7a3c7eeff00f191cd806e5a4a4565d42ab42e9e377e86dd35dfd7e7a11f16
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a809bcc35f5f24ddbd700757eec27f42200fd552d25d9e9350eb9eb02b3f046092a090d46dd0c6fdca1b0ecda444ba965b2c645558865e09069df7538a6617f
|
7
|
+
data.tar.gz: 94949d8a0a5c999531c1bdf3b4f845b0e61b6421a0aa9205589ead3d9c28fccc75c1553f2a6c229ccbeaf4ad71319e27bc64154ea7be25216de76c4f99385ab9
|
data/LICENSE
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
BSD 3-Clause License
|
2
|
+
|
3
|
+
Copyright © 2019 Daniel Aleksandersen.
|
4
|
+
Copyright © 2017 Denis Defreyne.
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
7
|
+
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
9
|
+
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# nanoc-neocities
|
2
|
+
|
3
|
+
This Gem provides a deployer that allows [Nanoc](https://nanoc.ws/),
|
4
|
+
the open-source static website generator, to deploy to
|
5
|
+
[Neocities](https://neocities.org/)™; the free and open-source web
|
6
|
+
hosting service for creative web-native individuals.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Either `gem install nanoc-neocities` and `require 'nanoc-neocities'`
|
11
|
+
from your Nanoc site’s `lib/`.
|
12
|
+
|
13
|
+
Or add `nanoc-neocities` to the `nanoc` group of your Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
group :nanoc do
|
17
|
+
gem 'nanoc-neocities'
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
Available on [RubyGem](https://rubygems.org/gems/nanoc-neocities/).
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Add a deployment target to your `nanoc.yaml` file and provide the
|
26
|
+
sitename (without the `.neocities.org` TLD) and your site API key:
|
27
|
+
|
28
|
+
```deploy:
|
29
|
+
my-example-neocities:
|
30
|
+
kind: neocities
|
31
|
+
sitename: example-site
|
32
|
+
api_key: example-api-key
|
33
|
+
filter :external, exec: 'wc'
|
34
|
+
```
|
35
|
+
|
36
|
+
You can then run `nanoc deploy my-example-neocities` from inside your
|
37
|
+
Nanoc site directory to deploy it to your configured Neocities™ site.
|
38
|
+
|
39
|
+
You can find the API key for your Neocities™ site on the Site
|
40
|
+
settings page on the main Neocities™ website.
|
41
|
+
|
42
|
+
---
|
43
|
+
|
44
|
+
The project is licensed under the MIT License (see LICENSE).
|
45
|
+
“Neocities” is a trademark of Neocities Ltd.
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file os based on Nanoc::Deploying::Deployer::Git
|
4
|
+
# by Copyright © 2017 Denis Defreyne (MIT License).
|
5
|
+
|
6
|
+
require 'neocities'
|
7
|
+
|
8
|
+
module Nanoc::Deploying::Deployers
|
9
|
+
# A deployer that deploys a site to [Neocities](https://neocities.org/).
|
10
|
+
#
|
11
|
+
# @example A deployment configuration for Neocities:
|
12
|
+
#
|
13
|
+
# deploy:
|
14
|
+
# default:
|
15
|
+
# kind: neocities
|
16
|
+
# api_key: 1234abcd
|
17
|
+
# sitename: mysite
|
18
|
+
#
|
19
|
+
class NeocitiesDeployer < ::Nanoc::Deploying::Deployer
|
20
|
+
identifier :neocities
|
21
|
+
|
22
|
+
module Errors
|
23
|
+
class Generic < ::Nanoc::Error
|
24
|
+
end
|
25
|
+
|
26
|
+
class OutputEmptyOrGone < Generic
|
27
|
+
def initialize(path)
|
28
|
+
super("The directory to deploy, #{path}, does not exist.")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class AuthenticationFailed < Generic
|
33
|
+
def initialize()
|
34
|
+
super('Your Neocities API key or sitename failed to authenticate your request.')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class APIerror < Generic
|
39
|
+
def initialize(object)
|
40
|
+
super("Neocities API error “#{object}”.")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class UploadFailed < Generic
|
45
|
+
def initialize(path)
|
46
|
+
super("Failed to upload file #{path} to Neocities.")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class DeleteOrphanFailed < Generic
|
51
|
+
def initialize(path)
|
52
|
+
super("Failed to delete orphaned file #{path} from Neocities.")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def run
|
58
|
+
unless File.exist?(source_path)
|
59
|
+
raise Errors::OutputEmptyOrGone.new(source_path)
|
60
|
+
end
|
61
|
+
|
62
|
+
api_key = config.fetch(:api_key, '')
|
63
|
+
sitename = config.fetch(:sitename, '')
|
64
|
+
|
65
|
+
client = Neocities::Client.new({api_key: api_key, sitename: sitename})
|
66
|
+
|
67
|
+
remote_files = client.list
|
68
|
+
|
69
|
+
unless remote_files[:result] == 'success'
|
70
|
+
if remote_files[:error_type] == 'invalid_auth'
|
71
|
+
puts remote_files
|
72
|
+
raise Errors::AuthenticationFailed
|
73
|
+
else
|
74
|
+
raise Errors::APIerror.new(remote_files)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
puts "Deploying to Neocities site “#{sitename}”…"
|
79
|
+
|
80
|
+
Dir.chdir(source_path) do
|
81
|
+
Dir.glob("**/*") {|path|
|
82
|
+
unless File.directory?(path)
|
83
|
+
upload = client.upload(path, path)
|
84
|
+
if upload[:result] == 'success'
|
85
|
+
puts "Uploaded file “#{path}”."
|
86
|
+
elsif upload[:error_type] == 'file_exists'
|
87
|
+
puts "Existing file “#{path}” was identical. Skipping upload."
|
88
|
+
else
|
89
|
+
raise Errors::UploadFailed.new(path)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
}
|
93
|
+
|
94
|
+
puts "Neocities site “#{sitename}” deployed."
|
95
|
+
|
96
|
+
remote_files = client.list
|
97
|
+
puts "Deleting orphaned files from Neocities site “#{sitename}”…"
|
98
|
+
|
99
|
+
orphans = client.list[:files].map{|file| file[:path]} - Dir.glob("**/*")
|
100
|
+
|
101
|
+
for path in orphans
|
102
|
+
puts "Deleting “#{path}”."
|
103
|
+
unless client.delete(orphan)[:result] == 'success'
|
104
|
+
raise Errors::DeleteOrphanFailed.new(path)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nanoc-neocities
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Aleksandersen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nanoc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.11'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 4.11.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.11'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.11.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: neocities
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.0.13
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.0.13
|
47
|
+
description: Deploy your static website built with Nanoc to your Neocities site.
|
48
|
+
email: code+rubygems@daniel.priv.no
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- LICENSE
|
54
|
+
- README.md
|
55
|
+
- lib/nanoc-neocities.rb
|
56
|
+
homepage:
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata:
|
60
|
+
bug_tracker_uri: https://bitbucket.org/da2x/nanoc-neocities/issues
|
61
|
+
changelog_uri: https://bitbucket.org/da2x/nanoc-neocities/commits/branch/master
|
62
|
+
homepage_uri: https://rubygems.org/gems/nanoc-neocities/
|
63
|
+
source_code_uri: https://bitbucket.org/da2x/nanoc-neocities/src
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubygems_version: 3.0.3
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Deploy from Nanoc to Neocities.
|
83
|
+
test_files: []
|