class JekyllAdmin::Directory

Constants

DOT_DIRECTORIES
RESOURCE_TYPES

Attributes

base[R]
content_type[R]
path[R]
splat[R]

Public Class Methods

new(path, base:, splat:, content_type:) click to toggle source

Parameters:

path - The full path of the directory at which its entries will be listed.

Named parameters:

        base: - The full path to the directory from source.
       splat: - The requested directory path relative to content namespace.
content_type: - The type of the requested directory entries. Corresponds to
                the resources' API namespace.
# File lib/jekyll-admin/directory.rb, line 27
def initialize(path, base:, splat:, content_type:)
  @path  = Pathname.new path
  @base  = Pathname.new base
  @splat = Pathname.new splat
  @content_type = content_type
end

Public Instance Methods

directories() click to toggle source
# File lib/jekyll-admin/directory.rb, line 60
def directories
  path.entries.map do |entry|
    next if DOT_DIRECTORIES.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/jekyll-admin/directory.rb, line 56
def http_url
  nil
end
relative_path() click to toggle source
# File lib/jekyll-admin/directory.rb, line 43
def relative_path
  @relative_path ||= path.relative_path_from(base).to_s
end
resource_path() click to toggle source
# File lib/jekyll-admin/directory.rb, line 47
def resource_path
  if RESOURCE_TYPES.include?(content_type)
    "/#{content_type}/#{splat}/#{name}"
  else
    "/collections/#{content_type}/entries/#{splat}/#{name}"
  end
end
Also aliased as: url
to_liquid() click to toggle source
# File lib/jekyll-admin/directory.rb, line 34
def to_liquid
  {
    "name"          => name,
    "modified_time" => modified_time,
    "path"          => relative_path,
    "type"          => "directory",
  }
end
url()
Alias for: resource_path