scale phantomjs, enable js for screenshots, strong browse visits

This commit is contained in:
Kyle Drake 2013-06-23 15:40:46 -07:00
parent 90e40168a2
commit c2ff6ca2e4
4 changed files with 11 additions and 5 deletions

2
app.rb
View file

@ -119,7 +119,7 @@ post '/site_files/upload' do
mime_type = Magic.guess_file_mime_type params[:newfile][:tempfile].path mime_type = Magic.guess_file_mime_type params[:newfile][:tempfile].path
unless Site::VALID_MIME_TYPES.include?(mime_type) && Site::VALID_EXTENSIONS.include?(File.extname(params[:newfile][:filename]).sub(/^./, '')) unless (Site::VALID_MIME_TYPES.include?(mime_type) || mime_type =~ /text/) && Site::VALID_EXTENSIONS.include?(File.extname(params[:newfile][:filename]).sub(/^./, ''))
@errors << 'File must me one of the following: HTML, Text, Image (JPG PNG GIF JPEG SVG), JS, CSS, Markdown.' @errors << 'File must me one of the following: HTML, Text, Image (JPG PNG GIF JPEG SVG), JS, CSS, Markdown.'
halt slim(:'site_files/new') halt slim(:'site_files/new')
end end

View file

@ -45,3 +45,9 @@ DB.loggers << Logger.new(STDOUT) if ENV['RACK_ENV'] == 'development'
if ENV['RACK_ENV'] == 'development' && Server.count == 0 if ENV['RACK_ENV'] == 'development' && Server.count == 0
Server.create ip: '127.0.0.1', slots_available: 999999 Server.create ip: '127.0.0.1', slots_available: 999999
end end
Backburner.configure do |config|
config.max_job_retries = 3
config.retry_delay = 200
config.respond_timeout = 20
end

View file

@ -10,9 +10,9 @@ class ScreenshotJob
screenshot = Tempfile.new 'neocities_screenshot' screenshot = Tempfile.new 'neocities_screenshot'
screenshot.close screenshot.close
caps = Selenium::WebDriver::Remote::Capabilities.htmlunit javascript_enabled: false, takesScreenshot: true caps = Selenium::WebDriver::Remote::Capabilities.htmlunit javascript_enabled: true, takesScreenshot: true
driver = Selenium::WebDriver.for :remote, url: $config['phantomjs_url'], desired_capabilities: caps driver = Selenium::WebDriver.for :remote, url: $config['phantomjs_url'][rand($config['phantomjs_url'].length)], desired_capabilities: caps
driver.manage.window.resize_to 1280, 720 driver.manage.window.resize_to 1280, 720
wait = Selenium::WebDriver::Wait.new(:timeout => 5) # seconds wait = Selenium::WebDriver::Wait.new(:timeout => 5) # seconds

View file

@ -3,7 +3,7 @@
div div
h1 Web Sites on NeoCities h1 Web Sites on NeoCities
p If you like a site, don't forget to bookmark it!<br>Visitor counts are updated hourly. p If you like a site, don't forget to bookmark it!<br>Visitor counts are updated hourly.
div style="margin-bottom: 40px": .btn.btn-success Create your NeoCities site now div style="margin-bottom: 40px": a.btn.btn-success href="/new" Create your NeoCities site now
- count = 0 - count = 0
- @sites.each_with_index do |site,i| - @sites.each_with_index do |site,i|
- if count == 0 - if count == 0
@ -16,7 +16,7 @@
.span1 .span1
h5: b style="margin-left: 20px": a href="http://#{site.username}.neocities.org" target="_blank" #{site.username} h5: b style="margin-left: 20px": a href="http://#{site.username}.neocities.org" target="_blank" #{site.username}
.span3.text-right .span3.text-right
p style="margin-right: 20px; margin-top: 10px; font-size: 10pt" #{site.hits} visits, updated #{site.updated_at.ago} p style="margin-right: 20px; margin-top: 10px; font-size: 10pt" <strong>#{site.hits} visits</strong>, updated #{site.updated_at.ago}
a href="http://#{site.username}.neocities.org" target="_blank": img src="/site_screenshots/#{ENV['RACK_ENV'] == 'development' ? 'victoria' : site.username}.jpg" a href="http://#{site.username}.neocities.org" target="_blank": img src="/site_screenshots/#{ENV['RACK_ENV'] == 'development' ? 'victoria' : site.username}.jpg"
- if @page_count > 1 - if @page_count > 1