now internal links open in same page and also removed dependency of rails

This commit is contained in:
Harry Bomrah 2015-10-28 18:57:02 +08:00
parent 1a1b79cc15
commit 0cbee23fa5
2 changed files with 23 additions and 4 deletions

View File

@ -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

View File

@ -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/**/*"]