aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-10-10 20:26:24 +0200
committerHarald Eilertsen <haraldei@anduin.net>2024-10-10 20:26:24 +0200
commitd08fa4e375748f0f2232ea75645cb15126155047 (patch)
treea157b2419601c8abc77ac1b72405a5aab3fcb779
parent51ef51bbe3b741a76d1d44b8ce8c1d8a07427e1f (diff)
downloadramaskrik-program-d08fa4e375748f0f2232ea75645cb15126155047.tar.gz
ramaskrik-program-d08fa4e375748f0f2232ea75645cb15126155047.tar.bz2
ramaskrik-program-d08fa4e375748f0f2232ea75645cb15126155047.zip
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...)
-rw-r--r--Gemfile.lock14
-rw-r--r--index.html.erb7
-rw-r--r--lib/events.rb4
-rw-r--r--program.ics.erb2
-rwxr-xr-xramaskrik-program.rb35
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 @@
<h1><%= title %></h1>
<section id="introduction">
<p>Dette er en annen visning av programmet for skrekkfilmfestivalen
- <a href="https://ramaskrik.no">Ramaskrik 2023</a>. Jeg laget det for
+ <a href="https://ramaskrik.no">Ramaskrik <%= year %></a>. 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å <a href="https://ramaskrik.no/program/">Ramaskrik sine egne websider</a>. Denne siden ble generert
<%= Date.today.strftime('%d.%m.%Y') %>, evt. endringer i programmet etter det er ikke tatt med.</p>
@@ -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.)</p>
- <p>Programmet er også tilgjengelig som en kalenderfil. <a href="./program-ramaskrik-2023.ics">Klikk her</a>
- for å legge den til i kalenderen din</a>.</p>
+ <p>Programmet er også tilgjengelig som en kalenderfil.
+ <a href="./program-ramaskrik-<%= year %>.ics">Klikk her</a>
+ for å legge den til i kalenderen din.</p>
<p>Har du spørsmål, ta kontakt med meg <a href="mailto:haraldei-ramaprogram@anduin.net">via epost</a>.</p>
</section>
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"))