Use a mixin for the `path` function to DRY it up

This commit is contained in:
Robin Ward 2015-03-09 15:24:16 -04:00
parent 31ca464c31
commit 3ad12d44f3
3 changed files with 9 additions and 8 deletions

View File

@ -8,11 +8,13 @@ require_dependency 'crawler_detection'
require_dependency 'json_error'
require_dependency 'letter_avatar'
require_dependency 'distributed_cache'
require_dependency 'global_path'
class ApplicationController < ActionController::Base
include CurrentUser
include CanonicalURL::ControllerExtensions
include JsonError
include GlobalPath
serialization_scope :guardian
@ -404,10 +406,6 @@ class ApplicationController < ActionController::Base
protected
def path(p)
"#{GlobalSetting.relative_url_root}#{p}"
end
def render_post_json(post, add_raw=true)
post_serializer = PostSerializer.new(post, scope: guardian, root: false)
post_serializer.add_raw = add_raw

View File

@ -6,11 +6,13 @@ require_dependency 'age_words'
require_dependency 'configurable_urls'
require_dependency 'mobile_detection'
require_dependency 'category_badge'
require_dependency 'global_path'
module ApplicationHelper
include CurrentUser
include CanonicalURL::Helpers
include ConfigurableUrls
include GlobalPath
def shared_session_key
if SiteSetting.long_polling_base_url != '/'.freeze && current_user
@ -23,10 +25,6 @@ module ApplicationHelper
end
end
def path(path)
"#{GlobalSetting.relative_url_root}#{path}"
end
def script(*args)
if SiteSetting.enable_cdn_js_debugging && GlobalSetting.cdn_url
tags = javascript_include_tag(*args, "crossorigin" => "anonymous")

5
lib/global_path.rb Normal file
View File

@ -0,0 +1,5 @@
module GlobalPath
def path(p)
"#{GlobalSetting.relative_url_root}#{p}"
end
end