mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
fixes and a bit of cleanup for store_file
This commit is contained in:
parent
6ae74c9caf
commit
5b33ebca6b
1 changed files with 4 additions and 7 deletions
|
@ -484,6 +484,7 @@ class Site < Sequel::Model
|
||||||
def store_file(path, uploaded, opts={})
|
def store_file(path, uploaded, opts={})
|
||||||
relative_path = scrubbed_path path
|
relative_path = scrubbed_path path
|
||||||
path = files_path path
|
path = files_path path
|
||||||
|
pathname = Pathname(path)
|
||||||
|
|
||||||
site_file = site_files_dataset.where(path: relative_path).first
|
site_file = site_files_dataset.where(path: relative_path).first
|
||||||
|
|
||||||
|
@ -493,7 +494,7 @@ class Site < Sequel::Model
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if File.extname(relative_path).match /\.#{EDITABLE_FILE_EXT}/
|
if pathname.extname.match EDITABLE_FILE_EXT
|
||||||
open(uploaded.path) {|f|
|
open(uploaded.path) {|f|
|
||||||
matches = f.grep SPAM_MATCH_REGEX
|
matches = f.grep SPAM_MATCH_REGEX
|
||||||
|
|
||||||
|
@ -515,8 +516,6 @@ class Site < Sequel::Model
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
pathname = Pathname(path)
|
|
||||||
|
|
||||||
if pathname.basename.to_s == 'index.html' && opts[:new_install] != true
|
if pathname.basename.to_s == 'index.html' && opts[:new_install] != true
|
||||||
begin
|
begin
|
||||||
new_title = Nokogiri::HTML(File.read(uploaded.path)).css('title').first.text
|
new_title = Nokogiri::HTML(File.read(uploaded.path)).css('title').first.text
|
||||||
|
@ -560,11 +559,9 @@ class Site < Sequel::Model
|
||||||
|
|
||||||
purge_cache path
|
purge_cache path
|
||||||
|
|
||||||
ext = File.extname(path).gsub(/^./, '')
|
if pathname.extname.match HTML_REGEX
|
||||||
|
|
||||||
if ext.match HTML_REGEX
|
|
||||||
ScreenshotWorker.perform_async values[:username], relative_path
|
ScreenshotWorker.perform_async values[:username], relative_path
|
||||||
elsif ext.match IMAGE_REGEX
|
elsif pathname.extname.match IMAGE_REGEX
|
||||||
ThumbnailWorker.perform_async values[:username], relative_path
|
ThumbnailWorker.perform_async values[:username], relative_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue