scribo 1.0.40 → 1.0.41

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: 2038388c9a53be7434cab9d09df117b3f6754bb2b58caa6725fb90e1dcc5f850
4
- data.tar.gz: 481ba9937602ced2dbde21c2082707e6f2b49af8eeb0847d473dd5b4bc01a05b
3
+ metadata.gz: b8d2faa173e2061b2cd692143e967c54c698703b7cf73dded3ab099ce90d4acb
4
+ data.tar.gz: 64192e917ef3cb45d88dacb9b379d055498880ffc016c752b91fb59b76f99d8a
5
5
  SHA512:
6
- metadata.gz: c19a2c507c6c58f2591e638f87015d12e2394e7185ba5271fc0f70f899cf44d61f70f81faed86a190fb84a1676e460252ba6b0d7093e842104a8e39b7a958d38
7
- data.tar.gz: 6296a79e4e9d8a1a519bd4d1139f1a70329b9d6e67694e69784a4d4f3abb7ca375692dd124927b977a4192c2d3919a8f80c69fc3433f1e05d3de564da1fba92f
6
+ metadata.gz: 94026a265b5a827cfb849e4ab89a761824df95be4f53f16c341cea9e3eead02a82ccc36214621c1765c08262ced4ca51f5b6c4e063228cc755b3822bd1dce7a2
7
+ data.tar.gz: 7a6f297f8c9153d6651ebbac27c33db3c1fa72d7397efb68fa79e1524c2929e2155edebcbfab0d324ed19336842304a8c2bdee388b6316a872244c15b7701296
data/Gemfile CHANGED
@@ -26,6 +26,8 @@ gem 'key_path', github: 'entdec/keypath-ruby.git', branch: 'master'
26
26
  gem 'rubocop'
27
27
  gem 'signum'
28
28
 
29
+ gem 'closure_tree'
30
+
29
31
  group :test do
30
32
  gem 'pry-rails'
31
33
  end
@@ -5,7 +5,7 @@ require_dependency 'scribo/application_record'
5
5
  module Scribo
6
6
  # Represents any content in the system
7
7
  class Content < ApplicationRecord
8
- has_ancestry(primary_key_format: /\A[\w\-]+(\/[\w\-]+)*\z/, counter_cache: true, cache_depth: true)
8
+ has_closure_tree
9
9
  belongs_to :site, class_name: 'Site', foreign_key: 'scribo_site_id'
10
10
  has_one_attached :asset
11
11
 
@@ -293,7 +293,7 @@ module Scribo
293
293
  end
294
294
 
295
295
  def store_full_path(force = false)
296
- if force || saved_changes.include?(:path) || saved_changes.include?(:ancestry)
296
+ if force || saved_changes.include?(:path) || saved_changes.include?(:parent_id)
297
297
  if post?
298
298
  result = categories.join('/') + '/'
299
299
  result += date.strftime('%Y/%m/%d/') if date
@@ -310,10 +310,10 @@ module Scribo
310
310
  children.reload.each do |child|
311
311
  child.store_full_path(true)
312
312
  end
313
-
314
313
  end
315
314
  end
316
315
 
316
+
317
317
  def tree_path
318
318
  result = (ancestors.map(&:path) << path).join('/')
319
319
  result = '/' + result unless result.start_with?('/')
@@ -31,7 +31,7 @@ module Scribo
31
31
  site.contents.located(File.dirname(name), restricted: false).first
32
32
  end
33
33
  content = parent.children.find_by(path: File.basename(name)) if parent
34
- content = site.contents.find_by(path: File.basename(name), ancestry: nil) if parent.nil? && content.nil?
34
+ content = site.contents.find_by(path: File.basename(name), parent_id: nil) if parent.nil? && content.nil?
35
35
  content = site.contents.create!(path: File.basename(name), parent: parent) if content.nil?
36
36
  if File.directory?(name)
37
37
  content.kind = 'folder'
@@ -0,0 +1,5 @@
1
+ class AddParentIdToScriboContents < ActiveRecord::Migration[7.1]
2
+ def change
3
+ add_column :scribo_contents, :parent_id, :uuid
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ class CreateScriboContentHierarchies < ActiveRecord::Migration[7.1]
2
+ def change
3
+ create_table :scribo_content_hierarchies, id: false do |t|
4
+ t.uuid :ancestor_id, null: false
5
+ t.uuid :descendant_id, null: false
6
+ t.integer :generations, null: false
7
+ end
8
+
9
+ add_index :scribo_content_hierarchies, [:ancestor_id, :descendant_id, :generations],
10
+ unique: true,
11
+ name: "content_anc_desc_idx"
12
+
13
+ add_index :scribo_content_hierarchies, [:descendant_id],
14
+ name: "content_desc_idx"
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Scribo
4
- VERSION = '1.0.40'
4
+ VERSION = '1.0.41'
5
5
  end
data/lib/scribo.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ancestry'
3
+ require 'closure_tree'
4
4
  require 'down'
5
5
  require 'kaminari'
6
6
  require 'liquid'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scribo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.40
4
+ version: 1.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-25 00:00:00.000000000 Z
11
+ date: 2024-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ancestry
@@ -1074,6 +1074,8 @@ files:
1074
1074
  - db/migrate/20200123095630_initial_scribo.rb
1075
1075
  - db/migrate/20220919124119_add_ancestry_to_scribo_contents.rb
1076
1076
  - db/migrate/20220919124749_remove_parent_id_from_scribo_contents.rb
1077
+ - db/migrate/20240603090353_add_parent_id_to_scribo_contents.rb
1078
+ - db/migrate/20240625131154_create_scribo_content_hierarchies.rb
1077
1079
  - docs/content.md
1078
1080
  - docs/editor.png
1079
1081
  - docs/features.md