def isMobileBrowser(self): ua = get_user_agent(self.request) if ua: return detect_mobile_browser(ua) else: # User agent missing from HTTP request return False
def isMobile(self): """ """ ua = get_user_agent(self.request) if ua and detect_mobile_browser(ua): return True return False
def plugin_detect_mobile(switch_view=True): from mobile.sniffer.detect import detect_mobile_browser if detect_mobile_browser(request.env.http_user_agent): if switch_view: view = '%(controller)s/%(function)s.mobile.%(extension)s' % request if os.path.exists(os.path.join(request.folder, 'views', view)): response.view = view return True return False
def plugin_detect_mobile(switch_view=True): from mobile.sniffer.detect import detect_mobile_browser if detect_mobile_browser(request.env.http_user_agent): if switch_view: view = '%(controller)s/%(function)s.mobile.%(extension)s' % request if os.path.exists(os.path.join(request.folder, 'views',view)): response.view = view return True return False
def on_mobile(self): """ Return True if the site is being browsed on a mobile phone. """ ua = get_user_agent(self.request) if ua: if detect_mobile_browser(ua): return True else: return False return False
def isMobileBrowser(self): ua = get_user_agent(self.request) if ua: is_mobile = detect_mobile_browser(ua) if is_mobile: exclude = getattr(self.mobile_properties, "exclude_user_agents", "") if exclude and re.search(exclude, ua, flags=re.I): return False return is_mobile else: # User agent missing from HTTP request return False
def is_text_view(self): """Check if text view (base for desktop is drag, mobile only has text) is selected. :returns: returns True or False, depending on text view being selected :rtype: boolean """ # Get HTTP_USER_AGENT from HTTP request object ua = get_user_agent(self.request) if ua and detect_mobile_browser(ua): # Redirect the visitor from a web site to a mobile site return True return self.request.form.get("view_type", "drag") == "text"
def is_handheld(self): # Get HTTP_USER_AGENT from HTTP request object class FakeRequest: def __init__(self, request): self.other = request ua = get_user_agent(FakeRequest(self.request)) if ua: # Apply reg if detect_mobile_browser(ua): # Redirect the visitor from a web site to a mobile site return True else: # A regular web site visitor return False else: # User agent header is missing from HTTP request return False
def is_mobile_request(): ua = request.user_agent.string if ua and detect_mobile_browser(ua): return True else: return False
from mobile.sniffer.detect import detect_mobile_browser from mobile.sniffer.utilities import get_user_agent # Get HTTP_USER_AGENT from HTTP request object ua = get_user_agent(self.request) if ua: # Apply reg if detect_mobile_browser(ua): # Redirect the visitor from a web site to a mobile site pass else: # A regular web site visitor pass else: # User agent header is missing from HTTP request return False