Sha256: d024732b9092870de5aeff7b64f11161ad63a919821040d2e5429cc4b435eb03

Contents?: true

Size: 1.19 KB

Versions: 44

Compression:

Stored size: 1.19 KB

Contents

namespace :alchemy do
  namespace :convert do

    namespace :urlnames do

      desc "Converts the urlname of all pages to nested url paths."
      task :to_nested => [:environment] do
        unless Alchemy::Config.get(:url_nesting)
          raise "\nURL nesting is disabled! Please enable url_nesting in `config/alchemy/config.yml` first.\n\n"
        end
        puts "Converting..."
        pages = Alchemy::Page.contentpages
        count = pages.count
        pages.each_with_index do |page, n|
          puts "Updating page #{n+1} of #{count}"
          page.update_urlname!
        end
        puts "Done."
      end

      desc "Converts the urlname of all pages to contain the slug only."
      task :to_slug => [:environment] do
        if Alchemy::Config.get(:url_nesting)
          raise "\nURL nesting is enabled! Please disable url_nesting in `config/alchemy/config.yml` first.\n\n"
        end
        puts "Converting..."
        pages = Alchemy::Page.contentpages
        count = pages.count
        pages.each_with_index do |page, n|
          puts "Updating page #{n+1} of #{count}"
          page.update_attribute :urlname, page.slug
        end
        puts "Done."
      end

    end

  end
end

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.3 lib/tasks/alchemy/convert.rake
lc_alchemy_cms-3.2.1 lib/tasks/alchemy/convert.rake
lc_alchemy_cms-3.2.0 lib/tasks/alchemy/convert.rake
alchemy_cms-3.2.0 lib/tasks/alchemy/convert.rake
alchemy_cms-3.2.0.rc1 lib/tasks/alchemy/convert.rake
alchemy_cms-3.2.0.beta lib/tasks/alchemy/convert.rake
alchemy_cms-2.9.1 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.1 lib/tasks/alchemy/convert.rake
alchemy_cms-3.0.4 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.0 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.0.rc3 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.0.rc2 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.0.rc1 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.0.beta6 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.0.beta5 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.0.beta4 lib/tasks/alchemy/convert.rake
alchemy_cms-3.0.3 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.0.beta3 lib/tasks/alchemy/convert.rake
alchemy_cms-3.1.0.beta2 lib/tasks/alchemy/convert.rake