Skip to content

Commit

Permalink
site and project notes no longer parsed by md, closes #264
Browse files Browse the repository at this point in the history
  • Loading branch information
cofiem committed Mar 27, 2016
1 parent a29782d commit 9ba8645
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 21 deletions.
5 changes: 0 additions & 5 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ def description_html
CustomRender.render_markdown(self, :description)
end

def notes_html
CustomRender.render_markdown(self, :notes)
end

# Define filter api settings
def self.filter_settings
{
Expand All @@ -60,7 +56,6 @@ def self.filter_settings
project_hash[:site_ids] = fresh_project.nil? ? nil : fresh_project.sites.pluck(:id).flatten

project_hash[:description_html]= fresh_project.description_html
project_hash[:notes_html] = fresh_project.notes_html

[item, project_hash]
},
Expand Down
8 changes: 1 addition & 7 deletions app/models/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,10 @@ def update_location_obfuscated(current_user)
@location_obfuscated = !is_owner
end

# I don't know why Rubymine complains about Kramdown where ever I use it...
def description_html
CustomRender.render_markdown(self, :description)
end

def notes_html
CustomRender.render_markdown(self, :notes)
end

def self.add_location_jitter(value, min, max)

# multiply by 10,000 to get to ~10m accuracy
Expand Down Expand Up @@ -192,8 +187,7 @@ def self.filter_settings
custom_latitude: fresh_site.latitude,
custom_longitude: fresh_site.longitude,
timezone_information: TimeZoneHelper.info_hash(fresh_site),
description_html: fresh_site.description_html,
notes_html: fresh_site.notes_html
description_html: fresh_site.description_html
}
end

Expand Down
1 change: 1 addition & 0 deletions lib/modules/custom_render.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class << self
def render_markdown(model, attribute)
value = model[attribute]
is_blank = value.blank?
# I don't know why Rubymine complains about Kramdown not being found...
is_blank ? nil : ApplicationController.helpers.sanitize(Kramdown::Document.new(value).to_html)
end
end
Expand Down
7 changes: 2 additions & 5 deletions spec/models/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@
expect(FactoryGirl.create(:project, created_at: nil)).not_to be_a_new(Project)
end

it 'generates html for description and notes' do
it 'generates html for description' do
md = "# Header\r\n [a link](https://github.com)."
html = "<h1>Header</h1>\n<p><a href=\"https://github.com\">a link</a>.</p>\n"
projectHtml = FactoryGirl.create(:project, description: md, notes: md)
projectHtml = FactoryGirl.create(:project, description: md)

expect(projectHtml.description).to eq(md)
expect(projectHtml.description_html).to eq(html)

expect(projectHtml.notes).to eq(md)
expect(projectHtml.notes_html).to eq(html)
end

# this should pass, but the paperclip implementation of validate_attachment_content_type is buggy.
Expand Down
6 changes: 2 additions & 4 deletions spec/models/site_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,14 @@
}.to raise_error(CustomErrors::OrphanedSiteError)
end

it 'generates html for description and notes' do
it 'generates html for description' do
md = "# Header\r\n [a link](https://github.com)."
html = "<h1>Header</h1>\n<p><a href=\"https://github.com\">a link</a>.</p>\n"
projectHtml = FactoryGirl.create(:site, description: md, notes: md)
projectHtml = FactoryGirl.create(:site, description: md)

expect(projectHtml.description).to eq(md)
expect(projectHtml.description_html).to eq(html)

expect(projectHtml.notes).to eq(md)
expect(projectHtml.notes_html).to eq(html)
end

it 'should error on invalid timezone' do
Expand Down

0 comments on commit 9ba8645

Please sign in to comment.