Skip to content

Commit

Permalink
Format posts with Markdown
Browse files Browse the repository at this point in the history
Closes #4.
  • Loading branch information
c-lliope committed Sep 20, 2016
1 parent ceb809a commit e2f4349
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gem "puma"
gem "rack-canonical-host"
gem "rails", "~> 5.0.0"
gem "recipient_interceptor"
gem "redcarpet"
gem "sass-rails", "~> 5.0"
gem "simple_form"
gem "skylight"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ GEM
ffi (>= 0.5.0)
recipient_interceptor (0.1.2)
mail
redcarpet (3.3.4)
refills (0.2.0)
rspec-core (3.5.3)
rspec-support (~> 3.5.0)
Expand Down Expand Up @@ -304,6 +305,7 @@ DEPENDENCIES
rails (~> 5.0.0)
rails_stdout_logging
recipient_interceptor
redcarpet
refills
rspec-rails (~> 3.5.0.beta4)
sass-rails (~> 5.0)
Expand Down
7 changes: 6 additions & 1 deletion app/assets/stylesheets/_layout.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
.content {
@include outer-container;
padding: $base-spacing 0;
}

.left-column,
.right-column {
@include span-columns(6 of 12);
@include span-columns(5.5 of 12);
}

.right-column {
@include shift(1);
}
7 changes: 0 additions & 7 deletions app/assets/stylesheets/base/_lists.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
ul,
ol {
list-style-type: none;
margin: 0;
padding: 0;
}

dl {
margin: 0;
}
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module ApplicationHelper
def markdown(source)
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(source).html_safe
end

def expiration_time
if Post.any?
Post.order(created_at: :desc).first.created_at + 7.days
Expand Down
2 changes: 1 addition & 1 deletion app/views/posts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<div class="post">
<%= link_to post.title, post, class: "post-title" %>
<div class="post-date"><%= l(post.created_at) %></div>
<%= simple_format post.body.truncate(300) %>
<%= markdown post.body.truncate(300) %>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/posts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="post-date"><%= l(@post.created_at) %></div>

<div class="post">
<%= simple_format @post.body %>
<%= markdown @post.body %>
</div>

<%= link_to "Back", posts_path %>

0 comments on commit e2f4349

Please sign in to comment.