siteleaf 2.0.0 → 2.0.1
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 -4
- data/bin/siteleaf +21 -20
- data/lib/siteleaf/collection.rb +11 -11
- data/lib/siteleaf/content.rb +6 -6
- data/lib/siteleaf/entity.rb +5 -5
- data/lib/siteleaf/site.rb +18 -40
- data/lib/siteleaf/source_file.rb +8 -8
- data/lib/siteleaf/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65d48226cecb838d1278ade7c5b7541b34a1109d
|
4
|
+
data.tar.gz: f0bf3187c1fc2421569d9ceb3bca7ca653c32c19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bba0b5d62f3b7b2dddcafaa5be8d578880cca38781b560d7b4b24f6478b8700c507484dd9d86c0143be1a3f2fbcf7baf4a55adcea2a25315f0e0495fc8ae4a2
|
7
|
+
data.tar.gz: 91412e0252c46d6e4a9648c31a45a82133d2555091791f1a4ad2bff6866e8831ecd596a02302d82153f1d554c27189d817f6b897e4de285f95fbaa7e636d6da5
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Siteleaf Gem
|
1
|
+
Siteleaf v2 Gem
|
2
2
|
===============
|
3
3
|
|
4
4
|
- [Installation](#installation)
|
@@ -13,9 +13,11 @@ Installation
|
|
13
13
|
|
14
14
|
The Siteleaf gem is available for installation on [Rubygems](https://rubygems.org/gems/siteleaf). To install run:
|
15
15
|
|
16
|
-
gem install siteleaf
|
16
|
+
gem install siteleaf
|
17
17
|
|
18
|
-
|
18
|
+
**Note:** the v2 gem only works with v2 sites. For documentation on v1 see: https://github.com/siteleaf/siteleaf-gem/tree/v1
|
19
|
+
|
20
|
+
If maintaining sites with multiple versions, we recommend using a [Gemfile](#using-this-gem-in-your-application).
|
19
21
|
|
20
22
|
|
21
23
|
Using the CLI
|
@@ -78,7 +80,7 @@ Using this gem in your application
|
|
78
80
|
|
79
81
|
To use this gem in your application, add the following to your Gemfile:
|
80
82
|
|
81
|
-
gem 'siteleaf',
|
83
|
+
gem 'siteleaf', '~>2'
|
82
84
|
|
83
85
|
|
84
86
|
Using the API
|
data/bin/siteleaf
CHANGED
@@ -58,12 +58,13 @@ end
|
|
58
58
|
|
59
59
|
def pull(site_id)
|
60
60
|
print "Reading site...\n"
|
61
|
-
|
61
|
+
|
62
62
|
# get all the things
|
63
63
|
site = Siteleaf::Site.find(site_id)
|
64
|
-
site_files = site.
|
64
|
+
site_files = site.source_files('.', recursive: true)
|
65
|
+
|
65
66
|
updated_count = 0
|
66
|
-
|
67
|
+
|
67
68
|
# download unmatched files
|
68
69
|
site_files.each do |file|
|
69
70
|
sha = ::File.exist?(file.name) && Siteleaf::GitHash.file(file.name)
|
@@ -75,11 +76,11 @@ def pull(site_id)
|
|
75
76
|
print "complete.\n"
|
76
77
|
end
|
77
78
|
end
|
78
|
-
|
79
|
+
|
79
80
|
# check for old files
|
80
81
|
local_files = read_dir
|
81
82
|
missing_files = []
|
82
|
-
local_files.each do |path|
|
83
|
+
local_files.each do |path|
|
83
84
|
missing_files << path if !site_files.find{|a| a.name.casecmp(path) == 0 }
|
84
85
|
end
|
85
86
|
if missing_files.empty?
|
@@ -105,23 +106,23 @@ end
|
|
105
106
|
|
106
107
|
def push(site_id)
|
107
108
|
print "Reading site...\n"
|
108
|
-
|
109
|
+
|
109
110
|
# get all the things
|
110
111
|
site = Siteleaf::Site.find(site_id)
|
111
|
-
site_files = site.
|
112
|
+
site_files = site.source_files('.', recursive: true)
|
112
113
|
local_files = read_dir
|
113
114
|
updated_count = 0
|
114
|
-
|
115
|
+
|
115
116
|
# find changed files
|
116
117
|
changed_files = local_files.reject do |path|
|
117
118
|
file = site_files.find{|a| a.name.casecmp(path) == 0 }
|
118
119
|
file && Siteleaf::GitHash.file(path) == file.sha
|
119
120
|
end
|
120
|
-
changed_files.unshift('_config.yml') if changed_files.delete('_config.yml')
|
121
|
-
|
121
|
+
changed_files.unshift('_config.yml') if changed_files.delete('_config.yml')
|
122
|
+
|
122
123
|
# upload changed files
|
123
|
-
changed_files.each do |path|
|
124
|
-
print "Uploading #{path}..."
|
124
|
+
changed_files.each do |path|
|
125
|
+
print "Uploading #{path}..."
|
125
126
|
response = Siteleaf::SourceFile.create(site_id: site_id, name: path, file: ::File.new(path))
|
126
127
|
if error = !response || response.error || response.message
|
127
128
|
print (error) ? "error: #{error}\n" : "error.\n"
|
@@ -131,10 +132,10 @@ def push(site_id)
|
|
131
132
|
print "complete.\n"
|
132
133
|
end
|
133
134
|
end
|
134
|
-
|
135
|
+
|
135
136
|
# check for old files
|
136
137
|
missing_assets = []
|
137
|
-
site_files.each do |asset|
|
138
|
+
site_files.each do |asset|
|
138
139
|
missing_assets << asset if !local_files.find{|p| p.casecmp(asset.name) == 0 }
|
139
140
|
end
|
140
141
|
if missing_assets.empty?
|
@@ -160,7 +161,7 @@ end
|
|
160
161
|
|
161
162
|
def import(file, quiet = true)
|
162
163
|
job = Siteleaf::Site.import(file: ::File.new(file))
|
163
|
-
|
164
|
+
|
164
165
|
if quiet
|
165
166
|
puts "=> Import queued.\n"
|
166
167
|
else
|
@@ -180,7 +181,7 @@ end
|
|
180
181
|
def publish(site_id, quiet = true)
|
181
182
|
site = Siteleaf::Site.new(id: site_id)
|
182
183
|
job = site.publish
|
183
|
-
|
184
|
+
|
184
185
|
if quiet
|
185
186
|
puts "=> Publish queued.\n"
|
186
187
|
else
|
@@ -209,7 +210,7 @@ def get_site_id
|
|
209
210
|
Siteleaf.send "#{key}=", value
|
210
211
|
end
|
211
212
|
end
|
212
|
-
|
213
|
+
|
213
214
|
ENV['SITELEAF_SITE_ID'] || if settings = Siteleaf.load_settings('.siteleaf.yml')
|
214
215
|
settings[:site_id]
|
215
216
|
end
|
@@ -217,13 +218,13 @@ end
|
|
217
218
|
|
218
219
|
def read_dir
|
219
220
|
jekyll_config = ::File.exist?('_config.yml') ? YAML::load(::File.read('_config.yml')) : {}
|
220
|
-
|
221
|
+
|
221
222
|
ignore_paths = ['config.ru', '.*', '_site/*', 'Gemfile', 'Gemfile.lock']
|
222
223
|
ignore_paths += ::File.read('.siteleafignore').split(/\r?\n/) if ::File.exists?('.siteleafignore')
|
223
224
|
ignore_paths += jekyll_config['exclude'] if jekyll_config['exclude'].is_a? Array
|
224
|
-
|
225
|
+
|
225
226
|
Dir.glob("**/*").reject do |path|
|
226
|
-
::File.directory?(path) ||
|
227
|
+
::File.directory?(path) ||
|
227
228
|
ignore_paths.any? {|i| ::File.fnmatch?(i, path, File::FNM_CASEFOLD) || ::File.fnmatch?(i, ::File.basename(path), File::FNM_CASEFOLD) }
|
228
229
|
end
|
229
230
|
end
|
data/lib/siteleaf/collection.rb
CHANGED
@@ -3,40 +3,40 @@ module Siteleaf
|
|
3
3
|
|
4
4
|
attr_accessor :title, :path, :permalink, :output, :site_id, :user_id, :metadata
|
5
5
|
attr_reader :id, :directory, :created_at, :updated_at
|
6
|
-
|
6
|
+
|
7
7
|
def create_endpoint
|
8
8
|
::File.join("sites", site_id, "collections")
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def entity_endpoint
|
12
12
|
::File.join(create_endpoint, identifier)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def identifier
|
16
16
|
path
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def site
|
20
20
|
Site.find(site_id)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def documents
|
24
24
|
result = Client.get "#{entity_endpoint}/documents"
|
25
|
-
result.map { |r| Document.new(r) } if result.is_a? Array
|
25
|
+
result.map { |r| Document.new(r) } if result.parsed_response.is_a? Array
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def files
|
29
29
|
result = Client.get "#{entity_endpoint}/files"
|
30
|
-
result.map { |r| File.new(r) } if result.is_a? Array
|
30
|
+
result.map { |r| File.new(r) } if result.parsed_response.is_a? Array
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def output?
|
34
34
|
output == true
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def filename
|
38
38
|
path
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
end
|
42
42
|
end
|
data/lib/siteleaf/content.rb
CHANGED
@@ -3,27 +3,27 @@ module Siteleaf
|
|
3
3
|
|
4
4
|
attr_accessor :title, :body, :path, :permalink, :visibility, :date, :user_id, :site_id, :metadata
|
5
5
|
attr_reader :id, :filename, :basename, :directory, :url, :sha, :created_at, :updated_at
|
6
|
-
|
6
|
+
|
7
7
|
def site
|
8
8
|
Site.find(site_id) if site_id
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def draft?
|
12
12
|
visibility == 'draft'
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def hidden?
|
16
16
|
visibility == 'hidden'
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def visible?
|
20
20
|
visibility == 'visible'
|
21
21
|
end
|
22
22
|
alias_method :published?, :visible?
|
23
|
-
|
23
|
+
|
24
24
|
def to_file
|
25
25
|
SourceFile.new(site_id: site_id, name: filename).to_file
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
end
|
29
29
|
end
|
data/lib/siteleaf/entity.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Siteleaf
|
2
2
|
class Entity
|
3
|
-
|
3
|
+
|
4
4
|
attr_reader :error, :message
|
5
5
|
|
6
6
|
def initialize(attributes = {})
|
@@ -9,7 +9,7 @@ module Siteleaf
|
|
9
9
|
|
10
10
|
def self.all
|
11
11
|
result = Client.get endpoint
|
12
|
-
result.map { |r| new(r) } if result.is_a? Array
|
12
|
+
result.map { |r| new(r) } if result.parsed_response.is_a? Array
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.find(identifier)
|
@@ -20,7 +20,7 @@ module Siteleaf
|
|
20
20
|
def self.create(attributes = {})
|
21
21
|
new(attributes).save
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def self.delete(identifier)
|
25
25
|
Client.delete "#{endpoint}/#{identifier}"
|
26
26
|
end
|
@@ -60,11 +60,11 @@ module Siteleaf
|
|
60
60
|
def create_endpoint
|
61
61
|
self.class.endpoint
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
def entity_endpoint
|
65
65
|
"#{self.class.endpoint}/#{identifier}"
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def identifier
|
69
69
|
id
|
70
70
|
end
|
data/lib/siteleaf/site.rb
CHANGED
@@ -3,79 +3,57 @@ module Siteleaf
|
|
3
3
|
|
4
4
|
attr_accessor :title, :domain, :timezone, :metadata, :defaults
|
5
5
|
attr_reader :id, :user_id, :created_at, :updated_at
|
6
|
-
|
6
|
+
|
7
7
|
def self.find_by_domain(domain)
|
8
8
|
results = Client.get self.endpoint
|
9
9
|
result = results.find {|d| d['domain'] == domain }
|
10
10
|
self.new(result) if result
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def self.import(attrs)
|
14
14
|
result = Client.post "import", attrs
|
15
15
|
Job.new(id: result["job_id"]) if result
|
16
16
|
end
|
17
|
-
|
18
|
-
def source_files(dir = '.')
|
19
|
-
result = Client.get ::File.join(entity_endpoint, "source", dir)
|
20
|
-
result.map { |r| SourceFile.new(r.merge('site_id' => id)) } if result.is_a? Array
|
17
|
+
|
18
|
+
def source_files(dir = '.', opts = {})
|
19
|
+
result = Client.get ::File.join(entity_endpoint, "source", dir), opts
|
20
|
+
result.map { |r| SourceFile.new(r.merge('site_id' => id)) } if result.parsed_response.is_a? Array
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def pages
|
24
24
|
result = Client.get "#{entity_endpoint}/pages"
|
25
|
-
result.map { |r| Page.new(r) } if result.is_a? Array
|
26
|
-
end
|
27
|
-
|
25
|
+
result.map { |r| Page.new(r) } if result.parsed_response.is_a? Array
|
26
|
+
end
|
27
|
+
|
28
28
|
def collections
|
29
29
|
result = Client.get "#{entity_endpoint}/collections"
|
30
|
-
result.map { |r| Collection.new(r) } if result.is_a? Array
|
30
|
+
result.map { |r| Collection.new(r) } if result.parsed_response.is_a? Array
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def posts
|
34
34
|
Collection.new(path: 'posts', site_id: id).documents
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def uploads
|
38
38
|
Collection.new(path: 'uploads', site_id: id).files
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def publish
|
42
42
|
result = Client.post "#{entity_endpoint}/publish", {}
|
43
43
|
Job.new(id: result["job_id"]) if result
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def full_url
|
47
47
|
"http://#{domain}"
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def filename
|
51
51
|
"_config.yml"
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def sha
|
55
55
|
Siteleaf::GitHash.string(to_file)
|
56
56
|
end
|
57
|
-
|
58
|
-
def source_tree(dir = '.')
|
59
|
-
@tree_files = []
|
60
|
-
@tree_dirs = []
|
61
|
-
recursive_source_files(dir)
|
62
|
-
@tree_files
|
63
|
-
end
|
64
|
-
|
65
|
-
protected
|
66
|
-
|
67
|
-
def recursive_source_files(dir = '.')
|
68
|
-
source_files(dir).each do |file|
|
69
|
-
if file.type == 'directory'
|
70
|
-
unless @tree_dirs.include?(file.name)
|
71
|
-
@tree_dirs << file.name
|
72
|
-
recursive_source_files(file.name)
|
73
|
-
end
|
74
|
-
else
|
75
|
-
@tree_files << file
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
57
|
+
|
80
58
|
end
|
81
59
|
end
|
data/lib/siteleaf/source_file.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
module Siteleaf
|
2
2
|
class SourceFile < Entity
|
3
|
-
|
3
|
+
|
4
4
|
attr_accessor :file, :name, :site_id
|
5
5
|
attr_reader :name, :url, :download_url, :type, :filesize, :sha, :created_at, :updated_at, :user_id
|
6
|
-
|
6
|
+
|
7
7
|
def create_endpoint
|
8
8
|
::File.join("sites", site_id, "source", URI.escape(identifier))
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def entity_endpoint
|
12
12
|
create_endpoint
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def identifier
|
16
16
|
name
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def to_file
|
20
20
|
response = Client.get(::File.join("sites", site_id, "source", "#{URI.escape(identifier)}?download"))
|
21
|
-
raise response['message'] if response['message'] # indicates API error
|
22
|
-
response.body
|
21
|
+
raise response['message'] if response.parsed_response.is_a?(Hash) && response['message'] # indicates API error
|
22
|
+
response.body
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
end
|
26
26
|
end
|
data/lib/siteleaf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: siteleaf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siteleaf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.5.1
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Siteleaf Ruby interface
|