blob: a7cea940d3251fa663b22b3c4cdd47383887ff11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
module Gitlab
class SymlinksConverter
EXTENTIONS = ['png', 'jpg', 'gif', 'svg']
def initialize(config, items)
@config = config
@items = items
end
def self.run(config, items)
new(config, items).run
end
def run
return unless Nanoc::Helpers::Generic.is_omnibus?
items.each do |item|
id = item.identifier
next unless id.to_s.start_with?('/ee/')
if EXTENTIONS.include?(id.ext)
file_path = File.join(config.fetch(:content_dir), id.to_s)
real_path = Pathname.new(file_path).realpath.to_s
symlink = File.join(config.output_dir, id.to_s)
# Replace a file with a symlink
File.delete(symlink) && File.symlink(real_path, symlink) if File.exist?(symlink)
end
end
end
private
attr_reader :config, :items
end
end
|