This commit is contained in:
Rikuoh Tsujitani 2024-08-02 22:54:42 +09:00
parent 5e9c7fa37e
commit a2cc0a737e
Signed by: riq0h
GPG key ID: 010F09DEA298C717
3 changed files with 24 additions and 1 deletions

View file

@ -39,16 +39,19 @@ end
get '/memos/:id' do
@memo = load_memos[params[:id]]
halt 404, erb(:not_found) unless @memo
erb :show
end
get '/memos/:id/edit' do
@memo = load_memos[params[:id]]
halt 404, erb(:not_found) unless @memo
erb :edit
end
patch '/memos/:id' do
memos = load_memos
halt 404, erb(:not_found) unless memos[params[:id]]
memos[params[:id]] = { 'title' => params[:title], 'content' => params[:content] }
save_memos(memos)
redirect "/memos/#{params[:id]}"
@ -56,7 +59,11 @@ end
delete '/memos/:id' do
memos = load_memos
memos.delete(params[:id])
halt 404, erb(:not_found) unless memos.delete(params[:id])
save_memos(memos)
redirect '/memos'
end
not_found do
erb :not_found
end

View file

@ -2,5 +2,9 @@
"1": {
"title": "",
"content": ""
},
"2": {
"title": "a",
"content": "aaa"
}
}

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>404 Not Found</title>
</head>
<body>
<h1>404 Not Found</h1>
<p>お探しのページは見つかりませんでした。</p>
<a href="/memos">メモ一覧に戻る</a>
</body>
</html>