@Override public void beforeView( final HttpServletRequest request, final HttpServletResponse response, final ModelAndView modelAndView) throws Exception { if (modelAndView != null && modelAndView.getModel().containsKey("metatags")) { final List<MetaElementData> metaelements = ((List<MetaElementData>) modelAndView.getModel().get("metatags")); final UiExperienceLevel currentUiExperienceLevel = uiExperienceService.getUiExperienceLevel(); if (UiExperienceLevel.DESKTOP.equals(currentUiExperienceLevel)) { if (!ResponsiveUtils.isResponsive()) { // Provide some hints to mobile browser even though this is not the mobile site --> metaelements.add(createMetaElement("HandheldFriendly", "True")); metaelements.add(createMetaElement("MobileOptimized", "970")); metaelements.add( createMetaElement("viewport", "width=970, target-densitydpi=160, maximum-scale=1.0")); } } else if (UiExperienceLevel.MOBILE.equals(currentUiExperienceLevel)) { // Provide some hints to mobile browser even though this is not the mobile site --> metaelements.add(createMetaElement("HandheldFriendly", "True")); metaelements.add(createMetaElement("MobileOptimized", "320")); metaelements.add( createMetaElement( "viewport", "width=device-width, target-densitydpi=160, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no")); metaelements.add(createMetaElement("format-detection", "telephone=no")); } } }
@Override public void beforeView( final HttpServletRequest request, final HttpServletResponse response, final ModelAndView modelAndView) { final CMSSiteModel currentSite = cmsSiteService.getCurrentSite(); final String siteName = currentSite.getUid(); final String themeName = getThemeNameForSite(currentSite); final String uiExperienceCode = uiExperienceService.getUiExperienceLevel().getCode(); final String uiExperienceCodeLower = uiExperienceViewResolver.getUiExperienceViewPrefix().isEmpty() ? uiExperienceCode.toLowerCase() : StringUtils.remove( uiExperienceViewResolver .getUiExperienceViewPrefix() .get(uiExperienceService.getUiExperienceLevel()), "/"); final Object urlEncodingAttributes = request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES); final String contextPath = StringUtils.remove( request.getContextPath(), (urlEncodingAttributes != null) ? urlEncodingAttributes.toString() : ""); final String siteRootUrl = contextPath + "/_ui/" + uiExperienceCodeLower; final String sharedResourcePath = contextPath + "/_ui/" + SHARED; final String siteResourcePath = siteRootUrl + "/site-" + siteName; final String themeResourcePath = siteRootUrl + "/theme-" + themeName; final String commonResourcePath = siteRootUrl + "/" + COMMON; final String encodedContextPath = request.getContextPath(); final LanguageModel currentLanguage = commerceCommonI18NService.getCurrentLanguage(); modelAndView.addObject("contextPath", contextPath); modelAndView.addObject("sharedResourcePath", sharedResourcePath); modelAndView.addObject("siteResourcePath", siteResourcePath); modelAndView.addObject("themeResourcePath", themeResourcePath); modelAndView.addObject("commonResourcePath", commonResourcePath); modelAndView.addObject("encodedContextPath", encodedContextPath); modelAndView.addObject("siteRootUrl", siteRootUrl); modelAndView.addObject( "language", (currentLanguage != null ? currentLanguage.getIsocode() : "en")); modelAndView.addObject("CSRFToken", CSRFTokenManager.getTokenForSession(request.getSession())); modelAndView.addObject("uiExperienceLevel", uiExperienceCode); final String detectedUiExperienceCode = uiExperienceService.getDetectedUiExperienceLevel().getCode(); modelAndView.addObject("detectedUiExperienceCode", detectedUiExperienceCode); final UiExperienceLevel overrideUiExperienceLevel = uiExperienceService.getOverrideUiExperienceLevel(); if (overrideUiExperienceLevel == null) { modelAndView.addObject("uiExperienceOverride", Boolean.FALSE); } else { modelAndView.addObject("uiExperienceOverride", Boolean.TRUE); modelAndView.addObject("overrideUiExperienceCode", overrideUiExperienceLevel.getCode()); } final DeviceData currentDetectedDevice = deviceDetectionFacade.getCurrentDetectedDevice(); modelAndView.addObject("detectedDevice", currentDetectedDevice); final List<String> dependantAddOns = requiredAddOnsNameProvider.getAddOns( request.getSession().getServletContext().getServletContextName()); modelAndView.addObject( "addOnCommonCssPaths", getAddOnCommonCSSPaths(contextPath, uiExperienceCodeLower, dependantAddOns)); modelAndView.addObject( "addOnThemeCssPaths", getAddOnThemeCSSPaths(contextPath, themeName, uiExperienceCodeLower, dependantAddOns)); modelAndView.addObject( "addOnJavaScriptPaths", getAddOnJSPaths(contextPath, siteName, uiExperienceCodeLower, dependantAddOns)); }