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:
parent
4759cb4f43
commit
be93b79024
3
Gemfile
3
Gemfile
@ -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'
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,5 +1,2 @@
|
||||
require 'rdiscount'
|
||||
|
||||
class Page < ActiveRecord::Base
|
||||
acts_as_markdown :content, :markdown_options => [ :smart ]
|
||||
end
|
||||
|
||||
9
app/presenters/page_presenter.rb
Normal file
9
app/presenters/page_presenter.rb
Normal 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
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
<div class="sg-11 about-content">
|
||||
<div>
|
||||
<%= raw(@page.content.to_html) %>
|
||||
<%= raw(@page.content_as_html) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user