Remove `ios_web_app?` helper
This commit is contained in:
parent
a2ae98eee8
commit
63436d3464
|
@ -33,15 +33,6 @@ module ApplicationHelper
|
|||
!current_user.nil? && ((current_user == user) || current_user.mod?)
|
||||
end
|
||||
|
||||
def ios_web_app?
|
||||
user_agent = request.env["HTTP_USER_AGENT"] || "Mozilla/5.0"
|
||||
# normal MobileSafari.app UA: Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/600.1.4
|
||||
# webapp UA: Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B435
|
||||
return true if user_agent.match(/^Mozilla\/\d+\.\d+ \(i(?:Phone|Pad|Pod); CPU(?:.*) like Mac OS X\)(?:.*) Mobile(?:\S*)$/)
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def rails_admin_path_for_resource(resource)
|
||||
[rails_admin_path, resource.model_name.param_key, resource.id].join("/")
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
%nav.navbar.navbar-themed.navbar-expand-lg.bg-primary.fixed-top.d-lg-block.d-none.d-print-none{ role: :navigation }
|
||||
.container{ class: ios_web_app? ? 'ios-web-app' : '' }
|
||||
.container
|
||||
%a.navbar-brand{ href: '/', title: APP_CONFIG["site_name"] }
|
||||
- if APP_CONFIG["use_svg_logo"]
|
||||
= render inline: Rails.application.config.justask_svg_logo
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
%nav.navbar.navbar-themed.navbar-expand-lg.bg-primary.fixed-top{ role: :navigation }
|
||||
.container{ class: ios_web_app? ? 'ios-web-app' : '' }
|
||||
.container
|
||||
%a.navbar-brand{ href: '/', title: APP_CONFIG["site_name"] }
|
||||
- if APP_CONFIG["use_svg_logo"]
|
||||
= render inline: Rails.application.config.justask_svg_logo
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
= render 'navigation/dropdown/notifications', notifications: notifications, size: "mobile"
|
||||
- notifications_icon = notification_count.nil? ? 'bell-o' : 'bell'
|
||||
%nav.navbar.navbar-themed.bg-primary.fixed-bottom.d-lg-none.d-block.d-print-none#rs-mobile-nav{ role: :navigation }
|
||||
.container{ class: ios_web_app? ? 'ios-web-app' : '' }
|
||||
.container
|
||||
%ul.nav.navbar-nav.navbar-icon-row
|
||||
= nav_entry t("navigation.timeline"), root_path, icon: 'home', icon_only: true
|
||||
= nav_entry t("navigation.inbox"), '/inbox',
|
||||
|
|
|
@ -87,32 +87,6 @@ describe ApplicationHelper, type: :helper do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#ios_web_app" do
|
||||
context "Non-iOS device" do
|
||||
it "should not return true" do
|
||||
controller.request.user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2;"
|
||||
|
||||
expect(helper.ios_web_app?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "iOS device (not in web app mode)" do
|
||||
it "should not return true" do
|
||||
controller.request.user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/600.1.4"
|
||||
|
||||
expect(helper.ios_web_app?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "iOS device" do
|
||||
it "should return true" do
|
||||
controller.request.user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B435"
|
||||
|
||||
expect(helper.ios_web_app?).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#rails_admin_path_for_resource" do
|
||||
context "user resource" do
|
||||
let(:resource) { FactoryBot.create(:user) }
|
||||
|
|
Loading…
Reference in New Issue