Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ fetch-remote:
- "docs/deprecated.md"
- dest: "engine/reference"
src:
- "docs/reference/builder.md"
- "docs/reference/run.md"
- dest: "engine/reference/commandline"
src:
Expand Down Expand Up @@ -174,3 +173,11 @@ fetch-remote:
- dest: "registry"
src:
- "docs/configuration.md"

- repo: "https://github.com/moby/buildkit"
default_branch: "master"
ref: "master"
paths:
- dest: "engine/reference/builder.md"
src:
- "frontend/dockerfile/docs/reference.md"
56 changes: 33 additions & 23 deletions _plugins/fetch_remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,40 @@
require 'rake'

module Jekyll
def self.download(url, dest)
uri = URI.parse(url)
result = File.join(dest, File.basename(uri.path))
puts " Downloading #{url}"
IO.copy_stream(URI.open(url), result)
return result
end
class FetchRemote < Octopress::Hooks::Site
priority :highest

def self.copy(src, dest)
if (tmp = Array.try_convert(src))
tmp.each do |s|
s = File.path(s)
yield s, File.join(dest, File.basename(s))
end
else
src = File.path(src)
if File.directory?(dest)
yield src, File.join(dest, File.basename(src))
def self.download(url, dest)
uri = URI.parse(url)
result = File.join(dest, File.basename(uri.path))
puts " Downloading #{url}"
IO.copy_stream(URI.open(url), result)
return result
end

def self.copy(src, dest)
if (tmp = Array.try_convert(src))
tmp.each do |s|
s = File.path(s)
yield s, File.join(dest, File.basename(s))
end
else
yield src, File.path(dest)
src = File.path(src)
if File.directory?(dest)
yield src, File.join(dest, File.basename(src))
else
yield src, File.path(dest)
end
end
end
end

class FetchRemote < Octopress::Hooks::Site
def pre_read(site)
beginning_time = Time.now
puts "Starting plugin fetch_remote.rb..."
site.config['fetch-remote'].each do |entry|
puts " Repo #{entry['repo']} (#{entry['ref']})"
Dir.mktmpdir do |tmpdir|
tmpfile = Jekyll.download("#{entry['repo']}/archive/#{entry['ref']}.zip", tmpdir)
tmpfile = FetchRemote.download("#{entry['repo']}/archive/#{entry['ref']}.zip", tmpdir)
Dir.mktmpdir do |ztmpdir|
puts " Extracting #{tmpfile}"
Archive::Zip.extract(
Expand All @@ -46,7 +48,15 @@ def pre_read(site)
:create => true
)
entry['paths'].each do |path|
FileUtils.mkdir_p path['dest']
if File.extname(path['dest']) != ""
if path['src'].size > 1
raise "Cannot use file destination #{path['dest']} with multiple sources"
end
FileUtils.mkdir_p File.dirname(path['dest'])
else
FileUtils.mkdir_p path['dest']
end

puts " Copying files"

# prepare file list to be copied
Expand All @@ -60,7 +70,7 @@ def pre_read(site)
end

files.each do |file|
Jekyll.copy(file, path['dest']) do |s, d|
FetchRemote.copy(file, path['dest']) do |s, d|
s = File.realpath(s)
# traverse source directory
FileUtils::Entry_.new(s, nil, false).wrap_traverse(proc do |ent|
Expand Down
2 changes: 0 additions & 2 deletions _plugins/fix_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 'octopress-hooks'

module Jekyll

class FetchRemote < Octopress::Hooks::Site
def post_read(site)
beginning_time = Time.now
Expand All @@ -20,5 +19,4 @@ def post_read(site)
Jekyll.logger.info "done in #{(end_time - beginning_time)} seconds"
end
end

end
2 changes: 0 additions & 2 deletions _plugins/update_api_toc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 'octopress-hooks'

module Jekyll

class UpdateApiToc < Octopress::Hooks::Site
def pre_read(site)
beginning_time = Time.now
Expand All @@ -22,5 +21,4 @@ def pre_read(site)
Jekyll.logger.info "done in #{(end_time - beginning_time)} seconds"
end
end

end