Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions haikus.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[
{
"text": "rain in seattle,\ndon't forget an umbrella,\nor it will be gloom",
"text": "西雅圖降雨,\n別忘帶把雨傘去,\n否則心情灰。",
"image": "puddle_jumper_octodex.jpg"
},
{
"text": "my tunes on repeat,\nit's time for me to dj,\nhave you heard this one?",
"text": "我的歌重播,\n現在輪到我DJ,\n你聽過這首?",
"image": "vinyltocat.jpeg"
},
{
"text": "snow is still falling,\nis it time for après yet?\nlet's do one more run",
"text": "雪花仍飄落,\n該是滑雪後放鬆?\n再滑一趟吧。",
"image": "snowtocat_final.jpg"
},
{
"text": "beep boop bop beep boop,\ni am robot octocat,\ni think there's a bug",
"text": "嗶嗶波波嗶,\n我是機器章魚貓,\n我想有個錯。",
"image": "Robotocat.jpeg"
},
{
"text": "same plot as before,\nso why is it still awesome?\ni think it's the hat",
"text": "情節如從前,\n為何依然很精彩?\n我想是帽子。",
"image": "linktocat.jpg"
}
]
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ app.get("/healthz", (req, res) => {
});

app.use((err, req, res, next) => {
console.error("Unhandled error:", err);
console.error("未處理的錯誤:", err);

if (res.headersSent) {
return next(err);
}

return res.status(500).json({
error: "internal_server_error",
error: "內部伺服器錯誤",
});
});

if (require.main === module) {
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
console.log(`伺服器正在連接埠 ${port} 上運行`);
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test("GET / returns html page", async () => {

assert.equal(response.status, 200);
assert.match(response.headers["content-type"], /text\/html/);
assert.match(response.text, /Haikus for Mona/);
assert.match(response.text, /Mona 的俳句/);
});

test("GET /healthz returns ok status", async () => {
Expand Down
15 changes: 8 additions & 7 deletions views/index.ejs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<!DOCTYPE html>
<html>
<html lang="zh-TW">
<head>
<title>Haikus for Mona</title>
<meta charset="UTF-8">
<title>Mona 的俳句</title>
<link href="/css/main.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="Haikus for Mona">
<meta property="og:description" content="Some of the best haikus you'll ever read about our rescue dog June">
<meta property="og:title" content="Mona 的俳句">
<meta property="og:description" content="關於我們救援犬 June 的最佳俳句">
<meta property="og:image" content="/images/snowtocat_final.jpg">
<meta property="og:image:alt" content="A snow-themed Octocat illustration">
<meta property="og:image:alt" content="雪主題的章魚貓插圖">
</head>
<body>
<h1>Haikus for Mona</h1>
<h1>Mona 的俳句</h1>
<div>
<% for (const [i, { image, text }] of haikus.entries()) { %>
<img
class="mona-images"
src="images/<%= image %>"
alt="Haiku illustration <%= i + 1 %>" />
alt="俳句插圖 <%= i + 1 %>" />
<div class="haiku-containers">
<p class="haikus"><%= text %></p>
</div>
Expand Down
Loading