From eeb2bf9938192925951530d108692bcab6b632b3 Mon Sep 17 00:00:00 2001 From: Shiho Takagi Date: Wed, 17 Sep 2014 21:38:43 +1000 Subject: [PATCH 1/4] added planting_id param to Flickr set search (new_photo_path form). --- app/views/photos/new.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index 32ea66915..365351fac 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -15,6 +15,7 @@ = form_tag(new_photo_path, :method => :get, :class => 'form-inline') do = label_tag :set, "Choose a photo set:", :class => 'control-label' = select_tag :set, options_for_select(@sets, @current_set), :class => 'input-large' + = hidden_field_tag :planting_id, @planting_id = submit_tag "Search", :class => 'btn btn-primary' %div.pagination From dd75f2aef909ab533f7c8c93db591f16ebc4778d Mon Sep 17 00:00:00 2001 From: Shiho Takagi Date: Thu, 18 Sep 2014 14:18:18 +1000 Subject: [PATCH 2/4] updated regex for crop in markdown --- lib/haml/filters/growstuff_markdown.rb | 2 +- spec/lib/haml/filters/growstuff_markdown_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/haml/filters/growstuff_markdown.rb b/lib/haml/filters/growstuff_markdown.rb index 35333a256..7069590e7 100644 --- a/lib/haml/filters/growstuff_markdown.rb +++ b/lib/haml/filters/growstuff_markdown.rb @@ -7,7 +7,7 @@ module Haml::Filters def render(text) # turn [tomato](crop) into [tomato](http://growstuff.org/crops/tomato) - expanded = text.gsub(/\[(.*?)\]\(crop\)/) do |m| + expanded = text.gsub(/\[([^\[\]]+?)\]\(crop\)/) do |m| crop_str = $1 # find crop case-insensitively crop = Crop.where('lower(name) = ?', crop_str.downcase).first diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index 566740307..cc6a2af54 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -52,4 +52,14 @@ describe 'Haml::Filters::Growstuff_Markdown' do rendered.should match /#{output_link(@crop, 'ToMaTo')}/ end + + it "doesn't convert when it's not followed by '(crop)'" do + tomato = FactoryGirl.create(:tomato) + maize = FactoryGirl.create(:maize) + string = "[maize](http://example.com) #{input_link(tomato)}" + rendered = Haml::Filters::GrowstuffMarkdown.render(string) + rendered.should match /#{output_link(tomato)}/ + rendered.should_not match /#{output_link(maize)}/ + rendered.should match "maize" + end end From aa028db2dc649d90a0f2090da1904ad35bbe7c6d Mon Sep 17 00:00:00 2001 From: Shiho Takagi Date: Wed, 17 Sep 2014 21:38:43 +1000 Subject: [PATCH 3/4] added planting_id param to Flickr set search (new_photo_path form). --- CONTRIBUTORS.md | 1 + app/views/photos/new.html.haml | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 5bd5cc601..79dfdcaa1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -45,3 +45,4 @@ submit the change with your pull request. - Marlena Compton / [Marlena](https://github.com/marlena) - Elizabeth A. Kari / [catfriend](https://github.com/catfriend) - Cheri Allen / [cherimarie](https://github.com/cherimarie) +- Shiho Takagi / [oshiho3](https://github.com/oshiho3) diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index 32ea66915..365351fac 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -15,6 +15,7 @@ = form_tag(new_photo_path, :method => :get, :class => 'form-inline') do = label_tag :set, "Choose a photo set:", :class => 'control-label' = select_tag :set, options_for_select(@sets, @current_set), :class => 'input-large' + = hidden_field_tag :planting_id, @planting_id = submit_tag "Search", :class => 'btn btn-primary' %div.pagination From 60354264d6643a6d268cb87efb83ade72444517a Mon Sep 17 00:00:00 2001 From: Shiho Takagi Date: Fri, 19 Sep 2014 16:00:25 +1000 Subject: [PATCH 4/4] Included PT bug# to its test description. Test using the case from the bug --- spec/lib/haml/filters/growstuff_markdown_spec.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index cc6a2af54..718645322 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -52,14 +52,12 @@ describe 'Haml::Filters::Growstuff_Markdown' do rendered.should match /#{output_link(@crop, 'ToMaTo')}/ end - - it "doesn't convert when it's not followed by '(crop)'" do + it "fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)" do tomato = FactoryGirl.create(:tomato) - maize = FactoryGirl.create(:maize) - string = "[maize](http://example.com) #{input_link(tomato)}" + string = "[test](http://example.com) [tomato](crop)" rendered = Haml::Filters::GrowstuffMarkdown.render(string) rendered.should match /#{output_link(tomato)}/ - rendered.should_not match /#{output_link(maize)}/ - rendered.should match "maize" + rendered.should match "test" end + end