app/models/scribo/content.rb in scribo-1.0.42 vs app/models/scribo/content.rb in scribo-1.0.43
- old
+ new
@@ -7,19 +7,23 @@
class Content < ApplicationRecord
has_closure_tree
belongs_to :site, class_name: 'Site', foreign_key: 'scribo_site_id'
has_one_attached :asset
+
+
validate :post_path
validate :layout_cant_be_current_content
before_save :store_properties, if: :config?
before_save :upload_asset
after_save -> { store_full_path(true) }
after_update -> {store_full_path(true)}
+
+
scope :layouts, -> { in_folder('_layouts') }
scope :posts, -> { in_folder('_posts') }
scope :pages, -> { not_in_folder('_posts').restricted.where(kind: 'text') }
scope :assets, -> { where(kind: 'asset') }
scope :html_pages, -> { where("full_path LIKE '%.html' OR full_path LIKE '%.md' OR full_path LIKE '%.markdown'") }
@@ -299,11 +303,11 @@
result += date.strftime('%Y/%m/%d/') if date
result += path[11..-1]
elsif part_of_collection? && site.output_collection?(collection_name)
result = "#{collection_name}/#{path}"
else
- result = (ancestors.map(&:path) << path).join('/')
+ result = (ancestors.reverse.map(&:path) << path).join('/')
end
result = '/' + result unless result.start_with?('/')
update_column(:full_path, result)
@@ -311,12 +315,11 @@
child.store_full_path(true)
end
end
end
-
def tree_path
- result = (ancestors.map(&:path) << path).join('/')
+ result = (ancestors.reverse.map(&:path) << path).join('/')
result = '/' + result unless result.start_with?('/')
result
end
private