Skip to content

Commit

Permalink
Comment form
Browse files Browse the repository at this point in the history
  • Loading branch information
luontola committed Feb 23, 2018
1 parent 04abc1b commit 6dd52bf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions app.rb
Expand Up @@ -16,6 +16,7 @@

get '/pictures/:picture.html' do
@title = "Picture"
@picture = params['picture']
@picture_url = find_picture_url(params['picture']) or halt 404
erb :picture
end
Expand Down
8 changes: 8 additions & 0 deletions public/style.css
Expand Up @@ -51,3 +51,11 @@ h1 {
.full-photo {
width: 100%;
}

.add-comment input, .add-comment textarea {
width: 40ch;
}

.add-comment textarea {
height: 3em;
}
11 changes: 11 additions & 0 deletions views/picture.erb
@@ -1,3 +1,14 @@
<img class="full-photo" src="<%= @picture_url %>">

<p><a href="/pictures.html">Return to album</a></p>

<h2>Comments</h2>

<form action="/add-comment" method="post" class="add-comment">
<input type="hidden" name="picture" value="<%= @picture %>">
<label for="author">Name</label>
<br><input type="text" name="author">
<br><label for="message">Comment</label>
<br><textarea type="text" name="message"></textarea>
<br><button type="submit">Add Comment</button>
</form>

0 comments on commit 6dd52bf

Please sign in to comment.