mirror of
https://github.com/neocities/neocities.git
synced 2025-08-06 01:24:56 +02:00
integrate IPFS using remote ssh for now, views
This commit is contained in:
parent
8424cc02e8
commit
59feb09928
8 changed files with 92 additions and 4 deletions
|
@ -558,10 +558,19 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
def add_to_ipfs
|
||||
line = Cocaine::CommandLine.new('ipfs', 'add -r :path')
|
||||
response = line.run path: files_path
|
||||
ipfs_hash = response.split("\n").last.split(' ')[1]
|
||||
ipfs_hash
|
||||
# Not ideal. An SoA version is in progress.
|
||||
if $config['ipfs_ssh_host'] && $config['ipfs_ssh_user']
|
||||
Rye::Cmd.add_command :ipfs, nil, 'add', :r
|
||||
rbox = Rye::Box.new $config['ipfs_ssh_host'], :user => $config['ipfs_ssh_user']
|
||||
response = rbox.ipfs "sites/#{self.username.gsub(/\/|\.\./, '')}"
|
||||
output_array = response
|
||||
else
|
||||
line = Cocaine::CommandLine.new('ipfs', 'add -r :path')
|
||||
response = line.run path: files_path
|
||||
output_array = response.to_s.split("\n")
|
||||
end
|
||||
|
||||
output_array.last.split(' ')[1]
|
||||
end
|
||||
|
||||
def archive!
|
||||
|
@ -570,6 +579,8 @@ class Site < Sequel::Model
|
|||
#else
|
||||
#end
|
||||
|
||||
ipfs_hash = add_to_ipfs
|
||||
|
||||
archive = archives_dataset.where(ipfs_hash: ipfs_hash).first
|
||||
if archive
|
||||
archive.updated_at = Time.now
|
||||
|
@ -579,6 +590,10 @@ class Site < Sequel::Model
|
|||
end
|
||||
end
|
||||
|
||||
def latest_archive
|
||||
@latest_archive ||= archives_dataset.order(:updated_at.desc).first
|
||||
end
|
||||
|
||||
def is_directory?(path)
|
||||
File.directory? files_path(path)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue