public
Description: RadiantCMS extensions for concurrent drafts
Homepage:
Clone URL: git://github.com/avonderluft/radiant-concurrent_draft-extension.git
radiant-concurrent_draft-extension / concurrent_draft_extension.rb
100644 44 lines (41 sloc) 2.108 kb
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
39
40
41
42
43
44
# Uncomment this if you reference any of your controllers in activate
begin
  require_dependency 'application_controller'
rescue MissingSourceFile
  require_dependency 'application'
end
 
class ConcurrentDraftExtension < Radiant::Extension
  version "0.8.0"
  description "Enables default draft versions of pages, snippets and layouts, which can be scheduled for promotion to Production"
  url "http://github.com/avonderluft/concurrent_draft/tree/master"
 
  define_routes do |map|
    map.page_schedule_draft_promotion 'admin/pages/schedule_draft_promotion/:id',
      :controller => 'admin/pages', :action => 'schedule_draft_promotion'
    map.snippet_schedule_draft_promotion 'admin/snippet/schedule_draft_promotion/:id',
      :controller => 'admin/snippets', :action => 'schedule_draft_promotion'
    map.layout_schedule_draft_promotion 'admin/layout/schedule_draft_promotion/:id',
      :controller => 'admin/layouts', :action => 'schedule_draft_promotion'
    map.page_unpublish 'admin/pages/unpublish/:id', :controller => 'admin/pages', :action => 'unpublish'
  end
 
  def activate
    [Page, Snippet, Layout, PagePart].each do |klass|
      klass.send :include, ConcurrentDraft::ModelExtensions
    end
    Page.send :include, ConcurrentDraft::PageExtensions
    Page.send :include, ConcurrentDraft::Tags
    [Admin::PagesController, Admin::SnippetsController, Admin::LayoutsController].each do |klass|
      klass.send :include, ConcurrentDraft::AdminControllerExtensions
      klass.class_eval do
        helper ConcurrentDraft::HelperExtensions
      end
    end
    SiteController.send :include, ConcurrentDraft::SiteControllerExtensions
    %w{page snippet layout}.each do |view|
      admin.send(view).edit.add :main, "admin/draft_controls", :before => "edit_header"
      admin.send(view).edit.form_bottom.delete 'edit_buttons'
      admin.send(view).edit.add :form_bottom, 'admin/edit_buttons'
    end
    admin.page.edit.add :extended_metadata, 'published_meta'
    Time::DATE_FORMATS[:long_civilian] = lambda {|time| time.strftime("%B %d, %Y %I:%M%p").gsub(/(\s+)0(\d+)/, '\1\2') }
  end
end