From d08fa4e375748f0f2232ea75645cb15126155047 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Thu, 10 Oct 2024 20:26:24 +0200 Subject: Updates for Ramaskrik 2024 - Don't hardcode year, use todays year instead. - Move output to separate build dir to make it a bit cleaner. - Misc fixes to set correct timezone in .ics file (still hardcoded, though...) --- Gemfile.lock | 14 +++++++------- index.html.erb | 7 ++++--- lib/events.rb | 4 ++++ program.ics.erb | 2 +- ramaskrik-program.rb | 35 +++++++---------------------------- 5 files changed, 23 insertions(+), 39 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5aff6f4..4a7483b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,14 +1,14 @@ GEM remote: https://rubygems.org/ specs: - byebug (10.0.2) - mini_portile2 (2.3.0) - nokogiri (1.8.4) - mini_portile2 (~> 2.3.0) - svg-graph (2.1.3) + byebug (11.1.3) + nokogiri (1.16.7-x86_64-linux) + racc (~> 1.4) + racc (1.6.0) + svg-graph (2.2.1) PLATFORMS - ruby + x86_64-linux DEPENDENCIES byebug @@ -16,4 +16,4 @@ DEPENDENCIES svg-graph BUNDLED WITH - 1.16.1 + 2.3.22 diff --git a/index.html.erb b/index.html.erb index 6b8630e..6b3c993 100644 --- a/index.html.erb +++ b/index.html.erb @@ -51,7 +51,7 @@

<%= title %>

Dette er en annen visning av programmet for skrekkfilmfestivalen - Ramaskrik 2023. Jeg laget det for + Ramaskrik <%= year %>. Jeg laget det for meg selv, for å få en bedre oversikt over hvilke filmer som går hvor og når. Offisielt program finner du på Ramaskrik sine egne websider. Denne siden ble generert <%= Date.today.strftime('%d.%m.%Y') %>, evt. endringer i programmet etter det er ikke tatt med.

@@ -60,8 +60,9 @@ har valgt, så du vil kunne bruke denne siden til å planlegge ruten din igjennom festivalen hvis du vil. (Ingen data sendes til websiden, hvilke filmer du har valgt vil kun lagres i din egen nettleser.)

-

Programmet er også tilgjengelig som en kalenderfil. Klikk her - for å legge den til i kalenderen din.

+

Programmet er også tilgjengelig som en kalenderfil. + Klikk her + for å legge den til i kalenderen din.

Har du spørsmål, ta kontakt med meg via epost.

diff --git a/lib/events.rb b/lib/events.rb index e647930..de9af64 100644 --- a/lib/events.rb +++ b/lib/events.rb @@ -21,6 +21,10 @@ module Events @start_time.to_date end + def end_time + @start_time + @duration + end + def slug "#{start_time.to_i}-#{title.downcase.gsub(/[^a-z0-9_-]/, '')}" end diff --git a/program.ics.erb b/program.ics.erb index 60c55bd..0e1835b 100644 --- a/program.ics.erb +++ b/program.ics.erb @@ -8,7 +8,7 @@ BEGIN:VEVENT UUID:<%= e.slug %> DTSTAMP;TZID=Europe/Oslo:<%= DateTime.now.strftime('%Y%m%dT%H%M%S') %> DTSTART;TZID=Europe/Oslo:<%= e.start_time.strftime('%Y%m%dT%H%M%S') %> -DURATION:PT<%= e.duration %>S +DTEND;TZID=Europe/Oslo:<%= e.end_time.strftime('%Y%m%dT%H%M%S') %> SUMMARY:<%= e.title %> LOCATION:<%= e.venue %> END:VEVENT diff --git a/ramaskrik-program.rb b/ramaskrik-program.rb index 5dfe5d5..87ba2ba 100755 --- a/ramaskrik-program.rb +++ b/ramaskrik-program.rb @@ -26,33 +26,8 @@ require 'json' require 'scrapers/ramaskrik' require 'nokogiri' require 'open-uri' -#require 'room-schedule' require 'uri' -def generate_graphs(events) - days = events.group_by { |event| event.start_time.strftime("%A %d.%m.%Y") } - days.map do |day, events| - rooms = events.group_by { |e| e.venue } - - graph = SVG::Graph::RoomSchedule.new({ - graph_title: day, - show_graph_title: true, - show_x_guidelines: true, - width: 1280, - height: rooms.keys.length * 100 + 25, - key: false, - x_label_format: "%H:%M", - timescale_divisions: "30 minutes", - }) - - rooms.each do |title, data| - graph.add_data(title: title, data: data) - end - - yield graph - end -end - class EventDecorator < SimpleDelegator attr_reader :offset attr_reader :height @@ -107,12 +82,16 @@ def make_sorted_event_lists_by_date(events_by_date) new_list end -title = "Ramaskrik 2023 - Program" +year = Date::today.year + +title = "Ramaskrik #{year} - Program" eventlist = make_sorted_event_lists_by_date(import_events_from_json(IO.read(ARGV[0]))) +Dir::mkdir('build') unless Dir::exist?('build') + t_html = ERB.new(IO.read("index.html.erb"), trim_mode: '>') -IO.write("index.html", t_html.result(binding)) +IO.write("build/index.html", t_html.result(binding)) t_ics = ERB.new(IO.read("program.ics.erb"), trim_mode: '<>') -IO.write("program.ics", t_ics.result(binding).gsub(/\n/, "\r\n")) +IO.write("build/program-ramaskrik-#{year}.ics", t_ics.result(binding).gsub(/\n/, "\r\n")) -- cgit v1.2.3