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
|
else
|
||||||
item["page_name"] = page.name
|
item["page_name"] = page.name
|
||||||
item["url"] = page.external_url
|
item["url"] = page.external_url
|
||||||
item["target"] = "_blank"
|
item["target"] = (is_internal_url?(page.external_url) ? "_self" : "_blank") rescue "_blank"
|
||||||
item["children"] = []
|
item["children"] = []
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,4 +16,3 @@ Gem::Specification.new do |s|
|
||||||
|
|
||||||
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
||||||
s.test_files = Dir["test/**/*"]
|
s.test_files = Dir["test/**/*"]
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in New Issue