From 6fcd59af8a5d55f199f13da23615efb1d4dca76d Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Thu, 23 Jan 2025 16:54:21 -0500 Subject: [PATCH] improvement: add upcoming events --- lib/ash_hq/events.ex | 83 +++++++++++++++++++ lib/ash_hq_web/controllers/home_controller.ex | 18 ++++ lib/ash_hq_web/templates/home/home.html.heex | 20 +++++ lib/ash_hq_web/templates/layout/app.html.heex | 4 + mix.exs | 3 + mix.lock | 5 +- 6 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 lib/ash_hq/events.ex diff --git a/lib/ash_hq/events.ex b/lib/ash_hq/events.ex new file mode 100644 index 0000000..88186b5 --- /dev/null +++ b/lib/ash_hq/events.ex @@ -0,0 +1,83 @@ +defmodule AshHq.Events do + @events [ + %{ + cta: "Tickets On Sale Now!", + title: "Ash Training @ CodeBeam US", + description: """ +

+ Supercharge Your Elixir Apps with Ash +

+

+ Level up on Ash and hang out with the Ash team at CodeBeam US in San Francisco CA! +

+ """, + date: ~D[2025-03-05], + date_in_english: "March 5th, 2025", + href: "https://codebeamamerica.com/trainings/supercharge-your-elixir-apps-with-ash/" + }, + %{ + title: "Ash Training @ AlchemyConf", + description: """ +

+ Supercharge Your Elixir Apps with Ash +

+

+ Level up on Ash and hang out with the Ash team at AlchemyConf in Braga Portugal! +

+ """, + date: ~D[2025-04-01], + date_in_english: "April 1st, 2025", + href: "https://codebeamamerica.com/trainings/supercharge-your-elixir-apps-with-ash/" + }, + %{ + title: "Talk @ GigCityElixir 2025", + description: """ +

+ Ash, Igniter and the Middle Way +

+

+ Zach gives a talk on the future of Ash and Igniter, and a first foray into new concepts. +

+ """, + date: ~D[2025-05-05], + date_in_english: "May 5th, 2025", + href: "https://www.gigcityelixir.com" + }, + %{ + title: "Talk @ ElixirConf EU", + description: """ +

+ The Next Dimension of Developer Experience +

+

+ Zach gives a talk on Igniter and the massive improvement it can make to the Elixir DX! +

+ """, + date: ~D[2025-05-15], + date_in_english: "May 15th, 2025", + href: "https://www.elixirconf.eu" + }, + %{ + title: "Talk @ GOATMIRE", + description: """ +

+ Talk title is a secret ;) +

+

+ Hang out with Zach in Varberg, Sweden +

+ """, + date: ~D[2025-09-10], + date_in_english: "September 10th, 2025", + href: "https://goatmire.com" + } + ] + |> Enum.sort_by(& &1.date, Date) + + def events do + today = Date.utc_today() + + @events + |> Enum.reject(&(Date.compare(today, &1.date) == :gt)) + end +end diff --git a/lib/ash_hq_web/controllers/home_controller.ex b/lib/ash_hq_web/controllers/home_controller.ex index 8dad4cd..8b9e362 100644 --- a/lib/ash_hq_web/controllers/home_controller.ex +++ b/lib/ash_hq_web/controllers/home_controller.ex @@ -7,6 +7,7 @@ defmodule AshHqWeb.HomeController do contributors = AshHq.Github.Contributor.in_order!() conn + |> assign_events() |> assign(:contributor_count, Enum.count(contributors)) |> assign(:contributors, contributors) |> render("community.html") @@ -14,6 +15,7 @@ defmodule AshHqWeb.HomeController do def media(conn, _) do conn + |> assign_events() |> render("media.html") end @@ -23,10 +25,26 @@ defmodule AshHqWeb.HomeController do conn |> assign(:url_base, @url_base) |> assign(:app_name, app_name) + |> assign_events() |> assign(:safe_app_name, safe(app_name)) |> render("home.html") end + def events(conn, _) do + conn + |> assign_events() + |> render("events.html") + end + + defp assign_events(conn) do + events = AshHq.Events.events() + + conn + |> assign(:events_count, Enum.count(events)) + |> assign(:next_event, Enum.at(events, 0)) + |> assign(:events, events) + end + defp safe(name) do name |> String.downcase() diff --git a/lib/ash_hq_web/templates/home/home.html.heex b/lib/ash_hq_web/templates/home/home.html.heex index 61cb6f3..8908eae 100644 --- a/lib/ash_hq_web/templates/home/home.html.heex +++ b/lib/ash_hq_web/templates/home/home.html.heex @@ -289,4 +289,24 @@ + +
+
+

+ Upcoming + + events + +

+
    +
  • + {event.title} +

    Date: {event.date_in_english}

    +

    + {{:safe, event.description}} +

    +
  • +
+
+
diff --git a/lib/ash_hq_web/templates/layout/app.html.heex b/lib/ash_hq_web/templates/layout/app.html.heex index e209a36..164dd8b 100644 --- a/lib/ash_hq_web/templates/layout/app.html.heex +++ b/lib/ash_hq_web/templates/layout/app.html.heex @@ -1,4 +1,8 @@