class BuntoAdmin::Directory
Constants
- TYPE
Attributes
base[R]
content_type[R]
path[R]
splat[R]
Public Class Methods
new(path, base: nil, content_type: nil, splat: nil)
click to toggle source
Arguments:
path - full path of the directory which its entries will be listed
base - passes site.source to generate `relative_path` needed for `to_api`
content_type
- type of the requested directory entries, this is used to generate API endpoint of the directory along with `splat`
splat - the requested directory path relative to content namespace
# File lib/bunto-admin/directory.rb, line 24 def initialize(path, base: nil, content_type: nil, splat: nil) @base = Pathname.new base @content_type = content_type @splat = Pathname.new splat @path = Pathname.new path end
Public Instance Methods
directories()
click to toggle source
# File lib/bunto-admin/directory.rb, line 59 def directories path.entries.map do |entry| next if [".", ".."].include? entry.to_s next unless path.join(entry).directory? self.class.new( path.join(entry), :base => base, :content_type => content_type, :splat => splat ) end.compact! end
http_url()
click to toggle source
# File lib/bunto-admin/directory.rb, line 55 def http_url nil end
relative_path()
click to toggle source
# File lib/bunto-admin/directory.rb, line 40 def relative_path path.relative_path_from(base).to_s end
resource_path()
click to toggle source
# File lib/bunto-admin/directory.rb, line 44 def resource_path if content_type == "pages" "/pages/#{splat}/#{name}" elsif content_type == "data" "/data/#{splat}/#{name}/" else "/collections/#{content_type}/entries/#{splat}/#{name}" end end
Also aliased as: url
to_liquid()
click to toggle source
# File lib/bunto-admin/directory.rb, line 31 def to_liquid { :name => name, :modified_time => modified_time, :path => relative_path, :type => TYPE, } end