mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-11-02 02:14:05 +09:00
Hello world
First open source release of Campfire 🎉
This commit is contained in:
commit
df76a227dc
664 files changed
+36235
No files matched your search
@@ -0,0 +1,61 @@
|
||||
class ApplicationPlatform < PlatformAgent
|
||||
def ios?
|
||||
match? /iPhone|iPad/
|
||||
end
|
||||
|
||||
def android?
|
||||
match? /Android/
|
||||
end
|
||||
|
||||
def mac?
|
||||
match? /Macintosh/
|
||||
end
|
||||
|
||||
def chrome?
|
||||
user_agent.browser.match? /Chrome/
|
||||
end
|
||||
|
||||
def firefox?
|
||||
user_agent.browser.match? /Firefox|FxiOS/
|
||||
end
|
||||
|
||||
def safari?
|
||||
user_agent.browser.match? /Safari/
|
||||
end
|
||||
|
||||
def edge?
|
||||
user_agent.browser.match? /Edg/
|
||||
end
|
||||
|
||||
def apple_messages?
|
||||
# Apple Messages pretends to be Facebook and Twitter bots via spoofed user agent.
|
||||
# We want to avoid showing "Unsupported browser" message when a Campfire link
|
||||
# is shared via Messages.
|
||||
match?(/facebookexternalhit/i) && match?(/Twitterbot/i)
|
||||
end
|
||||
|
||||
def mobile?
|
||||
ios? || android?
|
||||
end
|
||||
|
||||
def desktop?
|
||||
!mobile?
|
||||
end
|
||||
|
||||
def windows?
|
||||
operating_system == "Windows"
|
||||
end
|
||||
|
||||
def operating_system
|
||||
case user_agent.platform
|
||||
when /Android/ then "Android"
|
||||
when /iPad/ then "iPad"
|
||||
when /iPhone/ then "iPhone"
|
||||
when /Macintosh/ then "macOS"
|
||||
when /Windows/ then "Windows"
|
||||
when /CrOS/ then "ChromeOS"
|
||||
else
|
||||
os =~ /Linux/ ? "Linux" : os
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user