diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-11 12:12:25 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-11 12:12:25 -0400 |
commit | e09aa803cf3905c82c29dbaa9101cc4a4639cc5a (patch) | |
tree | 507ffb887044bfbcd2fd5cf89f8fe587654d01ba | |
parent | 3a628945ade35f3ba351ba90e271608520753174 (diff) | |
download | thoughts-e09aa803cf3905c82c29dbaa9101cc4a4639cc5a.tar.gz thoughts-e09aa803cf3905c82c29dbaa9101cc4a4639cc5a.tar.bz2 thoughts-e09aa803cf3905c82c29dbaa9101cc4a4639cc5a.zip |
We're on Markdown now
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | Gemfile.lock | 2 | ||||
-rw-r--r-- | app/assets/stylesheets/admin/layout.scss | 8 | ||||
-rw-r--r-- | app/controllers/admin/blogs_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 5 | ||||
-rw-r--r-- | app/models/blog.rb | 8 | ||||
-rw-r--r-- | app/views/blogs/_blog.html.haml | 7 | ||||
-rw-r--r-- | app/views/blogs/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/blogs/show.html.haml | 2 |
9 files changed, 33 insertions, 4 deletions
diff --git a/Gemfile b/Gemfile index 9ad82a9..1230941 100644 --- a/Gemfile +++ b/Gemfile | |||
@@ -77,3 +77,4 @@ gem 'enumerize' | |||
77 | gem 'sprockets', '3.7.2' | 77 | gem 'sprockets', '3.7.2' |
78 | gem 'lingo', git: "https://git.fourisland.com/lingo", glob: "rails/*.gemspec", branch: "main" | 78 | gem 'lingo', git: "https://git.fourisland.com/lingo", glob: "rails/*.gemspec", branch: "main" |
79 | gem 'will_paginate', '~> 4.0' | 79 | gem 'will_paginate', '~> 4.0' |
80 | gem 'redcarpet' | ||
diff --git a/Gemfile.lock b/Gemfile.lock index 47523e5..ac1e851 100644 --- a/Gemfile.lock +++ b/Gemfile.lock | |||
@@ -263,6 +263,7 @@ GEM | |||
263 | rb-fsevent (0.11.2) | 263 | rb-fsevent (0.11.2) |
264 | rb-inotify (0.10.1) | 264 | rb-inotify (0.10.1) |
265 | ffi (~> 1.0) | 265 | ffi (~> 1.0) |
266 | redcarpet (3.6.0) | ||
266 | request_store (1.5.1) | 267 | request_store (1.5.1) |
267 | rack (>= 1.4) | 268 | rack (>= 1.4) |
268 | responders (3.1.0) | 269 | responders (3.1.0) |
@@ -362,6 +363,7 @@ DEPENDENCIES | |||
362 | paperclip | 363 | paperclip |
363 | pokeviewer! | 364 | pokeviewer! |
364 | rails (~> 7.0.3) | 365 | rails (~> 7.0.3) |
366 | redcarpet | ||
365 | sassc-rails | 367 | sassc-rails |
366 | selenium-webdriver | 368 | selenium-webdriver |
367 | spring | 369 | spring |
diff --git a/app/assets/stylesheets/admin/layout.scss b/app/assets/stylesheets/admin/layout.scss index 3adf7da..bf15b0d 100644 --- a/app/assets/stylesheets/admin/layout.scss +++ b/app/assets/stylesheets/admin/layout.scss | |||
@@ -83,6 +83,7 @@ body { | |||
83 | 83 | ||
84 | #entry-form { | 84 | #entry-form { |
85 | display: flex; | 85 | display: flex; |
86 | height: 100%; | ||
86 | 87 | ||
87 | fieldset { | 88 | fieldset { |
88 | border: 0; | 89 | border: 0; |
@@ -143,9 +144,16 @@ body { | |||
143 | } | 144 | } |
144 | 145 | ||
145 | .body-field { | 146 | .body-field { |
147 | height: 100%; | ||
148 | |||
146 | label { | 149 | label { |
147 | display: none; | 150 | display: none; |
148 | } | 151 | } |
152 | |||
153 | textarea { | ||
154 | width: 100%; | ||
155 | height: 100%; | ||
156 | } | ||
149 | } | 157 | } |
150 | } | 158 | } |
151 | 159 | ||
diff --git a/app/controllers/admin/blogs_controller.rb b/app/controllers/admin/blogs_controller.rb index e79dd81..f17bce2 100644 --- a/app/controllers/admin/blogs_controller.rb +++ b/app/controllers/admin/blogs_controller.rb | |||
@@ -44,7 +44,7 @@ class Admin::BlogsController < Admin::AdminController | |||
44 | def update | 44 | def update |
45 | @blog = Blog.find(params[:id]) | 45 | @blog = Blog.find(params[:id]) |
46 | 46 | ||
47 | if @blog.update_attributes(blog_params) | 47 | if @blog.update(blog_params) |
48 | flash.notice = "Blog updated successfully!" | 48 | flash.notice = "Blog updated successfully!" |
49 | else | 49 | else |
50 | flash.alert = "Error updating blog." | 50 | flash.alert = "Error updating blog." |
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8008b04..f12cdd4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb | |||
@@ -11,4 +11,9 @@ module ApplicationHelper | |||
11 | link_to title, {:sort => col, :dir => direction}, {:class => css_class} | 11 | link_to title, {:sort => col, :dir => direction}, {:class => css_class} |
12 | end | 12 | end |
13 | 13 | ||
14 | def markdown(text) | ||
15 | options = %i[] | ||
16 | Markdown.new(text, *options).to_html.html_safe | ||
17 | end | ||
18 | |||
14 | end | 19 | end |
diff --git a/app/models/blog.rb b/app/models/blog.rb index 18f63f1..c12d0dc 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb | |||
@@ -18,6 +18,14 @@ class Blog < ApplicationRecord | |||
18 | self | 18 | self |
19 | end | 19 | end |
20 | 20 | ||
21 | def has_read_more | ||
22 | body.include?("<!--MORE-->") | ||
23 | end | ||
24 | |||
25 | def short_body | ||
26 | body[0..(body.index("<!--MORE-->")-1)] | ||
27 | end | ||
28 | |||
21 | private | 29 | private |
22 | def set_draft_title | 30 | def set_draft_title |
23 | if self.title.blank? and not self.published | 31 | if self.title.blank? and not self.published |
diff --git a/app/views/blogs/_blog.html.haml b/app/views/blogs/_blog.html.haml index 317ef1f..389f961 100644 --- a/app/views/blogs/_blog.html.haml +++ b/app/views/blogs/_blog.html.haml | |||
@@ -6,4 +6,9 @@ | |||
6 | .blog-title | 6 | .blog-title |
7 | %h2= blog.title | 7 | %h2= blog.title |
8 | .post-author Hatkirby | 8 | .post-author Hatkirby |
9 | %blockquote#blog-content.entry-content.bubble.rounded.bottom= blog.body.html_safe | 9 | %blockquote#blog-content.entry-content.bubble.rounded.bottom |
10 | - if short and blog.has_read_more | ||
11 | = markdown(blog.short_body) | ||
12 | = link_to "Read more...", blog | ||
13 | - else | ||
14 | = markdown(blog.body) | ||
diff --git a/app/views/blogs/index.html.haml b/app/views/blogs/index.html.haml index a1ad64c..e9639ca 100644 --- a/app/views/blogs/index.html.haml +++ b/app/views/blogs/index.html.haml | |||
@@ -1,3 +1,3 @@ | |||
1 | - @blogs.each do |blog| | 1 | - @blogs.each do |blog| |
2 | = render blog | 2 | = render blog, short: true |
3 | = will_paginate @blogs | 3 | = will_paginate @blogs |
diff --git a/app/views/blogs/show.html.haml b/app/views/blogs/show.html.haml index f915e64..9bff12b 100644 --- a/app/views/blogs/show.html.haml +++ b/app/views/blogs/show.html.haml | |||
@@ -1,6 +1,6 @@ | |||
1 | - title @blog.title | 1 | - title @blog.title |
2 | .breadcrumb= link_to "← Back to home page", root_path | 2 | .breadcrumb= link_to "← Back to home page", root_path |
3 | = render @blog | 3 | = render @blog, short: false |
4 | %footer#blog-footer | 4 | %footer#blog-footer |
5 | This entry was posted on | 5 | This entry was posted on |
6 | = succeed "." do | 6 | = succeed "." do |