<%= @heading %>
diff --git a/lib/mse25_web/controllers/page_controller.ex b/lib/mse25_web/controllers/page_controller.ex
index 5efff3a..05e1501 100644
--- a/lib/mse25_web/controllers/page_controller.ex
+++ b/lib/mse25_web/controllers/page_controller.ex
@@ -68,6 +68,26 @@ defmodule Mse25Web.PageController do
)
end
+ def notes(conn, params) do
+ {notes, page_title} =
+ case params do
+ %{"q" => query_string} ->
+ {Directus.get_notes!(limit: @almost_infinity, query: query_string),
+ "Anteckningar: \"#{query_string}\""}
+
+ _ ->
+ {Directus.get_notes!(limit: @almost_infinity), "Anteckningar"}
+ end
+
+ render(conn, :notes,
+ page_title: page_title,
+ breadcrumbs: [],
+ notes: group_by_creation_date(notes),
+ q: params["q"],
+ nosearch?: params["q"] == nil or params["q"] == ""
+ )
+ end
+
def events(conn, params) do
{_, %{"title" => title, "contents" => contents}} = Directus.get_page("evenemang")
@@ -93,7 +113,7 @@ defmodule Mse25Web.PageController do
end
def links(conn, _params) do
- links = Directus.get_links!(limit: @almost_infinity) |> group_by_date
+ links = Directus.get_links!(limit: @almost_infinity) |> group_by_pub_date
render(conn, :links,
page_title: "Delningar",
@@ -109,10 +129,17 @@ defmodule Mse25Web.PageController do
|> Enum.sort(fn {a, _a}, {b, _b} -> b < a end)
end
- defp group_by_date(items) do
+ defp group_by_pub_date(items) do
items
|> Enum.group_by(fn %{"pubDate" => pub_date} -> pub_date end)
|> Map.to_list()
|> Enum.sort(fn {a, _a}, {b, _b} -> b < a end)
end
+
+ defp group_by_creation_date(items) do
+ items
+ |> Enum.group_by(fn %{"date_created" => pub_date} -> String.slice(pub_date, 0..9) end)
+ |> Map.to_list()
+ |> Enum.sort(fn {a, _a}, {b, _b} -> b < a end)
+ end
end
diff --git a/lib/mse25_web/controllers/page_html.ex b/lib/mse25_web/controllers/page_html.ex
index c43c3e9..b8f5c85 100644
--- a/lib/mse25_web/controllers/page_html.ex
+++ b/lib/mse25_web/controllers/page_html.ex
@@ -3,4 +3,8 @@ defmodule Mse25Web.PageHTML do
import Mse25.EventHelpers
embed_templates "page_html/*"
+
+ defp fancy_timestamp(datestr) do
+ datestr |> IO.inspect()
+ end
end
diff --git a/lib/mse25_web/controllers/page_html/articles.html.heex b/lib/mse25_web/controllers/page_html/articles.html.heex
index e91cf6d..39a09a4 100644
--- a/lib/mse25_web/controllers/page_html/articles.html.heex
+++ b/lib/mse25_web/controllers/page_html/articles.html.heex
@@ -1,41 +1,45 @@
-
- <%= @page_title %>
-
-
- Inlägg skrivna sedan 2006.
- <%= if @nosearch? do %>
- Gå direkt till:
- <% end %>
-
-
- <%= for {year, articles} <- @articles do %>
- -
- year}><%= year %> (<%= Enum.count(articles) %>)
-
- <% end %>
-
-