1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00

Add redcarpet for Markdown. Specs pass!

This commit is contained in:
Dan Barber 2014-03-05 17:56:23 +00:00
parent 4759cb4f43
commit be93b79024
6 changed files with 14 additions and 9 deletions

View File

@ -71,9 +71,8 @@ gem 'formtastic'
gem 'squeel'
#gem 'mini_exiftool'
gem 'will_paginate'
gem 'rdiscount'
gem 'redcarpet'
gem 'paperclip'
#gem 'acts_as_markup'
gem 'haml'
gem 'slugtastic'

View File

@ -156,7 +156,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.1.1)
rdiscount (2.1.7)
redcarpet (3.1.1)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
@ -246,7 +246,7 @@ DEPENDENCIES
powder
pry
rails (~> 4.0.0)
rdiscount
redcarpet
rspec-rails
ruby_parser
sass-rails (~> 4.0.0)

View File

@ -1,6 +1,6 @@
class PagesController < ApplicationController
def show
@page = Page.find_by_name!(params[:name])
@page = PagePresenter.new(Page.find_by_name!(params[:name]))
@page_title = @page.title
end
end

View File

@ -1,5 +1,2 @@
require 'rdiscount'
class Page < ActiveRecord::Base
acts_as_markdown :content, :markdown_options => [ :smart ]
end

View File

@ -0,0 +1,9 @@
class PagePresenter < SimpleDelegator
def content_as_html
PagePresenter.markdown.render(content)
end
def self.markdown
@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions = {})
end
end

View File

@ -8,7 +8,7 @@
<div class="sg-11 about-content">
<div>
<%= raw(@page.content.to_html) %>
<%= raw(@page.content_as_html) %>
</div>
</div>