mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
catch errors with titles, run sidekiq jobs immediately in development
This commit is contained in:
parent
3fa67447bb
commit
c93d0bbc7f
2 changed files with 23 additions and 5 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue