about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-10-17 17:14:40 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-10-17 17:14:40 -0400
commit745b9e5485100c98cc73d1ff90661b43ade9404a (patch)
tree699dd3a32518b9752cdd3a68ddfab4671ecd6d22
parent95e7c215df89608a5b10bebb87968c9a713bbf3d (diff)
downloadthoughts-745b9e5485100c98cc73d1ff90661b43ade9404a.tar.gz
thoughts-745b9e5485100c98cc73d1ff90661b43ade9404a.tar.bz2
thoughts-745b9e5485100c98cc73d1ff90661b43ade9404a.zip
Added OpenGraph data for blog posts
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock3
-rw-r--r--app/controllers/blogs_controller.rb15
-rw-r--r--app/views/layouts/application.html.haml1
4 files changed, 20 insertions, 0 deletions
diff --git a/Gemfile b/Gemfile index 3044a2f..887f7eb 100644 --- a/Gemfile +++ b/Gemfile
@@ -82,3 +82,4 @@ gem 'rouge'
82gem 'akismet' 82gem 'akismet'
83gem 'active_storage_validations' 83gem 'active_storage_validations'
84gem "image_processing", ">= 1.2" 84gem "image_processing", ">= 1.2"
85gem "meta-tags"
diff --git a/Gemfile.lock b/Gemfile.lock index 4ba3db9..18f75fe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock
@@ -198,6 +198,8 @@ GEM
198 net-pop 198 net-pop
199 net-smtp 199 net-smtp
200 marcel (1.0.2) 200 marcel (1.0.2)
201 meta-tags (2.19.0)
202 actionpack (>= 3.2.0, < 7.2)
201 method_source (1.0.0) 203 method_source (1.0.0)
202 mime-types (3.5.1) 204 mime-types (3.5.1)
203 mime-types-data (~> 3.2015) 205 mime-types-data (~> 3.2015)
@@ -373,6 +375,7 @@ DEPENDENCIES
373 js-routes 375 js-routes
374 lingo! 376 lingo!
375 listen (>= 3.0.5, < 3.2) 377 listen (>= 3.0.5, < 3.2)
378 meta-tags
376 mini_racer 379 mini_racer
377 mysql2 380 mysql2
378 normalize-rails 381 normalize-rails
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 39a578a..0d218ae 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb
@@ -1,3 +1,5 @@
1require 'redcarpet/render_strip'
2
1class BlogsController < ApplicationController 3class BlogsController < ApplicationController
2 4
3 def summary 5 def summary
@@ -21,6 +23,19 @@ class BlogsController < ApplicationController
21 23
22 raise ActiveRecord::RecordNotFound unless @blog 24 raise ActiveRecord::RecordNotFound unless @blog
23 raise ActiveRecord::RecordNotFound unless @blog.published 25 raise ActiveRecord::RecordNotFound unless @blog.published
26
27 body = Redcarpet::Markdown.new(Redcarpet::Render::StripDown).render(@blog.body)
28
29 set_meta_tags(og: {
30 title: @blog.title,
31 type: "article",
32 description: (body.length <= 300 ? body : body[0..299]),
33 url: blog_url(@blog, host: "www.fourisland.com"),
34 article: {
35 published_time: @blog.published_at.iso8601,
36 modified_time: @blog.updated_at.iso8601
37 }
38 })
24 end 39 end
25 40
26end 41end
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 92546d1..32afb5d 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml
@@ -5,6 +5,7 @@
5 = csrf_meta_tags 5 = csrf_meta_tags
6 = stylesheet_link_tag 'main', media: 'all', 'data-turbolinks-track': 'reload' 6 = stylesheet_link_tag 'main', media: 'all', 'data-turbolinks-track': 'reload'
7 = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' 7 = javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
8 = display_meta_tags og: { site_name: "Four Island" }
8 %body#main-body 9 %body#main-body
9 - if flash[:alert] 10 - if flash[:alert]
10 %div#flash.flash-alert= flash[:alert] 11 %div#flash.flash-alert= flash[:alert]