about summary refs log tree commit diff stats
path: root/app
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-10-14 10:15:24 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-10-14 10:15:24 -0400
commit0aace2986a9a7a6d4c84a9ba6819d3df7821e267 (patch)
tree450acd91cbd522d47577233ca28725ede6697bb2 /app
parent07ac5db98c8884e0de81fc6c0ab873854a852ca5 (diff)
downloadthoughts-0aace2986a9a7a6d4c84a9ba6819d3df7821e267.tar.gz
thoughts-0aace2986a9a7a6d4c84a9ba6819d3df7821e267.tar.bz2
thoughts-0aace2986a9a7a6d4c84a9ba6819d3df7821e267.zip
Blogs have an author now
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/blogs_controller.rb1
-rw-r--r--app/mailers/comment_mailer.rb6
-rw-r--r--app/models/blog.rb2
-rw-r--r--app/models/user.rb2
-rw-r--r--app/views/blogs/_blog.html.haml4
5 files changed, 9 insertions, 6 deletions
diff --git a/app/controllers/admin/blogs_controller.rb b/app/controllers/admin/blogs_controller.rb index 8e288a8..f0ce519 100644 --- a/app/controllers/admin/blogs_controller.rb +++ b/app/controllers/admin/blogs_controller.rb
@@ -25,6 +25,7 @@ class Admin::BlogsController < Admin::AdminController
25 25
26 def create 26 def create
27 @blog = Blog.new(blog_params) 27 @blog = Blog.new(blog_params)
28 @blog.user = current_user
28 29
29 if @blog.save 30 if @blog.save
30 flash.notice = "Blog created successfully!" 31 flash.notice = "Blog created successfully!"
diff --git a/app/mailers/comment_mailer.rb b/app/mailers/comment_mailer.rb index e72b17d..aeed1b0 100644 --- a/app/mailers/comment_mailer.rb +++ b/app/mailers/comment_mailer.rb
@@ -1,13 +1,11 @@
1class CommentMailer < ApplicationMailer 1class CommentMailer < ApplicationMailer
2 def new_comment_email 2 def new_comment_email
3 @comment = params[:comment] 3 @comment = params[:comment]
4 @admin = User.first # this is weird 4 mail(to: @comment.blog.user.email, subject: "[Four Island] Comment on #{@comment.blog.title}")
5 mail(to: @admin.email, subject: "[Four Island] Comment on #{@comment.blog.title}")
6 end 5 end
7 6
8 def new_pending_comment_email 7 def new_pending_comment_email
9 @comment = params[:comment] 8 @comment = params[:comment]
10 @admin = User.first # this is weird 9 mail(to: @comment.blog.user.email, subject: "[Four Island] Pending comment on #{@comment.blog.title}")
11 mail(to: @admin.email, subject: "[Four Island] Pending comment on #{@comment.blog.title}")
12 end 10 end
13end 11end
diff --git a/app/models/blog.rb b/app/models/blog.rb index e640466..e43990e 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb
@@ -4,10 +4,12 @@ class Blog < ApplicationRecord
4 acts_as_taggable 4 acts_as_taggable
5 5
6 has_many :comments 6 has_many :comments
7 belongs_to :user
7 8
8 validates :title, presence: true 9 validates :title, presence: true
9 validates :body, presence: true, if: :published 10 validates :body, presence: true, if: :published
10 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/, if: :published 11 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/, if: :published
12 validates :user, presence: true
11 13
12 before_validation :set_draft_title 14 before_validation :set_draft_title
13 before_save :set_published_at 15 before_save :set_published_at
diff --git a/app/models/user.rb b/app/models/user.rb index 555729a..f9f68fa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb
@@ -5,4 +5,6 @@ class User < ApplicationRecord
5 :recoverable, :rememberable, :trackable, :validatable 5 :recoverable, :rememberable, :trackable, :validatable
6 6
7 has_secure_token :pokeviewer_token 7 has_secure_token :pokeviewer_token
8
9 has_many :blogs
8end 10end
diff --git a/app/views/blogs/_blog.html.haml b/app/views/blogs/_blog.html.haml index 5467683..ec61bb5 100644 --- a/app/views/blogs/_blog.html.haml +++ b/app/views/blogs/_blog.html.haml
@@ -5,7 +5,7 @@
5 %span.post-day= blog.visible_date.day 5 %span.post-day= blog.visible_date.day
6 .blog-title 6 .blog-title
7 %h2= link_to_unless_current blog.title, blog 7 %h2= link_to_unless_current blog.title, blog
8 .post-author Hatkirby 8 .post-author= blog.user.login.capitalize
9 %ul.post-tag-3 9 %ul.post-tag-3
10 - blog.tags.each do |tag| 10 - blog.tags.each do |tag|
11 %li= link_to tag, tag_url(tag.name) 11 %li= link_to tag, tag_url(tag.name)
@@ -16,6 +16,6 @@
16 - else 16 - else
17 = markdown(blog.body) 17 = markdown(blog.body)
18 %cite.bubble 18 %cite.bubble
19 %strong Hatkirby 19 %strong= blog.user.login.capitalize
20 on 20 on
21 = blog.visible_date.strftime("%B #{blog.visible_date.day.ordinalize}, %Y at %-I:%M:%S%P") 21 = blog.visible_date.strftime("%B #{blog.visible_date.day.ordinalize}, %Y at %-I:%M:%S%P")