catch errors with titles, run sidekiq jobs immediately in development

This commit is contained in:
Kyle Drake 2014-09-16 22:05:37 -07:00
parent 3fa67447bb
commit c93d0bbc7f
2 changed files with 23 additions and 5 deletions

View file

@ -54,6 +54,21 @@ Sidekiq.configure_client do |config|
config.redis = sidekiq_redis_config
end
# :nocov:
if ENV['RACK_ENV'] == 'development'
# Run async jobs immediately in development.
module Sidekiq
module Worker
module ClassMethods
def perform_async(*args)
self.new.perform *args
end
end
end
end
end
# :nocov:
# :nocov:
if $config['pubsub_url']
$pubsub_pool = ConnectionPool.new(size: 10, timeout: 5) {

View file

@ -415,10 +415,13 @@ class Site < Sequel::Model
pathname = Pathname(path)
if pathname.basename.to_s == 'index.html'
new_title = Nokogiri::HTML(File.read(uploaded.path)).css('title').first.text
if new_title.length < TITLE_MAX
self.title = new_title
begin
new_title = Nokogiri::HTML(File.read(uploaded.path)).css('title').first.text
rescue NoMethodError => e
else
if new_title.length < TITLE_MAX
self.title = new_title
end
end
self.site_changed = true
@ -786,7 +789,7 @@ class Site < Sequel::Model
def title
if values[:title].nil? || values[:title].empty?
domain ? domain : "#{username}.neocities.org"
!domain.nil? && !domain.empty? ? domain : "#{username}.neocities.org"
else
values[:title]
end