Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events feed #2495

Merged
merged 10 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion dune
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@
%{workspace_root}
(with-stdout-to
%{target}
(run %{gen_feed} video))))))
(run %{gen_feed} video)))))
(rule
(target events.xml)
(deps
(source_tree %{workspace_root}/data/events)
(:gen_feed %{workspace_root}/tool/ood-gen/bin/feed.exe))
(action
(chdir
%{workspace_root}
(with-stdout-to
%{target}
(run %{gen_feed} events))))))

(data_only_dirs playground data practice)
1 change: 1 addition & 0 deletions src/ocamlorg_static/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
%{workspace_root}/asset/planet.xml
%{workspace_root}/asset/changelog.xml
%{workspace_root}/asset/video.xml
%{workspace_root}/asset/events.xml
(source_tree %{workspace_root}/asset))
(action
(with-stdout-to
Expand Down
1 change: 1 addition & 0 deletions tool/ood-gen/bin/feed.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ open Ood_gen
let term_templates =
[
("changelog", Changelog.ChangelogFeed.create_feed);
("events", Event.EventsFeed.create_feed);
("planet", Planet.GlobalFeed.create_feed);
("video", Video.create_feed);
]
Expand Down
36 changes: 36 additions & 0 deletions tool/ood-gen/lib/event.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,42 @@ let all () =
in
String.compare t2 t1)

module EventsFeed = struct
let create_entry (log : t) =
cuihtlauac marked this conversation as resolved.
Show resolved Hide resolved
let authors = (Syndic.Atom.author "OCaml Events", []) in
let event_type = show_event_type log.event_type in
let textual_location = log.city ^ ", " ^ log.country in
let start_date_str =
log.starts.yyyy_mm_dd ^ "T"
^ Option.value ~default:"00:00" log.starts.utc_hh_mm
^ ":00Z"
in
let start_date = Syndic.Date.of_rfc3339 start_date_str in
let human_readable_date =
Format.sprintf "%s %d, %d"
(Syndic.Date.month start_date |> Syndic.Date.string_of_month)
(Syndic.Date.day start_date)
(Syndic.Date.year start_date)
in
let content =
Format.sprintf {|%s takes place in %s starting %s.|} log.title
textual_location human_readable_date
in
let id = Uri.of_string (log.slug ^ " " ^ start_date_str) in
Syndic.Atom.entry ~id ~authors
~title:(Syndic.Atom.Text (log.title ^ " // " ^ human_readable_date))
~updated:start_date
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The event start date should not be used here. The updated date is when the event announcement is created or updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sure, I'm in my uni rn for an exam, will check back later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cuihtlauac i checked the event feed markdown files, there isn't any updated date field
should i put a conditional whether when updated is present to use that or leave it as it is, thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For 1-shot events, we need an additional field in Event.t to hold that information. When all is built, using the function decode, we must initialize it with the file's last write time on the markdown.

For recurring events, it's trickier. We have to check in the RSS spec if it is allowed to skip that field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to research whether we can omit the field in recurring events or not but couldn't find anything substantial, will need some help here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A possible solution could be to use the filesystem information for one-shot events and remove recurring events from the feed. Does it make sense to you?

~links:[ Syndic.Atom.link (Uri.of_string log.url) ]
~categories:[ Syndic.Atom.category event_type ]
~content:(Syndic.Atom.Text content) ()

let create_feed () =
let open Rss in
() |> all
|> create_feed ~id:"events.xml" ~title:"OCaml Events" ~create_entry
|> feed_to_string
cuihtlauac marked this conversation as resolved.
Show resolved Hide resolved
end

let template () =
Format.asprintf
{|
Expand Down
Loading