mirror of
https://github.com/neocities/neocities.git
synced 2025-08-02 07:41:52 +02:00
use style.css for new installs, refactor new install to use store_file
This commit is contained in:
parent
42e21bce9a
commit
53d25cba1d
6 changed files with 39 additions and 23 deletions
|
@ -296,12 +296,24 @@ class Site < Sequel::Model
|
|||
FileUtils.mkdir_p files_path
|
||||
|
||||
%w{index not_found}.each do |name|
|
||||
File.write files_path("#{name}.html"), render_template("#{name}.erb")
|
||||
tmpfile = Tempfile.new "newinstall-#{name}"
|
||||
tmpfile.write render_template("#{name}.erb")
|
||||
tmpfile.close
|
||||
|
||||
store_file "#{name}.html", tmpfile, new_install: true
|
||||
purge_cache "/#{name}.html"
|
||||
ScreenshotWorker.perform_async values[:username], "#{name}.html"
|
||||
end
|
||||
|
||||
FileUtils.cp template_file_path('cat.png'), files_path('cat.png')
|
||||
tmpfile = Tempfile.new 'style.css'
|
||||
tmpfile.close
|
||||
FileUtils.cp template_file_path('style.css'), tmpfile.path
|
||||
store_file 'style.css', tmpfile, new_install: true
|
||||
|
||||
tmpfile = Tempfile.new 'cat.png'
|
||||
tmpfile.close
|
||||
FileUtils.cp template_file_path('cat.png'), tmpfile.path
|
||||
store_file 'cat.png', tmpfile, new_install: true
|
||||
end
|
||||
|
||||
def get_file(path)
|
||||
|
@ -451,7 +463,7 @@ class Site < Sequel::Model
|
|||
PurgeCacheWorker.perform_async payload
|
||||
end
|
||||
|
||||
def store_file(path, uploaded)
|
||||
def store_file(path, uploaded, opts={})
|
||||
relative_path = scrubbed_path path
|
||||
path = files_path path
|
||||
|
||||
|
@ -486,7 +498,8 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
pathname = Pathname(path)
|
||||
if pathname.basename.to_s == 'index.html'
|
||||
|
||||
if pathname.basename.to_s == 'index.html' && opts[:new_install] != true
|
||||
begin
|
||||
new_title = Nokogiri::HTML(File.read(uploaded.path)).css('title').first.text
|
||||
rescue NoMethodError => e
|
||||
|
@ -533,7 +546,7 @@ class Site < Sequel::Model
|
|||
ThumbnailWorker.perform_async values[:username], relative_path
|
||||
end
|
||||
|
||||
SiteChange.record self, relative_path
|
||||
SiteChange.record self, relative_path unless opts[:new_install]
|
||||
|
||||
true
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue