now internal links open in same page and also removed dependency of rails
This commit is contained in:
parent
1a1b79cc15
commit
0cbee23fa5
|
@ -40,7 +40,7 @@ class SiteMenuWidgetsController < ApplicationController
|
|||
else
|
||||
item["page_name"] = page.name
|
||||
item["url"] = page.external_url
|
||||
item["target"] = "_blank"
|
||||
item["target"] = (is_internal_url?(page.external_url) ? "_self" : "_blank") rescue "_blank"
|
||||
item["children"] = []
|
||||
end
|
||||
end
|
||||
|
@ -57,4 +57,24 @@ class SiteMenuWidgetsController < ApplicationController
|
|||
}
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def is_internal_url?(link)
|
||||
internal = false
|
||||
if !link.nil?
|
||||
link = link.split("?").first
|
||||
temp_url = URI.parse(link)
|
||||
if temp_url.host.nil?
|
||||
internal = true
|
||||
end
|
||||
end
|
||||
return internal
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -15,5 +15,4 @@ Gem::Specification.new do |s|
|
|||
s.license = "MIT"
|
||||
|
||||
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
||||
s.test_files = Dir["test/**/*"]
|
||||
end
|
||||
s.test_files = Dir["test/**/*"]
|
Loading…
Reference in New Issue