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