mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-23 12:12:21 -05:00
This was changed for the new `it` in Ruby 3.4, but linuxserver images can't use 3.4 yet, so we re-add the parameter name (as it) for 3.3.
32 lines
764 B
Ruby
32 lines
764 B
Ruby
module PathBuilder
|
|
extend ActiveSupport::Concern
|
|
|
|
def formatted_path
|
|
SiteSettings.model_path_template.gsub(/{.+?}/) do |token|
|
|
case token
|
|
when "{tags}"
|
|
(tags.count > 0) ?
|
|
File.join(tags.order(taggings_count: :desc, name: :asc).map { |it| it.to_s.parameterize }) :
|
|
"@untagged"
|
|
when "{creator}"
|
|
path_component(creator) || "@unattributed"
|
|
when "{collection}"
|
|
path_component(collection) || "@uncollected"
|
|
when "{modelName}"
|
|
path_component(self)
|
|
when "{modelId}"
|
|
"##{id}"
|
|
else
|
|
token
|
|
end
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def path_component(object)
|
|
return nil if object.nil?
|
|
SiteSettings.safe_folder_names ? object.slug : object.name
|
|
end
|
|
end
|