Skip to content

Commit 08a0a5a

Browse files
committed
Made new article and comment pages work with application.html.erb
1 parent 21e6238 commit 08a0a5a

File tree

2 files changed

+72
-48
lines changed

2 files changed

+72
-48
lines changed

app/views/articles/new.html.erb

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
1-
<h1>New Article</h1>
1+
<tr style="height:10px"></tr>
2+
<tr>
3+
<td>
4+
<h1>New Article</h1>
25

3-
<%= form_with model: @article do |form| %>
4-
<div>
5-
<div>
6-
<%= form.label :title %>
7-
</div>
8-
<%= form.text_field :title %>
9-
<% @article.errors.full_messages_for(:title).each do |message| %>
10-
<div><%= message %></div>
11-
<% end %>
12-
</div>
6+
<%= form_with model: @article do |form| %>
7+
<div>
8+
<div>
9+
<%= form.label :title %>
10+
</div>
11+
<%= form.text_field :title %>
12+
<% @article.errors.full_messages_for(:title).each do |message| %>
13+
<div><%= message %></div>
14+
<% end %>
15+
</div>
1316

14-
<div>
1517
<div>
16-
<%= form.label :link %>
18+
<div>
19+
<%= form.label :link %>
20+
</div>
21+
<div>
22+
<%= form.text_area :link %>
23+
</div>
24+
<% @article.errors.full_messages_for(:link).each do |message| %>
25+
<div><%= message %></div>
26+
<% end %>
1727
</div>
28+
1829
<div>
19-
<%= form.text_area :link %>
30+
<%= form.submit %>
2031
</div>
21-
<% @article.errors.full_messages_for(:link).each do |message| %>
22-
<div><%= message %></div>
2332
<% end %>
24-
</div>
33+
</td>
34+
</tr>
2535

26-
<div>
27-
<%= form.submit %>
28-
</div>
29-
<% end %>

app/views/comments/show.html.erb

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1-
<h1>Comment by <%= link_to comment.user.name, comment.user %></h1>
2-
<p><%= comment.text %></p>
3-
<div style="display: flex; align-items: center;">
4-
Posted on <%= comment.created_at.strftime("%B %d, %Y at %I:%M %p") %>
5-
- Score: <span id="score-Comment-<%= comment.id %>"><%= comment.score %></span>
6-
<% user_vote = @user_votes[comment.id] %>
7-
<%= button_to "Upvote", upvote_article_comment_path(comment), method: :post, class: "btn btn-sm upvote-button", data: { votable_type: 'Comment', votable_id: comment.id, article_id: comment.article.id } %>
8-
<%= button_to "Downvote", downvote_article_comment_path(comment), method: :post, method: :post, class: "btn btn-sm downvote-button", data: { votable_type: 'Comment', votable_id: comment.id, article_id: comment.article.id } %>
9-
</div>
10-
<h2>Replies</h2>
11-
<ul>
12-
<% comment.replies.each do |reply| %>
13-
<%= render_comment_tree(reply) %>
14-
<% end %>
15-
</ul>
16-
17-
<h3>Write a Reply</h3>
18-
<%= form_with(model: [comment.article, @reply], local: true) do |form| %>
19-
<div class="field">
20-
<%= form.text_area :text %>
21-
</div>
22-
<%= form.hidden_field :parent_id, value: comment.id %>
23-
<div class="actions">
24-
<%= form.submit "Reply" %>
25-
</div>
26-
<% end %>
27-
1+
<tr style="height:10px"></tr>
2+
<tr>
3+
<td>
4+
<table border="0" cellpadding="0" cellspacing="0">
5+
<tbody>
6+
<tr>
7+
<td align="right">
8+
<span class="rank"><%= 1 %>.</span>
9+
</td>
10+
<td valign="top" class="votelinks">
11+
<center>
12+
<%= button_to upvote_article_comment_path(comment), method: :post, class: "btn btn-sm upvote-button", data: { votable_type: 'Comment', votable_id: comment.id, article_id: comment.article.id } do %>
13+
<i class="fas fa-arrow-up"></i>
14+
<% end %>
15+
<%= button_to downvote_article_comment_path(comment), method: :post, class: "btn btn-sm downvote-button", data: { votable_type: 'Comment', votable_id: comment.id, article_id: comment.article.id } do %>
16+
<i class="fas fa-arrow-down"></i>
17+
<% end %>
18+
</center>
19+
</td>
20+
<td valign="top" style="padding-left: 10px;">
21+
<%= comment.text %>
22+
</td>
23+
</tr>
24+
<tr>
25+
<td colspan="2"></td>
26+
<td class="subtext">
27+
<span id="score-Comment-<%= comment.id %>"><%= comment.score %> points</span>
28+
by <%= link_to comment.user.name, user_path(comment.user) %>
29+
<span class="age"><%= time_ago_in_words(comment.created_at) %> ago</span>
30+
</td>
31+
</tr>
32+
<tr style="height:5px"></tr>
33+
</tbody>
34+
</table>
35+
<%= form_with(model: [comment.article, @reply], local: true) do |form| %>
36+
<div class="field">
37+
<%= form.text_area :text %>
38+
</div>
39+
<%= form.hidden_field :parent_id, value: comment.id %>
40+
<div class="actions">
41+
<%= form.submit "Reply" %>
42+
</div>
43+
<% end %>
44+
</td>
45+
</tr>

0 commit comments

Comments
 (0)