-
Notifications
You must be signed in to change notification settings - Fork 1
/
minutes_extension.rb
73 lines (59 loc) · 2.14 KB
/
minutes_extension.rb
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Uncomment this if you reference any of your controllers in activate
# require_dependency "application_controller"
require "radiant-minutes-extension"
class MinutesExtension < Radiant::Extension
version RadiantMinutesExtension::VERSION
description RadiantMinutesExtension::DESCRIPTION
url RadiantMinutesExtension::URL
# See your config/routes.rb file in this extension to define custom routes
extension_config do |config|
# config is the Radiant.configuration object
end
cattr_accessor :meeting_types, :minutes_path
@@meeting_types ||= ['General', 'Committee', 'Other']
@@minutes_path ||= '/minutes/'
def activate
MenuRenderer.exclude 'MinutesPage'
tab 'Content' do
add_item "Meeting Minutes", "/admin/minutes", :after => "Pages", :visibility => [:developer, :admin]
end
ApplicationHelper.module_eval do
def filter_options_for_select_with_minutes_restrictions(selected=nil)
minutes_filters = MinutesExtension.minutes_filters
filters = TextFilter.descendants - minutes_filters
options_for_select([[t('select.none'), '']] + filters.map { |s| s.filter_name }.sort, selected)
end
alias_method_chain :filter_options_for_select, :minutes_restrictions
end
Page.class_eval do
def minutes?
self.is_a?(Minutes::Instance)
end
include MinutesTags
end
Admin::NodeHelper.module_eval do
def render_node_with_minutes(page, locals = {})
unless page.minutes?
render_node_without_minutes(page, locals)
end
end
alias_method_chain :render_node, :minutes
end
SiteController.class_eval do
def self.minutes_cache_timeout
@minutes_cache_timeout ||= 365.days
end
def self.minutes_cache_timeout=(val)
@minutes_cache_timeout = val
end
def set_cache_control_with_minutes
if @page.minutes?
expires_in self.class.minutes_cache_timeout, :public => true, :private => false
else
set_cache_control_without_minutes
end
end
alias_method_chain :set_cache_control, :minutes
end
end
end