mirror of
https://github.com/neocities/neocities.git
synced 2025-05-10 08:48:30 +02:00
update bluesky atproto setup to use .well-known vs dns
This commit is contained in:
parent
0d78a105d4
commit
8aa48f1ac2
5 changed files with 41 additions and 22 deletions
|
@ -31,8 +31,6 @@ get '/settings/:username/?' do |username|
|
||||||
require_login
|
require_login
|
||||||
require_ownership_for_settings
|
require_ownership_for_settings
|
||||||
|
|
||||||
@bluesky_did = $redis_proxy.hget "dns-_atproto.#{@site.username}.neocities.org", 'TXT'
|
|
||||||
|
|
||||||
@title = "Site settings for #{username}"
|
@title = "Site settings for #{username}"
|
||||||
erb :'settings/site'
|
erb :'settings/site'
|
||||||
end
|
end
|
||||||
|
@ -191,16 +189,19 @@ end
|
||||||
post '/settings/:username/bluesky_set_did' do
|
post '/settings/:username/bluesky_set_did' do
|
||||||
require_login
|
require_login
|
||||||
require_ownership_for_settings
|
require_ownership_for_settings
|
||||||
redirect '/settings' if !@site.domain.empty?
|
|
||||||
|
|
||||||
# todo standards based validation
|
# todo standards based validation
|
||||||
if params[:did].length > 50
|
if params[:did].length > 50
|
||||||
flash[:error] = 'DID provided was too long'
|
flash[:error] = 'DID provided was too long'
|
||||||
elsif !params[:did].match(/^did=did:plc:([a-z|0-9)]+)$/)
|
elsif !params[:did].match(/^did:plc:([a-z|0-9)]+)$/)
|
||||||
flash[:error] = 'DID was invalid'
|
flash[:error] = 'DID was invalid'
|
||||||
else
|
else
|
||||||
$redis_proxy.hset "dns-_atproto.#{@site.username}.neocities.org", 'TXT', params[:did]
|
tmpfile = Tempfile.new 'atproto-did'
|
||||||
flash[:success] = 'DID set! You can now verify the domain on the Bluesky app.'
|
tmpfile.write params[:did]
|
||||||
|
tmpfile.close
|
||||||
|
|
||||||
|
@site.store_files [{filename: '.well-known/atproto-did', tempfile: tmpfile}]
|
||||||
|
flash[:success] = 'DID set! You can now verify the handle on the Bluesky app.'
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect "/settings/#{@site.username}#bluesky"
|
redirect "/settings/#{@site.username}#bluesky"
|
||||||
|
|
|
@ -1777,7 +1777,6 @@ class Site < Sequel::Model
|
||||||
|
|
||||||
files.each do |file|
|
files.each do |file|
|
||||||
existing_size = 0
|
existing_size = 0
|
||||||
|
|
||||||
site_file = site_files_dataset.where(path: scrubbed_path(file[:filename])).first
|
site_file = site_files_dataset.where(path: scrubbed_path(file[:filename])).first
|
||||||
|
|
||||||
if site_file
|
if site_file
|
||||||
|
|
|
@ -197,4 +197,33 @@ describe 'site/settings' do
|
||||||
_(page.body).must_match /You cannot delete the parent site without deleting the children sites first/i
|
_(page.body).must_match /You cannot delete the parent site without deleting the children sites first/i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'bluesky' do
|
||||||
|
it 'should set did verification file' do
|
||||||
|
Capybara.reset_sessions!
|
||||||
|
@site = Fabricate :site
|
||||||
|
page.set_rack_session id: @site.id
|
||||||
|
visit "/settings/#{@site.username}#bluesky"
|
||||||
|
did = 'did:plc:testexampletest'
|
||||||
|
fill_in 'did', with: did
|
||||||
|
click_button 'Update DID'
|
||||||
|
_(body).must_include 'DID set'
|
||||||
|
path = '.well-known/atproto-did'
|
||||||
|
_(@site.site_files_dataset.where(path: path).count).must_equal 1
|
||||||
|
_(File.read(@site.files_path(path))).must_equal did
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'fails with weirdness' do
|
||||||
|
Capybara.reset_sessions!
|
||||||
|
@site = Fabricate :site
|
||||||
|
page.set_rack_session id: @site.id
|
||||||
|
visit "/settings/#{@site.username}#bluesky"
|
||||||
|
fill_in 'did', with: 'DIJEEDIJSFDSJNFLKJJFN'
|
||||||
|
click_button 'Update DID'
|
||||||
|
_(body).must_include 'DID was invalid'
|
||||||
|
fill_in 'did', with: 'did:plc:'+('a'*50)
|
||||||
|
click_button 'Update DID'
|
||||||
|
_(body).must_include 'DID provided was too long'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -35,10 +35,7 @@
|
||||||
<li><a href="#nsfw" data-toggle="tab">18+</a></li>
|
<li><a href="#nsfw" data-toggle="tab">18+</a></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @site.domain.empty? %>
|
<li><a href="#bluesky" data-toggle="tab">Bluesky</a></li>
|
||||||
<li><a href="#bluesky" data-toggle="tab">Bluesky</a></li>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<li><a href="#delete" data-toggle="tab">Delete</a></li>
|
<li><a href="#delete" data-toggle="tab">Delete</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
|
|
|
@ -16,18 +16,11 @@
|
||||||
Select <strong>No DNS Panel</strong>
|
Select <strong>No DNS Panel</strong>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>Paste the DID here:</p>
|
||||||
Back on Neocities, create a new file on your site named: <strong>.well-known/atproto-did</strong>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Paste the DID provided to the file you created, click save, and then click "Verify Text File" on the Bluesky app.
|
|
||||||
</p>
|
|
||||||
<!--
|
|
||||||
<form method="POST" action="/settings/<%= @site.username %>/bluesky_set_did">
|
<form method="POST" action="/settings/<%= @site.username %>/bluesky_set_did">
|
||||||
<%== csrf_token_input_html %>
|
<%== csrf_token_input_html %>
|
||||||
<input name="did" type="text" style="width: 50%" placeholder="did=did:plc:somethingexamplesomething" value="<%= @bluesky_did %>">
|
<input name="did" type="text" style="width: 50%" placeholder="did:plc:somethingexamplesomething" value="<%= params[:did] %>">
|
||||||
<br>
|
<br>
|
||||||
<input class="btn-Action" type="submit" value="Update">
|
<input class="btn-Action" type="submit" value="Update DID">
|
||||||
</form>
|
</form>
|
||||||
-->
|
|
Loading…
Add table
Reference in a new issue