riesa-efau-kalender: add link, image

This commit is contained in:
Astro 2021-07-17 23:47:57 +02:00
parent 150f62c377
commit 18e40b3f3b
1 changed files with 7 additions and 3 deletions

View File

@ -16,7 +16,7 @@ def fmt_time t
end
class Event
attr_accessor :name, :location, :link
attr_accessor :name, :location, :link, :image
attr_reader :date
def date=(s)
@ -35,14 +35,16 @@ end
events = []
doc = Nokogiri::HTML URI.open("https://riesa-efau.de/index.php?id=87")
url = "https://riesa-efau.de/index.php?id=87"
doc = Nokogiri::HTML URI.open(url)
doc.css(".tx-cal-controller .vevent").each do |vevent|
ev = Event::new
ev.name = vevent.css("h3").text
ev.location = vevent.css(".location").text
.sub(/ *\.\.\.[^\.]*$/, "")
ev.date = vevent.css(".datum").text
ev.link = vevent.css(".url").attr('href').value
ev.link = URI.join url, vevent.css(".url").attr('href').value
ev.image = URI.join url, vevent.css(".images img").attr('src').value
events << ev
end
@ -62,6 +64,8 @@ ical = ERB::new <<~EOF
DTEND:<%= fmt_time(ev.date + 2 * 3600) %>
SUMMARY:<%= ev.name %>
LOCATION:<%= ev.location %>
URL:<%= ev.link %>
ATTACH;FMTTYPE=image/jpeg:<%= ev.image %>
END:VEVENT
<% end %>
END:VCALENDAR