diff --git a/README.md b/README.md index f4b0eda..d536c37 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ ## Backend - [ ] Posting + - [x] Making posts locally + - [ ] Figuring out follower list + - [ ] Sending to followers - [ ] Timeline + - [x] My posts + - [ ] Posts from accounts you follow - [ ] Deleting posts - [x] Following - [ ] Unfollowing @@ -13,8 +18,10 @@ ## UX -- [ ] Posting +- [x] Posting - [ ] Timeline + - [~] My posts + - [ ] Posts from accounts you follow - [ ] Deleting posts - [~] Following - [ ] Unfollowing diff --git a/lib/postland/activity.ex b/lib/postland/activity.ex index 08fcbff..03432db 100644 --- a/lib/postland/activity.ex +++ b/lib/postland/activity.ex @@ -8,6 +8,8 @@ defmodule Postland.Activity do field :actor_id, :string field :type, :string field :data, :map + + timestamps() end def changeset(attrs) do diff --git a/lib/postland/post.ex b/lib/postland/timeline.ex similarity index 54% rename from lib/postland/post.ex rename to lib/postland/timeline.ex index a00ea48..0b565cf 100644 --- a/lib/postland/post.ex +++ b/lib/postland/timeline.ex @@ -1,4 +1,9 @@ -defmodule Postland.Post do +defmodule Postland.Timeline do + alias Postland.Activity + alias Postland.Repo + + import Ecto.Query + def html_content(activity) do case Map.get(activity.data, "object") do map when is_map(map) -> @@ -13,4 +18,11 @@ defmodule Postland.Post do "" end end + + def timeline do + from(a in Activity, where: a.type == "Create", order_by: [desc: a.inserted_at]) + # Only accounts I'm following + myself + # Only notes + |> Repo.all() + end end diff --git a/lib/postland_web/components/core_components.ex b/lib/postland_web/components/core_components.ex index 4915bca..1af7895 100644 --- a/lib/postland_web/components/core_components.ex +++ b/lib/postland_web/components/core_components.ex @@ -36,6 +36,7 @@ defmodule PostlandWeb.CoreComponents do id="post-body" class="block w-full resize-none border-0 bg-transparent py-1.5 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6" placeholder="post body" + value={@post_content} >