From 1100562e29f6476448b656dbddd4cf22505523f6 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Sun, 10 Mar 2024 14:59:14 +0100 Subject: Move back to JBMAFP --- bin/webring.rb | 80 ---------------------------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 bin/webring.rb (limited to 'bin/webring.rb') diff --git a/bin/webring.rb b/bin/webring.rb deleted file mode 100644 index 05537a2..0000000 --- a/bin/webring.rb +++ /dev/null @@ -1,80 +0,0 @@ -require "erb" -require "htmlentities" -require "open-uri" -require "simple-rss" - -summary_max_length = 320 - -feeds = [ - "https://blog.regehr.org/feed", - "https://www.neilhenning.dev/index.xml", - "https://drewdevault.com/blog/index.xml", - "https://offbeatpursuit.com/blog/index.rss", - "https://mirzapandzo.com/rss.xml", - "https://journal.valeriansaliou.name/rss/", - "https://neil.computer/rss/", - "https://michael.stapelberg.ch/feed.xml", - "https://utcc.utoronto.ca/~cks/space/blog/?atom", - "https://szymonkaliski.com/feed.xml" -] - -out_html = "" -decoder = HTMLEntities.new - -feeds.each do |feed_url| - begin - rss_content = URI.open(feed_url).read - rss = SimpleRSS.parse(rss_content) - - first = rss.items.first - author = rss.channel.title - website = rss.channel.link.gsub(%r{]+?>}, '') - title = first.title - link = first.link - - description = first.description - summary = description - content = first.content - - if not summary - summary = content - end - - summary.force_encoding("UTF-8") - summary = decoder.decode(summary) - .gsub(%r{]+?>}, '') - .gsub(/\s{2,}/, ' ') - .gsub("\n", ' ') - - if summary.length > summary_max_length - summary = "#{summary[0...summary_max_length]}..." - end - - template = ERB.new <<-EOF -
  • -
    <%= title %> — <%= author %>
    -
    <%= summary %>
    -
  • - EOF - - partial = template.result(binding) - out_html.concat(partial) - - puts "Feed: #{author}" - puts "Title: #{title}" - puts "Link: #{link}" - puts "Summary: #{summary}" - puts - rescue OpenURI::HTTPError => e - puts "Failed to fetch #{feed_url}: #{e.message}" - rescue SimpleRSSError => e - puts "Failed to parse #{feed_url}: #{e.message}" - end -end - -template = ERB.new <<-EOF -

    Posts from blogs I follow around the net

    - -EOF -out_html = template.result(binding) -File.write("_includes/webring.html", out_html) -- cgit v1.2.3