diff options
-rw-r--r-- | app/controllers/admin/blog/posts_controller.rb | 16 | ||||
-rw-r--r-- | app/controllers/blog/posts_controller.rb | 5 | ||||
-rw-r--r-- | app/views/blog/shared/_post.html.erb | 2 | ||||
-rw-r--r-- | app/views/blog/shared/_tags.html.erb | 2 | ||||
-rw-r--r-- | changelog.md | 4 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | features/support/step_definitions/tags_steps.rb | 2 | ||||
-rw-r--r-- | lib/refinery/blog/version.rb | 2 | ||||
-rw-r--r-- | refinerycms-blog.gemspec | 4 |
9 files changed, 28 insertions, 11 deletions
diff --git a/app/controllers/admin/blog/posts_controller.rb b/app/controllers/admin/blog/posts_controller.rb index 9fdc638..e180741 100644 --- a/app/controllers/admin/blog/posts_controller.rb +++ b/app/controllers/admin/blog/posts_controller.rb @@ -12,9 +12,21 @@ class Admin::Blog::PostsController < Admin::BaseController end def tags + op = case ActiveRecord::Base.connection.adapter_name.downcase + when 'postgresql' + '~*' + else + 'LIKE' + end + wildcard = case ActiveRecord::Base.connection.adapter_name.downcase + when 'postgresql' + '.*' + else + '%' + end @tags = BlogPost.tag_counts_on(:tags).where( - ["tags.name LIKE ?", "%#{params[:term].to_s.downcase}%"] - ).map { |tag| {:id => tag.id, :value => tag.name}} + ["tags.name #{op} ?", "#{wildcard}#{params[:term].to_s.downcase}#{wildcard}"] + ).map { |tag| {:id => tag.id, :value => tag.name}} render :json => @tags.flatten end diff --git a/app/controllers/blog/posts_controller.rb b/app/controllers/blog/posts_controller.rb index 6b59867..4ea2e73 100644 --- a/app/controllers/blog/posts_controller.rb +++ b/app/controllers/blog/posts_controller.rb @@ -67,8 +67,9 @@ class Blog::PostsController < BlogController end def tagged - @tag_name = params[:tag_name] - @blog_posts = BlogPost.tagged_with(@tag_name.titleize).paginate({ + @tag = ActsAsTaggableOn::Tag.find(params[:tag_id]) + @tag_name = @tag.name + @blog_posts = BlogPost.tagged_with(@tag_name).paginate({ :page => params[:page], :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10) }) diff --git a/app/views/blog/shared/_post.html.erb b/app/views/blog/shared/_post.html.erb index 3b91930..4750ef8 100644 --- a/app/views/blog/shared/_post.html.erb +++ b/app/views/blog/shared/_post.html.erb @@ -15,7 +15,7 @@ <% if (tags = post.tag_list).any? %> <aside class='tagged'> <%= t('tagged', :scope => 'blog.posts.show') %> - <%=raw tags.collect { |tag| link_to tag, tagged_posts_path(tag.parameterize) }.to_sentence %> + <%=raw tags.collect { |tag| link_to tag, tagged_posts_path(tag.id, tag.name.parameterize) }.to_sentence %> </aside> <% end %> </section> diff --git a/app/views/blog/shared/_tags.html.erb b/app/views/blog/shared/_tags.html.erb index 140e60e..b0b11ee 100644 --- a/app/views/blog/shared/_tags.html.erb +++ b/app/views/blog/shared/_tags.html.erb @@ -2,7 +2,7 @@ <h2><%= t('.title') %></h2> <nav id='tags'> <% tag_cloud(@tags, %w(tag1 tag2 tag3 tag4)) do |tag, css_class| %> - <%= link_to tag.name, tagged_posts_path(tag.name.parameterize), :class => css_class %> + <%= link_to tag.name, tagged_posts_path(tag.id, tag.name.parameterize), :class => css_class %> <% end %> </nav> <% end %>
\ No newline at end of file diff --git a/changelog.md b/changelog.md index 84e4684..0d363ed 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +## 1.6.1 [21 June 2011] +* Tagging URL strategy updated for reliability /blog/posts/tagged/ID-name-parameterized [joemsak](https://github.com/joemsak) +* Heroku/PostgreSQL support for autocomplete tags [joemsak](https://github.com/joemsak) + ## 1.6 [20 June 2011] * Category bug fixes and cleanup [wikyd](https://github.com/wikyd) * Cleaned up deprecated code [ugisozols](https://github.com/ugisozols) diff --git a/config/routes.rb b/config/routes.rb index 4deeb4e..5eb899a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,7 @@ match 'categories/:id', :to => 'categories#show', :as => 'blog_category' match ':id/comments', :to => 'posts#comment', :as => 'blog_post_blog_comments' get 'archive/:year(/:month)', :to => 'posts#archive', :as => 'archive_blog_posts' - get 'tagged/:tag_name' => 'posts#tagged', :as => 'tagged_posts' + get 'tagged/:tag_id-:tag_name' => 'posts#tagged', :as => 'tagged_posts' end scope(:path => 'refinery', :as => 'admin', :module => 'admin') do diff --git a/features/support/step_definitions/tags_steps.rb b/features/support/step_definitions/tags_steps.rb index 5d4dced..a99b5d6 100644 --- a/features/support/step_definitions/tags_steps.rb +++ b/features/support/step_definitions/tags_steps.rb @@ -3,7 +3,7 @@ Given /^there is a blog post titled "([^"]*)" and tagged "([^"]*)"$/ do |title, end When /^I visit the tagged posts page for "([^"]*)"$/ do |tag_name| - visit tagged_posts_path(tag_name.parameterize) + visit tagged_posts_path(tag.id, tag_name.parameterize) end Then /^the blog post should have the tags "([^"]*)"$/ do |tag_list| diff --git a/lib/refinery/blog/version.rb b/lib/refinery/blog/version.rb index b4bad51..62e3490 100644 --- a/lib/refinery/blog/version.rb +++ b/lib/refinery/blog/version.rb @@ -3,7 +3,7 @@ module Refinery class Version @major = 1 @minor = 6 - @tiny = 0 + @tiny = 1 class << self attr_reader :major, :minor, :tiny diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec index 32739fc..2d78207 100644 --- a/refinerycms-blog.gemspec +++ b/refinerycms-blog.gemspec @@ -1,8 +1,8 @@ Gem::Specification.new do |s| s.name = %q{refinerycms-blog} - s.version = %q{1.6.0} + s.version = %q{1.6.1} s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.} - s.date = %q{2011-06-21} + s.date = %q{2011-06-22} s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.} s.email = %q{info@refinerycms.com} s.homepage = %q{http://refinerycms.com/blog} |