mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
fix for titles coming from subdir indexes
This commit is contained in:
parent
8ed3183c5f
commit
70f2057854
2 changed files with 15 additions and 2 deletions
|
@ -567,7 +567,7 @@ class Site < Sequel::Model
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if pathname.basename.to_s == 'index.html' && opts[:new_install] != true
|
if relative_path == '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
|
||||||
rescue NoMethodError => e
|
rescue NoMethodError => e
|
||||||
|
|
|
@ -58,9 +58,22 @@ describe 'site_files' do
|
||||||
args = ScreenshotWorker.jobs.first['args']
|
args = ScreenshotWorker.jobs.first['args']
|
||||||
args.first.must_equal @site.username
|
args.first.must_equal @site.username
|
||||||
args.last.must_equal 'index.html'
|
args.last.must_equal 'index.html'
|
||||||
@site.reload.site_changed.must_equal true
|
@site.title.must_equal "#{@site.username}.neocities.org"
|
||||||
|
@site.reload
|
||||||
|
@site.site_changed.must_equal true
|
||||||
|
@site.title.must_equal 'Hello?'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not change title for subdir index.html' do
|
||||||
|
title = @site.title
|
||||||
|
upload(
|
||||||
|
'dir' => 'derpie',
|
||||||
|
'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
||||||
|
)
|
||||||
|
@site.reload.title.must_equal title
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'succeeds with valid file' do
|
it 'succeeds with valid file' do
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
last_response.body.must_match /successfully uploaded/i
|
last_response.body.must_match /successfully uploaded/i
|
||||||
|
|
Loading…
Add table
Reference in a new issue