From 1ff11e975cf2d5a07f4d1c4f5b9f84b8e74c6e4f Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 1 Oct 2018 20:00:14 +0200 Subject: Link to movie info page from event box. --- ramaskrik-program.rb | 6 ++++-- room-schedule.rb | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ramaskrik-program.rb b/ramaskrik-program.rb index a9af3a0..c485fce 100644 --- a/ramaskrik-program.rb +++ b/ramaskrik-program.rb @@ -18,12 +18,14 @@ require 'date' require 'nokogiri' require 'open-uri' require 'room-schedule' +require 'uri' class Movie - attr_reader :title, :start_time, :end_time, :venue + attr_reader :title, :link, :start_time, :end_time, :venue def initialize(node) @title = node.css("h4").text.strip + @link = URI.join("https://ramaskrik.no", node.css("h4 a").attribute('href').value) @start_time = DateTime.parse(node.css(".date").attribute('title').value) @end_time = DateTime.parse(@start_time.strftime('%F') + node.css(".prgtype-endTime").text.strip.sub(/\w+/, '')) @end_time += 1 if @end_time < @start_time @@ -35,7 +37,7 @@ class Movie end end -doc = Nokogiri::HTML(open("program.html")) ## open("https://ramaskrik.no/program/")) +doc = Nokogiri::HTML(open("https://ramaskrik.no/program/")) movies = doc.css(".kultur-type-movie").map { |movie| Movie.new(movie) } days = movies.group_by { |movie| movie.start_time.strftime("%A %d.%m.%Y") } days.each do |d, movies| diff --git a/room-schedule.rb b/room-schedule.rb index bb6e677..fd4e282 100644 --- a/room-schedule.rb +++ b/room-schedule.rb @@ -94,6 +94,9 @@ module SVG p = body.add_element("p", { "class" => "event-title", }) + if entry.link + p = p.add_element("a", { "href" => entry.link }) + end p.add_text(entry.title) t = switch.add_element("text", { "x" => (bar_start + @font_size / 2).to_s, -- cgit v1.2.3