forked from jfqd/radiant-ssl_requirement-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssl_requirement_extension.rb
49 lines (41 loc) · 1.23 KB
/
ssl_requirement_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
require_dependency 'application_controller'
class SslRequirementExtension < Radiant::Extension
version "0.3"
description "Add ssl requirement to admin pages."
url "http://github.com/jfqd/radiant-ssl_requirement-extension"
def activate
# add ssl requirement to admin area
if respond_to?(:tab) # 0.9
controllers = [ApplicationController, Admin::ResourceController, Admin::PagesController]
else
controllers = [ApplicationController]
end
controllers.each do |c|
c.class_eval {
include SslRequirement
def ssl_required?
# you may wanna change this
local_request? || RAILS_ENV == 'test' || RAILS_ENV == 'development' ? false : true
end
}
end
# remove ssl requirement from site_contoller
ApplicationController::SiteController.class_eval do
include SslRequirement
def ssl_required?
false
end
end
# add compatibility for the sitemap_xml extension (http://blog.aissac.ro/radiant/sitemap-xml-extension/)
if defined?(SitemapXmlExtension)
SitemapXmlController.class_eval {
def ssl_required?
false
end
}
end
end
def deactivate
# will never happen
end
end