siteleaf 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 046b60a59a32c75e4294c753c2593933a1cc4c7f4bd631d063680810f9c9c4ac
4
- data.tar.gz: d5d9312cab00db6b14ad706420649f008bd12382d1a54f3ef030fb90601c0024
3
+ metadata.gz: 2bd0d1ce58e3d7f0059cd0139fac42e5111efc232ee2cf758dc541088c9cc49f
4
+ data.tar.gz: ed3a5393e428f18c0f86f0e0709e5f6ea57990512aff8dfe726233a1599bfde1
5
5
  SHA512:
6
- metadata.gz: e1c28c75af43d0c5472d721dc228c76c553d3f1aecc688c0911862b226ddacb080d09f7d3051fd3f9daa92b1bccb313006ea717dc5846ccdd0d632b89a84037e
7
- data.tar.gz: d6a2293493b93183677f2e287adcdd5be234c7a2115fda7d78461722bd2537c0e4cb3adfba55a8caef5a3e344e5baf1f3ddb3ec272db69a854d05eaff0623746
6
+ metadata.gz: f4510e656e0fd8ecfe51d46bc0548e2af4a351fc7d6d7f9f76a3d77db9c133042c742c3fef8a8717696bcff70a18cf0ebe8c6771ff9c7cf980e7c271b73e4a65
7
+ data.tar.gz: d03897ef87c4a63b09487ff843ad129940f63e5704e94054b9724b6ce63e96af60b1e19f4ccde4bf2379c3f44226a4498f6aaa568eaff66de0a2965ade0123d9
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <img alt="Siteleaf" src="https://learn.siteleaf.com/assets/images/logo.svg" width="10%">
2
2
 
3
- Siteleaf v2 Gem
4
- ===============
3
+ Siteleaf v2 Gem & CLI
4
+ =====================
5
5
 
6
6
  - [Prerequisites](#prerequisites)
7
7
  - [Installation](#installation)
@@ -79,6 +79,12 @@ To download your theme (or the default theme for new sites) from Siteleaf, run t
79
79
  To publish your site changes to your hosting provider, run the following command:
80
80
 
81
81
  siteleaf publish
82
+
83
+ **Clean unused uploads:**
84
+
85
+ To check for unused uploads and tidy up disk space (runs locally):
86
+
87
+ siteleaf clean _uploads
82
88
 
83
89
  **For a full list of commands, run:**
84
90
 
data/bin/siteleaf CHANGED
@@ -16,6 +16,7 @@ Commands:
16
16
  auth Login in with your credentials
17
17
  c, config DOMAIN Configure an existing directory
18
18
  n, new DOMAIN Creates new site on siteleaf.net
19
+ clean Clean up unused uploads
19
20
  pull Pulls files for configured site from Siteleaf
20
21
  push Pushes all files in dir to configured site
21
22
  publish Publish website to hosting provider
@@ -93,7 +94,7 @@ def pull(site_id)
93
94
  puts path
94
95
  end
95
96
  print '(y/n)? '
96
- if $stdin.gets.chomp == 'y'
97
+ if $stdin.gets.chomp.downcase == 'y'
97
98
  missing_files.each do |path|
98
99
  print "Deleting #{path}..."
99
100
  ::File.delete(path)
@@ -210,6 +211,42 @@ def preview(site_id, quiet = true)
210
211
  end
211
212
  end
212
213
 
214
+ def clean(path = '_uploads')
215
+ searcher = if system('which ag', out: File::NULL)
216
+ ['ag', '-lQ']
217
+ else
218
+ puts "\nWarning: Silver Searcher not found, install for faster results (https://geoff.greer.fm/ag/)\n"
219
+ ['grep', '-lr']
220
+ end
221
+
222
+ puts "\nBuilding Jekyll site..."
223
+ system 'bundle exec jekyll build --future --unpublished --drafts'
224
+
225
+ puts "\nFinding unused files..."
226
+ unused = Dir.glob("#{path}/**/*").select do |file|
227
+ next unless File.file? file
228
+ escaped = Jekyll::URL.escape_path file
229
+
230
+ found = system(*searcher, escaped.sub(/^_/, '/'), '_site', out: File::NULL) ||
231
+ system(*searcher, file.sub(/^_/, '/'), '_site', out: File::NULL)
232
+
233
+ if !found
234
+ puts file
235
+ true
236
+ end
237
+ end
238
+
239
+ if unused.length == 0
240
+ puts "\nNo unused files found."
241
+ else
242
+ puts "=> Delete above #{unused.length} file(s)? (y/n)"
243
+ if $stdin.gets.chomp.downcase == 'y'
244
+ FileUtils.rm unused
245
+ puts "=> #{unused.size} file(s) deleted."
246
+ end
247
+ end
248
+ end
249
+
213
250
  def config(site)
214
251
  Siteleaf.save_settings({site_id: site.id}, '.siteleaf.yml')
215
252
  puts "=> Site configured."
@@ -325,6 +362,8 @@ begin
325
362
  import(file, quiet)
326
363
  end
327
364
  end
365
+ when 'clean'
366
+ ARGV[1] ? clean(ARGV[1]) : clean
328
367
  else
329
368
  puts "Error: `#{ARGV[0]}` command not found.\n"
330
369
  puts help
@@ -0,0 +1,12 @@
1
+ module Siteleaf
2
+ class Role < Entity
3
+
4
+ attr_accessor :kind, :user_id, :site_id
5
+ attr_reader :id, :created_at, :updated_at
6
+
7
+ def create_endpoint
8
+ "sites/#{site_id}/roles"
9
+ end
10
+
11
+ end
12
+ end
data/lib/siteleaf/site.rb CHANGED
@@ -48,6 +48,11 @@ module Siteleaf
48
48
  Job.new(id: result["job_id"]) if result
49
49
  end
50
50
 
51
+ def users
52
+ result = Client.get "#{entity_endpoint}/users"
53
+ result.map { |r| User.new(r) } if result.is_a? Array
54
+ end
55
+
51
56
  def full_url
52
57
  "http://#{domain}"
53
58
  end
@@ -1,3 +1,3 @@
1
1
  module Siteleaf
2
- VERSION = "2.2.0"
2
+ VERSION = "2.3.0"
3
3
  end
data/lib/siteleaf.rb CHANGED
@@ -14,6 +14,7 @@ require 'siteleaf/document'
14
14
  require 'siteleaf/site'
15
15
  require 'siteleaf/source_file'
16
16
  require 'siteleaf/user'
17
+ require 'siteleaf/role'
17
18
  require 'digest/sha1'
18
19
  require 'rbconfig'
19
20
  require 'uri'
data/siteleaf.gemspec CHANGED
@@ -16,7 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.required_ruby_version = '>= 1.9.3'
17
17
 
18
18
  gem.add_dependency 'httparty', '>= 0.16.0'
19
- gem.add_dependency 'psych', '>= 2.1.0'
20
19
  gem.add_dependency 'jekyll', '>= 1.4.1'
21
20
  gem.add_dependency 'rack'
22
21
 
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.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siteleaf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-20 00:00:00.000000000 Z
11
+ date: 2024-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.16.0
27
- - !ruby/object:Gem::Dependency
28
- name: psych
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.1.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 2.1.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: jekyll
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +77,7 @@ files:
91
77
  - lib/siteleaf/git_hash.rb
92
78
  - lib/siteleaf/job.rb
93
79
  - lib/siteleaf/page.rb
80
+ - lib/siteleaf/role.rb
94
81
  - lib/siteleaf/site.rb
95
82
  - lib/siteleaf/source_file.rb
96
83
  - lib/siteleaf/user.rb