Browse Source

ref: rename blogcontroller to postcontroller

master
Inhji Y. 10 months ago
parent
commit
b79922950b
  1. 8
      apps/tomie_web/lib/tomie_web/controllers/blog_controller.ex
  2. 15
      apps/tomie_web/lib/tomie_web/router.ex
  3. 2
      apps/tomie_web/lib/tomie_web/templates/blog/edit.html.eex
  4. 6
      apps/tomie_web/lib/tomie_web/templates/blog/index.html.eex
  5. 2
      apps/tomie_web/lib/tomie_web/templates/blog/new.html.eex
  6. 2
      apps/tomie_web/lib/tomie_web/templates/layout/navigation.html.eex

8
apps/tomie_web/lib/tomie_web/controllers/blog_controller.ex

@ -1,4 +1,4 @@
defmodule TomieWeb.BlogController do
defmodule TomieWeb.PostController do
use TomieWeb, :controller
def index(conn, _params) do
@ -20,7 +20,7 @@ defmodule TomieWeb.BlogController do
case Blog.update_post(post, post_params) do
{:ok, _post} ->
conn
|> redirect(to: Routes.blog_path(conn, :index))
|> redirect(to: Routes.post_path(conn, :index))
{:error, changeset} ->
render(conn, "edit.html", changeset: changeset)
@ -37,7 +37,7 @@ defmodule TomieWeb.BlogController do
case Blog.create_post(post_params) do
{:ok, _post} ->
conn
|> redirect(to: Routes.blog_path(conn, :index))
|> redirect(to: Routes.post_path(conn, :index))
{:error, changeset} ->
render(conn, "new.html", changeset: changeset)
@ -50,6 +50,6 @@ defmodule TomieWeb.BlogController do
conn
|> put_flash(:info, "Post deleted!")
|> redirect(to: Routes.blog_path(conn, :index))
|> redirect(to: Routes.post_path(conn, :index))
end
end

15
apps/tomie_web/lib/tomie_web/router.ex

@ -68,13 +68,14 @@ defmodule TomieWeb.Router do
live "/", PageLive.Index
get "/posts", BlogController, :index
get "/posts/new", BlogController, :new
post "/posts/new", BlogController, :create
get "/posts/:id/edit", BlogController, :edit
post "/posts/:id/edit", BlogController, :update
put "/posts/:id/edit", BlogController, :update
delete "/posts/:id", BlogController, :delete
get "/posts", PostController, :index
get "/posts/new", PostController, :new
post "/posts/new", PostController, :create
get "/posts/:id/edit", PostController, :edit
post "/posts/:id/edit", PostController, :update
put "/posts/:id/edit", PostController, :update
put "/posts/:id/edit", PostController, :update
delete "/posts/:id", PostController, :delete
live "/bookmarks", BookmarkLive.Index
live "/bookmarks/new", BookmarkLive.New

2
apps/tomie_web/lib/tomie_web/templates/blog/edit.html.eex

@ -1,3 +1,3 @@
<div>
<%= render "form.html", Map.put(assigns, :action, Routes.blog_path(@conn, :update, @post)) %>
<%= render "form.html", Map.put(assigns, :action, Routes.post_path(@conn, :update, @post)) %>
</div>

6
apps/tomie_web/lib/tomie_web/templates/blog/index.html.eex

@ -1,7 +1,7 @@
<nav>
<ul>
<li>
<%= link to: Routes.blog_path(@conn, :new) do %>
<%= link to: Routes.post_path(@conn, :new) do %>
<span class="icon">
<%= IconView.icon(:add_outline) %>
</span>
@ -22,8 +22,8 @@
</div>
<footer>
<%= link "Edit", to: Routes.blog_path(@conn, :edit, post.id), class: "button" %>
<%= link "Delete", to: Routes.blog_path(@conn, :delete, post.id), method: :delete, data: [confirm: "Are you sure?"], class: "button" %>
<%= link "Edit", to: Routes.post_path(@conn, :edit, post.id), class: "button" %>
<%= link "Delete", to: Routes.post_path(@conn, :delete, post.id), method: :delete, data: [confirm: "Are you sure?"], class: "button" %>
</footer>
</article>
<% end %>

2
apps/tomie_web/lib/tomie_web/templates/blog/new.html.eex

@ -1,3 +1,3 @@
<div>
<%= render "form.html", Map.put(assigns, :action, Routes.blog_path(@conn, :create)) %>
<%= render "form.html", Map.put(assigns, :action, Routes.post_path(@conn, :create)) %>
</div>

2
apps/tomie_web/lib/tomie_web/templates/layout/navigation.html.eex

@ -7,7 +7,7 @@
</span>
<% end %>
</li>
<li><%= active_link @conn, to: Routes.blog_path(@conn, :index) do %>
<li><%= active_link @conn, to: Routes.post_path(@conn, :index) do %>
<span class="icon">
<%= IconView.icon(:blog) %>
</span>

Loading…
Cancel
Save