From 042e35caf4c1451f95ecf01760a0feeddde4810a Mon Sep 17 00:00:00 2001 From: Original User Date: Fri, 24 Jan 2020 10:12:30 -0800 Subject: [PATCH] [rzz] change links to self --- ansible/docker/rzz/rzz.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ansible/docker/rzz/rzz.rb b/ansible/docker/rzz/rzz.rb index 57c2ab8..46c8943 100644 --- a/ansible/docker/rzz/rzz.rb +++ b/ansible/docker/rzz/rzz.rb @@ -12,11 +12,16 @@ module Rzz route do |r| r.get do r.is "test-gym" do - url = "https://elemental.medium.com/feed/" + url = "https://elemental.medium.com/feed" xml = URI.open(url).read r.etag Digest::SHA1.hexdigest(xml) doc = Nokogiri::XML(xml) + + self_url = "#{r.base_url}#{r.path}" # Should this be configured via the environment? + doc.at_xpath("/rss/channel/link/text()").content = self_url + doc.at_xpath("/rss/channel/atom:link[@href='#{url}']")["href"] = self_url + doc .xpath("/rss/channel/item") .select {|item| item.xpath("./category[text()='test-gym']").empty? } @@ -39,6 +44,10 @@ module Rzz end if __FILE__ == $0 + url = "https://elemental.medium.com/feed" + xml = URI.open(url).read + doc = Nokogiri::XML(xml) + require "pry" binding.pry end