aboutsummaryrefslogtreecommitdiffstats
path: root/lib/refinerycms-blog.rb
blob: 334380eab738096b4d7d6c7043c01e36be2dc670 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'filters_spam'
require File.expand_path('../generators/blog_generator', __FILE__)

module Refinery
  module Blog
    autoload :Version, File.expand_path('../refinery/blog/version', __FILE__)
    autoload :Tab, File.expand_path("../refinery/blog/tabs", __FILE__)

    class << self
      attr_accessor :root
      def root
        @root ||= Pathname.new(File.expand_path('../../', __FILE__))
      end

      def version
        ::Refinery::Blog::Version.to_s
      end
    end

    class Engine < Rails::Engine
      config.to_prepare do
        require File.expand_path('../refinery/blog/tabs', __FILE__)
      end

      initializer "init plugin", :after => :set_routes_reloader do |app|
        Refinery::Plugin.register do |plugin|
          plugin.pathname = root
          plugin.name = "refinerycms_blog"
          plugin.url = app.routes.url_helpers.refinery_admin_blog_posts_path
          plugin.menu_match = /^\/refinery\/blog\/?(posts|comments|categories)?/
          plugin.activity = {
            :class => Refinery::BlogPost
          }
        end
      end
    end if defined?(Rails::Engine)
  end
end