diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e70e5abc8f820561b3a63263c5252473362c09a..c42741523e5ac3592d79bc64bee3c7517cd38c13 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,7 @@ test: #- ./generate ../assets/Changelog -o ../html/changelog.html - cd .. - bundle exec jekyll build -d test + - bundle exec ruby rewrite_url_download.rb test/ artifacts: paths: - test @@ -39,6 +40,7 @@ pages: #- ./generate ../assets/Changelog -o ../html/changelog.html - cd .. - bundle exec jekyll build -d public + - bundle exec ruby rewrite_url_download.rb public/ artifacts: paths: - public diff --git a/Gemfile b/Gemfile index 83bc3bdb5620f6dcfb82be6df59251f94735becb..47521ed3d941594b34139317ad86a24787dfc4df 100644 --- a/Gemfile +++ b/Gemfile @@ -30,3 +30,6 @@ gem "wdm", "~> 0.1.1", :install_if => Gem.win_platform? gem 'jekyll-paginate', group: :jekyll_plugins gem 'jekyll-category-pages', group: :jekyll_plugins + +#For rewriting link after generation +gem 'nokogiri' diff --git a/rewrite_url_download.rb b/rewrite_url_download.rb new file mode 100644 index 0000000000000000000000000000000000000000..c3a9c76d4917173c23d766352dd1f6e9e6f3eb5e --- /dev/null +++ b/rewrite_url_download.rb @@ -0,0 +1,12 @@ +require 'cgi' +require 'rubygems' rescue nil +require 'nokogiri' + +Dir.glob(ARGV[0] + '**/*.html') do |file_path| + doc = Nokogiri::HTML(open(file_path)) + doc.css("a").each do |link| + next if link.attributes["href"].nil? or not link.attributes["href"].value.start_with?("/download/") + link.attributes["href"].value = "https://git.frama-c.com/frama-c/frama-c.frama-c.com/raw/master" + link.attributes["href"].value + end + doc.write_to(open(file_path, 'w')) +end