-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUGFIX: mobile ui was being cached for anon views
- Loading branch information
1 parent
e8afe87
commit 177983a
Showing
4 changed files
with
39 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module MobileDetection | ||
def self.mobile_device?(user_agent) | ||
# TODO: this is dumb. user agent matching is a doomed approach. a better solution is coming. | ||
user_agent =~ /Mobile|webOS|Nexus 7/ && !(user_agent =~ /iPad/) | ||
end | ||
|
||
# we need this as a reusable chunk that is called from the cache | ||
def self.resolve_mobile_view!(user_agent, params, session) | ||
return false unless SiteSetting.enable_mobile_theme | ||
|
||
session[:mobile_view] = params[:mobile_view] if params.has_key?(:mobile_view) | ||
|
||
if session[:mobile_view] | ||
session[:mobile_view] == '1' | ||
else | ||
mobile_device?(user_agent) | ||
end | ||
end | ||
end |