mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
only take screenshot for index change
This commit is contained in:
parent
87c733c932
commit
f54332e5f4
1 changed files with 7 additions and 7 deletions
14
app.rb
14
app.rb
|
@ -75,7 +75,7 @@ post '/create' do
|
||||||
redirect '/dashboard'
|
redirect '/dashboard'
|
||||||
else
|
else
|
||||||
@site.errors.add :captcha, 'You must type in the two words correctly! Try again.' if !recaptcha_is_valid
|
@site.errors.add :captcha, 'You must type in the two words correctly! Try again.' if !recaptcha_is_valid
|
||||||
|
|
||||||
slim :'/new'
|
slim :'/new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -142,8 +142,8 @@ post '/site_files/upload' do
|
||||||
dest_path = File.join(site_base_path(current_site.username), sanitized_filename)
|
dest_path = File.join(site_base_path(current_site.username), sanitized_filename)
|
||||||
FileUtils.mv params[:newfile][:tempfile].path, dest_path
|
FileUtils.mv params[:newfile][:tempfile].path, dest_path
|
||||||
File.chmod(0640, dest_path) if self.class.production?
|
File.chmod(0640, dest_path) if self.class.production?
|
||||||
|
|
||||||
Backburner.enqueue ScreenshotJob, current_site.username
|
Backburner.enqueue(ScreenshotJob, current_site.username) if sanitized_filename =~ /index\.html/
|
||||||
|
|
||||||
flash[:success] = "Successfully uploaded file #{sanitized_filename}."
|
flash[:success] = "Successfully uploaded file #{sanitized_filename}."
|
||||||
redirect '/dashboard'
|
redirect '/dashboard'
|
||||||
|
@ -174,7 +174,7 @@ get '/site_files/:username.zip' do |username|
|
||||||
|
|
||||||
content_type 'application/octet-stream'
|
content_type 'application/octet-stream'
|
||||||
attachment "#{current_site.username}.zip"
|
attachment "#{current_site.username}.zip"
|
||||||
|
|
||||||
return zipfile
|
return zipfile
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -189,21 +189,21 @@ end
|
||||||
|
|
||||||
post '/site_files/save/:filename' do |filename|
|
post '/site_files/save/:filename' do |filename|
|
||||||
tmpfile = Tempfile.new 'neocities_saving_file'
|
tmpfile = Tempfile.new 'neocities_saving_file'
|
||||||
|
|
||||||
if (tmpfile.size + current_site.total_space) > Site::MAX_SPACE
|
if (tmpfile.size + current_site.total_space) > Site::MAX_SPACE
|
||||||
halt 'File is too large, it has NOT been saved. Please make a local copy and then try to reduce the size.'
|
halt 'File is too large, it has NOT been saved. Please make a local copy and then try to reduce the size.'
|
||||||
end
|
end
|
||||||
|
|
||||||
tmpfile.write request.body.read
|
tmpfile.write request.body.read
|
||||||
tmpfile.close
|
tmpfile.close
|
||||||
|
|
||||||
sanitized_filename = filename.gsub(/[^a-zA-Z_\-.]/, '')
|
sanitized_filename = filename.gsub(/[^a-zA-Z_\-.]/, '')
|
||||||
dest_path = File.join site_base_path(current_site.username), sanitized_filename
|
dest_path = File.join site_base_path(current_site.username), sanitized_filename
|
||||||
|
|
||||||
FileUtils.mv tmpfile.path, dest_path
|
FileUtils.mv tmpfile.path, dest_path
|
||||||
File.chmod(0640, dest_path) if self.class.production?
|
File.chmod(0640, dest_path) if self.class.production?
|
||||||
|
|
||||||
Backburner.enqueue ScreenshotJob, current_site.username
|
Backburner.enqueue(ScreenshotJob, current_site.username) if sanitized_filename =~ /index\.html/
|
||||||
|
|
||||||
'ok'
|
'ok'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue