From 642bcb4d7c22ea6688751455670080c81c1149d4 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Thu, 26 Jan 2017 16:33:07 -0600 Subject: automatically correct CSS urls on assets:precompile --- lib/tasks/assets.rake | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lib/tasks/assets.rake (limited to 'lib/tasks') diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake new file mode 100644 index 00000000000..aca2a318b31 --- /dev/null +++ b/lib/tasks/assets.rake @@ -0,0 +1,10 @@ +namespace :assets do + desc 'GitLab | Assets | Fix Absolute URLs in CSS' + task :precompile do + css_files = Dir['public/assets/*.css'] + css_files.each do | file | + puts "Fixing #{file}" + system "sed", "-i", "-e", 's/url(\([\"\']\?\)\/assets\//url(\1.\//g', file + end + end +end -- cgit v1.2.1 From 0ed86119b08ed99d5fa193a5742a1d1de350d3a3 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Thu, 26 Jan 2017 16:33:22 -0600 Subject: correct gzip files if they exist as well --- lib/tasks/assets.rake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/tasks') diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index aca2a318b31..33a0ad26d0e 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -3,8 +3,27 @@ namespace :assets do task :precompile do css_files = Dir['public/assets/*.css'] css_files.each do | file | + # replace url(/assets/*) with url(./*) puts "Fixing #{file}" system "sed", "-i", "-e", 's/url(\([\"\']\?\)\/assets\//url(\1.\//g', file + + # rewrite the corresponding gzip file (if it exists) + gzip = "#{file}.gz" + if File.exist?(gzip) + puts "Fixing #{gzip}" + + FileUtils.rm(gzip) + mtime = File.stat(file).mtime + + File.open(gzip, 'wb+') do |f| + gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION) + gz.mtime = mtime + gz.write IO.binread(file) + gz.close + + File.utime(mtime, mtime, f.path) + end + end end end end -- cgit v1.2.1 From 336d780d95ae30819262782e8ce079b58082a3e9 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Fri, 27 Jan 2017 12:58:50 -0600 Subject: namespace assets rake tasks to gitlab:assets:* --- lib/tasks/assets.rake | 29 --------------------------- lib/tasks/gitlab/assets.rake | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 29 deletions(-) delete mode 100644 lib/tasks/assets.rake create mode 100644 lib/tasks/gitlab/assets.rake (limited to 'lib/tasks') diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake deleted file mode 100644 index 33a0ad26d0e..00000000000 --- a/lib/tasks/assets.rake +++ /dev/null @@ -1,29 +0,0 @@ -namespace :assets do - desc 'GitLab | Assets | Fix Absolute URLs in CSS' - task :precompile do - css_files = Dir['public/assets/*.css'] - css_files.each do | file | - # replace url(/assets/*) with url(./*) - puts "Fixing #{file}" - system "sed", "-i", "-e", 's/url(\([\"\']\?\)\/assets\//url(\1.\//g', file - - # rewrite the corresponding gzip file (if it exists) - gzip = "#{file}.gz" - if File.exist?(gzip) - puts "Fixing #{gzip}" - - FileUtils.rm(gzip) - mtime = File.stat(file).mtime - - File.open(gzip, 'wb+') do |f| - gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION) - gz.mtime = mtime - gz.write IO.binread(file) - gz.close - - File.utime(mtime, mtime, f.path) - end - end - end - end -end diff --git a/lib/tasks/gitlab/assets.rake b/lib/tasks/gitlab/assets.rake new file mode 100644 index 00000000000..5d884bf9f66 --- /dev/null +++ b/lib/tasks/gitlab/assets.rake @@ -0,0 +1,47 @@ +namespace :gitlab do + namespace :assets do + desc 'GitLab | Assets | Compile all frontend assets' + task :compile do + Rake::Task['assets:precompile'].invoke + Rake::Task['gitlab:assets:fix_urls'].invoke + end + + desc 'GitLab | Assets | Clean up old compiled frontend assets' + task :clean do + Rake::Task['assets:clean'].invoke + end + + desc 'GitLab | Assets | Remove all compiled frontend assets' + task :purge do + Rake::Task['assets:clobber'].invoke + end + + desc 'GitLab | Assets | Fix all absolute url references in CSS' + task :fix_urls do + css_files = Dir['public/assets/*.css'] + css_files.each do | file | + # replace url(/assets/*) with url(./*) + puts "Fixing #{file}" + system "sed", "-i", "-e", 's/url(\([\"\']\?\)\/assets\//url(\1.\//g', file + + # rewrite the corresponding gzip file (if it exists) + gzip = "#{file}.gz" + if File.exist?(gzip) + puts "Fixing #{gzip}" + + FileUtils.rm(gzip) + mtime = File.stat(file).mtime + + File.open(gzip, 'wb+') do |f| + gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION) + gz.mtime = mtime + gz.write IO.binread(file) + gz.close + + File.utime(mtime, mtime, f.path) + end + end + end + end + end +end -- cgit v1.2.1 From 89a2438ab44862b34ba1030761c27b37059389ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 31 Jan 2017 17:37:31 +0100 Subject: Fix wrong call to ProjectCacheWorker.perform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's either ProjectCacheWorker#perform or ProjectCacheWorker.perform_async! Signed-off-by: Rémy Coutable --- lib/tasks/gitlab/import.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/tasks') diff --git a/lib/tasks/gitlab/import.rake b/lib/tasks/gitlab/import.rake index a2eca74a3c8..036a9307ab5 100644 --- a/lib/tasks/gitlab/import.rake +++ b/lib/tasks/gitlab/import.rake @@ -63,7 +63,7 @@ namespace :gitlab do if project.persisted? puts " * Created #{project.name} (#{repo_path})".color(:green) - ProjectCacheWorker.perform(project.id) + ProjectCacheWorker.perform_async(project.id) else puts " * Failed trying to create #{project.name} (#{repo_path})".color(:red) puts " Errors: #{project.errors.messages}".color(:red) -- cgit v1.2.1