Skip to content
Merged
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
16 changes: 12 additions & 4 deletions publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,23 @@
# prepend ev3dev.github.io to all root-relative urls
basename = ENV['BASENAME'] || "/ev3dev.github.io"
basename = basename.gsub(/@FULL_PATH@/, tmp)
file_names = `git ls-files | grep '.html$'`
file_names.each_line do |file_name|

html_file_names = `git ls-files | grep '.html$'`
html_file_names.each_line do |file_name|
file_name = file_name.strip
text = File.read(file_name)
new_contents = text.gsub(/(href|src)="\//, "\\1=\"#{basename}/")
File.open(file_name, "w") { |file| file.puts new_contents }
end

css_file_names = `git ls-files | grep '.css$'`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that explains why it wasn't working.

css_file_names.each_line do |file_name|
file_name = file_name.strip
text = File.read(file_name)
new_contents = text.gsub(/(url\(\s*)"\//, "\\1\"#{basename}/")
File.open(file_name, "w") { |file| file.puts new_contents }
end

# Do the same thing for seach files
file_name = 'javascripts/search.js'
text = File.read(file_name)
Expand All @@ -80,7 +88,7 @@
new_contents = text.gsub(/("href"\s*:\s*")\//, "\\1#{basename}/")
File.open(file_name, "w") { |file| file.puts new_contents }
end

if ARGV.include? '--test'
# run test command
exit(system ARGV[ARGV.index('--test') + 1])
Expand Down