Class | Cms::ApplicationController |
In: |
app/controllers/cms/application_controller.rb
|
Parent: | ApplicationController |
# File app/controllers/cms/application_controller.rb, line 47 47: def self.check_permissions(*perms) 48: opts = Hash === perms.last ? perms.pop : {} 49: before_filter(opts) do |controller| 50: raise Cms::Errors::AccessDenied unless controller.send(:current_user).able_to?(*perms) 51: end 52: end
# File app/controllers/cms/application_controller.rb, line 38 38: def append_to_query_string(url, *params) 39: new_url = url["?"] ? url : "#{url}?" 40: new_url << params.map{|k,v| "#{k.to_s}=#{CGI::escape(v.to_s)}"}.join("&") 41: end
# File app/controllers/cms/application_controller.rb, line 43 43: def cms_access_required 44: raise Cms::Errors::AccessDenied unless current_user.able_to?(:administrate, :edit_content, :publish_content) 45: end
# File app/controllers/cms/application_controller.rb, line 54 54: def cms_domain_prefix 55: "cms" 56: end
# File app/controllers/cms/application_controller.rb, line 58 58: def cms_site? 59: subdomains = request.subdomains 60: subdomains.shift if subdomains.first == "www" 61: subdomains.first == cms_domain_prefix 62: end
# File app/controllers/cms/application_controller.rb, line 28 28: def current_site 29: @current_site ||= Site.find_by_domain(request.host) 30: end
# File app/controllers/cms/application_controller.rb, line 16 16: def escape_javascript(javascript) 17: (javascript || '').gsub('\\','\0\0').gsub('</','<\/').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" } 18: end
# File app/controllers/cms/application_controller.rb, line 32 32: def redirect_to_cms_site 33: if perform_caching && !cms_site? 34: redirect_to(url_with_cms_domain_prefix) 35: end 36: end
# File app/controllers/cms/application_controller.rb, line 20 20: def redirect_to_first(*urls) 21: urls.each do |url| 22: unless url.blank? 23: return redirect_to(url) 24: end 25: end 26: end
# File app/controllers/cms/application_controller.rb, line 64 64: def url_with_cms_domain_prefix 65: if cms_site? 66: request.url 67: elsif request.subdomains.first == "www" 68: request.url.sub(/www\./, "#{cms_domain_prefix}.") 69: else 70: request.url.sub(/:\/\//, "://#{cms_domain_prefix}.") 71: end 72: end