about summary refs log tree commit diff stats
path: root/app
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-10-11 12:12:25 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-10-11 12:12:25 -0400
commite09aa803cf3905c82c29dbaa9101cc4a4639cc5a (patch)
tree507ffb887044bfbcd2fd5cf89f8fe587654d01ba /app
parent3a628945ade35f3ba351ba90e271608520753174 (diff)
downloadthoughts-e09aa803cf3905c82c29dbaa9101cc4a4639cc5a.tar.gz
thoughts-e09aa803cf3905c82c29dbaa9101cc4a4639cc5a.tar.bz2
thoughts-e09aa803cf3905c82c29dbaa9101cc4a4639cc5a.zip
We're on Markdown now
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/admin/layout.scss8
-rw-r--r--app/controllers/admin/blogs_controller.rb2
-rw-r--r--app/helpers/application_helper.rb5
-rw-r--r--app/models/blog.rb8
-rw-r--r--app/views/blogs/_blog.html.haml7
-rw-r--r--app/views/blogs/index.html.haml2
-rw-r--r--app/views/blogs/show.html.haml2
7 files changed, 30 insertions, 4 deletions
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
14end 19end
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