fix blog tag clicks, and new post

This commit is contained in:
Firehose Bot
2026-03-19 22:14:19 +00:00
parent 3ffb0883f9
commit f148fe4fcd
10 changed files with 208 additions and 176 deletions
@@ -1,4 +1,4 @@
<div class="space-y-8">
<a href={@base_path} class="text-sm text-primary hover:underline">&larr; Back to posts</a>
<.post_show post={@post} />
<.post_show post={@post} base_path={@base_path} />
</div>
@@ -4,7 +4,7 @@
<p class="mt-2 text-base-content/70">Posts tagged "{@tag}"</p>
</header>
<.post_index posts={@posts} base_path={@base_path} />
<.post_index posts={@posts} base_path={@base_path} current_tag={@tag} />
<a href={@base_path} class="text-sm text-primary hover:underline">&larr; All posts</a>
</div>
@@ -1,6 +1,7 @@
%{
title: "Hello World",
author: "Firehose Team",
published: false,
tags: ~w(elixir phoenix),
description: "Our first engineering blog post"
}
@@ -0,0 +1,13 @@
%{
title: "Coding agent from scratch - a loop with tools, not that complicated",
author: "Willem van den Ende",
published: True,
tags: ~w(llm coding-agent python exercise),
description: "Coding agents are not that complicated. A loop with some tools. I found an interactive tutorial that lets you experience it"
}
---
I had started on a "Write your own coding agent" exercise. Four iterations in, actually. And then I found [Tiny Agents]( https://tinyagents.dev/lesson/agent-loop), a set of interactive exercises that let you experience how agents work, from a simple chat request, through a tool, more tools etc. It has a live graph, that visualises of the flow of data and actions.
It is good fun to play with, it starts simple and builds up. It lets you inspect the messages between the 'agent' loop code and the large language model server (which is just HTTP and some JSON).
@@ -0,0 +1,123 @@
defmodule FirehoseWeb.BlogTagsTest do
use FirehoseWeb.ConnCase
defp goto_engineering_tag_page(conn, tag) do
path = "/blog/engineering/tag/#{tag}"
conn = get(conn, path)
body = html_response(conn, 200)
assert body =~ ~s(tagged "#{tag}")
assert body =~ "Engineering Blog"
body
end
defp goto_releases_tag_page(conn, tag) do
path = "/blog/releases/tag/#{tag}"
conn = get(conn, path)
body = html_response(conn, 200)
assert body =~ ~s(tagged "#{tag}")
assert body =~ "Release Notes"
body
end
describe "engineering blog tags" do
test "GET /blog/engineering/tag/:tag shows tag page with all posts", %{conn: conn} do
body = goto_engineering_tag_page(conn, "elixir")
assert body =~ "Hello World"
end
test "GET /blog/engineering/tag/:tag page shows filtered posts", %{conn: conn} do
body = goto_engineering_tag_page(conn, "phoenix")
assert body =~ "Hello World"
end
test "GET /blog/engineering/tag/:tag page shows empty list for nonexistent tag", %{
conn: conn
} do
body = get(conn, "/blog/engineering/tag/nonexistent-tag")
assert html_response(body, 200) =~ ~s(tagged "nonexistent-tag")
end
end
describe "release notes blog tags" do
test "GET /blog/releases/tag/:tag shows tag page with all posts", %{conn: conn} do
body = goto_releases_tag_page(conn, "release")
assert body =~ "v0.1.0 Released"
end
test "GET /blog/releases/tag/:tag page shows filtered posts", %{conn: conn} do
body = get(conn, "/blog/releases/tag/nonexistent-tag")
assert html_response(body, 200) =~ ~s(tagged "nonexistent-tag")
end
end
describe "tag URL pattern" do
test "tag URLs follow pattern /blog/:blog_id/tag/:tag for engineering blog", %{conn: conn} do
# Test that the tag route exists and works correctly
conn = get(conn, "/blog/engineering/tag/elixir")
assert html_response(conn, 200) =~ ~s(tagged "elixir")
conn = get(conn, "/blog/engineering/tag/phoenix")
assert html_response(conn, 200) =~ ~s(tagged "phoenix")
end
test "tag URLs follow pattern /blog/:blog_id/tag/:tag for releases blog", %{conn: conn} do
# Test that the tag route exists and works correctly
conn = get(conn, "/blog/releases/tag/release")
assert html_response(conn, 200) =~ ~s(tagged "release")
end
test "nonexistent tags return 200 with empty post list", %{conn: conn} do
conn = get(conn, "/blog/engineering/tag/nonexistent-tag")
assert html_response(conn, 200)
end
end
describe "tag page structure" do
test "tag page has proper layout and back link", %{conn: conn} do
body = goto_engineering_tag_page(conn, "elixir")
assert body =~ "Engineering Blog"
assert body =~ ~s(tagged "elixir")
assert body =~ "All posts"
end
test "release tag page has proper layout and back link", %{conn: conn} do
body = goto_releases_tag_page(conn, "release")
assert body =~ "Release Notes"
assert body =~ ~s(tagged "release")
assert body =~ "All posts"
end
end
describe "clickable tags on index page" do
test "tags are rendered as clickable links on engineering blog index", %{
conn: conn
} do
conn = get(conn, "/blog/engineering")
body = html_response(conn, 200)
# Verify tag links exist with correct href pattern
assert body =~ ~r{href="/blog/engineering/tag/meta"}
assert body =~ ~r{href="/blog/engineering/tag/ai"}
end
test "tags are rendered as clickable links on releases blog index", %{
conn: conn
} do
conn = get(conn, "/blog/releases")
body = html_response(conn, 200)
# Verify tag link exists
assert body =~ ~r{href="/blog/releases/tag/release"}
end
test "tag links have proper styling classes", %{conn: conn} do
conn = get(conn, "/blog/engineering")
body = html_response(conn, 200)
# Verify blogex-tag-link class is present for tag links
assert body =~ ~r{class="[^"]*blogex-tag-link}
end
end
end