Template of a custom feed generator service for the Bluesky network in Ruby

added separate server file for customizations

Changed files
+35 -12
app
+3 -12
app/config.rb
··· 3 3 require 'blue_factory' 4 4 require 'sinatra/activerecord' 5 5 6 + require_relative 'server' 7 + 6 8 ActiveRecord::Base.connection.execute "PRAGMA journal_mode = WAL" 7 9 8 10 BlueFactory.set :publisher_did, 'did:plc:<your_identifier_here>' ··· 12 14 BlueFactory.add_feed 'linux', LinuxFeed.new 13 15 BlueFactory.add_feed 'starwars', StarWarsFeed.new 14 16 15 - # do any additional config & customization on BlueFactory::Server here: 16 - # 17 - # BlueFactory::Server.disable :logging 18 - # BlueFactory::Server.set :port, 4000 19 - # 20 - # BlueFactory::Server.get '/' do 21 - # redirect 'https://web.example.com' 22 - # end 23 - # 24 - # BlueFactory::Server.before do 25 - # headers "X-Powered-By" => "BlueFactory/#{BlueFactory::VERSION}" 26 - # end 17 + Server.configure
+26
app/server.rb
··· 1 + require 'blue_factory' 2 + 3 + module Server 4 + def self.configure 5 + self.instance_method(:run).bind_call(BlueFactory::Server) 6 + end 7 + 8 + def run 9 + # do any additional config & customization on BlueFactory::Server here 10 + # see Sinatra docs for more info: https://sinatrarb.com/intro.html 11 + # e.g.: 12 + # 13 + # disable :logging 14 + # enable :static 15 + # set :views, File.expand_path('views', __dir__) 16 + # set :default_encoding, 'cp1250' 17 + # 18 + # before do 19 + # headers "X-Powered-By" => "BlueFactory/#{BlueFactory::VERSION}" 20 + # end 21 + # 22 + # get '/' do 23 + # erb :index 24 + # end 25 + end 26 + end
+3
config.ru
··· 1 1 require_relative 'app/config' 2 + require_relative 'app/server' 2 3 3 4 # might not be needed depending on the app server you use - comment out these lines to leave logs on STDOUT 4 5 Dir.mkdir('log') unless Dir.exist?('log') ··· 9 10 10 11 # Sinatra turns off its own logging to stdout if another logger is in the stack 11 12 use Rack::CommonLogger, $sinatra_log 13 + 14 + Server.configure 12 15 13 16 run BlueFactory::Server
+3
server.rb
··· 3 3 require 'bundler/setup' 4 4 5 5 require_relative 'app/config' 6 + require_relative 'app/server' 7 + 8 + Server.configure 6 9 7 10 BlueFactory::Server.set :port, 3000 8 11 BlueFactory::Server.run!