37 lines
1.0 KiB
Ruby
37 lines
1.0 KiB
Ruby
module ApplicationHelper
|
|
def nav_link_class(target_controller)
|
|
base_classes = "flex items-center gap-3 px-3 py-2.5 text-sm font-medium rounded-lg transition-colors duration-200"
|
|
|
|
if controller_name == target_controller
|
|
"#{base_classes} bg-blue-50 text-blue-600 font-semibold"
|
|
else
|
|
"#{base_classes} text-gray-700 hover:bg-gray-50"
|
|
end
|
|
end
|
|
|
|
def parse_user_agent(user_agent_string)
|
|
ua = user_agent_string.to_s.downcase
|
|
|
|
# Browser-Erkennung via Case-Regex (nutzt === im Hintergrund)
|
|
browser = case ua
|
|
when /firefox/ then "Firefox"
|
|
when /chrome/ then "Chrome"
|
|
when /safari/ then "Safari"
|
|
when /edge/ then "Edge"
|
|
else "Unbekannter Browser"
|
|
end
|
|
|
|
# Betriebssystem-Erkennung via Case-Regex
|
|
os = case ua
|
|
when /windows/ then "Windows"
|
|
when /macintosh|mac os/ then "macOS"
|
|
when /iphone/ then "iPhone"
|
|
when /android/ then "Android"
|
|
when /linux/ then "Linux"
|
|
else "Betriebssystem"
|
|
end
|
|
|
|
"#{browser} auf #{os}"
|
|
end
|
|
end
|