-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathserver.rb
More file actions
56 lines (48 loc) · 1.51 KB
/
server.rb
File metadata and controls
56 lines (48 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'blue_factory'
module Server
def self.configure
self.instance_method(:run).bind_call(BlueFactory::Server)
end
def run
register Sinatra::ActiveRecordExtension
# do any additional config & customization on BlueFactory::Server here
# see Sinatra docs for more info: https://sinatrarb.com/intro.html
# e.g.:
#
# disable :logging
# enable :static
# set :views, File.expand_path('views', __dir__)
# set :default_encoding, 'cp1250'
#
# before do
# headers "X-Powered-By" => "BlueFactory/#{BlueFactory::VERSION}"
# end
#
# get '/' do
# erb :index
# end
get '/' do
content_type 'text/html'
html = %(
<style>
body { width: 960px; margin: 40px auto; } li { margin: 5px 0px; }
a { text-decoration: none; color: #00e; } a:hover { text-decoration: underline; } a:visited { color: #00e; }
</style>
<h2>Bluesky Feed Server at #{request.host}</h2>
<p>This is an AT Protocol XRPC service hosting a Bluesky custom feed generator.</p>
<p>Available feeds:</p>
<ul>
)
BlueFactory.feed_keys.each do |k|
feed = BlueFactory.get_feed(k)
title = feed.display_name
html << %(<li><a href="https://bsky.app/profile/#{BlueFactory.publisher_did}/feed/#{k}">#{title}</a></li>\n)
end
html << %(
</ul>
<p>Powered by Ruby and <a href="https://github.com/mackuba/blue_factory">BlueFactory</a>.</p>
)
html
end
end
end