mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
finalize integration of screenshot capture
This commit is contained in:
parent
f54332e5f4
commit
b057ecc7a1
2 changed files with 17 additions and 5 deletions
6
Rakefile
6
Rakefile
|
@ -1,6 +1,10 @@
|
|||
require "rake/testtask"
|
||||
require 'backburner/tasks'
|
||||
|
||||
task :environment do
|
||||
require './environment.rb'
|
||||
end
|
||||
|
||||
desc "Run all tests"
|
||||
Rake::TestTask.new do |t|
|
||||
t.libs << "spec"
|
||||
|
@ -8,4 +12,4 @@ Rake::TestTask.new do |t|
|
|||
t.verbose = true
|
||||
end
|
||||
|
||||
task :default => :test
|
||||
task :default => :test
|
||||
|
|
|
@ -10,7 +10,9 @@ class ScreenshotJob
|
|||
screenshot = Tempfile.new 'neocities_screenshot'
|
||||
screenshot.close
|
||||
|
||||
driver = Selenium::WebDriver.for :remote, url: $config['phantomjs_url']
|
||||
caps = Selenium::WebDriver::Remote::Capabilities.htmlunit javascript_enabled: false, takesScreenshot: true
|
||||
|
||||
driver = Selenium::WebDriver.for :remote, url: $config['phantomjs_url'], desired_capabilities: caps
|
||||
driver.manage.window.resize_to 1280, 720
|
||||
|
||||
wait = Selenium::WebDriver::Wait.new(:timeout => 5) # seconds
|
||||
|
@ -21,8 +23,14 @@ class ScreenshotJob
|
|||
|
||||
driver.quit
|
||||
|
||||
img = Magick::Image.read(screenshot.path).first
|
||||
img.crop_resized!(600, 400, Magick::NorthGravity)
|
||||
img.write File.join(DIR_ROOT, 'public', 'site_screenshots', "#{user}.jpg")
|
||||
img_list = Magick::ImageList.new
|
||||
img_list.read screenshot.path
|
||||
screenshot.unlink
|
||||
img_list.new_image(img_list.first.columns, img_list.first.rows) { self.background_color = "white" }
|
||||
img = img_list.reverse.flatten_images
|
||||
puts 'boners'
|
||||
img.crop!(0, 0, 1280, 720)
|
||||
img.resize! 600, 400
|
||||
img.write File.join(DIR_ROOT, 'public', 'site_screenshots', "#{username}.jpg")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue