Add platform attribute

This commit is contained in:
Adrien Maston
2025-12-17 08:56:08 +01:00
parent a5a0cda295
commit 5b7aa67bb3
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -35,10 +35,26 @@ class ApplicationPlatform < PlatformAgent
!mobile?
end
def native?
match? /Hotwire Native/
end
def windows?
operating_system == "Windows"
end
def type
if native? && android?
"native android"
elsif native? && ios?
"native ios"
elsif mobile?
"mobile web"
else
"desktop web"
end
end
def operating_system
case user_agent.platform
when /Android/ then "Android"
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="en">
<%= render "layouts/shared/head" %>
<body data-controller="local-time timezone-cookie turbo-navigation theme" data-action="turbo:morph@window->local-time#refreshAll turbo:before-visit@document->turbo-navigation#rememberLocation">
<body data-controller="local-time timezone-cookie turbo-navigation theme" data-action="turbo:morph@window->local-time#refreshAll turbo:before-visit@document->turbo-navigation#rememberLocation" data-platform="<%= platform.type %>">
<header class="header <%= @header_class %>" id="header">
<a href="#main" class="header__skip-navigation btn" data-turbo="false">Skip to main content</a>
<%= render "my/menu" if Current.user %>