   def edit(conn, _params) do
     current_user = Plug.current_resource(conn)
 
-    post = case current_user.admin do
-      false -> current_user
-           |> assoc(:posts)
-           |> Repo.get_by!(slug: conn.assigns.slug)
-      true -> Repo.get_by!(Post, slug: conn.assigns.slug)
-    end
+    post =
+      case current_user.admin do
+        false ->
+          current_user
+          |> assoc(:posts)
+          |> Repo.get_by!(slug: conn.assigns.slug)
+
+        true ->
+          Repo.get_by!(Post, slug: conn.assigns.slug)
+      end
 
     changeset = Post.changeset(post)
 

    )
  end

  def index(conn, %{"format" => format}) when format in ~w(rss atom), do: redirect(conn, to: "/rss")

  def index(conn, params) do
    page = params
    |> Map.get("page", "1")
    |> String.to_integer

    posts = Posts.all(page)


  alias Phoenix.Controller
  alias Tilex.{Channel, Notifications, Liking, Post, Posts}

  plug(:load_channels when action in [:new, :create, :edit, :update])
  plug(:extract_slug when action in [:show, :edit, :update])

  plug(
    Plug.EnsureAuthenticated,
    [handler: __MODULE__]
    when action in ~w(new create edit update)a
  )

  def unauthenticated(conn, _) do
    conn
