mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
ipfs: archive every 10 minutes, allow disabling, make archives public
This commit is contained in:
parent
f82cbad73e
commit
1002aa01f7
7 changed files with 45 additions and 29 deletions
|
@ -52,7 +52,8 @@ post '/settings/:username/profile' do
|
|||
|
||||
@site.update(
|
||||
profile_comments_enabled: params[:site][:profile_comments_enabled],
|
||||
profile_enabled: params[:site][:profile_enabled]
|
||||
profile_enabled: params[:site][:profile_enabled],
|
||||
archiving_disabled: params[:site][:archiving_disabled]
|
||||
)
|
||||
flash[:success] = 'Profile settings changed.'
|
||||
redirect "/settings/#{@site.username}#profile"
|
||||
|
|
|
@ -38,11 +38,9 @@ get '/site/:username/?' do |username|
|
|||
end
|
||||
|
||||
get '/site/:username/archives' do
|
||||
require_login
|
||||
@site = Site[username: params[:username]]
|
||||
@title = "Site archives for #{@site.title}"
|
||||
not_found if @site.nil?
|
||||
redirect request.referrer unless current_site.id == @site.id
|
||||
not_found if @site.nil? || @site.archiving_disabled
|
||||
|
||||
@archives = @site.archives_dataset.limit(300).order(:updated_at.desc).all
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ class Archive < Sequel::Model
|
|||
set_primary_key [:site_id, :ipfs_hash]
|
||||
unrestrict_primary_key
|
||||
MAXIMUM_ARCHIVES_PER_SITE = 100
|
||||
ARCHIVE_WAIT_TIME = 1.hour
|
||||
ARCHIVE_WAIT_TIME = 10.minutes
|
||||
|
||||
def before_destroy
|
||||
unpin
|
||||
|
|
|
@ -1530,8 +1530,10 @@ class Site < Sequel::Model
|
|||
]
|
||||
sql.first
|
||||
|
||||
unless archiving_disabled
|
||||
ArchiveWorker.perform_in Archive::ARCHIVE_WAIT_TIME, self.id
|
||||
end
|
||||
end
|
||||
|
||||
reload
|
||||
|
||||
|
|
|
@ -1,20 +1,37 @@
|
|||
<h2>Site Profile</h2>
|
||||
<h2>General Settings</h2>
|
||||
|
||||
<div>
|
||||
<form method="POST" action="/settings/<%= @site.username %>/profile">
|
||||
<%== csrf_token_input_html %>
|
||||
<p>
|
||||
|
||||
<h3>Site Profile</h3>
|
||||
|
||||
<div style="text-align: center">
|
||||
<div style="display: inline-block; text-align: left; margin-bottom: 10px">
|
||||
<input name="site[profile_comments_enabled]" type="hidden" value="true">
|
||||
<input name="site[profile_comments_enabled]" type="checkbox" value="false"
|
||||
<% if @site.profile_comments_enabled == false %>checked<% end %>
|
||||
> Disable Site Profile Comments
|
||||
</p>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
<input name="site[profile_enabled]" type="hidden" value="true">
|
||||
<input name="site[profile_enabled]" type="checkbox" value="false"
|
||||
<% if @site.profile_enabled == false %>checked<% end %>
|
||||
> Disable Site Profile
|
||||
</p>
|
||||
<input class="btn-Action" type="submit" value="Update Site Profile Settings">
|
||||
<br>
|
||||
</div>
|
||||
|
||||
<h3>IPFS Archiving</h3>
|
||||
|
||||
<div style="display: inline-block; text-align: left; margin-bottom: 10px">
|
||||
<input name="site[archiving_disabled]" type="hidden" value="false">
|
||||
<input name="site[archiving_disabled]" type="checkbox" value="true"
|
||||
<% if @site.archiving_disabled == true %>checked<% end %>
|
||||
> Disable IPFS Archiving
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input class="btn-Action" type="submit" value="Update Settings">
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<a href="/dashboard" class="btn-Action edit"><i class="fa fa-edit" title="Edit"></i> Edit Site</a>
|
||||
<% end %>
|
||||
|
||||
<% if current_site && current_site.id == site.id && site.latest_archive %>
|
||||
<% if site.latest_archive && !site.archiving_disabled %>
|
||||
<a href="/site/<%= site.username %>/archives" class="btn-Action edit"><i class="fa fa-history" title="Archives"></i> Archives</a>
|
||||
<% end %>
|
||||
|
||||
|
@ -49,8 +49,6 @@
|
|||
<span class="following"><i class="fa fa-check"></i>Following</span>
|
||||
<span class="follow"><i class="fa fa-plus"></i>Follow</span>
|
||||
</a>
|
||||
|
||||
<!-- <a href="#" class="btn-Action tip"><span>Tip</span></a> -->
|
||||
<% end %>
|
||||
|
||||
<a href="#" id="shareButton" class="btn-Action" data-container="body" data-toggle="popover" data-placement="bottom" data-content='<%== erb :'_share', layout: false, locals: {site: site} %>'><i class="fa fa-share-alt"></i> <span>Share</span></a>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="header-Outro">
|
||||
<div class="row content single-Col">
|
||||
<h1>Permanent Web Archives</h1>
|
||||
<h1>IPFS Archives</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -23,10 +23,10 @@
|
|||
</table>
|
||||
|
||||
<p>
|
||||
This is a very early, experimental preview release of a new technology! We're still figuring things out. We may stop hosting archives without notice. <a href="/permanent-web">Learn how you can host your own copies of these archives</a>.
|
||||
This is a preview release of a new technology. We're still figuring things out, and may stop hosting archives without notice. <a href="/permanent-web">Learn how you can host your own copies of these archives</a>.
|
||||
</p>
|
||||
<p>
|
||||
Archives are captured once every 24 hours, so if you don't see your latest changes, check back later.
|
||||
Archives are captured once every <%= Archive::ARCHIVE_WAIT_TIME / 60 %> minutes, so if you don't see your latest changes, check back later.
|
||||
</p>
|
||||
<p>
|
||||
The URLs are using <a href="https://github.com/neocities/hshca">hshca</a>, a standard for using cryptographic hashes with subdomains.
|
||||
|
|
Loading…
Add table
Reference in a new issue