first commit
This commit is contained in:
26
app/views/articles/_form.html.erb
Normal file
26
app/views/articles/_form.html.erb
Normal file
@@ -0,0 +1,26 @@
|
||||
<%= form_with model: article do |form| %>
|
||||
<div>
|
||||
<%= form.label :title %><br>
|
||||
<%= form.text_field :title %>
|
||||
<% article.errors.full_messages_for(:title).each do |message| %>
|
||||
<div><%= message %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :body %><br>
|
||||
<%= form.text_area :body %>
|
||||
<% article.errors.full_messages_for(:body).each do |message| %>
|
||||
<div><%= message %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :status %><br>
|
||||
<%= form.select :status, Visible::VALID_STATUSES, selected: article.status || 'public' %><br>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
3
app/views/articles/edit.html.erb
Normal file
3
app/views/articles/edit.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<h1>Edit Article</h1>
|
||||
|
||||
<%= render "form", article: @article %>
|
||||
15
app/views/articles/index.html.erb
Normal file
15
app/views/articles/index.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<h1>Articles!</h1>
|
||||
|
||||
Our blog has <%= Article.public_count %> articles and counting!
|
||||
|
||||
<ul>
|
||||
<% @articles.each do |article| %>
|
||||
<% unless article.archived? %>
|
||||
<li>
|
||||
<%= link_to article.title, article %>
|
||||
</li>
|
||||
<%end%>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<%= link_to "New Article", new_article_path %>
|
||||
3
app/views/articles/new.html.erb
Normal file
3
app/views/articles/new.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<h1>New Article</h1>
|
||||
|
||||
<%= render "form", article: @article %>
|
||||
17
app/views/articles/show.html.erb
Normal file
17
app/views/articles/show.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<h1><%= @article.title %></h1>
|
||||
|
||||
<p><%= @article.body %></p>
|
||||
|
||||
<ul>
|
||||
<li><%= link_to "Edit", edit_article_path(@article) %></li>
|
||||
<li><%= link_to "Destroy", article_path(@article), data: {
|
||||
turbo_method: :delete,
|
||||
turbo_confirm: "Are you sure?"
|
||||
} %></li>
|
||||
</ul>
|
||||
|
||||
<h2>Comments</h2>
|
||||
<%= render @article.comments %>
|
||||
|
||||
<h2>Add a comment</h2>
|
||||
<%= render "comments/form" %>
|
||||
17
app/views/comments/_comment.html.erb
Normal file
17
app/views/comments/_comment.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<% unless comment.archived? %>
|
||||
<p>
|
||||
<strong>Commenter:</strong>
|
||||
<%= comment.commenter %>
|
||||
</p>
|
||||
<p>
|
||||
<strong>Comment:</strong>
|
||||
<%= comment.body %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= link_to "Destroy Comment", [comment.article, comment], data: {
|
||||
turbo_method: :delete,
|
||||
turbo_confirm: "Are you sure?"
|
||||
} %>
|
||||
</p>
|
||||
<% end %>
|
||||
17
app/views/comments/_form.html.erb
Normal file
17
app/views/comments/_form.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<%= form_with model: [ @article, @article.comments.build ] do |form| %>
|
||||
<p>
|
||||
<%= form.label :commenter %><br>
|
||||
<%= form.text_field :commenter %><br>
|
||||
</p>
|
||||
<p>
|
||||
<%= form.label :body %><br>
|
||||
<%= form.text_area :body %><br>
|
||||
</p>
|
||||
<p>
|
||||
<%= form.label :status %><br>
|
||||
<%= form.select :status, Visible::VALID_STATUSES, selected: 'public' %><br>
|
||||
</p>
|
||||
<p>
|
||||
<%= form.submit %><br>
|
||||
</p>
|
||||
<% end %>
|
||||
16
app/views/layouts/application.html.erb
Normal file
16
app/views/layouts/application.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Blog</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
|
||||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
||||
<%= javascript_importmap_tags %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
13
app/views/layouts/mailer.html.erb
Normal file
13
app/views/layouts/mailer.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<style>
|
||||
/* Email styles need to be inline */
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
1
app/views/layouts/mailer.text.erb
Normal file
1
app/views/layouts/mailer.text.erb
Normal file
@@ -0,0 +1 @@
|
||||
<%= yield %>
|
||||
Reference in New Issue
Block a user