Skip to content

Commit 3f8ba6f

Browse files
committed
Add second half of publish.rb changes
First half was included in merge commit by accident :|
1 parent 7e0b178 commit 3f8ba6f

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

publish.rb

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,34 @@
5151
# having cname sends you annoying email
5252
FileUtils.rm 'CNAME'
5353

54-
# prepend ev3dev.github.io to all root-relative urls
55-
basename = ENV['BASENAME'] || "/ev3dev.github.io"
56-
basename = basename.gsub(/@FULL_PATH@/, tmp)
5754
system "git add ."
58-
file_names = `git ls-files | grep '.html$'`
59-
file_names.each_line do |file_name|
60-
file_name = file_name.strip
61-
text = File.read(file_name)
62-
new_contents = text.gsub(/(href|src)="\//, "\\1=\"#{basename}/")
63-
File.open(file_name, "w") { |file| file.puts new_contents }
64-
end
6555

66-
# Do the same thing for seach files
67-
file_name = 'javascripts/search.js'
68-
text = File.read(file_name)
69-
new_contents = text.gsub(/(\/search-index.json)/, "#{basename}\\1")
70-
File.open(file_name, "w") { |file| file.puts new_contents }
56+
unless ARGV.include? "--no-fix-links"
57+
58+
# prepend ev3dev.github.io to all root-relative urls
59+
basename = ENV['BASENAME'] || "/ev3dev.github.io"
60+
basename = basename.gsub(/@FULL_PATH@/, tmp)
61+
62+
file_names = `git ls-files | grep '.html$'`
63+
file_names.each_line do |file_name|
64+
file_name = file_name.strip
65+
text = File.read(file_name)
66+
new_contents = text.gsub(/(href|src)="\//, "\\1=\"#{basename}/")
67+
File.open(file_name, "w") { |file| file.puts new_contents }
68+
end
7169

72-
file_name = 'search-index.json'
73-
text = File.read(file_name)
74-
new_contents = text.gsub(/("href"\s*:\s*")\//, "\\1#{basename}/")
75-
File.open(file_name, "w") { |file| file.puts new_contents }
70+
# Do the same thing for seach files
71+
file_name = 'javascripts/search.js'
72+
text = File.read(file_name)
73+
new_contents = text.gsub(/(\/search-index.json)/, "#{basename}\\1")
74+
File.open(file_name, "w") { |file| file.puts new_contents }
7675

76+
file_name = 'search-index.json'
77+
text = File.read(file_name)
78+
new_contents = text.gsub(/("href"\s*:\s*")\//, "\\1#{basename}/")
79+
File.open(file_name, "w") { |file| file.puts new_contents }
80+
end
81+
7782
if git_url
7883
system "git add ."
7984
message = "Site updated at #{Time.now.utc}"

0 commit comments

Comments
 (0)