Sha256: 8105be94842268006e00cd2935b6ab7bd70d498599732ded5cdaba44201edd13

Contents?: true

Size: 1.83 KB

Versions: 15

Compression:

Stored size: 1.83 KB

Contents

require 'alchemy/tasks/tidy'

namespace :alchemy do
  namespace :tidy do
    desc "Tidy up Alchemy database."
    task :up do
      Rake::Task['alchemy:tidy:cells'].invoke
      Rake::Task['alchemy:tidy:element_positions'].invoke
      Rake::Task['alchemy:tidy:content_positions'].invoke
      Rake::Task['alchemy:tidy:remove_orphaned_records'].invoke
    end

    desc "Creates missing cells for pages."
    task cells: :environment do
      if !File.exist? Rails.root.join('config/alchemy/cells.yml')
        puts "No page cell definitions found."
      else
        cells = Alchemy::Cell.definitions
        page_layouts = Alchemy::PageLayout.all
        if cells && page_layouts
          Alchemy::Tidy.create_missing_cells(page_layouts, cells)
        else
          puts "No page layouts or cell definitions found."
        end
      end
    end

    desc "Fixes element positions."
    task element_positions: [:environment] do
      Alchemy::Tidy.update_element_positions
    end

    desc "Fixes content positions."
    task content_positions: [:environment] do
      Alchemy::Tidy.update_content_positions
    end

    desc "Remove orphaned records (cells, elements, contents)."
    task remove_orphaned_records: [:environment] do
      Rake::Task['alchemy:tidy:remove_orphaned_cells'].invoke
      Rake::Task['alchemy:tidy:remove_orphaned_elements'].invoke
      Rake::Task['alchemy:tidy:remove_orphaned_contents'].invoke
    end

    desc "Remove orphaned cells."
    task remove_orphaned_cells: [:environment] do
      Alchemy::Tidy.remove_orphaned_cells
    end

    desc "Remove orphaned elements."
    task remove_orphaned_elements: [:environment] do
      Alchemy::Tidy.remove_orphaned_elements
    end

    desc "Remove orphaned contents."
    task remove_orphaned_contents: [:environment] do
      Alchemy::Tidy.remove_orphaned_contents
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
alchemy_cms-3.6.7 lib/tasks/alchemy/tidy.rake
alchemy_cms-3.6.6 lib/tasks/alchemy/tidy.rake
alchemy_cms-4.1.2 lib/tasks/alchemy/tidy.rake
alchemy_cms-4.1.1 lib/tasks/alchemy/tidy.rake
alchemy_cms-4.1.0 lib/tasks/alchemy/tidy.rake
alchemy_cms-4.1.0.rc1 lib/tasks/alchemy/tidy.rake
alchemy_cms-4.0.3 lib/tasks/alchemy/tidy.rake
alchemy_cms-3.6.5 lib/tasks/alchemy/tidy.rake
alchemy_cms-4.0.2 lib/tasks/alchemy/tidy.rake
alchemy_cms-4.1.0.beta lib/tasks/alchemy/tidy.rake
alchemy_cms-4.0.1 lib/tasks/alchemy/tidy.rake
alchemy_cms-3.6.4 lib/tasks/alchemy/tidy.rake
alchemy_cms-4.0.0 lib/tasks/alchemy/tidy.rake
alchemy_cms-3.6.3 lib/tasks/alchemy/tidy.rake
alchemy_cms-3.6.2 lib/tasks/alchemy/tidy.rake