Top Level Namespace

Defined Under Namespace

Modules: Jekyll

Instance Method Summary collapse

Instance Method Details

#copy_resource_contents(resource_cfg, site_dest) ⇒ Object



11
12
13
# File 'lib/jekyll-theme-isotc211-helpers/resource_copy.rb', line 11

def copy_resource_contents(resource_cfg, site_dest)
  FileUtils.cp_r("#{resource_cfg['resource_root']}/.", "#{site_dest}/#{resource_cfg['index_url']}")
end

#directory_hash(path, name = nil, level = 0) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/jekyll-theme-isotc211-helpers/resource_listing.rb', line 115

def directory_hash(path, name=nil, level=0)
  data = {
    'data' => (name || path),
    'full_path' => path,
    'level' => level,
  }
  data['children'] = children = []

  # Increment nesting indicator
  level += 1

  Dir.foreach(path) do |entry|
    next if (entry == '..' || entry == '.')

    full_path = File.join(path, entry)

    if File.directory?(full_path)
      children << directory_hash(full_path, entry, level=level)
    else
      children << {
        'data' => entry,
        'full_path' => full_path,
        'level' => level,
      }
    end
  end

  return data
end