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

added "Build in Public" feed

Changed files
+49
app
+1
app/config.rb
··· 8 8 BlueFactory.set :publisher_did, 'did:plc:<your_identifier_here>' 9 9 BlueFactory.set :hostname, 'feeds.example.com' 10 10 11 + BlueFactory.add_feed 'build', BuildInPublicFeed.new 11 12 BlueFactory.add_feed 'linux', LinuxFeed.new 12 13 BlueFactory.add_feed 'starwars', StarWarsFeed.new 13 14
+48
app/feeds/build_in_public_feed.rb
··· 1 + require_relative 'feed' 2 + require 'rainbow' 3 + 4 + class BuildInPublicFeed < Feed 5 + REGEXPS = [/\bbuild\s?in\s?public\b/i] 6 + 7 + def feed_id 8 + 3 9 + end 10 + 11 + def display_name 12 + "#buildinpublic" 13 + end 14 + 15 + def description 16 + "Indie hackers and entrepreneurs building things in public - use #buildinpublic hashtag" 17 + end 18 + 19 + def post_matches?(post) 20 + all_text = matched_text(post) 21 + 22 + REGEXPS.any? { |x| all_text =~ x } 23 + end 24 + 25 + def matched_text(post) 26 + lines = [post.text] 27 + 28 + if embed = post.record['embed'] 29 + if images = (embed['images'] || embed['media'] && embed['media']['images']) 30 + lines += images.map { |i| i['alt'] }.compact 31 + end 32 + 33 + if link = embed['external'] 34 + lines += [link['uri'], link['title'], link['description']].compact 35 + end 36 + end 37 + 38 + lines.join("\n") 39 + end 40 + 41 + def colored_text(t) 42 + text = t.dup 43 + 44 + REGEXPS.each { |r| text.gsub!(r) { |s| Rainbow(s).green }} 45 + 46 + text 47 + end 48 + end